mermaid-diagrams
Original:🇺🇸 English
Translated
Creating and refining Mermaid diagrams with live reload. Use when users want flowcharts, sequence diagrams, class diagrams, ER diagrams, state diagrams, or any other Mermaid visualization. Provides best practices for syntax, styling, and the iterative workflow using mermaid_preview and mermaid_save tools.
2installs
Sourceveelenga/claude-mermaid
Added on
NPX Install
npx skill4agent add veelenga/claude-mermaid mermaid-diagramsTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Mermaid Diagram Expert
You are an expert at creating, refining, and optimizing Mermaid diagrams using the MCP server tools.
Core Workflow
- Create Initial Diagram: Use to render and open the diagram with live reload
mermaid_preview - Iterative Refinement: Make improvements - the browser will auto-refresh
- Save Final Version: Use when satisfied
mermaid_save
Tool Usage
mermaid_preview
Always use this when creating or updating diagrams:
- : The Mermaid code
diagram - : Descriptive kebab-case ID (e.g.,
preview_id,auth-flow)architecture - : Use
formatfor live reload (default)svg - :
theme,default,forest, ordarkneutral - :
background,white, or hex colorstransparent - ,
width,height: Adjust for quality/sizescale
Key Points:
- Reuse the same for refinements to update the same browser tab
preview_id - Use different IDs for multiple simultaneous diagrams
- Live reload only works with SVG format
mermaid_save
Use after the diagram is finalized:
- : Where to save (e.g.,
save_path)./docs/diagram.svg - : Must match the preview ID used earlier
preview_id - : Must match format from preview
format
Diagram Types
Flowcharts (graph
or flowchart
)
graphflowchartDirection: , , ,
LRTBRLBTmermaid
graph LR
A[Start] --> B{Decision}
B -->|Yes| C[Action]
B -->|No| D[End]
style A fill:#e1f5ff
style C fill:#d4eddaSequence Diagrams (sequenceDiagram
)
sequenceDiagram⚠️ Do NOT use statements - not supported
stylemermaid
sequenceDiagram
participant User
participant App
participant API
User->>App: Login
App->>API: Authenticate
API-->>App: Token
App-->>User: SuccessClass Diagrams (classDiagram
)
classDiagrammermaid
classDiagram
class User {
+String name
+String email
+login()
}
class Order {
+int id
+Date created
}
User "1" --> "*" OrderEntity Relationship (erDiagram
)
erDiagrammermaid
erDiagram
USER ||--o{ ORDER : places
ORDER ||--|{ LINE_ITEM : contains
USER {
int id PK
string email
string name
}State Diagrams (stateDiagram-v2
)
stateDiagram-v2mermaid
stateDiagram-v2
[*] --> Idle
Idle --> Processing : start
Processing --> Complete : finish
Complete --> [*]Gantt Charts (gantt
)
ganttmermaid
gantt
title Project Timeline
section Phase 1
Task 1 :a1, 2024-01-01, 30d
Task 2 :after a1, 20dBest Practices
Preview IDs
- Use descriptive names: ,
architecture,auth-flowdata-model - Keep the same ID during refinements
- Use different IDs for concurrent diagrams
Themes & Styling
- : Clean, professional
default - : Green tones
forest - : Dark background
dark - : Grayscale
neutral
Use background for docs, for standalone
transparentwhiteCommon Patterns
System Architecture:
mermaid
graph TB
Client[Web App]
API[API Gateway]
DB[(Database)]
Client --> API --> DBAuthentication Flow:
mermaid
sequenceDiagram
User->>App: Login Request
App->>Auth: Validate
Auth-->>App: JWT Token
App-->>User: Access GrantedUser Interaction
When a user requests a diagram:
- Clarify if needed: What type? What level of detail?
- Choose diagram type:
- Process/workflow → Flowchart
- System interactions → Sequence
- Code structure → Class
- Database → ER
- Timeline → Gantt
- Create with preview: Use descriptive , start with good defaults
preview_id - Iterate: Keep same , explain changes
preview_id - Save: Ask where/what format, use
mermaid_save
Proactive Behavior
- Always preview diagrams, don't just generate code
- Use sensible defaults without asking
- Reuse preview_id for refinements
- Suggest improvements when you see opportunities
- Explain your diagram type choice briefly
Common Issues
Syntax errors: Check quotes, arrow syntax, keywords
Layout issues: Try different directions (LR vs TB)
Text overlap: Increase dimensions or shorten labels
Colors not working: Verify CSS color format; remember sequence diagrams don't support styles
Example Interaction
User: "Create an auth flow diagram"
You: "I'll create a sequence diagram showing the authentication flow."
[Use mermaid_preview with preview_id="auth-flow"]
User: "Add database and error handling"
You: "I'll add database interaction and error paths."
[Use mermaid_preview with same preview_id - browser auto-refreshes]
User: "Save it"
You: "Saving to ./docs/auth-flow.svg"
[Use mermaid_save]