Diagramming
Understandable first, beautiful second. Every diagram exists to communicate — if it fails to communicate, aesthetics are
irrelevant. When both are achievable, pursue both.
References
- Visual design principles — [
${CLAUDE_SKILL_DIR}/references/design-principles.md] Gestalt principles, grid
system, spacing rules, color palette, typography, complexity budgets, anti-patterns, Tufte's data-ink principle
- Excalidraw format — [
${CLAUDE_SKILL_DIR}/references/excalidraw.md] JSON schema, element types, styling
properties, arrow binding, layout templates (linear, grid, radial, tiered, decision tree), diagram type conventions
- Mermaid syntax — [
${CLAUDE_SKILL_DIR}/references/mermaid.md] Flowchart, sequence, class, state, ER diagram
syntax, theming, per-node styling, subgraphs
Format Selection
Choose the format that matches the delivery context:
Use Mermaid when:
- The diagram lives in markdown (README, design doc, PR description, wiki)
- Auto-layout is acceptable — precise element positioning is not required
- The diagram type maps to a Mermaid-supported type
- Version-control readability matters (text diffs)
- Quick iteration speed matters more than visual refinement
Use Excalidraw when:
- Precise spatial layout is needed (architecture diagrams with specific grouping)
- The diagram needs freeform elements that don't fit a standard type
- Visual polish matters — color coding, consistent spacing, professional appearance
- The diagram will be used in presentations, external documentation, or design reviews
- The diagram needs to be manually editable after generation
Core Design Rules
These rules apply to every diagram regardless of format. They are non-negotiable.
- Consistent shapes — same concept type uses the same shape everywhere in the diagram. All services are rectangles.
All databases are cylinders. All decisions are diamonds. Never vary shapes for the same concept.
- Consistent flow direction — pick one direction (top-to-bottom or left-to-right) and maintain it for all
relationships of the same type within the diagram.
- Semantic color — color encodes meaning (tier, status, domain), never decoration. Maximum 2–3 accent colors per
diagram. Use the semantic palette from the design-principles reference.
- Label everything that isn't obvious — every arrow in a complex diagram gets a label. Every color gets a legend
entry. If a reader has to guess what something means, the diagram has failed.
- Whitespace is structure — group related elements tightly, separate groups with 2x the intra-group gap. When in
doubt, add more space.
- Complexity budget — if a diagram exceeds 20 elements, split it. Create a high-level overview + detail diagrams. No
exceptions.
Spatial Reasoning Strategy
LLMs cannot reliably reason about spatial coordinates from scratch. Compensate with these strategies:
For Excalidraw:
- Start from a layout template. Never invent coordinates from scratch. Pick the template that matches the diagram's
topology (linear flow, grid, hub-and-spoke, tiered architecture, decision tree) from the Excalidraw reference.
- Use the grid. All coordinates should be multiples of 50. Standard horizontal gap: 250px between elements.
Standard vertical gap: 150px between rows.
- Calculate before placing. Count elements first, determine grid dimensions, then assign coordinates
systematically. Do not place elements one at a time hoping they'll line up.
- Work outward from anchor points. Place the most important element first (center or top-left), then position
everything else relative to it using consistent offsets.
- Verify mentally. After computing all coordinates, check: do any elements overlap? Is the spacing consistent? Are
arrows routing cleanly (no diagonal spaghetti)?
For Mermaid:
- Let the engine handle layout. Do not fight the auto-layout — work with it.
- Use subgraphs for grouping. The engine treats subgraph contents as a unit, producing cleaner layouts.
- Keep labels short. Long labels break auto-layout. Use aliases for participants/nodes when labels exceed 3 words.
- Choose the right direction.
LR for processes, TD for hierarchies. Match direction to the conceptual flow.
- Never use lowercase
end as a node ID — it terminates blocks. See Mermaid reference for the full pitfall list.
Diagram Type Guidance
Flowcharts / Process Diagrams
- Start and end with terminal shapes (ellipse in Excalidraw,
([text]) in Mermaid)
- Decisions get diamond shapes with labeled outgoing edges ("Yes"/"No")
- Keep to a single flow direction — avoid loops that create visual spaghetti
- 3–10 steps is the sweet spot; 15 is the hard maximum per diagram
Architecture / System Diagrams
- Group related services using frames (Excalidraw) or subgraphs (Mermaid)
- Use color to distinguish tiers: frontend (blue), backend (yellow), data (green), external (purple)
- Label connections with protocols and data formats (HTTP, gRPC, SQL, JSON)
- Include a legend when using 3+ colors or shape conventions
- Show system boundaries explicitly — what's inside vs. outside the system
Sequence Diagrams
- Participants ordered left-to-right by first interaction
- Name participants with short aliases; use full names in the participant declaration
- Number messages when order matters
- Use activation boxes to show processing duration
- Keep to 3–6 participants and 10–15 messages per diagram
Entity Relationship Diagrams
- Include primary keys (PK) and foreign keys (FK) in entity definitions
- Label relationships with both the verb and cardinality
- Use grid layout — entities at regular intervals, relationships as straight-line connections
- Group related entities spatially (user-domain entities together, product-domain together)
Mind Maps
- Central topic at the center, main branches radiating outward
- 4–6 main branches maximum
- Use radial layout template (Excalidraw) — even angular distribution
- Color-code branches by theme
- Sub-topics attach to their branch, not to the center
Excalidraw Defaults
When generating Excalidraw JSON, use these defaults unless the context demands otherwise:
roughness: 0 — clean lines for professional output
fillStyle: "solid" — solid fills, not hachure
strokeWidth: 2 — normal weight
fontFamily: 5 — Excalifont (current Excalidraw default)
fontSize: 20 — box labels; 28 for titles; 16 for descriptions
roundness: { "type": 3 } — rounded rectangle corners
- Background:
#ffffff
Output Conventions
After generating a diagram:
- Save with a descriptive filename —
user-auth-flow.excalidraw or include Mermaid inline in the document
- State what the diagram shows — one sentence summarizing scope and element count
- Provide viewing instructions for Excalidraw files:
- Drag-and-drop at excalidraw.com
- Open with VS Code Excalidraw extension
- Open with Obsidian Excalidraw plugin
- Offer to split if the diagram is complex — "This has 18 elements. Want me to split into overview + detail?"
Worked Example
Request: "Create a diagram showing the user authentication flow"
Format decision: This is a process flow for a design doc → Mermaid (markdown-embedded, auto-layout sufficient).
Output:
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A([Start]) --> B[Enter Credentials]
B --> C{Valid?}
C -->|Yes| D[Generate JWT]
C -->|No| E[Show Error]
E --> B
D --> F[Redirect to Dashboard]
F --> G([End])
Created: authentication flow diagram (7 nodes, 7 edges). Embedded inline in the design document.
Request: "Create an architecture diagram of our API gateway setup"
Format decision: Architecture diagram needing spatial grouping and color-coded tiers → Excalidraw.
Agent approach:
- Count components: API Gateway, Auth Service, User Service, Product Service, PostgreSQL, Redis — 6 elements
- Select template: Tiered Architecture (3 tiers: gateway, services, data)
- Assign coordinates from template, semantic colors per tier
- Generate
.excalidraw JSON with bound arrows and labels
- Save as
api-gateway-architecture.excalidraw
Integration with Blueprint Skills
Diagrams are a design-phase artifact. They compose naturally with the blueprint pipeline:
- During
alignment — create diagrams to illustrate the problem space, compare solution options visually
- During
frame — create architecture diagrams showing component relationships, data flow, deployment topology
- Standalone — create diagrams on request outside the pipeline context
Quality Gate
Before delivering any diagram, verify:
1---2name: diagramming3description: Technical diagram creation with visual design principles: format selection, layout, readability, and aesthetics. Invoke whenever task involves any interaction with diagrams — creating, reviewing, or improving visual representations of systems, processes, data flows, or relationships using Excalidraw or Mermaid.4---56# Diagramming78Understandable first, beautiful second. Every diagram exists to communicate — if it fails to communicate, aesthetics are9irrelevant. When both are achievable, pursue both.1011## References1213- **Visual design principles** — [`${CLAUDE_SKILL_DIR}/references/design-principles.md`] Gestalt principles, grid14 system, spacing rules, color palette, typography, complexity budgets, anti-patterns, Tufte's data-ink principle15- **Excalidraw format** — [`${CLAUDE_SKILL_DIR}/references/excalidraw.md`] JSON schema, element types, styling16 properties, arrow binding, layout templates (linear, grid, radial, tiered, decision tree), diagram type conventions17- **Mermaid syntax** — [`${CLAUDE_SKILL_DIR}/references/mermaid.md`] Flowchart, sequence, class, state, ER diagram18 syntax, theming, per-node styling, subgraphs1920## Format Selection2122Choose the format that matches the delivery context:2324<format-decision>2526**Use Mermaid when:**2728- The diagram lives in markdown (README, design doc, PR description, wiki)29- Auto-layout is acceptable — precise element positioning is not required30- The diagram type maps to a Mermaid-supported type31- Version-control readability matters (text diffs)32- Quick iteration speed matters more than visual refinement3334**Use Excalidraw when:**3536- Precise spatial layout is needed (architecture diagrams with specific grouping)37- The diagram needs freeform elements that don't fit a standard type38- Visual polish matters — color coding, consistent spacing, professional appearance39- The diagram will be used in presentations, external documentation, or design reviews40- The diagram needs to be manually editable after generation4142</format-decision>4344## Core Design Rules4546These rules apply to every diagram regardless of format. They are non-negotiable.4748- **Consistent shapes** — same concept type uses the same shape everywhere in the diagram. All services are rectangles.49 All databases are cylinders. All decisions are diamonds. Never vary shapes for the same concept.50- **Consistent flow direction** — pick one direction (top-to-bottom or left-to-right) and maintain it for all51 relationships of the same type within the diagram.52- **Semantic color** — color encodes meaning (tier, status, domain), never decoration. Maximum 2–3 accent colors per53 diagram. Use the semantic palette from the design-principles reference.54- **Label everything that isn't obvious** — every arrow in a complex diagram gets a label. Every color gets a legend55 entry. If a reader has to guess what something means, the diagram has failed.56- **Whitespace is structure** — group related elements tightly, separate groups with 2x the intra-group gap. When in57 doubt, add more space.58- **Complexity budget** — if a diagram exceeds 20 elements, split it. Create a high-level overview + detail diagrams. No59 exceptions.6061## Spatial Reasoning Strategy6263LLMs cannot reliably reason about spatial coordinates from scratch. Compensate with these strategies:6465<spatial-strategy>6667**For Excalidraw:**68691. **Start from a layout template.** Never invent coordinates from scratch. Pick the template that matches the diagram's70 topology (linear flow, grid, hub-and-spoke, tiered architecture, decision tree) from the Excalidraw reference.712. **Use the grid.** All coordinates should be multiples of 50. Standard horizontal gap: 250px between elements.72 Standard vertical gap: 150px between rows.733. **Calculate before placing.** Count elements first, determine grid dimensions, then assign coordinates74 systematically. Do not place elements one at a time hoping they'll line up.754. **Work outward from anchor points.** Place the most important element first (center or top-left), then position76 everything else relative to it using consistent offsets.775. **Verify mentally.** After computing all coordinates, check: do any elements overlap? Is the spacing consistent? Are78 arrows routing cleanly (no diagonal spaghetti)?7980**For Mermaid:**81821. **Let the engine handle layout.** Do not fight the auto-layout — work with it.832. **Use subgraphs for grouping.** The engine treats subgraph contents as a unit, producing cleaner layouts.843. **Keep labels short.** Long labels break auto-layout. Use aliases for participants/nodes when labels exceed 3 words.854. **Choose the right direction.** `LR` for processes, `TD` for hierarchies. Match direction to the conceptual flow.865. **Never use lowercase `end` as a node ID** — it terminates blocks. See Mermaid reference for the full pitfall list.8788</spatial-strategy>8990## Diagram Type Guidance9192### Flowcharts / Process Diagrams9394- Start and end with terminal shapes (ellipse in Excalidraw, `([text])` in Mermaid)95- Decisions get diamond shapes with labeled outgoing edges ("Yes"/"No")96- Keep to a single flow direction — avoid loops that create visual spaghetti97- 3–10 steps is the sweet spot; 15 is the hard maximum per diagram9899### Architecture / System Diagrams100101- Group related services using frames (Excalidraw) or subgraphs (Mermaid)102- Use color to distinguish tiers: frontend (blue), backend (yellow), data (green), external (purple)103- Label connections with protocols and data formats (HTTP, gRPC, SQL, JSON)104- Include a legend when using 3+ colors or shape conventions105- Show system boundaries explicitly — what's inside vs. outside the system106107### Sequence Diagrams108109- Participants ordered left-to-right by first interaction110- Name participants with short aliases; use full names in the participant declaration111- Number messages when order matters112- Use activation boxes to show processing duration113- Keep to 3–6 participants and 10–15 messages per diagram114115### Entity Relationship Diagrams116117- Include primary keys (PK) and foreign keys (FK) in entity definitions118- Label relationships with both the verb and cardinality119- Use grid layout — entities at regular intervals, relationships as straight-line connections120- Group related entities spatially (user-domain entities together, product-domain together)121122### Mind Maps123124- Central topic at the center, main branches radiating outward125- 4–6 main branches maximum126- Use radial layout template (Excalidraw) — even angular distribution127- Color-code branches by theme128- Sub-topics attach to their branch, not to the center129130## Excalidraw Defaults131132When generating Excalidraw JSON, use these defaults unless the context demands otherwise:133134- `roughness: 0` — clean lines for professional output135- `fillStyle: "solid"` — solid fills, not hachure136- `strokeWidth: 2` — normal weight137- `fontFamily: 5` — Excalifont (current Excalidraw default)138- `fontSize: 20` — box labels; 28 for titles; 16 for descriptions139- `roundness: { "type": 3 }` — rounded rectangle corners140- Background: `#ffffff`141142## Output Conventions143144After generating a diagram:1451461. **Save with a descriptive filename** — `user-auth-flow.excalidraw` or include Mermaid inline in the document1472. **State what the diagram shows** — one sentence summarizing scope and element count1483. **Provide viewing instructions** for Excalidraw files:149 - Drag-and-drop at excalidraw.com150 - Open with VS Code Excalidraw extension151 - Open with Obsidian Excalidraw plugin1524. **Offer to split** if the diagram is complex — "This has 18 elements. Want me to split into overview + detail?"153154## Worked Example155156<examples>157158**Request:** "Create a diagram showing the user authentication flow"159160**Format decision:** This is a process flow for a design doc → Mermaid (markdown-embedded, auto-layout sufficient).161162**Output:**163164```mermaid165%%{init: {'theme': 'neutral'}}%%166flowchart TD167 A([Start]) --> B[Enter Credentials]168 B --> C{Valid?}169 C -->|Yes| D[Generate JWT]170 C -->|No| E[Show Error]171 E --> B172 D --> F[Redirect to Dashboard]173 F --> G([End])174```175176Created: authentication flow diagram (7 nodes, 7 edges). Embedded inline in the design document.177178---179180**Request:** "Create an architecture diagram of our API gateway setup"181182**Format decision:** Architecture diagram needing spatial grouping and color-coded tiers → Excalidraw.183184**Agent approach:**1851861. Count components: API Gateway, Auth Service, User Service, Product Service, PostgreSQL, Redis — 6 elements1872. Select template: Tiered Architecture (3 tiers: gateway, services, data)1883. Assign coordinates from template, semantic colors per tier1894. Generate `.excalidraw` JSON with bound arrows and labels1905. Save as `api-gateway-architecture.excalidraw`191192</examples>193194## Integration with Blueprint Skills195196Diagrams are a design-phase artifact. They compose naturally with the blueprint pipeline:197198- During `alignment` — create diagrams to illustrate the problem space, compare solution options visually199- During `frame` — create architecture diagrams showing component relationships, data flow, deployment topology200- Standalone — create diagrams on request outside the pipeline context201202## Quality Gate203204Before delivering any diagram, verify:205206- [ ] All elements have unique IDs (Excalidraw)207- [ ] No elements overlap — coordinates verified against element sizes208- [ ] Text is readable — minimum 14px, labels fit within their containers209- [ ] Colors follow semantic palette — no decorative rainbow210- [ ] Arrows are labeled when the relationship isn't obvious211- [ ] Flow direction is consistent throughout212- [ ] Element count is within budget (≤20, or split proposed)213- [ ] Legend present if using color/shape coding with 3+ categories