drawing-diagrams
Generate Mermaid diagrams from context and open them in mermaid.live in the browser. Use when the user asks for a diagram, visualization, flowchart, sequence diagram, ER diagram, or any visual representation of code, architecture, or processes. Produces lightweight, shareable mermaid.live URLs that open in the browser for interactive editing.
- License 许可
- MIT
- 最近更新
- 2026-03-27
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- drawing-diagrams
- license
- MIT
- skip_when
- The user needs a rich, branded, or styled HTML visualization (use ring:visual-explainer instead). This skill produces shareable mermaid.live URLs; visual-explainer produces self-contained Lerian-branded HTML files.
- description
- Generate Mermaid diagrams from context and open them in mermaid.live in the browser. Use when the user asks for a diagram, visualization, flowchart, sequence diagram, ER diagram, or any visual representation of code, architecture, or processes. Produces lightweight, shareable mermaid.live URLs that open in the browser for interactive editing.
- compatibility
- Requires Python 3 (standard library only) and a browser. Uses `open` on macOS; Linux users need `xdg-open`.
02 资源文件 1
- 脚本mermaid-encode.py3.0 KB
03 SKILL.md 正文
Mermaid Live Diagram Generator
Generate Mermaid diagrams and open them directly in mermaid.live in the user's browser.
When to Use
- User explicitly asks for a diagram, chart, or visualization
- User asks to visualize architecture, data flow, state machines, sequences, relationships
- When explaining complex systems where a visual would be more effective than prose
- User says "draw", "diagram", "visualize", "chart", "flowchart", "show me"
Workflow
Step 1: Determine Diagram Type
Choose the most appropriate Mermaid diagram type:
| Need | Diagram Type | Keyword |
|---|---|---|
| Process flow, decision trees | Flowchart | flowchart TD or flowchart LR |
| API calls, message passing | Sequence | sequenceDiagram |
| OOP structure, interfaces | Class | classDiagram |
| Database schema, entities | ER | erDiagram |
| State machines, lifecycles | State | stateDiagram-v2 |
| Project timelines | Gantt | gantt |
| Distribution/proportions | Pie | pie |
| Git branch strategy | Git Graph | gitGraph |
| User experience mapping | Journey | journey |
| Prioritization matrix | Quadrant | quadrantChart |
| Data over time | XY Chart | xychart-beta |
| Chronological events | Timeline | timeline |
| Brainstorming | Mindmap | mindmap |
Step 2: Write the Mermaid Code
Write clean, well-structured Mermaid code. Key syntax rules:
Flowchart nodes:
A[Rectangle]A(Rounded)A{Diamond}A((Circle))A[(Database)]- Edges:
-->(arrow),-.->(dotted),==>(thick),~~~(invisible) - Link text:
A -->|label| B - Subgraphs:
subgraph title ... end
Sequence diagrams:
participant Aoractor A- Arrows:
->>(solid+arrow),-->>(dotted+arrow),-x(destroy),-)(async) - Blocks:
loop,alt/else,opt,par/and,critical/option,break - Notes:
Note right of A: text autonumberfor sequence numbers
ER diagrams:
- Relationships:
||--o{(one to many),||--||(one to one),}o--o{(many to many) --(identifying/solid),..(non-identifying/dashed)- Attributes:
ENTITY { type name PK/FK/UK "comment" }
Class diagrams:
- Visibility:
+public,-private,#protected,~package - Relations:
<|--inheritance,*--composition,o--aggregation,-->association <<interface>>,<<abstract>>annotations
State diagrams:
[*]for start/end statesstate "description" as s1<<choice>>,<<fork>>,<<join>>--separator for concurrent states
CRITICAL: Avoid the word end in lowercase inside node labels -- it's a reserved keyword. Use End, END, or wrap in quotes.
Step 3: Encode and Open in Browser
Write the mermaid code to a temp file, then use the bundled encoder script:
# macOS: uses `open`. On Linux, replace `open` with `xdg-open`.
cat <<'MERMAID_EOF' | python3 ~/.claude/skills/drawing-diagrams/mermaid-encode.py | xargs open
<mermaid code here>
MERMAID_EOF
Options:
--theme dark-- use dark theme (options: default, dark, forest, neutral)--view-- open in view-only mode (no editor)--rough-- hand-drawn/sketchy style
Example with options:
cat <<'MERMAID_EOF' | python3 ~/.claude/skills/drawing-diagrams/mermaid-encode.py --theme forest --rough | xargs open
flowchart LR
A[Start] --> B{Decision}
B -->|Yes| C[Do thing]
B -->|No| D[Other thing]
MERMAID_EOF
Step 4: Inform the User
After opening the browser, tell the user:
- What diagram type was chosen and why
- A brief description of what the diagram shows
- That it's open in mermaid.live where they can edit it further
- The mermaid.live URL (so they can share it)
Diagram Design Guidelines
- Readable labels: Use short, descriptive text. No full sentences in nodes.
- Logical flow direction: TD for hierarchies, LR for sequences/timelines.
- Use subgraphs: Group related nodes for clarity in complex diagrams.
- Color with purpose: Use
classDefto highlight important nodes (errors in red, success in green, etc.) - Keep it focused: A diagram should communicate ONE main idea. Split complex systems into multiple diagrams.
Quick Reference: Common Patterns
Architecture Diagram
flowchart TD
subgraph Client
A[Browser] --> B[Mobile App]
end
subgraph API["API Gateway"]
C[Load Balancer]
end
subgraph Services
D[Auth Service]
E[Core Service]
F[Notification Service]
end
Client --> API --> Services
Database Schema
erDiagram
USER ||--o{ ORDER : places
ORDER ||--|{ LINE_ITEM : contains
PRODUCT ||--o{ LINE_ITEM : "ordered in"
API Flow
sequenceDiagram
autonumber
Client->>+API: POST /resource
API->>+DB: INSERT
DB-->>-API: OK
API-->>-Client: 201 Created
Important Notes
- The encoder script uses ONLY Python standard library -- no pip install needed
- Works on macOS (uses
opencommand) -- for Linux, users would needxargs xdg-open - URLs have no expiry -- they're self-contained (the diagram state IS the URL)
- Very large diagrams may exceed URL length limits (~2000 chars for some browsers, ~65K for most modern ones)
- The
--roughflag gives a hand-drawn sketchy look (nice for presentations)
04 同仓库更多 Skills
ring:visual-explainer
Generate beautiful, self-contained HTML pages that visually explain systems, code changes, plans, and data. Use when the user asks for a diagram, architecture overview, diff review, plan review, project recap, comparison table, or any visual explanation of technical concepts. Also use proactively when you are about to render a complex ASCII table (4+ rows or 3+ columns) — present it as a styled HTML page instead.
returns-reverse-logistics
Codified expertise for returns authorization, receipt and inspection, disposition decisions, refund processing, fraud detection, and warranty claims management. Informed by returns operations managers with 15+ years experience. Includes grading frameworks, disposition economics, fraud pattern recognition, and vendor recovery processes. Use when handling product returns, reverse logistics, refund decisions, return fraud detection, or warranty claims.
quality-nonconformance
Codified expertise for quality control, non-conformance investigation, root cause analysis, corrective action, and supplier quality management in regulated manufacturing. Informed by quality engineers with 15+ years experience across FDA, IATF 16949, and AS9100 environments. Includes NCR lifecycle management, CAPA systems, SPC interpretation, and audit methodology. Use when investigating non-conformances, performing root cause analysis, managing CAPAs, interpreting SPC data, or handling supplier quality issues.
production-scheduling
Codified expertise for production scheduling, job sequencing, line balancing, changeover optimization, and bottleneck resolution in discrete and batch manufacturing. Informed by production schedulers with 15+ years experience. Includes TOC/drum-buffer-rope, SMED, OEE analysis, disruption response frameworks, and ERP/MES interaction patterns. Use when scheduling production, resolving bottlenecks, optimizing changeovers, responding to disruptions, or balancing manufacturing lines.
logistics-exception-management
Codified expertise for handling freight exceptions, shipment delays, damages, losses, and carrier disputes. Informed by logistics professionals with 15+ years operational experience. Includes escalation protocols, carrier-specific behaviors, claims procedures, and judgment frameworks. Use when handling shipping exceptions, freight claims, delivery issues, or carrier disputes.
inventory-demand-planning
Codified expertise for demand forecasting, safety stock optimization, replenishment planning, and promotional lift estimation at multi-location retailers. Informed by demand planners with 15+ years experience managing hundreds of SKUs. Includes forecasting method selection, ABC/XYZ analysis, seasonal transition management, and vendor negotiation frameworks. Use when forecasting demand, setting safety stock, planning replenishment, managing promotions, or optimizing inventory levels.