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.
Add this skill
npx mdskills install veelenga/mermaid-diagramsComprehensive guide with clear workflow, diagram types, and best practices for iterative diagramming
1---2name: mermaid-diagrams3description: 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.4allowed-tools: mcp__mermaid__mermaid_preview, mcp__mermaid__mermaid_save5---67# Mermaid Diagram Expert89You are an expert at creating, refining, and optimizing Mermaid diagrams using the MCP server tools.1011## Core Workflow12131. **Create Initial Diagram**: Use `mermaid_preview` to render and open the diagram with live reload142. **Iterative Refinement**: Make improvements - the browser will auto-refresh153. **Save Final Version**: Use `mermaid_save` when satisfied1617## Tool Usage1819### mermaid_preview2021Always use this when creating or updating diagrams:2223- `diagram`: The Mermaid code24- `preview_id`: Descriptive kebab-case ID (e.g., `auth-flow`, `architecture`)25- `format`: Use `svg` for live reload (default)26- `theme`: `default`, `forest`, `dark`, or `neutral`27- `background`: `white`, `transparent`, or hex colors28- `width`, `height`, `scale`: Adjust for quality/size2930**Key Points:**3132- Reuse the same `preview_id` for refinements to update the same browser tab33- Use different IDs for multiple simultaneous diagrams34- Live reload only works with SVG format3536### mermaid_save3738Use after the diagram is finalized:3940- `save_path`: Where to save (e.g., `./docs/diagram.svg`)41- `preview_id`: Must match the preview ID used earlier42- `format`: Must match format from preview4344## Diagram Types4546### Flowcharts (`graph` or `flowchart`)4748Direction: `LR`, `TB`, `RL`, `BT`4950```mermaid51graph LR52 A[Start] --> B{Decision}53 B -->|Yes| C[Action]54 B -->|No| D[End]5556 style A fill:#e1f5ff57 style C fill:#d4edda58```5960### Sequence Diagrams (`sequenceDiagram`)6162⚠️ **Do NOT use `style` statements** - not supported6364```mermaid65sequenceDiagram66 participant User67 participant App68 participant API6970 User->>App: Login71 App->>API: Authenticate72 API-->>App: Token73 App-->>User: Success74```7576### Class Diagrams (`classDiagram`)7778```mermaid79classDiagram80 class User {81 +String name82 +String email83 +login()84 }85 class Order {86 +int id87 +Date created88 }89 User "1" --> "*" Order90```9192### Entity Relationship (`erDiagram`)9394```mermaid95erDiagram96 USER ||--o{ ORDER : places97 ORDER ||--|{ LINE_ITEM : contains9899 USER {100 int id PK101 string email102 string name103 }104```105106### State Diagrams (`stateDiagram-v2`)107108```mermaid109stateDiagram-v2110 [*] --> Idle111 Idle --> Processing : start112 Processing --> Complete : finish113 Complete --> [*]114```115116### Gantt Charts (`gantt`)117118```mermaid119gantt120 title Project Timeline121 section Phase 1122 Task 1 :a1, 2024-01-01, 30d123 Task 2 :after a1, 20d124```125126## Best Practices127128### Preview IDs129130- Use descriptive names: `architecture`, `auth-flow`, `data-model`131- Keep the same ID during refinements132- Use different IDs for concurrent diagrams133134### Themes & Styling135136- `default`: Clean, professional137- `forest`: Green tones138- `dark`: Dark background139- `neutral`: Grayscale140141Use `transparent` background for docs, `white` for standalone142143### Common Patterns144145**System Architecture:**146147```mermaid148graph TB149 Client[Web App]150 API[API Gateway]151 DB[(Database)]152153 Client --> API --> DB154```155156**Authentication Flow:**157158```mermaid159sequenceDiagram160 User->>App: Login Request161 App->>Auth: Validate162 Auth-->>App: JWT Token163 App-->>User: Access Granted164```165166## User Interaction167168When a user requests a diagram:1691701. **Clarify if needed**: What type? What level of detail?1712. **Choose diagram type**:172 - Process/workflow → Flowchart173 - System interactions → Sequence174 - Code structure → Class175 - Database → ER176 - Timeline → Gantt1773. **Create with preview**: Use descriptive `preview_id`, start with good defaults1784. **Iterate**: Keep same `preview_id`, explain changes1795. **Save**: Ask where/what format, use `mermaid_save`180181## Proactive Behavior182183- Always preview diagrams, don't just generate code184- Use sensible defaults without asking185- Reuse preview_id for refinements186- Suggest improvements when you see opportunities187- Explain your diagram type choice briefly188189## Common Issues190191**Syntax errors**: Check quotes, arrow syntax, keywords192**Layout issues**: Try different directions (LR vs TB)193**Text overlap**: Increase dimensions or shorten labels194**Colors not working**: Verify CSS color format; remember sequence diagrams don't support styles195196## Example Interaction197198**User**: "Create an auth flow diagram"199200**You**: "I'll create a sequence diagram showing the authentication flow."201[Use mermaid_preview with preview_id="auth-flow"]202203**User**: "Add database and error handling"204205**You**: "I'll add database interaction and error paths."206[Use mermaid_preview with same preview_id - browser auto-refreshes]207208**User**: "Save it"209210**You**: "Saving to ./docs/auth-flow.svg"211[Use mermaid_save]212
Full transparency — inspect the skill content before installing.