Create Mermaid diagrams (activity, deployment, sequence, architecture) from text descriptions or source code...
Mermaid diagram and documentation system with specialized guides and code-to-diagram capabilities.
How this skill works:
User Intent Analysis:
flowchart TD
Start([User Request]) --> Analyze{Analyze Intent}
Analyze -->|"workflow, process, business logic"| Activity[Load Activity Diagram Guide<br/>references/guides/diagrams/activity-diagrams.md]
Analyze -->|"infrastructure, deployment, cloud"| Deploy[Load Deployment Diagram Guide<br/>references/guides/diagrams/deployment-diagrams.md]
Analyze -->|"system architecture, components"| Arch[Load Architecture Guide<br/>references/guides/diagrams/architecture-diagrams.md]
Analyze -->|"API flow, interactions"| Sequence[Load Sequence Diagram Guide<br/>references/guides/diagrams/sequence-diagrams.md]
Analyze -->|"class, ER, state, wiki, walkthrough"| WikiGuide[Load WikiTicket GitHub Guide<br/>references/guides/wiki-ticket-and-github.md]
Analyze -->|"code to diagram"| CodeToDiag[Load Code-to-Diagram Guide<br/>references/guides/code-to-diagram/ + examples/]
Analyze -->|"design document, full docs"| DesignDoc[Load Design Document Template<br/>assets/*-design-template.md]
Analyze -->|"unicode symbols, icons"| Unicode[Load Unicode Symbols Guide<br/>references/guides/unicode-symbols/guide.md]
Analyze -->|"extract, validate, convert"| Scripts[Use Python Scripts<br/>scripts/extract_mermaid.py<br/>scripts/mermaid_to_image.py]
Activity --> Generate[Generate Diagram]
Deploy --> Generate
Arch --> Generate
Sequence --> Generate
WikiGuide --> Generate
CodeToDiag --> Generate
DesignDoc --> Generate
Unicode --> Generate
Scripts --> Execute[Execute Script]
Generate --> Validate{Validate?}
Validate -->|Yes| RunValidation[Run mmdc validation]
Validate -->|No| Output
RunValidation --> Output[Output Result]
Execute --> Output
classDef decision fill:#FFD700,stroke:#333,stroke-width:2px,color:black
classDef guide fill:#90EE90,stroke:#333,stroke-width:2px,color:darkgreen
classDef action fill:#87CEEB,stroke:#333,stroke-width:2px,color:darkblue
class Analyze,Validate decision
class Activity,Deploy,Arch,Sequence,WikiGuide,CodeToDiag,DesignDoc,Unicode,Scripts guide
class Generate,Execute,RunValidation,Output action
references/guides/diagrams/)| Guide | Full Path | Load When User Wants | Examples |
|---|---|---|---|
| Activity Diagrams | references/guides/diagrams/activity-diagrams.md |
Workflows, processes, business logic, user flows, decision trees | "Show checkout flow", "Document ETL pipeline", "Create approval workflow" |
| Deployment Diagrams | references/guides/diagrams/deployment-diagrams.md |
Infrastructure, cloud architecture, K8s, serverless, network topology | "Show AWS architecture", "Document GCP deployment", "Create K8s diagram" |
| Architecture Diagrams | references/guides/diagrams/architecture-diagrams.md |
System architecture, component design, high-level structure | "Show system components", "Document microservices", "Architecture overview" |
| Sequence Diagrams | references/guides/diagrams/sequence-diagrams.md |
API interactions, service communication, request/response flows | "Show API call sequence", "Document auth flow", "Service interactions" |
| WikiTicket / GitHub / Confluence | references/guides/wiki-ticket-and-github.md |
Design docs, walkthroughs, requirements, wiki publish, Confluence images | "architecture doc", "code walkthrough", "wiki", "Confluence" |
Default for WikiTicket and GitHub wiki is this skill, including classDiagram, erDiagram, and stateDiagram-v2. Do not send those to PlantUML. If GitHub fails to render C4 / architecture-beta / block-beta, fall back to flowchart TD.
| Resource | Full Path | What It Provides |
|---|---|---|
| Master Guide | references/guides/code-to-diagram/README.md |
Complete workflow for analyzing any codebase and extracting diagrams |
| Spring Boot | examples/spring-boot/README.md |
ControllerβServiceβRepository architecture, deployment config, sequence from methods, activity from business logic |
| FastAPI | examples/fastapi/README.md |
Python async patterns, Pydantic models, dependency injection, cloud deployment |
| React | examples/react/README.md |
Component hierarchy, state management, data flow, build pipeline |
| Python ETL | examples/python-etl/README.md |
Data pipeline, transformation steps, error handling, scheduling |
| Node/Express | examples/node-webapp/README.md |
Middleware chain, route handlers, async patterns, deployment |
| Java Web App | examples/java-webapp/README.md |
Traditional MVC, servlet containers, WAR deployment |
| Template | Full Path | Use For | Load When |
|---|---|---|---|
| Architecture Design | assets/architecture-design-template.md |
System-wide architecture | "Create architecture doc", "Document system design" |
| API Design | assets/api-design-template.md |
API specifications | "API design doc", "Document REST API" |
| Feature Design | assets/feature-design-template.md |
Feature planning | "Feature design", "Plan new feature" |
| Database Design | assets/database-design-template.md |
Database schema | "Database design", "Document schema" |
| System Design | assets/system-design-template.md |
Complete system | "System design doc", "Full system documentation" |
Full Path: references/guides/unicode-symbols/guide.md
Load when user mentions: "unicode symbols", "emoji in diagrams", "semantic icons", "add symbols"
Quick Reference:
scripts/)| Script | Use For | Load When |
|---|---|---|
extract_mermaid.py |
Extract diagrams from Markdown, validate syntax, replace with images | "extract diagrams", "validate mermaid", "find all diagrams" |
mermaid_to_image.py |
Convert .mmd to PNG/SVG, batch conversion, custom themes | "convert to image", "render diagram", "create PNG" |
resilient_diagram.py |
Full workflow: save .mmd, generate image, validate, error recovery | "generate diagram", "create diagram with validation", "resilient diagram" |
Load references/guides/wiki-ticket-and-github.md for WikiTicket design docs,
code walkthroughs, requirements, GitHub wiki, or Confluence.
| Target | What to ship |
|---|---|
| GitHub wiki / GFM | Fenced mermaid block. GitHub renders class, ER, state, sequence, flowchart, C4. |
| Confluence / Notion / Word / PDF | Also render PNG or SVG (scripts/resilient_diagram.py or mmdc) and upload the image. Do not rely on Confluence to render Mermaid. |
PlantUML is opt-in for Salt wireframes, use case, timing, ArchiMate, nwdiag, and WBS. Those always ship as PNG or SVG.
Common request patterns and guide selection. See When to Use What for complete mapping.
| Pattern | Example Request | Guides to Load |
|---|---|---|
| Single Diagram | "Create activity diagram for login flow" | Diagram type guide + Unicode symbols |
| Code-to-Diagram | "Generate deployment from application.yml" | Framework example + Deployment guide |
| Design Document | "Create API design document" | Template from assets/ + Relevant diagram guides |
| Extract/Validate | "Extract diagrams from design.md" | Use scripts/extract_mermaid.py |
| Batch Convert | "Convert all .mmd to PNG" | Use scripts/mermaid_to_image.py |
CRITICAL: This is the recommended approach for ALL diagram generation. It ensures validation, error recovery, and consistent file organization.
Full Guide: references/guides/resilient-workflow.md
flowchart LR
A[1. Identify Type] --> B[2. Save .mmd + Image]
B --> C{3. Valid?}
C -->|Yes| D[4. Add to Markdown]
C -->|No| E[5. Error Recovery]
E --> F{Fix Found?}
F -->|Yes| A
F -->|No| G[Search External]
G --> A
classDef step fill:#90EE90,stroke:#333,color:darkgreen
classDef decision fill:#FFD700,stroke:#333,color:black
class A,B,D,E,G step
class C,F decision
NEVER add a diagram to markdown until it passes validation. This prevents broken diagrams in documentation.
# Generate with full error recovery
python scripts/resilient_diagram.py \
--code "flowchart TD; A-->B" \
--markdown-file design_doc \
--diagram-num 1 \
--title "process_flow" \
--format png \
--json
Output: Both .mmd and .png files in ./diagrams/ directory.
./diagrams/<markdown_file>_<num>_<type>_<title>.mmd
./diagrams/<markdown_file>_<num>_<type>_<title>.png
Example: ./diagrams/api_design_01_sequence_auth_flow.png
When validation fails, the workflow automatically:
references/guides/troubleshooting.md (28 documented errors)perplexity_ask MCP for syntax questionsbrave_web_search MCP for recent solutionsgemini skill for alternative perspectiveWebSearch tool as fallbackIf the script is unavailable:
references/guides/diagrams/./diagrams/<markdown_file>_<num>_<type>_<title>.mmdmmdc -i file.mmd -o file.png -b transparentreferences/guides/troubleshooting.md for matching errorUser: "Create a sequence diagram and add it to the design doc"
Skill Actions:
references/guides/resilient-workflow.mdreferences/guides/diagrams/sequence-diagrams.mdpython scripts/resilient_diagram.py \
--code "[generated code]" \
--markdown-file design_doc \
--diagram-num 1 \
--title "api_sequence" \
--json
 to markdownAlways use Unicode symbols to enhance diagram clarity. Common patterns:
graph TB
Client[π€ User] --> LB[π Load Balancer]
LB --> App1[βοΈ App Server 1]
LB --> App2[βοΈ App Server 2]
App1 --> DB[(πΎ Database)]
App1 --> Cache[(β‘ Redis)]
flowchart TD
Start([π Start]) --> Process[βοΈ Process Data]
Process --> Check{β Valid?}
Check -->|Yes| Save[πΎ Save]
Check -->|No| Error[β Error]
Save --> Complete([β
Complete])
graph TB
API[π API Gateway] --> Auth[π Auth Service]
API --> Orders[π Order Service]
Orders --> Queue[π¬ Message Queue]
Queue --> Worker[βοΈ Background Worker]
Worker --> Storage[π¦ Object Storage]
For complete symbol reference, load: references/guides/unicode-symbols/guide.md
# List all diagrams
python scripts/extract_mermaid.py document.md --list-only
# Extract to separate files
python scripts/extract_mermaid.py document.md --output-dir diagrams/
# Validate all diagrams
python scripts/extract_mermaid.py document.md --validate
# Replace with image references (for Confluence upload)
python scripts/extract_mermaid.py document.md --replace-with-images \
--image-format png --output-markdown output.md
# Single conversion
python scripts/mermaid_to_image.py diagram.mmd output.png
# With custom settings
python scripts/mermaid_to_image.py diagram.mmd output.svg \
--theme dark --background white --width 1200
# Batch convert directory
python scripts/mermaid_to_image.py diagrams/ output/ --format png --recursive
# From stdin
echo "graph TD; A-->B" | python scripts/mermaid_to_image.py - output.png
Input: "Show the checkout process workflow"
Skill Decision Path:
1. Analyze: workflow, process β ACTIVITY DIAGRAM
2. Load guide: guides/diagrams/activity-diagrams.md
3. Find pattern: E-commerce checkout (template exists in guide)
4. Generate using template + Unicode symbols
5. Output activity diagram with decision points
Output: Complete activity diagram with Unicode symbols for cart, payment, order states.
Input: "Here's my Spring Boot controller, create diagrams"
Skill Decision Path:
1. Analyze: Spring Boot, code provided β CODE-TO-DIAGRAM + SPRING BOOT
2. Load guides:
- examples/spring-boot/README.md
- guides/diagrams/architecture-diagrams.md (for structure)
- guides/diagrams/sequence-diagrams.md (for method calls)
- guides/diagrams/activity-diagrams.md (for business logic)
3. Generate multiple diagrams:
a. Architecture diagram from @RestController/@Service/@Repository annotations
b. Sequence diagram from method call chain
c. Activity diagram from business logic flow
4. Output all diagrams with explanations
Output: 3-4 diagrams showing different views of the Spring Boot application.
Input: "Document my GCP Cloud Run deployment with AlloyDB"
Skill Decision Path:
1. Analyze: infrastructure, GCP, Cloud Run β DEPLOYMENT DIAGRAM
2. Load guides:
- guides/diagrams/deployment-diagrams.md
- examples/spring-boot/ or examples/fastapi/ (if code provided)
3. Check for IaC files (Pulumi, Terraform, docker-compose)
4. Generate deployment diagram with:
- Cloud Run services with specs
- VPC connector
- AlloyDB cluster
- Security (IAM, Secret Manager)
- Monitoring
5. Apply Unicode symbols for clarity
6. Output with resource specifications
Output: Complete GCP deployment diagram with all resources labeled.
ALL diagrams MUST use high-contrast colors:
graph TB
classDef primary fill:#90EE90,stroke:#333,stroke-width:2px,color:darkgreen
classDef secondary fill:#87CEEB,stroke:#333,stroke-width:2px,color:darkblue
classDef database fill:#E6E6FA,stroke:#333,stroke-width:2px,color:darkblue
classDef error fill:#FFB6C1,stroke:#DC143C,stroke-width:2px,color:black
%% Every classDef MUST have color: property
Rules:
color: in every classDefdesign-doc-mermaid/
βββ SKILL.md # This file - Main orchestrator
βββ README.md # User documentation
βββ CLAUDE.md # Claude Code instructions
β
βββ references/ # Reference materials
β βββ mermaid-diagram-guide.md # Legacy general guide
β βββ guides/ # Specialized guides (load on-demand)
β βββ diagrams/
β β βββ activity-diagrams.md # Workflows, processes
β β βββ deployment-diagrams.md # Infrastructure, cloud
β β βββ architecture-diagrams.md # System architecture
β β βββ sequence-diagrams.md # API interactions
β βββ code-to-diagram/
β β βββ README.md # Master guide for code analysis
β βββ unicode-symbols/
β β βββ guide.md # Complete symbol reference
β βββ troubleshooting.md # Common syntax errors & fixes
β
βββ assets/ # Design document templates
β βββ architecture-design-template.md
β βββ api-design-template.md
β βββ feature-design-template.md
β βββ database-design-template.md
β βββ system-design-template.md
β
βββ scripts/ # Python utilities
β βββ extract_mermaid.py # Extract & validate diagrams
β βββ mermaid_to_image.py # Convert to PNG/SVG
β
βββ examples/ # Language-specific patterns
β βββ spring-boot/ # Spring Boot patterns
β βββ fastapi/ # FastAPI patterns
β βββ react/ # React patterns
β βββ python-etl/ # Data pipeline patterns
β βββ node-webapp/ # Express.js patterns
β βββ java-webapp/ # Traditional Java patterns
β
βββ references/ # General Mermaid reference
βββ mermaid-diagram-guide.md # Complete Mermaid syntax guide
| User Request | Load This |
|---|---|
| "activity diagram", "workflow", "process flow" | references/guides/diagrams/activity-diagrams.md |
| "deployment", "infrastructure", "cloud", "k8s" | references/guides/diagrams/deployment-diagrams.md |
| "architecture", "system design", "components" | references/guides/diagrams/architecture-diagrams.md + design template |
| "API", "sequence", "interactions", "flow" | references/guides/diagrams/sequence-diagrams.md |
| "class diagram", "ER", "state machine", "wiki", "walkthrough", "architecture doc" | references/guides/wiki-ticket-and-github.md plus the matching type guide |
| "Confluence", "upload image", "PNG", "SVG" | scripts/resilient_diagram.py or scripts/mermaid_to_image.py |
| "Spring Boot code" | examples/spring-boot/ + relevant diagram guides |
| "FastAPI code", "Python API" | examples/fastapi/ + relevant diagram guides |
| "React app", "frontend" | examples/react/ + architecture guide |
| "ETL", "data pipeline", "Python batch" | examples/python-etl/ + activity guide |
| "symbols", "unicode", "emoji" | references/guides/unicode-symbols/guide.md |
| "syntax error", "diagram won't render", "troubleshoot" | references/guides/troubleshooting.md |
| "extract diagrams" | scripts/extract_mermaid.py |
| "convert to image", "PNG", "SVG" | scripts/mermaid_to_image.py |
| "create diagram", "generate diagram", "add diagram to markdown" | scripts/resilient_diagram.py + references/guides/resilient-workflow.md |
| "design document", "full docs" | assets/*-design-template.md + diagram guides |
color: property in stylesNew to Mermaid? Start here:
references/guides/unicode-symbols/guide.md for symbol meaningsreferences/guides/diagrams/activity-diagrams.md for basic patternsexamples/spring-boot/ or examples/fastapi/scripts/extract_mermaid.py --validate to check your workNeed to document code? Follow this:
examples/{framework}/Creating design docs? Follow this:
assets/docs/design/ with timestampVersion: 2.0 (Hierarchical Architecture) Last Updated: 2025-01-13 Maintained by: Claude Code Skills