Get the FREE Ultimate OpenClaw Setup Guide →

excalidraw

Scanned
npx machina-cli add skill sandover/codex-skills/excalidraw --openclaw
Files (1)
SKILL.md
6.8 KB

Excalidraw Diagram Generator

Generate architecture diagrams as .excalidraw files directly from codebase analysis.


Quick Start

User just asks:

"Generate an architecture diagram for this project"
"Create an excalidraw diagram of the system"
"Visualize this codebase as an excalidraw file"

Claude Code will:

  1. Analyze the codebase (any language/framework)
  2. Identify components, services, databases, APIs
  3. Map relationships and data flows
  4. Generate valid .excalidraw JSON with dynamic IDs and labels

No prerequisites: Works without existing diagrams, Terraform, or specific file types.


Critical Rules

1. NEVER Use Diamond Shapes

Diamond arrow connections are broken in raw Excalidraw JSON. Use styled rectangles instead:

Semantic MeaningRectangle Style
Orchestrator/HubCoral (#ffa8a8/#c92a2a) + strokeWidth: 3
Decision PointOrange (#ffd8a8/#e8590c) + dashed stroke

2. Labels Require TWO Elements

The label property does NOT work in raw JSON. Every labeled shape needs:

// 1. Shape with boundElements reference
{
  "id": "my-box",
  "type": "rectangle",
  "boundElements": [{ "type": "text", "id": "my-box-text" }]
}

// 2. Separate text element with containerId
{
  "id": "my-box-text",
  "type": "text",
  "containerId": "my-box",
  "text": "My Label"
}

3. Elbow Arrows Need Three Properties

For 90-degree corners (not curved):

{
  "type": "arrow",
  "roughness": 0,        // Clean lines
  "roundness": null,     // Sharp corners
  "elbowed": true        // 90-degree mode
}

4. Arrow Edge Calculations

Arrows must start/end at shape edges, not centers:

EdgeFormula
Top(x + width/2, y)
Bottom(x + width/2, y + height)
Left(x, y + height/2)
Right(x + width, y + height/2)

Detailed arrow routing: See references/arrows.md


Element Types

TypeUse For
rectangleServices, databases, containers, orchestrators
ellipseUsers, external systems, start/end points
textLabels inside shapes, titles, annotations
arrowData flow, connections, dependencies
lineGrouping boundaries, separators

Full JSON format: See references/json-format.md


Workflow

Step 1: Analyze Codebase

Discover components by looking for:

Codebase TypeWhat to Look For
Monorepopackages/*/package.json, workspace configs
Microservicesdocker-compose.yml, k8s manifests
IaCTerraform/Pulumi resource definitions
Backend APIRoute definitions, controllers, DB models
FrontendComponent hierarchy, API calls

Use tools:

  • Glob**/package.json, **/Dockerfile, **/*.tf
  • Grepapp.get, @Controller, CREATE TABLE
  • Read → README, config files, entry points

Step 2: Plan Layout

Vertical flow (most common):

Row 1: Users/Entry points (y: 100)
Row 2: Frontend/Gateway (y: 230)
Row 3: Orchestration (y: 380)
Row 4: Services (y: 530)
Row 5: Data layer (y: 680)

Columns: x = 100, 300, 500, 700, 900
Element size: 160-200px x 80-90px

Other patterns: See references/examples.md

Step 3: Generate Elements

For each component:

  1. Create shape with unique id
  2. Add boundElements referencing text
  3. Create text with containerId
  4. Choose color based on type

Color palettes: See references/colors.md

Step 4: Add Connections

For each relationship:

  1. Calculate source edge point
  2. Plan elbow route (avoid overlaps)
  3. Create arrow with points array
  4. Match stroke color to destination type

Arrow patterns: See references/arrows.md

Step 5: Add Grouping (Optional)

For logical groupings:

  • Large transparent rectangle with strokeStyle: "dashed"
  • Standalone text label at top-left

Step 6: Validate and Write

Run validation before writing. Save to docs/ or user-specified path.

Validation checklist: See references/validation.md


Quick Arrow Reference

Straight down:

{ "points": [[0, 0], [0, 110]], "x": 590, "y": 290 }

L-shape (left then down):

{ "points": [[0, 0], [-325, 0], [-325, 125]], "x": 525, "y": 420 }

U-turn (callback):

{ "points": [[0, 0], [50, 0], [50, -125], [20, -125]], "x": 710, "y": 440 }

Arrow width/height = bounding box of points:

points [[0,0], [-440,0], [-440,70]] → width=440, height=70

Multiple arrows from same edge - stagger positions:

5 arrows: 20%, 35%, 50%, 65%, 80% across edge width

Default Color Palette

ComponentBackgroundStroke
Frontend#a5d8ff#1971c2
Backend/API#d0bfff#7048e8
Database#b2f2bb#2f9e44
Storage#ffec99#f08c00
AI/ML#e599f7#9c36b5
External APIs#ffc9c9#e03131
Orchestration#ffa8a8#c92a2a
Message Queue#fff3bf#fab005
Cache#ffe8cc#fd7e14
Users#e7f5ff#1971c2

Cloud-specific palettes: See references/colors.md


Quick Validation Checklist

Before writing file:

  • Every shape with label has boundElements + text element
  • Text elements have containerId matching shape
  • Multi-point arrows have elbowed: true, roundness: null
  • Arrow x,y = source shape edge point
  • Arrow final point offset reaches target edge
  • No diamond shapes
  • No duplicate IDs

Full validation algorithm: See references/validation.md


Common Issues

IssueFix
Labels don't appearUse TWO elements (shape + text), not label property
Arrows curvedAdd elbowed: true, roundness: null, roughness: 0
Arrows floatingCalculate x,y from shape edge, not center
Arrows overlappingStagger start positions across edge

Detailed bug fixes: See references/validation.md


Reference Files

FileContents
references/json-format.mdElement types, required properties, text bindings
references/arrows.mdRouting algorithm, patterns, bindings, staggering
references/colors.mdDefault, AWS, Azure, GCP, K8s palettes
references/examples.mdComplete JSON examples, layout patterns
references/validation.mdChecklists, validation algorithm, bug fixes

Output

  • Location: docs/architecture/ or user-specified
  • Filename: Descriptive, e.g., system-architecture.excalidraw
  • Testing: Open in https://excalidraw.com or VS Code extension

Source

git clone https://github.com/sandover/codex-skills/blob/main/skills/excalidraw/SKILL.mdView on GitHub

Overview

Excalidraw Diagram Generator analyzes your codebase to produce architecture diagrams as .excalidraw JSON. It identifies components, services, databases, and APIs, then maps their relationships into a clean, editable diagram. The tool follows Excalidraw constraints (no diamond shapes, paired labels, elbowed arrows) to ensure valid exports.

How This Skill Works

The tool scans the repository to locate components across monorepos, microservices, IaC, backend APIs, and frontend code. It then plans layout, creates shaped elements for each component, wires them with colored connections, and outputs a valid .excalidraw JSON with dynamic IDs and boundElements-based labels.

When to Use It

  • When asked to create an architecture or system diagram from a codebase
  • When visualizing a codebase's structure (services, databases, APIs)
  • When generating an Excalidraw file for collaboration or sharing
  • When documenting deployment or data-flow architecture
  • When outlining monorepos or microservices architectures

Quick Start

  1. Step 1: Analyze the codebase to identify components, services, databases, and APIs
  2. Step 2: Plan a vertical layout and create shapes with unique IDs and boundElements for labels
  3. Step 3: Add connections as arrows, ensure edge-based routing, and export a valid .excalidraw JSON

Best Practices

  • Avoid diamond shapes by using rectangles for hubs/orchestrators and apply the prescribed colors and stroke widths
  • Use the two-element label pattern: a shape with boundElements and a separate text element linked via containerId
  • Draw elbowed arrows with three properties (type: arrow, roughness: 0, elbowed: true) for 90-degree connections
  • Size and layout: 160-200px wide and 80-90px tall shapes; plan vertical flow with clear rows and columns
  • Ensure edges touch shape boundaries (top, bottom, left, right) for clean data-flow visuals and accurate routing

Example Use Cases

  • Diagram a microservices app with Users, Gateway, Orchestrator, multiple Services, and a Datastore
  • Visualize a monorepo's codebase (Frontend, API, Workers, Infra) as an Excalidraw file
  • Map data flow between services and databases in an e-commerce platform
  • Generate a system diagram for a CI/CD pipeline and associated IaC resources
  • Create a cloud-native app diagram with Kubernetes components, services, and external APIs

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers