Get the FREE Ultimate OpenClaw Setup Guide →

diagrams

npx machina-cli add skill gologo13/agent-skills/diagrams --openclaw
Files (1)
SKILL.md
2.8 KB

Generate Mermaid Diagram

Overview

Analyze the provided code, architecture, or concept and generate a clear, well-structured Mermaid diagram that visualizes the relationships, flow, or structure.

Instructions

  1. Analyze the input - Understand what the user wants to visualize (code flow, architecture, data relationships, state machines, sequences, etc).

  2. Choose the appropriate diagram type:

    • flowchart - For process flows, decision trees, algorithms
    • sequenceDiagram - For API calls, message passing, request/response flows
    • classDiagram - For class structures, inheritance, interfaces
    • erDiagram - For database schemas, entity relationships
    • stateDiagram-v2 - For state machines, lifecycle flows
    • graph TD/LR - For dependency graphs, module relationships
    • gitgraph - For git branching strategies
    • journey - For user journeys
    • gantt - For timelines and schedules
  3. Generate the diagram with these qualities:

    • Clear, descriptive node labels
    • Logical grouping with subgraphs where appropriate
    • Consistent styling and direction
    • Meaningful relationship labels on edges
    • Not overly complex - split into multiple diagrams if needed
  4. Output format: Always wrap the diagram in a mermaid code block:

    [diagram code here]
    

Diagram Style Guidelines

  • Use descriptive IDs: userService not a1
  • Add labels to relationships when they add clarity
  • Use subgraphs to group related components
  • Keep diagrams readable - max ~15-20 nodes per diagram
  • Use appropriate arrow styles:
  • --> solid arrow (main flow)
  • -.-> dotted arrow (optional/async)
  • ==> thick arrow (important path)
  • o--> circle end (aggregation)
  • *--> diamond end (composition)

Examples

Flowchart

flowchart TD
    A[Start] --> B{Is valid?}
    B -->|Yes| C[Process]
    B -->|No| D[Error]
    C --> E[End]
    D --> E

Sequence Diagram

sequenceDiagram
    participant C as Client
    participant S as Server
    participant DB as Database

    C->>S: Request
    S->>DB: Query
    DB-->>S: Results
    S-->>C: Response

Class Diagram

classDiagram
    class Animal {
         String name
         makeSound()
    }
    class Dog {
         bark()
    }
    Animal <|-- Dog

ER Diagram

erDiagram
    USER ||--o{ ORDER : places
    ORDER ||--|{ LINE_ITEM : contains
    PRODUCT ||--o{ LINE_ITEM : "ordered in"

After generating

  • Explain what the diagram shows
  • Offer to refine or expand specific sections
  • Suggest alternative diagram types if applicable

Source

git clone https://github.com/gologo13/agent-skills/blob/main/skills/diagrams/SKILL.mdView on GitHub

Overview

Generate Mermaid diagrams to visualize code, architecture, or conceptual relationships. It supports multiple diagram types (flowchart, sequenceDiagram, classDiagram, erDiagram, stateDiagram-v2, graph TD/LR, gitgraph, journey, gantt) and emphasizes clear labels, logical grouping, and readable edges.

How This Skill Works

Analyze the input to determine what you want visualized, select the appropriate Mermaid diagram type, and emit a diagram with descriptive node IDs and labeled edges. The final diagram is wrapped in a Mermaid code block for immediate rendering.

When to Use It

  • Document an API call sequence using sequenceDiagram
  • Model a class hierarchy or data model with classDiagram or erDiagram
  • Show module dependencies or architecture with graph TD/LR
  • Illustrate a Git workflow or branching strategy with gitgraph
  • Map a user journey or lifecycle with journey or stateDiagram-v2

Quick Start

  1. Step 1: Provide the input to visualize (code, architecture, or concept)
  2. Step 2: Pick the diagram type and draft edge labels
  3. Step 3: Render the Mermaid code block and refine for readability

Best Practices

  • Use descriptive IDs like userService or orderController instead of short placeholders
  • Group related components with subgraphs to improve readability
  • Label edges with meaningful relationships (e.g., calls, responds, depends on)
  • Keep each diagram under 15-20 nodes; split larger ones into multiple diagrams
  • Choose the right diagram type for the scenario (sequence for API calls, class for structures, etc.)

Example Use Cases

  • API call sequence for a login flow (sequenceDiagram)
  • Class and inheritance diagram for a user management system (classDiagram)
  • Module dependency graph of a frontend-backend stack (graph TD)
  • Git branching strategy demonstrated with gitgraph
  • User onboarding journey from visit to activation (journey diagram)

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers