axiomantic/spellbook/generating-diagrams
Claude Code and agent skill by axiomantic/spellbook
- community
Checking that the SKILL.md file is still in the repository.
Use when generating flowcharts, diagrams, dependency graphs, or visual representations of processes, relationships, architecture, or state machines. Triggers: 'diagram this', 'flowchart', 'visualize', 'dependency graph', 'ER diagram', 'state machine diagram', 'class diagram', 'sequence diagram', 'map the relationships', 'draw the architecture', 'how does X connect to Y'. NOT for: simple bullet point explanations, runtime monitoring, or text-only documentation.
Install
npx vskill@latest install axiomantic/spellbook/generating-diagramsSKILL.md
The same SKILL.md was published earlier as axiomantic/spellbook/generating-diagrams.
Generating Diagrams
<ROLE> Diagram Architect. Your reputation depends on diagrams that are accurate, renderable, and exhaustively sourced from real material -- never invented. </ROLE>
Overview
Generate accurate, renderable, exhaustive diagrams from code, processes, instructions, or architecture. Every node justified by source material. Every reference traced to its deepest level. Mermaid for inline markdown; Graphviz DOT for complex or heavily styled output.
When to Use
- Visualizing process flows, decision trees, or multi-phase workflows
- Mapping dependency/invocation relationships between components
- Documenting state machines or lifecycle transitions
- Creating entity-relationship or class hierarchy diagrams
- Analyzing skill, command, or instruction structure visually
- Generating sequence diagrams for temporal interactions
When NOT to use: Structure is flat (no branches, decisions, or relationships) AND content is 10 items or fewer -- a list or table suffices. Runtime observability. Text-only documentation.
Invariant Principles
- Source-Grounded Nodes: Every node traces to a specific source location (file:line, section heading, or code symbol). No invented nodes.
- Exhaustive Traversal: Follow every reference, invocation, and branch to its terminal point. "..." and "etc." are forbidden. If too complex for one diagram, decompose into linked diagrams.
- One Entity, One Node: Each entity appears exactly once in relationship/dependency diagrams. Multiple connections use multiple edges, not duplicate nodes.
- Renderability Over Completeness: A diagram that cannot render is worthless. Always verify. When too complex for one diagram, decompose.
Quick Reference
| Diagram Type | Best For | Mermaid Syntax | Graphviz Alternative | |
|---|---|---|---|---|
| Flowchart | Processes, decisions, workflows | flowchart TD | digraph { } with shapes | |
| Sequence | Temporal interactions, request/response | sequenceDiagram | Not recommended | |
| State | Lifecycles, state machines | stateDiagram-v2 | digraph { } with edge labels | |
| ER | Data models, entity relationships | erDiagram | graph { } undirected | |
| Class | Type hierarchies, composition | classDiagram | digraph { } with record shapes | |
| Dependency | Import/invocation graphs | flowchart LR | digraph { } with clusters |
Workflow
Phase 1: Analysis
<analysis>Before generating any diagram, identify: subject type, traversal scope, source material locations, and rendering format.</analysis>
1.1 Identify Diagram Subject
| Subject Type | Examples | Primary Diagram Type | |
|---|---|---|---|
| Process/workflow | CI pipeline, feature workflow, approval flow | Flowchart | |
| Temporal interaction | API call sequence, auth handshake | Sequence | |
| Lifecycle/states | Order states, connection lifecycle | State | |
| Data model | Database schema, domain entities | ER | |
| Type hierarchy | Class inheritance, interface impl | Class | |
| Dependencies | Module imports, skill invocations, package deps | Dependency graph |
If the subject spans multiple types, produce separate diagrams for each concern rather than a hybrid.
1.2 Scope the Traversal
Define boundaries BEFORE reading source material. Confirm with user; in autonomous mode, use default depth.
Default DEPTH: follow all references until reaching external dependencies or leaf nodes.
1.3 Select Format
| Criterion | Mermaid | Graphviz DOT | |
|---|---|---|---|
| Node count < 50 | Yes | Overkill | |
| Node count 50-150 | Risky (test render) | Yes | |
| Node count > 150 | No (decompose) | Yes (with clusters) | |
| Needs GitHub inline rendering | Yes | No (render to SVG) | |
| Complex layout (overlapping edges) | Limited control | Full control | |
| Custom styling (colors, fonts, shapes) | Basic | Full | |
| Subgraph nesting > 3 levels | Fragile | Solid |
Default: Mermaid unless complexity indicators from the table above suggest otherwise.
1.4 Plan Decomposition (if needed)
When estimated node count exceeds format limits:
- Level 0 (Overview): High-level boxes with phase/component names. No internal detail. Include "see Diagram N" references.
- Level 1 (Phase Detail): One diagram per major phase/component. Shows all internal steps and decision points.
- Level 2 (Deep Dive): Optional. For phases that are themselves complex (e.g., a sub-skill with its own multi-phase workflow).
Each level's diagrams must use consistent node IDs so cross-references are unambiguous.
Phase 2: Content Extraction
<CRITICAL> Phase 2 traversal is mandatory. Skipping it to go directly to generation produces invented nodes and missing edges. There are no shortcuts here. </CRITICAL>
2.1 Systematic Traversal Protocol
Extract from each source file/section:
- Decision points (if/else, switch, routing logic)
- Subagent dispatches or skill invocations
- Data transformations (input -> output)
- Quality gates (pass/fail with consequences)
- Loop/retry logic
- Terminal conditions (exit, error, completion)
- Conditional branches (with the condition on the edge label)
2.2 Verify Completeness
- [ ] Every item in VISITED has at least one edge (no orphan nodes)
- [ ] Every terminal node is explicitly marked (success, error, exit)
- [ ] Every decision has all branches represented (not just the happy path)
- [ ] Every loop has both continue and break conditions
- [ ] No "..." or placeholder nodes exist
Phase 3: Diagram Generation
3.1 Generate Diagram Code
| Rule | Mermaid | Graphviz | |
|---|---|---|---|
| Flow direction | TD for processes, LR for dependencies | rankdir=TB or rankdir=LR | |
| Subgraphs | Group by phase/component | subgraph cluster_name { } | |
| Decision nodes | {Diamond text} | shape=diamond | |
| Process nodes | [Rectangle text] | shape=box | |
| Terminal nodes | ([Stadium text]) | shape=doubleoctagon | |
| Subagent dispatch | Blue fill | fillcolor="#4a9eff" | |
| Quality gate | Red fill | fillcolor="#ff6b6b" | |
| Conditional edge | Dashed line + label | style=dashed, label="condition" |
Node label guidelines:
- Max 5 words per line
- Use
<br/>for line breaks in Mermaid,\nin Graphviz - Put detail in edge labels or annotations, not node labels
- Reference skill/command names inline:
Invoke: skill-name
Multiplicity annotation: When the same target is invoked multiple times from the same source, use a single edge with multiplicity in the label: -->|"x3: per-task, comprehensive, pre-PR"| FC. Create separate edges only when the edge source, target, or conditional label differs between invocations.
3.2 Generate Legend
Every diagram MUST include a legend. For Mermaid, add a disconnected subgraph:
Include color meanings if using classDef or fill colors. For Graphviz, add subgraph cluster_legend.
3.3 Generate Cross-Reference Table
For decomposed diagrams, produce a table mapping node IDs to their detail diagram:
| Node in Overview | Detail Diagram | Source File | |
|---|---|---|---|
phase_1 | Diagram 2: Research | commands/feature-research.md | |
phase_2 | Diagram 3: Design | commands/feature-design.md |
Phase 4: Verification
4.1 Syntax Check
- Mermaid: Paste into mermaid.live or a local renderer
- Graphviz: Run
dot -Tsvg input.dot -o output.svg - If no renderer available, manual syntax audit:
- Count opening/closing braces and brackets (must match)
- Verify every
subgraphhas a matchingend - Verify all node IDs are alphanumeric (no spaces or unquoted special chars)
- Verify all edge labels use correct quoting (
|"label"|for Mermaid) - Verify
classDefnames matchclassreferences - Check for Mermaid reserved words used as node IDs (
end,graph,subgraph)
4.2 Renderability Check
| Issue | Symptom | Fix | |
|---|---|---|---|
| Too many nodes | Render timeout or blank output | Decompose into levels | |
| Overlapping labels | Text collision in rendered output | Shorten labels, use edge labels | |
| Subgraph overflow | Nodes escape their container | Reduce nesting depth, use clusters | |
| Mermaid max nodes (~100) | Render fails silently | Switch to Graphviz or decompose | |
| Edge spaghetti | Unreadable crossing lines | Reorder nodes, use LR vs TD, add invisible edges for spacing |
4.3 Completeness Check
- Every file/section in scope has corresponding nodes
- Every conditional branch from source appears as a labeled edge
- Every skill/subagent invocation is represented
- Every quality gate shows both pass and fail paths
- Terminal conditions match source (exit, error, completion, loop-back)
If anything is missing, return to Phase 2 and re-traverse.
<reflection>After generating any diagram, verify: every node traces to source, no placeholders remain, legend is present, syntax renders cleanly, and completeness check passes.</reflection>
Mermaid in Markdown Files
When writing mermaid diagrams inside markdown files, use <br> for newlines within node labels. Never use literal newline characters inside node text, as they break the mermaid parser in most renderers.
Mermaid Syntax Reference
Graphviz DOT Reference
Common Mistakes
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/generating-diagrams/SKILL.md
Popularity
- Repository stars
- 10
- Repository forks
- 6
- 7-day trend score
- 12
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/axiomantic/spellbook/generating-diagrams)