Loading...
Loading...
Generate architecture diagrams as .excalidraw files from codebase analysis, with optional PNG/SVG export. Use when the user asks to create architecture diagrams, system diagrams, data flow diagrams, parameter threading traces, call chain visualizations, visualize codebase structure, generate excalidraw files, export excalidraw diagrams to PNG or SVG, or convert .excalidraw files to image formats.
npx skill4agent add edwingao28/excalidraw-skill excalidraw(0,0) ────────── x increases ──────────►
│
│ ┌──────────┐ ┌──────────┐
│ │ Box A │─────►│ Box B │
│ └──────────┘ └──────────┘
│ │
y ▼
increases ┌──────────┐
│ │ Box C │
▼ └──────────┘| Tool | What It Does | When to Use |
|---|---|---|
| Returns color palette + sizing rules | First call. Read once, use throughout. |
| Create many shapes + arrows at once | Main workhorse. Create your whole diagram in 1-2 calls. |
| Take a photo of the current canvas | After every batch. Verify it looks right. |
| Wipe everything | Start fresh before a new diagram. |
| Save as PNG or SVG | Final step if user wants an image file. |
describe_scenecreate_from_mermaidexport_sceneset_viewportexport_to_excalidraw_url{
"type": "rectangle",
"id": "my-box",
"x": 100,
"y": 100,
"width": 180,
"height": 70,
"backgroundColor": "#a5d8ff",
"strokeColor": "#1971c2",
"roughness": 0,
"text": "My Service\nPort 8080"
}textroughness: 0roughness: 1\nrectangleellipsediamondtext{
"type": "arrow",
"x": 0,
"y": 0,
"startElementId": "my-box",
"endElementId": "other-box",
"strokeColor": "#1971c2",
"text": "HTTP"
}startElementIdendElementIdidx, ytextstrokeStyle: "dashed""dotted"startArrowheadendArrowhead"arrow""dot""triangle""bar"null\nmcp__excalidraw__read_diagram_guide()mcp__excalidraw__clear_canvas()
mcp__excalidraw__get_canvas_screenshot() // MUST verify empty!Vertical flow (most common):
Row 1 (y=0): Zone backgrounds (large dashed rectangles)
Row 2 (y=60): Entry points / Users
Row 3 (y=350): Middle layer (APIs, services)
Row 4 (y=650): Data layer (databases, storage)
Columns: x = 40, 440, 840 (spaced 400px apart for labeled arrows)
Box size: 230 x 160 (standard) | 200 x 120 (for decision diamonds)
Spacing between rows: ~200px gap after accounting for box height
Spacing between boxes in a row: 180px gap (for arrow labels)batch_create_elementsidstartElementIdendElementIdmcp__excalidraw__get_canvas_screenshot()update_elementdelete_elementcreate_elementmcp__excalidraw__set_viewport({ scrollToContent: true })mcp__excalidraw__export_to_image({ format: "png", filePath: "/path/to/output.png" })
mcp__excalidraw__export_scene({ filePath: "/path/to/output.excalidraw" })
mcp__excalidraw__export_to_excalidraw_url() // shareable linkbatch_create_elements{
"elements": [
// --- ZONE BACKGROUNDS (render behind everything) ---
{
"type": "rectangle", "id": "zone-frontend",
"x": 0, "y": 0, "width": 500, "height": 160,
"backgroundColor": "#e9ecef", "strokeColor": "#868e96",
"strokeStyle": "dashed", "opacity": 40, "roughness": 0
},
{
"type": "text", "x": 10, "y": 10,
"text": "Frontend Layer", "fontSize": 14, "strokeColor": "#868e96"
},
{
"type": "rectangle", "id": "zone-backend",
"x": 0, "y": 200, "width": 500, "height": 160,
"backgroundColor": "#eebefa", "strokeColor": "#9c36b5",
"strokeStyle": "dashed", "opacity": 30, "roughness": 0
},
{
"type": "text", "x": 10, "y": 210,
"text": "Backend Layer", "fontSize": 14, "strokeColor": "#9c36b5"
},
// --- SHAPES (give each an id so arrows can reference them) ---
{
"type": "rectangle", "id": "react-app",
"x": 40, "y": 50, "width": 180, "height": 70,
"backgroundColor": "#a5d8ff", "strokeColor": "#1971c2", "roughness": 0,
"text": "React App\nFrontend"
},
{
"type": "rectangle", "id": "api-server",
"x": 40, "y": 250, "width": 180, "height": 70,
"backgroundColor": "#d0bfff", "strokeColor": "#7048e8", "roughness": 0,
"text": "API Server\nExpress.js"
},
{
"type": "rectangle", "id": "database",
"x": 280, "y": 250, "width": 180, "height": 70,
"backgroundColor": "#b2f2bb", "strokeColor": "#2f9e44", "roughness": 0,
"text": "PostgreSQL\nDatabase"
},
// --- ARROWS (connect shapes by ID) ---
{
"type": "arrow", "x": 130, "y": 120,
"startElementId": "react-app", "endElementId": "api-server",
"strokeColor": "#1971c2", "text": "REST API"
},
{
"type": "arrow", "x": 220, "y": 285,
"startElementId": "api-server", "endElementId": "database",
"strokeColor": "#2f9e44", "text": "SQL"
},
// --- TITLE ---
{
"type": "text", "x": 100, "y": -40,
"text": "System Architecture", "fontSize": 24, "strokeColor": "#1e1e1e"
}
]
}{
"elements": [
// --- TITLE ---
{"type": "text", "x": 20, "y": 10, "text": "Data Flow: parameter_name Threading", "fontSize": 24, "strokeColor": "#1e1e1e"},
{"type": "text", "x": 20, "y": 48, "text": "Subtitle describing the trace", "fontSize": 16, "strokeColor": "#868e96"},
// --- WHY SECTION (top-right, first-principles context) ---
{"type": "rectangle", "id": "why-bg", "x": 460, "y": 80, "width": 440, "height": 310,
"backgroundColor": "#e9ecef", "strokeColor": "#868e96", "roughness": 0},
{"type": "text", "x": 480, "y": 95, "text": "WHY: The Problem", "fontSize": 20, "strokeColor": "#e03131"},
{"type": "text", "x": 480, "y": 135, "text": "1. What currently happens", "fontSize": 16, "strokeColor": "#1e1e1e"},
{"type": "text", "x": 480, "y": 195, "text": "2. Why it's expensive/wrong", "fontSize": 16, "strokeColor": "#e03131"},
{"type": "text", "x": 480, "y": 275, "text": "3. Gap in current design", "fontSize": 16, "strokeColor": "#1e1e1e"},
{"type": "text", "x": 480, "y": 335, "text": "Solution: what this change does", "fontSize": 16, "strokeColor": "#2f9e44"},
// --- FLOW BOXES (center column, 150px vertical pitch) ---
{"type": "rectangle", "id": "l1", "x": 60, "y": 420, "width": 300, "height": 65,
"backgroundColor": "#a5d8ff", "strokeColor": "#1971c2", "roughness": 0,
"text": "Entry Point\nfile/path.py"},
// Split into two paths
{"type": "rectangle", "id": "l2a", "x": -100, "y": 570, "width": 290, "height": 65,
"backgroundColor": "#a5d8ff", "strokeColor": "#1971c2", "roughness": 0,
"text": "Path A\nfile/path_a.py"},
{"type": "rectangle", "id": "l2b", "x": 230, "y": 570, "width": 290, "height": 65,
"backgroundColor": "#a5d8ff", "strokeColor": "#1971c2", "roughness": 0,
"text": "Path B\nfile/path_b.py"},
// Converge point
{"type": "rectangle", "id": "l4", "x": 60, "y": 720, "width": 300, "height": 65,
"backgroundColor": "#eebefa", "strokeColor": "#9c36b5", "roughness": 0,
"text": "Convergence Point\nfile/path_merge.py"},
// Decision
{"type": "diamond", "id": "dec", "x": 110, "y": 870, "width": 200, "height": 120,
"backgroundColor": "#fff3bf", "strokeColor": "#fab005", "roughness": 0,
"text": "condition?"},
// Outcome branches
{"type": "rectangle", "id": "yes", "x": -100, "y": 1080, "width": 260, "height": 65,
"backgroundColor": "#ffc9c9", "strokeColor": "#e03131", "roughness": 0,
"text": "Expensive Operation"},
{"type": "rectangle", "id": "no", "x": 250, "y": 1080, "width": 220, "height": 65,
"backgroundColor": "#b2f2bb", "strokeColor": "#2f9e44", "roughness": 0,
"text": "Skip / Fast Path"},
// --- ARROWS (bound by ID, auto-routed) ---
{"type": "arrow", "x": 150, "y": 485, "startElementId": "l1", "endElementId": "l2a",
"text": "Path A label", "strokeColor": "#1971c2"},
{"type": "arrow", "x": 280, "y": 485, "startElementId": "l1", "endElementId": "l2b",
"text": "Path B label", "strokeColor": "#1971c2"},
{"type": "arrow", "x": 45, "y": 635, "startElementId": "l2a", "endElementId": "l4",
"text": "data form", "strokeColor": "#9c36b5"},
{"type": "arrow", "x": 375, "y": 635, "startElementId": "l2b", "endElementId": "l4",
"text": "data form", "strokeColor": "#1971c2", "strokeStyle": "dashed"},
{"type": "arrow", "x": 210, "y": 785, "startElementId": "l4", "endElementId": "dec",
"strokeColor": "#2f9e44"},
{"type": "arrow", "x": 150, "y": 990, "startElementId": "dec", "endElementId": "yes",
"text": "True", "strokeColor": "#e03131"},
{"type": "arrow", "x": 270, "y": 990, "startElementId": "dec", "endElementId": "no",
"text": "False", "strokeColor": "#2f9e44"},
// --- LAYER LABELS (left column, gray) ---
{"type": "text", "x": -100, "y": 420, "text": "Layer 1\nEntry", "fontSize": 14, "strokeColor": "#868e96"},
{"type": "text", "x": -210, "y": 570, "text": "Layer 2\nBackend", "fontSize": 14, "strokeColor": "#868e96"},
// --- DATA FORM ANNOTATIONS (right column, orange) ---
{"type": "text", "x": 570, "y": 440, "text": "Data form: Python bool", "fontSize": 14, "strokeColor": "#e8590c"},
{"type": "text", "x": 570, "y": 590, "text": "Data form: JSON / arg", "fontSize": 14, "strokeColor": "#e8590c"},
{"type": "text", "x": 570, "y": 740, "text": "Data form: Dataclass", "fontSize": 14, "strokeColor": "#e8590c"}
]
}| Component Type | Background | Stroke | When to Use |
|---|---|---|---|
| Frontend/UI | | | React, Next.js, web apps |
| Backend/API | | | API servers, processors |
| Database | | | PostgreSQL, Redis, MongoDB |
| Storage | | | S3, file systems |
| AI/ML | | | ML models, AI services |
| External API | | | Third-party services |
| Queue/Event | | | Kafka, RabbitMQ, SQS |
| Cache | | | Redis cache, Memcached |
| Decision/Gate | | | Conditionals, routers |
| Zone/Group | | | Logical groupings |
| Property | Value | Why |
|---|---|---|
| Box width | 200-240px | Fits multiline labels with breathing room |
| Box height | 120-160px | Fits 3-4 line labels comfortably |
| Horizontal gap (labeled arrows) | 150-200px | Arrow labels are ~80-120px wide, need clearance on both sides |
| Horizontal gap (unlabeled arrows) | 100-120px | Just the arrow line + breathing room |
| Column spacing (labeled) | 400px | 220px box + 180px gap |
| Column spacing (unlabeled) | 340px | 220px box + 120px gap |
| Row spacing | 280-350px | 150px box + 150px gap for arrows + annotations |
| Font size (labels) | 16px | Default, readable |
| Font size (titles) | 20-24px | Stands out as header |
| Font size (zone labels) | 14px | Subtle, doesn't compete |
| Zone opacity | 25-40 | Background, not foreground |
| Zone padding | 50-60px around children | Zone borders must NOT hug inner boxes |
| Section header to box gap | 40px | Headers need clearance from boxes below |
Title (y = -40)
[Zone 1: y=0, height=260]
[Box A: x=40] [Box B: x=440] [Box C: x=840]
[Zone 2: y=350, height=260]
[Box D: x=40] [Box E: x=440]
[Zone 3: y=700, height=260]
[Box F: x=240][Source] ──► [Transform 1] ──► [Transform 2] ──► [Output]
x=40 x=440 x=840 x=1240y [Consumer A]
▲
│
[Producer] ──► [Event Bus] ──► [Consumer B]
│
▼
[Consumer C] Layer Labels Main Flow Column Side Annotations
(left, gray) (center, colored) (right, orange)
Layer 1 ┌─────────────────────┐ Data form: Python bool
User API │ Entry Point │
│ file/path.py │
└──────┬──────┬───────┘
│ │
┌───────┘ └────────┐
▼ ▼
Layer 2 ┌──────────┐ ┌──────────┐ Data form: JSON / bool
Backend │ Path A │ │ Path B │
└────┬─────┘ └────┬─────┘
│ │ (dashed = direct)
▼ │
Layer 3 ┌──────────┐ │ Data form: Dataclass
HTTP │ Server │ │
└────┬─────┘ │
└──────┬───────┘ (converge)
▼
Layer 4 ┌─────────────────────┐ Data form: IPC message
Manager │ Manager │
└──────┬──────────────┘
▼
Layer 5 ┌─────────────────────┐ Data form: Conditional
Executor │ Executor │
└──────┬──────────────┘
▼
◇ Decision? ◇
/ \
True/ \False
▼ ▼
[Yes] [No]| Element | x | y | width | height |
|---|---|---|---|---|
| Main boxes | 60 | +150 per row | 300 | 65 |
| Split left | -100 | row_y | 290 | 65 |
| Split right | 230 | row_y | 290 | 65 |
| Decision diamond | 110 | row_y | 200 | 120 |
| Layer labels | -100 to -50 | aligned to box | — | fontSize: 14 |
| Annotations | 570 | aligned to box | — | fontSize: 14 |
| WHY section | 460, y=80 | — | 440 | 310 |
#868e96ComponentName\nfile/path.py#e8590c#a5d8ff#1971c2#eebefa#9c36b5#b2f2bb#2f9e44#fff3bf#fab005#ffc9c9#e03131#e9ecef#868e96strokeStyle: "dashed"x: 460| Mistake | Fix |
|---|---|
| Ghost elements from previous diagram | Always |
| Arrows don't connect | Set |
| Shapes overlap | Increase spacing. Use 240px column gap, 140px row gap |
| Labels cut off | Make boxes wider (200px+) or use shorter text |
| Can't tell layers apart | Add zone background rectangles with dashed stroke + low opacity |
| Too many colors | Limit to 3-4 fill colors. Same role = same color |
| Diagram too cluttered | Split into multiple diagrams, or use |
| Arrows cross messily | Rearrange shapes so related ones are adjacent. Vertical flow reduces crossings |
| Annotations overlap with flow | Use 3-column layout: labels (x<0), flow (x:60-360), annotations (x:570+) |
| Lost detail from sample diagram | Sample is source of truth for content. Reproduce ALL text verbatim — titles, subtitles, tool lists, metrics, annotations. Size boxes larger if needed |
# 1. Read the code to understand components and connections
# 2. Read the design guide
mcp__excalidraw__read_diagram_guide()
# 3. Clear canvas
mcp__excalidraw__clear_canvas()
# 4. Create everything in one batch
mcp__excalidraw__batch_create_elements(elements=[...])
# 5. Zoom to fit
mcp__excalidraw__set_viewport(scrollToContent=True)
# 6. Screenshot to verify
mcp__excalidraw__get_canvas_screenshot()
# 7. Adjust if needed, then export# For simple diagrams, Mermaid is fastest:
mcp__excalidraw__create_from_mermaid(
mermaidDiagram="graph TD; A[Frontend] -->|REST| B[API]; B -->|SQL| C[Database]"
)| Method | Output | Use Case |
|---|---|---|
| PNG file | Embed in docs, Slack, PRs |
| SVG file | Scalable, embed in web pages |
| .excalidraw JSON | Editable in excalidraw.com or VS Code |
| Shareable URL | Share with anyone, no file needed |