Skip to main content
Agent skill

Mermaid Diagrams

Comprehensive guide for creating software diagrams using Mermaid syntax. Use when users need to create, visualize, or document software through diagrams including class diagrams (domain modeling, object-oriented design), sequence diagrams (application flows, API interactions, code execution), flowcharts (processes, algorithms, user journeys), entity relationship diagrams (database schemas), C4 architecture diagrams (system context, containers, components), state diagrams, git graphs, pie charts, gantt charts, or any other diagram type. Triggers include requests to "diagram", "visualize", "model", "map out", "show the flow", or when explaining system architecture, database design, code structure, or user/application flows.

Get started

Get the complete skill folder, including its scripts and reference files.

When to use this skill

Use Mermaid Diagrams when an AI agent needs a reusable SKILL.md workflow for this job: Comprehensive guide for creating software diagrams using Mermaid syntax. Use when users need to create, visualize, or document software through diagrams including class diagrams (domain modeling, object-oriented design), sequence diagrams (application flows, API interactions, code execution), flowcharts (processes, algorithms, user journeys), entity relationship diagrams (database schemas), C4 architecture diagrams (system context, containers, components), state diagrams, git graphs, pie charts, gantt charts, or any other diagram type. Triggers include requests to "diagram", "visualize", "model", "map out", "show the flow", or when explaining system architecture, database design, code structure, or user/application flows.

When not to use it

Skip Mermaid Diagrams when the task is outside the coding category, or when a more specific skill in this directory already covers the same workflow with clearer triggers.

How to install

Where will you use it?

Install scope
Claude Code folder setup
mkdir -p ~/.claude/skills/mermaid-diagrams
# Save SKILL.md to ~/.claude/skills/mermaid-diagrams/SKILL.md
  1. Claude Code personal install: place the skill and its bundled files at ~/.claude/skills/mermaid-diagrams/SKILL.md. For a shared project, commit the folder at .claude/skills/mermaid-diagrams/ instead.
  2. Current Claude Code detects SKILL.md changes in watched directories during the session. If you just created a top-level skills directory, run /reload-skills. Check that the skill is listed before testing its trigger.
  3. For Claude chat or Cowork in the Desktop app, manage uploaded skills in Customize > Skills; copying files into a local Claude Code folder is not a Desktop install. Other agents may use different install locations.

Full install guide for Claude, Cursor, and Codex →

Try a starter prompt

After installing the skill, paste this starter prompt into your agent to verify it triggers on a small task.

Starter prompt
Use the Mermaid Diagrams skill for this task: Use Mermaid Diagrams when this documented workflow matches the task. Confirm any required inputs or files before making changes.

What supports this recommendation?

76/100 provisional content score. This measures documentation, practical detail and source signals. It is not a measured task success rate or a security certification.

Documentation
85/100
Practical detail
76/100
Source evidence
62/100
Source signals
72/100
Model compatibility evidence
  • claudeinferred

    The skill text mentions Claude or a closely associated term. This is keyword-derived compatibility; no hands-on model test is recorded.

  • chatgptuntested

    No model-specific signal or recorded compatibility test was found.

  • geminiuntested

    No model-specific signal or recorded compatibility test was found.

  • copilotuntested

    No model-specific signal or recorded compatibility test was found.

  • llamauntested

    No model-specific signal or recorded compatibility test was found.

  • perplexityuntested

    No model-specific signal or recorded compatibility test was found.

  • mistraluntested

    No model-specific signal or recorded compatibility test was found.

  • grokuntested

    No model-specific signal or recorded compatibility test was found.

Inferred compatibility is based on content signals. Check the app, its available tools and setup requirements before running a skill.

What this skill does

# Mermaid Diagramming

Create professional software diagrams using Mermaid's text-based syntax. Mermaid renders diagrams from simple text definitions, making diagrams version-controllable, easy to update, and maintainable alongside code.

## Core Syntax Structure

All Mermaid diagrams follow this pattern:

```mermaid diagramType definition content ```

**Key principles:**

- First line declares diagram type (e.g., `classDiagram`, `sequenceDiagram`, `flowchart`) - Use `%%` for comments - Line breaks and indentation improve readability but aren't required - Unknown words break diagrams; parameters fail silently

## Diagram Type Selection Guide

**Choose the right diagram type:**

1. **Class Diagrams** - Domain modeling, OOP design, entity relationships

- Domain-driven design documentation - Object-oriented class structures - Entity relationships and dependencies

2. **Sequence Diagrams** - Temporal interactions, message flows

- API request/response flows - User authentication flows - System component interactions - Method call sequences

3. **Flowcharts** - Processes, algorithms, decision trees

- User journeys and workflows - Business processes - Algorithm logic - Deployment pipelines

4. **Entity Relationship Diagrams (ERD)** - Database schemas

- Table relationships - Data modeling - Schema design

5. **C4 Diagrams** - Software architecture at multiple levels

- System Context (systems and users) - Container (applications, databases, services) - Component (internal structure) - Code (class/interface level)

6. **State Diagrams** - State machines, lifecycle states 7. **Git Graphs** - Version control branching strategies 8. **Gantt Charts** - Project timelines, scheduling 9. **Pie/Bar Charts** - Data visualization

## Quick Start Examples

### Class Diagram (Domain Model)

```mermaid classDiagram Title -- Genre Title *-- Season Title *-- Review User --> Review : creates

class Title { +string name +int releaseYear +play() }

class Genre { +string name +getTopTitles() } ```

### Sequence Diagram (API Flow)

```mermaid sequenceDiagram participant User participant API participant Database

User->>API: POST /login API->>Database: Query credentials Database-->>API: Return user data alt Valid credentials API-->>User: 200 OK + JWT token else Invalid credentials API-->>User: 401 Unauthorized end ```

### Flowchart (User Journey)

```mermaid flowchart TD Start([User visits site]) --> Auth{Authenticated?} Auth -->|No| Login[Show login page] Auth -->|Yes| Dashboard[Show dashboard] Login --> Creds[Enter credentials] Creds --> Validate{Valid?} Validate -->|Yes| Dashboard Validate -->|No| Error[Show error] Error --> Login ```

### ERD (Database Schema)

```mermaid erDiagram USER ||--o{ ORDER : places ORDER ||--|{ LINE_ITEM : contains PRODUCT ||--o{ LINE_ITEM : includes

USER { int id PK string email UK string name datetime created_at }

ORDER { int id PK int user_id FK decimal total datetime created_at } ```

## Detailed References

For in-depth guidance on specific diagram types, see:

- **[references/class-diagrams.md](references/class-diagrams.md)** - Domain modeling, relationships (association, composition, aggregation, inheritance), multiplicity, methods/properties - **[references/sequence-diagrams.md](references/sequence-diagrams.md)** - Actors, participants, messages (sync/async), activations, loops, alt/opt/par blocks, notes - **[references/flowcharts.md](references/flowcharts.md)** - Node shapes, connections, decision logic, subgraphs, styling - **[references/erd-diagrams.md](references/erd-diagrams.md)** - Entities, relationships, cardinality, keys, attributes - **[references/c4-diagrams.md](references/c4-diagrams.md)** - System context, container, component diagrams, boundaries - **[references/architecture-diagrams.md](references/architecture-diagrams.md)** - Cloud services, infrastructure, CI/CD deployments - **[references/advanced-features.md](references/advanced-features.md)** - Themes, styling, configuration, layout options

## Best Practices

1. **Start Simple** - Begin with core entities/components, add details incrementally 2. **Use Meaningful Names** - Clear labels make diagrams self-documenting 3. **Comment Extensively** - Use `%%` comments to explain complex relationships 4. **Keep Focused** - One diagram per concept; split large diagrams into multiple focused views 5. **Version Control** - Store `.mmd` files alongside code for easy updates 6. **Add Context** - Include titles and notes to explain diagram purpose 7. **Iterate** - Refine diagrams as understanding evolves

## Configuration and Theming

Configure diagrams using frontmatter:

```mermaid --- config: theme: base themeVariables: primaryColor: "#ff6b6b" --- flowchart LR A --> B ```

**Available themes:** default, forest, dark, neutral, base

**Layout options:**

- `layout: dagre` (default) - Classic balanced layout - `layout: elk` - Advanced layout for complex diagrams (requires integration)

**Look options:**

- `look: classic` - Traditional Mermaid style - `look: handDrawn` - Sketch-like appearance

## Exporting and Rendering

**Native support in:**

- GitHub/GitLab - Automatically renders in Markdown - VS Code - With Markdown Mermaid extension - Notion, Obsidian, Confluence - Built-in support

**Export options:**

- [Mermaid Live Editor](https://mermaid.live) - Online editor with PNG/SVG export - Mermaid CLI - `npm install -g @mermaid-js/mermaid-cli` then `mmdc -i input.mmd -o output.png` - Docker - `docker run --rm -v $(pwd):/data minlag/mermaid-cli -i /data/input.mmd -o /data/output.png`

## Common Pitfalls

- **Breaking characters** - Avoid `{}` in comments, use proper escape sequences for special characters - **Syntax errors** - Misspellings break diagrams; validate syntax in Mermaid Live - **Overcomplexity** - Split complex diagrams into multiple focused views - **Missing relationships** - Document all important connections between entities

## When to Create Diagrams

**Always diagram when:**

- Starting new projects or features - Documenting complex systems - Explaining architecture decisions - Designing database schemas - Planning refactoring efforts - Onboarding new team members

**Use diagrams to:**

- Align stakeholders on technical decisions - Document domain models collaboratively - Visualize data flows and system interactions - Plan before coding - Create living documentation that evolves with code

Intended uses

  • Use Mermaid Diagrams when this documented workflow matches the task.

Implementation notes

  • Start Simple - Begin with core entities/components, add details incrementally
  • Use Meaningful Names - Clear labels make diagrams self-documenting
  • Comment Extensively - Use %% comments to explain complex relationships
  • Keep Focused - One diagram per concept; split large diagrams into multiple focused views
  • Version Control - Store .mmd files alongside code for easy updates
  • Add Context - Include titles and notes to explain diagram purpose
  • Iterate - Refine diagrams as understanding evolves

Try it, then tell us how it went

A copied prompt does not tell us whether the task worked. Report your result after checking the output. We collect your tool and outcome, never your files or prompt.