Back to Documentation & Writing

mermaid-diagrams

MermaiddiagramsUMLsoftware architectureflowchartssequence diagramsERDdocumentation
⭐ 2.0kπŸ“„ MITπŸ•’ 2026-03-05Source β†—

Install this skill

npx skills add softaworks/agent-toolkit

Works across Claude Code, Cursor, Codex, Copilot & Antigravity

The mermaid-diagrams skill converts structured text definitions into visual representations of software systems and logic. It supports developers and architects in maintaining documentation that lives alongside source code. By defining nodes, connections, and actors in specific syntax, agents can render flowcharts, sequence diagrams, class structures, and entity relationship models directly in supported editors. This approach eliminates the need for external graphical tools that often drift out of sync with actual codebases. Because the diagrams are plain text, they remain fully version-controllable, allowing team members to track architectural changes through diffs. The skill handles the rendering logic for various diagram types including C4 models, state machines, and Gantt charts, ensuring that documentation remains as iterative and agile as the software it describes.

When to Use This Skill

  • β€’Documenting complex API authentication request-response lifecycles
  • β€’Mapping out user registration journeys to identify decision bottlenecks
  • β€’Defining relational constraints for new database table migrations
  • β€’Communicating microservice boundaries in architectural planning
  • β€’Visualizing git branching strategies for team training materials

How to Invoke This Skill

Example prompts that trigger this skill in Claude Code, Cursor, or Antigravity:

  • β€œCreate a mermaid flowchart for the user login process
  • β€œGenerate a sequence diagram showing the API call from the client to the server
  • β€œDraft an ERD for a user profile database schema
  • β€œVisualise the class hierarchy for this object-oriented module
  • β€œWrite a mermaid diagram explaining the current system architecture

Pro Tips

  • πŸ’‘Use `%%` for comments within your Mermaid syntax to add context and explanations, making diagrams more readable and maintainable for your team.
  • πŸ’‘Leverage live Mermaid renderers in your IDE or documentation platform to get instant visual feedback as you define your diagrams.
  • πŸ’‘For complex architecture, break down C4 diagrams into separate context, container, and component views to manage detail and improve clarity.

What this skill does

  • β€’Transform text-based definitions into renderable UML and flow diagrams
  • β€’Model system interactions using sequence and state machine syntax
  • β€’Define database schemas via Entity Relationship Diagram (ERD) syntax
  • β€’Visualize software architecture levels using C4 model notation
  • β€’Apply custom color themes and layout configurations via configuration blocks

When not to use it

  • βœ•When you require complex free-form artistic layouts or non-standard vector graphics
  • βœ•When the information is highly dynamic and requires real-time data integration
  • βœ•When non-technical stakeholders need to edit the diagram using drag-and-drop tools

Example workflow

  1. Identify the core system process or structure requiring visualization
  2. Select the appropriate diagram type based on the object (e.g., flowchart for logic)
  3. Draft the entity nodes and connecting relationships in the agent console
  4. Review the syntax for accuracy and missing connections
  5. Render the diagram in the markdown viewer to verify visual clarity
  6. Commit the generated code block into the project repository

Prerequisites

  • –A Markdown-compliant editor or IDE extension with Mermaid support
  • –Knowledge of basic structural logic for the chosen diagram type

Pitfalls & limitations

  • !Silent failures occur if diagram syntax is slightly malformed or indentation is incorrect
  • !Excessively large diagrams can become unreadable or render improperly in some viewers
  • !Limited support for highly specific layout adjustments compared to drag-and-drop editors

FAQ

Can I style the colors of my diagrams?
Yes, you can use frontmatter at the top of your code block to define themes and specific variable colors like primaryColor.
Are Mermaid diagrams searchable in my repository?
Since they are written as plain text inside your markdown files, they are fully indexed by search tools and version control systems.
How do I add comments to my diagrams?
You can use the '%%' prefix on any line to insert comments that will be ignored by the renderer.

How it compares

Unlike manual drawing tools that produce binary image files, this skill creates machine-readable text that integrates directly into your version history and CI/CD pipelines.

Source & trust

⭐ 2.0k starsπŸ“„ MITπŸ•’ Updated 2026-03-05
πŸ“„ Full skill instructions β€” original source: softaworks/agent-toolkit
# 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:

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)
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)
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)
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)
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/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:

---
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

How to Use This Skill Unit

Option A: Project-Specific (Recommended)

  1. Click "Download" above
  2. In your project, create the directory: .agent/skills/mermaid-diagrams/
  3. Save the file as SKILL.md
  4. The agent will automatically discover the skill based on its description.

Option B: Global Installation (All Agents)

Save the file to these locations to make it available across all projects:

  • Claude Code: ~/.claude/skills/softaworks/agent-toolkit/mermaid-diagrams/SKILL.md
  • Cursor: ~/.cursor/skills/softaworks/agent-toolkit/mermaid-diagrams/SKILL.md
  • Antigravity: ~/.gemini/antigravity/skills/softaworks/agent-toolkit/mermaid-diagrams/SKILL.md

πŸš€ Install with CLI:
npx skills add softaworks/agent-toolkit

Read the Master Guide: Mastering Agent Skills β†’

Recommended Rules

View more rules β†’

Recommended Workflows

View more workflows β†’

Recommended MCP Servers

View more MCP servers β†’

Take It Further

Maximize your productivity with these powerful resources

πŸ“‹

Define Your Standards

Set up coding standards to ensure this workflow produces consistent, high-quality results.

Browse Rules Library
πŸ“–

Master Workflows

Learn how to create custom workflows, use Turbo Mode, and build your automation library.

Complete Guide

How to use this Skill in Claude Code & Cursor

For Claude Code (CLI)

To use this skill in Claude Code, copy the rule content into your project's custom instructions or follow our Add-Skill CLI guide. This ensures Claude follows your standards during every code generation.

For Cursor & Windsurf

For Cursor or Windsurf, individual skills are best used in the "Rules for AI" section. This specific unit helps the agent avoid documentation & writing issues, leading to cleaner, more efficient code.

Why the skill format matters: the standardized Agent Skills format lets your AI agent load detailed instructions only when they are relevant, keeping your prompt clean while improving results.

Source & attribution

This skill is categorized under Documentation & Writing and is published by Softaworks, maintained in softaworks/agent-toolkit.

← Browse All Agent Skills
Sponsored AI assistant. Recommendations may be paid.