Help us improve
Share bugs, ideas, or general feedback.
Use when the user wants to create any technical diagram - architecture, data flow, flowchart, sequence, agent/memory, or concept map - and export as SVG+PNG. Trigger on: "画图" "帮我画" "生成图" "做个图" "架构图" "流程图" "可视化一下" "出图" "generate diagram" "draw diagram" "visualize" or any system/flow description the user wants illustrated.
npx claudepluginhub theglitchking/the-joy-of-diagramingHow this skill is triggered — by the user, by Claude, or both
Slash command
/the-joy-of-diagraming:the-joy-of-diagramingThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Generate production-quality SVG technical diagrams exported as PNG via `@resvg/resvg-js`.
fixtures/agent-memory-types-style4.jsonfixtures/api-flow-style7.jsonfixtures/mem0-style1.jsonfixtures/microservices-style3.jsonfixtures/multi-agent-style5.jsonfixtures/system-architecture-style6.jsonfixtures/tool-call-style2.jsonreferences/icons.mdreferences/style-1-flat-icon.mdreferences/style-2-dark-terminal.mdreferences/style-3-blueprint.mdreferences/style-4-notion-clean.mdreferences/style-5-glassmorphism.mdreferences/style-6-claude-official.mdreferences/style-7-openai.mdreferences/style-diagram-matrix.mdreferences/svg-layout-best-practices.mdscripts/README.mdscripts/generate-diagram.jsscripts/generate-diagram.shProvides a checklist for code reviews covering functionality, security, performance, maintainability, tests, and quality. Use for pull requests, audits, team standards, and developer training.
Share bugs, ideas, or general feedback.
Generate production-quality SVG technical diagrams exported as PNG via @resvg/resvg-js.
Install this skill from GitHub:
npx skills add the-glitch-king/the-joy-of-diagraming
Public package page:
https://www.npmjs.com/package/@the-glitch-king/the-joy-of-diagraming
Do not pass @the-glitch-king/the-joy-of-diagraming directly to skills add, because the CLI expects a GitHub or local repository source.
Update command:
npx skills add the-glitch-king/the-joy-of-diagraming --force -g -y
Four helper scripts in scripts/ directory provide stable SVG generation and validation:
generate-diagram.js - Validate SVG + export PNGnode scripts/generate-diagram.js -t architecture -s 1 -o ./output/arch.svg
node scripts/generate-diagram.js -t architecture -s 1 -o ./output/arch.svggenerate-from-template.js - Create starter SVG from templatenode scripts/generate-from-template.js architecture ./output/arch.svg '{"title":"My Diagram","nodes":[],"arrows":[]}'
validate-svg.js - Validate SVG syntaxnode scripts/validate-svg.js <svg-file>
test-all-styles.js - Batch test all stylesnode scripts/test-all-styles.js
When to use scripts:
When to generate SVG directly:
references/style-1-flat-icon.md unless user specifies another; load the matching references/style-N.md for exact color tokens and SVG patternsreferences/icons.md for known productsnode scripts/validate-svg.js file.svg to check syntaxnode scripts/generate-diagram.js -t architecture -o file.svgNodes = services/components. Group into horizontal layers (top→bottom or left→right).
Canvas sizing for layered architecture — calculate before writing any JSON:
height = last_container_bottom + 130 (room for legend + footer)last_container_bottom = first_container_y + (num_layers × container_height) + ((num_layers - 1) × 15)Container layout rules — the #1 cause of visual overlap:
y = 80. Each next: y = prev_y + prev_height + 15 (never less than 15px gap)node_height + 60 (40px top clearance for section label + 20px bottom padding)
x = 120; width = canvas_width − 200 (leaves 80px right margin)UI, API, SVC, DATA, INTG, OBS). Set side_label_anchor: "end", side_label_x: 112Node positioning — nodes MUST clear the section label:
y = container_y + 50 (not 40 — the section label at y+24 needs 26px of clear space below it)gap = (container_width - num_nodes × node_width) / (num_nodes + 1)node_1_x = container_x + gapnode_n_x = node_(n-1)_x + node_width + gapNode sizing — calculate width before placing:
max(160, label.length × 9 + 40) — never let labels clipCross-layer arrow routing — arrows skipping intermediate layers must NOT route through nodes:
"corridor_x": [x] to force routing through a clear vertical channelx = container_x - 10 = ~110), right edge (x = container_x + container_width + 10 = ~1270)label field — let arrow color + legend carry the meaningLegend placement:
legend_position: "bottom-left", legend_x: 130, legend_y: last_container_bottom + 60legend_y + (num_legend_items × 22) + 40 to avoid clippingEmphasizes what data moves where. Focus on data transformation.
stroke-width: 2.5) for primary data pathsSequential decision/process steps.
Shows how an AI agent reasons, uses tools, and manages memory. Key conceptual layers to always consider:
Specialized agent diagram focused on memory operations.
store(), retrieve(), forget(), consolidate()Time-ordered message exchanges between participants.
<rect> loop/alt frames with label in top-left cornerSide-by-side comparison of approaches, systems, or components.
#dcfce7) + ✓ checkmark; unsupported: #f9fafb fill#f9fafb / #ffffff) for readabilityHorizontal time axis showing durations, phases, and milestones.
0 0 960 400 typical; wider for many time periods: 0 0 1200 400Radial layout from central concept.
cx=480, cy=280<path> with cubic bezier for branches, not straight linesStatic structure showing classes, attributes, methods, and relationships.
+ public, - private, # protected)<<interface>> stereotype above name, or circle/lollipop notation<<enumeration>> stereotype, values in bottom0 0 960 600 standard; 0 0 960 800 for deep hierarchiesSystem functionality from user perspective.
<<include>> from base to included use case<<extend>> from extension to base use case0 0 960 600 standardLifecycle states and transitions of an entity.
entry/ action, exit/ action, do/ activity[condition]event [guard] / action
/0 0 960 600 standardDatabase schema and data relationships.
1, N, 0..1, 0..*, 1..*0 0 960 600 standard; wider 0 0 1200 600 for many entitiesPhysical or logical network infrastructure.
0 0 960 600 standardFull mapping of UML 14 diagram types to supported diagram types:
| UML Diagram | Supported As | Notes |
|---|---|---|
| Class | Class Diagram | Full UML notation |
| Component | Architecture Diagram | Use colored fills per component type |
| Deployment | Architecture Diagram | Add node/instance labels |
| Package | Architecture Diagram | Use dashed grouping containers |
| Composite Structure | Architecture Diagram | Nested rects within components |
| Object | Class Diagram | Instance boxes with underlined name |
| Use Case | Use Case Diagram | Full actor/ellipse/relationship |
| Activity | Flowchart / Process Flow | Add fork/join bars |
| State Machine | State Machine Diagram | Full UML notation |
| Sequence | Sequence Diagram | Add alt/opt/loop frames |
| Communication | — | Approximate with Sequence (swap axes) |
| Timing | Timeline | Adapt time axis |
| Interaction Overview | Flowchart | Combine activity + sequence fragments |
| ER Diagram | ER Diagram | Chen/Crow's foot notation |
Map semantic concepts to consistent shapes across all diagram types:
| Concept | Shape | Notes |
|---|---|---|
| User / Human | Circle + body path | Stick figure or avatar |
| LLM / Model | Rounded rect with brain/spark icon or gradient fill | Use accent color |
| Agent / Orchestrator | Hexagon or rounded rect with double border | Signals "active controller" |
| Memory (short-term) | Rounded rect, dashed border | Ephemeral = dashed |
| Memory (long-term) | Cylinder (database shape) | Persistent = solid cylinder |
| Vector Store | Cylinder with grid lines inside | Add 3 horizontal lines |
| Graph DB | Circle cluster (3 overlapping circles) | |
| Tool / Function | Gear-like rect or rect with wrench icon | |
| API / Gateway | Hexagon (single border) | |
| Queue / Stream | Horizontal tube (pipe shape) | |
| File / Document | Folded-corner rect | |
| Browser / UI | Rect with 3-dot titlebar | |
| Decision | Diamond | Flowcharts only |
| Process / Step | Rounded rect | Standard box |
| External Service | Rect with cloud icon or dashed border | |
| Data / Artifact | Parallelogram | I/O in flowcharts |
Always assign arrow meaning, not just color:
| Flow Type | Color | Stroke | Dash | Meaning |
|---|---|---|---|---|
| Primary data flow | blue #2563eb | 2px solid | none | Main request/response path |
| Control / trigger | orange #ea580c | 1.5px solid | none | One system triggering another |
| Memory read | green #059669 | 1.5px solid | none | Retrieval from store |
| Memory write | green #059669 | 1.5px | 5,3 | Write/store operation |
| Async / event | gray #6b7280 | 1.5px | 4,2 | Non-blocking, event-driven |
| Embedding / transform | purple #7c3aed | 1px solid | none | Data transformation |
| Feedback / loop | purple #7c3aed | 1.5px curved | none | Iterative reasoning loop |
Always include a legend when 2+ arrow types are used.
Spacing:
container_y + 50 to clear the section labellast_container_bottom + 130 minimum (legend + footer)Legend placement:
legend_position: "bottom-left", legend_x: 130legend_y = last_container_bottom + 60legend_y + (num_items × 22) + 40Pre-generation checklist — run through this before writing the JSON:
y = prev_y + prev_height + 15last_container_bottom + 130max(160, label.length × 9 + 40), same width across each layercontainer_y + 50Arrow Labels (CRITICAL):
<rect fill="canvas_bg" opacity="0.95"/> with 4px horizontal, 2px vertical paddingArrow Routing:
Line Overlap Prevention (CRITICAL - most common bug on Codex): When two arrows must cross each other, ALWAYS use jump-over arcs to prevent visual overlap:
Validation Checklist (run before finalizing):
text.length × 7px ≤ shape_width - 16px)<style>font-family: ...</style> — no external @import (breaks resvg-js)<defs>: arrow markers, gradients, filters, clip paths<marker> with markerEnd, sized markerWidth="10" markerHeight="7"<feDropShadow> in <filter>, apply sparingly (key nodes only)M x1,y1 C cx1,cy1 cx2,cy2 x2,y2 cubic bezier for loops/feedback arrows<clipPath> if text might overflow a node boxMANDATORY: Use the JS generator (always use this, never write raw SVG by hand):
node scripts/generate-from-template.js <template-type> <output-path> '<json-data>'
Example:
node scripts/generate-from-template.js architecture ./output/arch.svg '{"style":6,"title":"My Diagram","height":890,"containers":[...],"nodes":[...],"arrows":[...],"legend":[...]}'
Then export to PNG:
node scripts/generate-diagram.js -t architecture -o ./output/arch.svg -w 1920
Why mandatory: The JS generator handles XML escaping, marker defs, orthogonal routing, and label collision avoidance automatically. Writing raw SVG by hand introduces syntax errors and layout bugs.
Pre-Tool-Call Checklist (CRITICAL - use EVERY time):
If ANY answer is NO: STOP. Do NOT call the tool. Prepare the content first.
Error Recovery Protocol:
Validation (run after generation):
rsvg-convert file.svg -o /tmp/test.png 2>&1 && echo "✓ Valid" && rm /tmp/test.png
If using generate-from-template.js:
source / target node ids in arrow JSON so the generator can snap to node edgesx1,y1,x2,y2 as hints or fallback coordinates, not the main routing primitiveCommon Syntax Errors to Avoid:
yt-anchor → ✅ y="60" text-anchor="middle"x="390 (missing y) → ✅ x="390" y="250"fill=#fff → ✅ fill="#ffffff"marker-end= → ✅ marker-end="url(#arrow)"L 29450 → ✅ L 290,220</svg> at end./[derived-name].svg and ./[derived-name].png in current directory--output /path/ or 输出到 /path/node scripts/generate-diagram.js -t architecture -o file.svg (1920px = 2x retina)| # | Name | Background | Best For |
|---|---|---|---|
| 1 | Flat Icon (default) | White | Blogs, docs, presentations |
| 2 | Dark Terminal | #0f0f1a | GitHub, dev articles |
| 3 | Blueprint | #0a1628 | Architecture docs |
| 4 | Notion Clean | White, minimal | Notionnce |
| 5 | Glassmorphism | Dark gradient | Product sites, keynotes |
| 6 | Claude Official | Warm cream #f8f6f3 | Anthropic-style diagrams |
| 7 | OpenAI Official | Pure white #ffffff | OpenAI-style diagrams |
Load references/style-N.md for exact color tokens and SVG patterns.
Default: Style 1 (Flat Icon) for most diagrams. Load references/style-diagram-matrix.md for detailed style-to-diagram-type recommendations.
These patterns appear frequently — internalize them:
RAG Pipeline: Query → Embed → VectorSearch → Retrieve → Augment → LLM → Response Agentic RAG: adds Agent loop with Tool use between Query and LLM Agentic Search: Query → Planner → [Search Tool / Calculator / Code] → Synthesizer → Response Mem0 / Memory Layer: Input → Memory Manager → [Write: VectorDB + GraphDB] / [Read: Retrieve+Rank] → Context Agent Memory Types: Sensory (raw input) → Working (context window) → Episodic (past interactions) → Semantic (facts) → Procedural (skills) Multi-Agent: Orchestrator → [SubAgent A / SubAgent B / SubAgent C] → Aggregator → Output Tool Call Flow: LLM → Tool Selector → Tool Execution → Result Parser → LLM (loop)