Skills diagram-drawing
Generate production-quality SVG+PNG technical diagrams from natural language. Use when user wants to create any technical diagram — architecture, data flow, flowchart, sequence, agent/memory, UML, mind map, or concept map — and export as SVG+PNG. Triggers (EN): "generate diagram", "draw diagram", "create chart", "visualize", "architecture diagram", "flowchart", "sequence diagram", "data flow", "tech graph". Triggers (中文): "画图", "帮我画", "生成图", "做个图", "架构图", "流程图", "可视化", "出图", "技术图". Also triggers on any system/flow description the user wants illustrated, especially for AI/Agent systems (RAG, Agentic Search, Mem0, Multi-Agent, Tool Call).
git clone https://github.com/openclaw/skills
T=$(mktemp -d) && git clone --depth=1 https://github.com/openclaw/skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/0xcjl/diagram-drawing" ~/.claude/skills/clawdbot-skills-diagram-drawing && rm -rf "$T"
skills/0xcjl/diagram-drawing/SKILL.mdDiagram Drawing
Generate production-quality SVG+PNG technical diagrams from natural language descriptions.
Quick Start
- Classify diagram type from user request
- Extract layers, nodes, edges, flows
- Plan layout (top→bottom for most, left→right for wide flows)
- Generate SVG with semantic shapes and arrows
- Export PNG at 1920px width
Diagram Types & Layout
Architecture
Nodes = services/components. Group into horizontal layers (top→bottom or left→right).
- Typical: Client → Gateway → Services → Data/Storage
- Dashed
containers group related services<rect> - ViewBox:
or0 0 960 6000 0 960 800
Data Flow
Label every arrow with data type ("embeddings", "query", "context"). Wider arrows for primary paths.
Flowchart / Process
Top-to-bottom preferred. Diamond = decision, rounded rect = process, parallelogram = I/O.
Agent Architecture
5 layers: Input → Agent Core (LLM) → Memory → Tools → Output
- Show iterative reasoning with loop arcs (curved arrows)
- Separate memory read/write paths visually
Memory Architecture (Mem0-style)
- Show memory write path and read path separately
- Tiers: Working → Short-term → Long-term → External Store
- Operations:
,store()
,retrieve()
,forget()consolidate()
Sequence Diagram
- Vertical lifelines (dashed lines)
- Horizontal arrows = messages, top-to-bottom time order
- Activation boxes (thin filled rects on lifeline)
- ViewBox height = 80 + (num_messages × 50)
Comparison Matrix
- Column headers = systems, row headers = attributes
- Checked:
fill + ✓; unsupported:#dcfce7
fill#f9fafb
Mind Map
- Central node at
cx=480, cy=280 - Curved bezier branches, not straight lines
- First-level: 360/N degrees apart
UML Diagrams
- Class: 3-compartment rect (name / attributes / methods)
- Use Case: Ellipse + stick figure actors
- State Machine: Rounded rects + transitions with guards
- ER: Rect entities + diamond relationships + cardinality
Shape Vocabulary
| Concept | Shape |
|---|---|
| User / Human | Circle head + body path |
| LLM / Model | Rounded rect, double border, ⚡ |
| Agent | Hexagon or double-border rect |
| Memory (short-term) | Dashed-border rounded rect |
| Memory (long-term) | Solid cylinder |
| Vector Store | Cylinder with grid lines |
| Graph DB | 3 overlapping circles |
| Tool / Function | Rect with ⚙ icon |
| API Gateway | Hexagon |
| Queue / Stream | Horizontal pipe/tube |
| Document | Folded-corner rect |
| Browser / UI | Rect with 3-dot titlebar |
| Decision | Diamond |
Arrow Semantics
| Flow Type | Color | Stroke | Dash |
|---|---|---|---|
| Primary data | blue | 2px solid | none |
| Control/trigger | orange | 1.5px solid | none |
| Memory read | green | 1.5px solid | none |
| Memory write | green | 1.5px | |
| Async/event | gray | 1.5px | |
| Embedding | purple | 1px solid | none |
| Feedback/loop | purple | 1.5px curved | none |
Always include a legend when 2+ arrow types are used.
Workflow (Always Follow)
- Classify diagram type
- Extract structure — layers, nodes, edges, flows
- Plan layout
- Load style reference from
for exact colorsreferences/styles.md - Map nodes to shapes
- Check
for known productsreferences/icons.md - Generate SVG
- Validate: run
orpython3 scripts/svg2png.py <file.svg>rsvg-convert - Export PNG at 1920px width
- Report output paths
SVG Generation Strategy
Estimate complexity:
- Count nodes: N, arrows: A
- Estimated SVG lines: L = 50 (header) + N×15 + A×3 + 20 (legend)
Generation method:
- L < 150: Write tool directly (single call, most reliable)
- L ≥ 150: Python script via exec tool (avoids heredoc issues)
Python method (recommended for complex SVGs):
python3 << 'EOF' svg_content = '''<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 600"> ...complete SVG here... </svg>''' with open('/path/to/output.svg', 'w') as f: f.write(svg_content) print("Generated output.svg") EOF
SVG Technical Rules
- ViewBox:
default;0 0 960 600
tall;0 0 960 800
wide0 0 1200 600 - Fonts:
— no external @import<style>font-family: system-ui, Helvetica, sans-serif</style>
: arrow markers, gradients, filters, clip paths<defs>- Text: minimum 12px, prefer 13-14px labels
- All arrows:
with<marker>
, sizedmarkerEndmarkerWidth="10" markerHeight="7" - Drop shadows:
sparingly<feDropShadow> - Curved paths:
cubic bezierM x1,y1 C cx1,cy1 cx2,cy2 x2,y2
Built-in Patterns
RAG Pipeline: Query → Embed → VectorSearch → Retrieve → LLM → Response Agentic RAG: Query → Embed → VectorSearch → Agent loop (Tool use) → LLM → Response Agentic Search: Query → Planner → [Search / Calculator / Code] → Synthesizer → Response Mem0 Memory: Input → Memory Manager → [Write: VectorDB + GraphDB] → [Read: Retrieve+Rank] → Context Multi-Agent: Orchestrator → [SubAgent A / B / C] → Aggregator → Output Tool Call Flow: LLM → Tool Selector → Tool Execution → Parser → LLM (loop)
Error Recovery
| Problem | Fix |
|---|---|
| PNG blank/black | Remove — use system fonts only |
| rsvg-convert not found | Use fallback |
| SVG cut off at bottom | Increase ViewBox height |
| Text overflowing | + shorten label |
| Marker undefined | Ensure in |
| Arrow crossing nodes | Use orthogonal routing or bezier detour |
Output
- Default:
and./[derived-name].svg./[derived-name].png - Custom: user specifies
--output /path/
Styles
| # | Name | Background | Best For |
|---|---|---|---|
| 1 | Flat Icon (default) | White | Blogs, docs, slides |
| 2 | Dark Terminal | | GitHub, dev articles |
| 3 | Blueprint | | Architecture docs |
| 4 | Notion Clean | White | Notion, wikis |
| 5 | Glassmorphism | gradient | Product sites, keynotes |
| 6 | Claude Official | warm cream | Anthropic-style diagrams |
| 7 | OpenAI Official | Pure white | OpenAI-style diagrams |
Load
references/styles.md for exact color tokens and patterns.