All skills
softaworks avatar

/mermaid-diagrams

@b00cf84
by softaworkssoftaworks/agent-toolkit2.5k stars
230

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.

Use this Skill: https://skilld.dev/gh/softaworks/agent-toolkit/mermaid-diagrams

This session only. Nothing lands on disk.

referencesadvanced-features.md

≈2.6k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Advanced Mermaid Features

Advanced configuration, styling, theming, and other powerful features for creating professional diagrams.

Frontmatter Configuration

Add YAML configuration at the top of diagrams:

---
config:
  theme: dark
  themeVariables:
    primaryColor: "#ff6b6b"
    primaryTextColor: "#fff"
    primaryBorderColor: "#333"
    lineColor: "#666"
    secondaryColor: "#4ecdc4"
    tertiaryColor: "#ffe66d"
---
flowchart TD
    A --> B

Themes

Built-in Themes

---
config:
  theme: default
---

Available themes:

  • default - Standard blue theme
  • forest - Green earth tones
  • dark - Dark mode friendly
  • neutral - Grayscale professional
  • base - Minimal base theme for customization

Theme Examples

Default Theme:

---
config:
  theme: default
---
flowchart LR
    A[Start] --> B[Process]
    B --> C{Decision}
    C -->|Yes| D[Action 1]
    C -->|No| E[Action 2]

Dark Theme:

---
config:
  theme: dark
---
flowchart LR
    A[Start] --> B[Process]
    B --> C{Decision}

Forest Theme:

---
config:
  theme: forest
---
flowchart LR
    A[Start] --> B[Process]

Custom Theme Variables

Override specific colors:

---
config:
  theme: base
  themeVariables:
    primaryColor: "#ff6b6b"
    primaryTextColor: "#fff"
    primaryBorderColor: "#d63031"
    lineColor: "#74b9ff"
    secondaryColor: "#00b894"
    tertiaryColor: "#fdcb6e"
    background: "#f0f0f0"
    mainBkg: "#ffffff"
    textColor: "#333333"
    nodeBorder: "#333333"
    clusterBkg: "#f9f9f9"
    clusterBorder: "#666666"
---
flowchart TD
    A --> B --> C

Layout Options

Dagre Layout (Default)

---
config:
  layout: dagre
---
flowchart TD
    A --> B

ELK Layout (Advanced)

For complex diagrams with better automatic layout:

---
config:
  layout: elk
  elk:
    mergeEdges: true
    nodePlacementStrategy: BRANDES_KOEPF
---
flowchart TD
    A --> B

ELK node placement strategies:

  • SIMPLE - Basic placement
  • NETWORK_SIMPLEX - Network optimization
  • LINEAR_SEGMENTS - Linear arrangement
  • BRANDES_KOEPF - Balanced (default)

Look Options

Classic Look

Traditional Mermaid appearance:

---
config:
  look: classic
---
flowchart LR
    A --> B --> C

Hand-Drawn Look

Sketch-like, informal style:

---
config:
  look: handDrawn
---
flowchart LR
    A --> B --> C

Complete Configuration Example

---
config:
  theme: base
  look: handDrawn
  layout: dagre
  themeVariables:
    primaryColor: "#ff6b6b"
    primaryTextColor: "#fff"
    primaryBorderColor: "#d63031"
    lineColor: "#74b9ff"
    secondaryColor: "#00b894"
    tertiaryColor: "#fdcb6e"
---
flowchart TD
    Start([Begin Process]) --> Input[Gather Data]
    Input --> Process{Valid?}
    Process -->|Yes| Store[(Save to DB)]
    Process -->|No| Error[Show Error]
    Store --> Notify[Send Notification]
    Error --> Input
    Notify --> End([Complete])

Diagram-Specific Styling

Flowchart Styling

Class-based styling:

flowchart TD
    A[Normal]:::success
    B[Warning]:::warning
    C[Error]:::error
    
    classDef success fill:#00b894,stroke:#00a383,color:#fff
    classDef warning fill:#fdcb6e,stroke:#e8b923,color:#333
    classDef error fill:#ff6b6b,stroke:#ee5253,color:#fff
    
    A --> B --> C

Node-specific styling:

flowchart LR
    A[Node A]
    B[Node B]
    C[Node C]
    
    style A fill:#ff6b6b,stroke:#333,stroke-width:4px
    style B fill:#4ecdc4,stroke:#333,stroke-width:2px
    style C fill:#ffe66d,stroke:#333,stroke-width:2px
    
    A --> B --> C

Link styling:

flowchart LR
    A --> B
    B --> C
    C --> D
    
    linkStyle 0 stroke:#ff6b6b,stroke-width:4px
    linkStyle 1 stroke:#4ecdc4,stroke-width:2px
    linkStyle 2 stroke:#ffe66d,stroke-width:2px

Sequence Diagram Styling

sequenceDiagram
    participant A
    participant B
    participant C
    
    A->>B: Message 1
    B->>C: Message 2
    
    Note over A,C: Styled note
    
    %%{init: {'theme':'forest'}}%%

Class Diagram Styling

classDiagram
    class User {
        +String name
        +login()
    }
    
    class Admin {
        +manageUsers()
    }
    
    User <|-- Admin
    
    %%{init: {'theme':'dark'}}%%

Directional Hints

Control layout direction for specific nodes:

flowchart TB
    A --> B
    B --> C
    B --> D
    C --> E
    D --> E
    
    %% This is a comment - helps organize complex diagrams

Click Events and Links

Add interactive elements:

flowchart LR
    A[GitHub]
    B[Documentation]
    C[Live Demo]
    
    click A "https://github.com" "Go to GitHub"
    click B "https://mermaid.js.org" "View Docs"
    click C "https://mermaid.live" "Try Live Editor"
    
    A --> B --> C

Tooltips

Add hover information:

flowchart LR
    A[Service A]
    B[Service B]
    
    A -.->|REST API| B
    
    %% Tooltips are defined with links
    link A: API Documentation @ https://api.example.com
    link B: Service Dashboard @ https://dashboard.example.com

Subgraph Styling

flowchart TB
    subgraph Frontend
        A[Web App]
        B[Mobile App]
    end
    
    subgraph Backend
        C[API]
        D[Database]
    end
    
    A & B --> C
    C --> D
    
    style Frontend fill:#e3f2fd,stroke:#2196f3,stroke-width:2px
    style Backend fill:#fff3e0,stroke:#ff9800,stroke-width:2px

Comments and Documentation

flowchart TD
    %% This is a single-line comment
    
    %% Multi-line comments can be created
    %% by using multiple comment lines
    
    A[Start]
    B[Process]
    C[End]
    
    %% Define relationships
    A --> B
    B --> C
    
    %% Add styling
    style A fill:#90EE90
    style C fill:#FFB6C1

Complex Styling Example

flowchart TB
    subgraph production[Production Environment]
        direction LR
        lb[Load Balancer]
        
        subgraph servers[Application Servers]
            app1[Server 1]
            app2[Server 2]
            app3[Server 3]
        end
        
        cache[(Redis Cache)]
        db[(PostgreSQL)]
    end
    
    subgraph monitoring[Monitoring]
        logs[Log Aggregator]
        metrics[Metrics Dashboard]
    end
    
    users[Users] --> lb
    lb --> app1 & app2 & app3
    app1 & app2 & app3 --> cache
    app1 & app2 & app3 --> db
    app1 & app2 & app3 --> logs
    logs --> metrics
    
    style production fill:#e8f5e9,stroke:#4caf50,stroke-width:3px
    style servers fill:#fff3e0,stroke:#ff9800,stroke-width:2px
    style monitoring fill:#e3f2fd,stroke:#2196f3,stroke-width:2px
    
    style lb fill:#ffeb3b,stroke:#fbc02d,stroke-width:2px
    style cache fill:#ce93d8,stroke:#ab47bc,stroke-width:2px
    style db fill:#ce93d8,stroke:#ab47bc,stroke-width:2px
    
    classDef serverClass fill:#81c784,stroke:#4caf50,stroke-width:2px,color:#000
    class app1,app2,app3 serverClass
    
    linkStyle 0,1,2,3 stroke:#4caf50,stroke-width:2px
    linkStyle 4,5,6,7,8,9 stroke:#ff9800,stroke-width:1px

Responsive Sizing

Use CSS to make diagrams responsive:

<div style="max-width: 100%; overflow: auto;">
    <pre class="mermaid">
        flowchart LR
            A --> B --> C
    </pre>
</div>

SVG Export Options

When exporting to SVG:

# Export with custom dimensions
mmdc -i diagram.mmd -o output.svg -w 1920 -H 1080

# Export with background color
mmdc -i diagram.mmd -o output.svg -b "#ffffff"

# Export with transparent background
mmdc -i diagram.mmd -o output.svg -b "transparent"

Best Practices for Advanced Features

  1. Use themes consistently - Pick one theme for related diagrams
  2. Don't over-style - Too many colors can reduce clarity
  3. Test hand-drawn look - Some diagrams work better with classic look
  4. Use ELK for complex layouts - When dagre creates crossed lines
  5. Comment complex configurations - Explain non-obvious styling choices
  6. Keep it accessible - Ensure sufficient color contrast
  7. Test exports - Verify diagrams render correctly in target format
  8. Version control configs - Track theme changes in your repository

Accessibility Considerations

---
config:
  theme: base
  themeVariables:
    primaryColor: "#0066cc"
    primaryTextColor: "#ffffff"
    primaryBorderColor: "#003d7a"
    lineColor: "#333333"
    background: "#ffffff"
    mainBkg: "#f0f0f0"
---
flowchart TD
    A[High Contrast Text] --> B[Clear Labels]
    B --> C[Meaningful Colors]

Accessibility tips:

  • Use high contrast color combinations
  • Don't rely solely on color to convey meaning
  • Include descriptive text labels
  • Test with color blindness simulators
  • Consider dark mode alternatives

Performance Considerations

For large diagrams:

---
config:
  layout: elk
  elk:
    mergeEdges: true
---
flowchart TD
    %% ELK handles complex layouts better
    %% Merge edges reduces visual clutter

Performance tips:

  • Use ELK layout for diagrams with >20 nodes
  • Enable edge merging for simplified connections
  • Split very large diagrams into multiple focused views
  • Consider using subgraphs to organize complexity
  • Limit styling to essential elements

Integration Examples

Markdown Files

# System Architecture

```mermaid
flowchart LR
    A --> B
```

HTML Files

<!DOCTYPE html>
<html>
<head>
    <script type="module">
        import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
        mermaid.initialize({ 
            startOnLoad: true,
            theme: 'dark',
            look: 'handDrawn'
        });
    </script>
</head>
<body>
    <pre class="mermaid">
        flowchart LR
            A --> B
    </pre>
</body>
</html>

React Components

import React from 'react';
import mermaid from 'mermaid';

mermaid.initialize({
    startOnLoad: true,
    theme: 'forest'
});

function DiagramComponent() {
    React.useEffect(() => {
        mermaid.contentLoaded();
    }, []);
    
    return (
        <div className="mermaid">
            flowchart LR
                A --> B
        </div>
    );
}

Source: SKILL.md on GitHub

No alerts16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    The skill is a comprehensive documentation set and syntax guide for creating software diagrams using Mermaid. It provides clear instructions and examples for various diagram types and references official, well-known tools and resources. No security issues were detected.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer7mo

    9 files scanned · No issues

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at b00cf84. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 8 months ago
  • Documentation
  • mermaid
  • diagrams
  • visualization
  • architecture
  • flowchart
  • sequence-diagram
  • class-diagram
  • erd
  • c4

README badge

README badge for softaworks/agent-toolkit/mermaid-diagrams

Guides Claude in creating software diagrams using Mermaid's text-based syntax, covering class diagrams for domain modeling, sequence diagrams for API flows, flowcharts for processes, ERDs for database schemas, C4 architecture diagrams, and state/git/gantt charts. Use this skill when documenting system architecture, visualizing code structure, or explaining application flows.

Generated from the current SKILL.md.

What diagram types does this skill support?
Mermaid supports class diagrams, sequence diagrams, flowcharts, entity relationship diagrams, C4 architecture diagrams, state diagrams, git graphs, Gantt charts, and pie/bar charts.
Can I use Mermaid diagrams in GitHub or GitLab?
Yes. GitHub and GitLab automatically render Mermaid diagrams in Markdown files without additional configuration.
How do I export Mermaid diagrams as images?
You can use the Mermaid Live Editor for online export, the Mermaid CLI (`mmdc` command), or Docker to convert `.mmd` files to PNG or SVG.
Does this skill cover styling and theming?
Yes. The skill includes configuration options for themes (default, forest, dark, neutral, base), layout algorithms (dagre, elk), and visual appearance (classic or hand-drawn look).

Generated from the current SKILL.md. These answers refresh after source changes.