Claude mermaid skill: 10 diagrams from one prompt
Ten diagrams you can paste into a README today — flowchart, sequence, ERD, Gantt, state, class, C4 architecture, git-graph, mindmap, and a broken-diagram repair — each as a single Claude prompt with the exact Mermaid syntax the mermaid-gen skill produces.
Mermaid is the Markdown-native diagram syntax: you write indented text, and GitHub, GitLab, Obsidian, and Notion render it as a real diagram. The skill’s job is to write that text for you from a prose description — the right diagram type, valid node IDs, escaped labels — so the output renders on the first try instead of throwing a parse error.
Already know what skills are? Skip to the cookbook. First time? Read the explainer then come back. Need the install? It’s on the /skills/mermaid-gen page.

On this page · 21 sections▾
- What this skill does
- The cookbook
- Install + README
- Watch it explained
- 01 · Flowchart from a prose process description
- 02 · Sequence diagram of an OAuth handshake
- 03 · ERD from a database schema
- 04 · Gantt project timeline
- 05 · State diagram of a workflow
- 06 · Class diagram from code
- 07 · C4-style architecture with subgraphs
- 08 · Git-graph branching strategy
- 09 · Mindmap from rough notes
- 10 · Fix a syntax-broken diagram and theme it
- Community signal
- The contrarian take
- Real diagrams shipped
- Gotchas
- Pairs well with
- FAQ
- Sources
What this skill actually does
Sixty seconds of context before the cookbook — what the mermaid-gen skill is, what Claude hands back when you invoke it, and the one thing it does NOT do for you.
What this skill actually does
“Generate syntactically correct Mermaid diagrams for technical documentation.”
— vladm3105, the skill author · /skills/mermaid-gen
What Claude returns
When triggered, Claude returns a fenced ```mermaid block: it picks the diagram type from your ask (flowchart, sequenceDiagram, erDiagram, gantt, stateDiagram-v2, classDiagram, gitGraph, mindmap), assigns short node IDs, escapes labels that contain parens or punctuation, draws the edges, and keeps the whole thing inside one code fence so GitHub, GitLab, Obsidian, or the Mermaid Live Editor render it as-is. The diagram IS the deliverable — text you commit, not an image you upload.
What it does NOT do
It does not render the diagram to a PNG or SVG for you — the text renders wherever Markdown does (GitHub, Obsidian, mermaid.live); reach for a Mermaid MCP server when you need a static image file.
How you trigger it
Draw this auth flow as a Mermaid sequence diagram.Turn db/schema.sql into a Mermaid ERD.Fix this broken Mermaid block — it won't render.Cost when idle
~100 tokens at idle (the skill name + description in the system prompt). The body and any reference files load only when the skill is triggered.
The cookbook
Each entry below is a diagram you could paste into a doc this afternoon. They run roughly from the everyday (a flowchart from a paragraph) to the structural (an ERD from a live database, a C4 architecture view) to the repair job (fixing a parse error and theming it). Every entry uses a different Mermaid diagram type, and each pairs with a skill or MCP server you can find on mcp.directory.
Install + README
If the skill isn’t on your machine yet, here’s the one-liner. The full install panel (Codex, Copilot, Antigravity variants) is on the skill page — the same UI’s embedded below.
One-line install · by vladm3105
Open skill pageInstall
mkdir -p .claude/skills/mermaid-gen && curl -L -o skill.zip "https://mcp.directory/api/skills/download/289" && unzip -o skill.zip -d .claude/skills/mermaid-gen && rm skill.zipInstalls to .claude/skills/mermaid-gen
Watch it explained
The official Mermaid channel’s from-scratch primer. Worth ten minutes before the cookbook because it anchors the syntax — the fenced block, the diagram-type keyword, the node-and-arrow grammar — that every prompt below relies on Claude getting right.
Flowchart from a prose process description
Turn a paragraph describing a refund process into a top-down flowchart with decision diamonds. The skill picks node IDs, escapes the labels, and keeps the branch logic intact.
ForAnyone documenting a process who would rather write sentences than drag boxes.
The prompt
Read the refund policy in `docs/refunds.md` and draw it as a Mermaid `flowchart TD`. A request comes in, we check if it's within 30 days; if yes we check whether the item is opened; unopened refunds auto-approve, opened ones go to manual review; outside 30 days we decline with a reason. Use decision nodes for the two checks and label every edge with Yes/No. Wrap it in a ```mermaid fenced block so it renders on GitHub.What slides.md looks like
flowchart TD
A[Refund request] --> B{Within 30 days?}
B -- No --> D[Decline: outside window]
B -- Yes --> C{Item opened?}
C -- No --> E[Auto-approve]
C -- Yes --> F[Manual review]
F --> G{Approved?}
G -- Yes --> E
G -- No --> DOne-line tweak
Swap `flowchart TD` for `flowchart LR` and the same logic reads left-to-right — better for a wide slide, worse for a tall README.
Sequence diagram of an OAuth handshake
Render a four-actor authorization-code flow — browser, app, auth server, API — as a Mermaid sequence diagram. Solid arrows for requests, dashed for responses, an activation bar over the token exchange.
ForBackend engineers documenting an auth flow in an ADR or onboarding doc.
The prompt
Draw the OAuth 2.0 authorization-code flow as a Mermaid `sequenceDiagram`. Participants: Browser, App, AuthServer, API. Browser hits App, App redirects to AuthServer, user authenticates, AuthServer returns a code to App, App exchanges the code for an access token (wrap this exchange in an activation), then App calls API with the bearer token. Use `->>` for requests and `-->>` for responses, and add a Note over the token exchange.What slides.md looks like
sequenceDiagram
participant Browser
participant App
participant AuthServer
participant API
Browser->>App: GET /login
App-->>Browser: 302 redirect to AuthServer
Browser->>AuthServer: Authenticate + consent
AuthServer-->>App: Authorization code
activate App
App->>AuthServer: Exchange code for token
AuthServer-->>App: Access token
deactivate App
Note over App,API: Bearer token on every call
App->>API: GET /me (Authorization: Bearer)
API-->>App: 200 user profileOne-line tweak
Add `autonumber` on the line after `sequenceDiagram` and every message gets a step number — handy when the ADR references 'step 4' in prose.
ERD from a database schema
Take a SQL schema (or a Postgres connection) and emit a Mermaid `erDiagram` with the right cardinality crow's-feet between customers, orders, and line items.
ForData engineers who need an entity diagram that lives next to the migration.
The prompt
Read `db/schema.sql` and produce a Mermaid `erDiagram`. Entities: CUSTOMER, ORDER, LINE_ITEM, PRODUCT. A customer places many orders (one-to-many, mandatory order side). An order contains one or more line items. Each line item references exactly one product. Use the crow's-foot notation `||--o{` for one-to-many and `}o--||` where the order side is mandatory. List the primary key and two key columns per entity.What slides.md looks like
erDiagram
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ LINE_ITEM : contains
LINE_ITEM }o--|| PRODUCT : references
CUSTOMER {
int id PK
string email
}
ORDER {
int id PK
int customer_id FK
}
LINE_ITEM {
int id PK
int qty
}One-line tweak
Point the prompt at a live database instead of the .sql file and pair with the Postgres MCP — the skill reads the real `information_schema` and never drifts from the migration.
Gantt project timeline
Convert a milestone list into a Mermaid `gantt` chart with sections, dependencies (`after`), and an `active`/`done` status per task. Dates stay as real ISO dates, durations as `3d`.
ForTech leads who want a timeline in the planning doc without opening a project tool.
The prompt
Build a Mermaid `gantt` for a 6-week migration. `dateFormat YYYY-MM-DD`, title 'DB migration'. Section Prep: schema audit (done, 2026-07-06, 3d), backfill script (active, after the audit, 5d). Section Cutover: dry run (after the backfill, 2d), production switch (1d), monitoring window (after the switch, 5d). Mark the schema audit `done` and the backfill `active`. Use `after` for every dependency so shifting one task moves the rest.What slides.md looks like
gantt
dateFormat YYYY-MM-DD
title DB migration
section Prep
Schema audit :done, a1, 2026-07-06, 3d
Backfill script :active, a2, after a1, 5d
section Cutover
Dry run : a3, after a2, 2d
Production switch: a4, after a3, 1d
Monitoring : a5, after a4, 5dOne-line tweak
Add `excludes weekends` under `dateFormat` and the bars skip Saturdays and Sundays — durations now read as working days, not calendar days.
State diagram of a workflow
Describe an order lifecycle in words and get a Mermaid `stateDiagram-v2` with a start marker, transitions, and a terminal state. The skill uses the v2 renderer so nested states stay clean.
ForEngineers modelling a finite-state machine — order status, ticket status, job status.
The prompt
Model an order's lifecycle as a Mermaid `stateDiagram-v2`. States: Pending, Paid, Shipped, Delivered, Cancelled. Start at Pending. Pending goes to Paid on payment or Cancelled on timeout. Paid goes to Shipped. Shipped goes to Delivered. Paid and Pending can both reach Cancelled. Delivered and Cancelled are terminal. Use `[*]` for the start and label each transition with the event that triggers it.What slides.md looks like
stateDiagram-v2
[*] --> Pending
Pending --> Paid: payment
Pending --> Cancelled: timeout
Paid --> Shipped: fulfil
Paid --> Cancelled: refund
Shipped --> Delivered: arrive
Delivered --> [*]
Cancelled --> [*]One-line tweak
Group Paid/Shipped/Delivered inside a composite `state Fulfilment { ... }` block to collapse the happy path into one box on a busy diagram.
Class diagram from code
Read a set of classes and emit a Mermaid `classDiagram` with fields, methods, and the right relationship arrows — inheritance, composition, association. Visibility markers (`+`/`-`) come through.
ForDevelopers reverse-documenting an existing module for a design review.
The prompt
Read `src/billing/*.py` and draw a Mermaid `classDiagram`. Classes: Invoice, LineItem, Customer, PaymentGateway. Invoice is composed of many LineItems (`*--`). Invoice has one Customer (association `-->`). CardGateway and BankGateway both inherit from PaymentGateway (`<|--`). Show each class's public methods with `+` and private fields with `-`. Keep it to the relationships that exist in the code — don't invent any.What slides.md looks like
classDiagram
PaymentGateway <|-- CardGateway
PaymentGateway <|-- BankGateway
Invoice *-- LineItem
Invoice --> Customer
class Invoice {
-id: str
+total() Decimal
+charge(gateway) bool
}
class PaymentGateway {
+authorize(amount) bool
}One-line tweak
Ask for `<<interface>>` on PaymentGateway and it renders with the interface stereotype — the right call when the gateways implement a protocol rather than subclass.
C4-style architecture with subgraphs
Render a container-level architecture view as a Mermaid `flowchart` using `subgraph` blocks to group services into boundaries — web tier, service tier, data tier — with arrows crossing between them.
ForArchitects sketching a C4 container diagram without a heavyweight modelling tool.
The prompt
Draw a C4-style container view as a Mermaid `flowchart LR`. Three `subgraph` boundaries: 'Edge' (Browser, CDN), 'Services' (API, Auth, Worker), 'Data' (Postgres, Redis, S3). Browser hits CDN then API. API talks to Auth and reads/writes Postgres. Worker reads from Redis and writes to S3. Label the cross-boundary edges with the protocol (HTTPS, gRPC, SQL). Keep each subgraph titled so the boundaries are obvious.What slides.md looks like
flowchart LR
subgraph Edge
Browser --> CDN
end
subgraph Services
API
Auth
Worker
end
subgraph Data
Postgres[(Postgres)]
Redis[(Redis)]
S3[(S3)]
end
CDN -->|HTTPS| API
API -->|gRPC| Auth
API -->|SQL| Postgres
Worker --> Redis
Worker --> S3One-line tweak
Add `classDef data fill:#0b3a34,stroke:#14b8a6` and `class Postgres,Redis,S3 data` to tint the whole data tier one colour — instant visual grouping without redrawing.
Git-graph branching strategy
Explain your branching model — trunk-based, GitFlow, release branches — as a Mermaid `gitGraph` showing commits, branches, checkouts, and merges in the order they happen.
ForTeam leads onboarding new contributors to the repo's branching conventions.
The prompt
Draw our release-branch workflow as a Mermaid `gitGraph`. Start on main with two commits. Branch `develop`, add three commits. Branch `release/1.2` off develop, add a commit (the version bump), then merge `release/1.2` back into main and tag it. Return to develop and add one more commit. Use `commit`, `branch`, `checkout`, and `merge` — the order of operations is the whole point.What slides.md looks like
gitGraph
commit
commit
branch develop
checkout develop
commit
commit
commit
branch release/1.2
commit id: "v1.2 bump"
checkout main
merge release/1.2 tag: "v1.2"
checkout develop
commitOne-line tweak
Add `commit type: HIGHLIGHT` on the version bump and that node renders filled — useful when the release commit is the one you want the reader's eye to land on.
Mindmap from rough notes
Take a flat bullet list of ideas and reshape it into a Mermaid `mindmap` — indentation defines the hierarchy, so the skill infers parent/child from the structure of your notes.
ForAnyone turning brainstorm notes into a structured map for a planning doc.
The prompt
Convert my launch-planning notes in `notes/launch.md` into a Mermaid `mindmap`. Root node 'Launch'. Three branches: 'Product' (feature freeze, QA pass, changelog), 'Marketing' (landing page, email, demo video), 'Ops' (status page, on-call, rollback plan). Children sit one indent deeper than their parent — indentation is the only thing that sets the level, so keep it consistent.What slides.md looks like
mindmap
root((Launch))
Product
Feature freeze
QA pass
Changelog
Marketing
Landing page
Email
Demo video
Ops
Status page
On-call
Rollback planOne-line tweak
Wrap the root in `root((...))` for a circle, `root[...]` for a square, or `root)...(` for a cloud — the shape signals what kind of map it is at a glance.
Fix a syntax-broken diagram and theme it
Hand the skill a Mermaid block that won't render and a renderer error. It finds the offending line — a reserved word as a node ID, an unescaped paren, a bad arrow — fixes it, then applies a theme via the init directive.
ForAnyone staring at a 'Parse error on line 4' from GitHub or the Mermaid Live Editor.
The prompt
This Mermaid block fails to render with 'Parse error on line 3'. The label has an unescaped paren and `end` is being used as a node ID (it's reserved). Fix both, then add an init directive to apply the `dark` theme and set the primary colour to teal. Return the corrected ```mermaid block and one sentence on what was wrong.What slides.md looks like
%%{init: {'theme': 'dark', 'themeVariables': {'primaryColor': '#14b8a6'}}}%%
flowchart TD
A["Start (entry)"] --> B[Process]
B --> finish[End]
%% was: end[End] — 'end' is a reserved
%% keyword and cannot be a node id;
%% the label paren also needed quotesOne-line tweak
Swap `'theme': 'dark'` for `'theme': 'neutral'` to get a print-friendly greyscale version of the exact same diagram — one keyword, no other edits.
Community signal
Three voices from people using Mermaid for real work. The first is the one that matters most here — it’s about feeding a description to an LLM and getting valid syntax back, which is the exact loop this skill formalises. The second is the production docs-as-code story; the third is the speed argument.
“Mermaidjs is amazing. you could ask LLM to visualise your question (e.g codebase) using mermaidjs syntax and it mostly works just fine without any syntax errors. or at least on Claude Sonnet 3.5 from my experience”
Crier1002 · Hacker News
Hacker News commenter on exactly why Mermaid pairs with an LLM — text-in, diagram-out, rarely a syntax error.
“We use mermaid for our charting in our technical documentation (which is public facing). Mostly object diagrams and sequence diagrams. Moved from plantUML... Love the ability to version control your charts as well as write them out quickly without involving a design team and still have them look pretty good.”
mooreds · Hacker News
Production docs-as-code usage, and the version-control argument that makes Mermaid stick over a design-team workflow.
“I treated it like LaTeX, used it as I wanted to and if I hit a blocker then I learned how to do it. Now I can do Diagrams as Code faster than some diagramming-specific tools/excel. I whipped up an entire C4 diagram in less than an hour.”
GloomyAmoeba6872 · Reddit
An Obsidian user on how fast the text syntax beats GUI tools once it's in your fingers — relevant to use case 7.
The contrarian take
Mermaid is not the right tool for every diagram, and the most honest take on its limit is the auto-layout one, from CuriousCurmudgeon on r/ObsidianMD:
“90% is our rule of thumb at work. The other 10% of the time the diagram is too complex and/or Mermaid chooses a terrible layout. We fall back to a tool like Excalidraw in those cases.”
CuriousCurmudgeon · Reddit
From the r/ObsidianMD 'TIL about Mermaid diagrams' thread — the 90/10 rule many teams land on.
Fair, and worth naming up front: Mermaid lays diagrams out for you, and you cannot nudge a box three pixels left the way you can in a canvas tool. When the graph is dense, the auto-layout can pick a routing you would not. The skill does not fix that — no skill can, it’s a property of Mermaid’s renderer. What it does do is keep the syntax valid so you spend your time on the 90% that renders cleanly, and for the other 10% the answer is a canvas tool. mcp.directory has skills for both Excalidraw and draw.io when the layout matters more than the version history — see the drawio skill cookbook for the manual-positioning counterpart.
One more comparison worth naming: there are several Mermaid MCP servers — mermaid, mermaid-validator, and mermaid-chart — but they solve a different problem. They render or validate Mermaid syntax over MCP; the mermaid-gen skill writes it. Author with the skill, then hand the output to a server when you need a static PNG/SVG or a pre-commit validation gate. For everyday docs-as-code, the skill alone is enough, because GitHub and Obsidian render the fenced block with no server at all.
Real diagrams shipped as Mermaid
Concrete examples from public projects and platforms. Most don’t use the Claude skill specifically — they’re here to show where Mermaid renders in the wild, so you have a target in mind when you write the prompt.
- GitHub — native Mermaid rendering inside Markdown, READMEs, and issues via fenced ```mermaid blocks
- GitLab — renders Mermaid natively across wikis, issues, and Markdown docs
- Microsoft Azure DevOps — Mermaid diagrams in wiki Markdown for version-controlled architecture and sequence diagrams
- mermaid-js/mermaid — the project's own README is written diagrams-as-code, embedding live flowchart and sequence examples
- Bryce Mecum — rendering distributed traces as Mermaid Gantt charts inline in Markdown (front-paged on Hacker News)
- gin66/tui-logger — a Rust crate documenting its widget architecture with a ```mermaid diagram in the README
Gotchas (the four that bite)
Sourced from the Mermaid syntax reference and the parse errors people actually hit. The skill knows these — they’re the reason a generated diagram renders where a hand-typed one throws.
Reserved words can't be node IDs
`end` is the classic trap — it closes a subgraph, so `end[Done]` breaks the parse. Other keywords (graph, subgraph) bite too. The fix is a different ID and a label: `finish[Done]`. Use case 10 is exactly this repair.
Special characters in labels need quotes
A label with parentheses, colons, or punctuation — `A[Start (entry)]` — fails. Wrap it: `A["Start (entry)"]`. The skill quotes labels defensively so this never reaches your README, but it's the #1 hand-typed error.
Renderers differ — pin the version that matters
GitHub, GitLab, and mermaid.live can ship different Mermaid versions, so a brand-new diagram type (mindmap, quadrantChart) may render on one and not another. Stick to flowchart/sequence/class/state/ERD for maximum portability; treat the newer types as Live-Editor-first.
Mindmaps and indentation are strict
Mermaid mindmaps derive the hierarchy purely from indentation — a single inconsistent indent reparents a node or errors out. Keep the indent step consistent (two spaces). Use case 9 leans on this; it's why the skill's output indents uniformly.
Pairs well with
Curated to match the cookbook’s actual integrations: the diagram-adjacent skills (excalidraw, svg-precision, drawio-diagrams-enhanced, confluence) plus the MCP servers the structural use cases (3, 4, 9, 10) lean on.
Related skills
Related MCP servers
Two posts that compose well with this cookbook: What are Claude Code skills? covers the underlying mechanism, and the svg skill cookbook covers hand-authored vector graphics — the right reach when you need pixel-precise output that Mermaid’s auto-layout won’t give you.
Frequently asked questions
Do I need to know Mermaid syntax before I use the mermaid skill?
No. The whole point of the mermaid skill is that you describe the diagram in plain English and it writes the syntax — the right diagram type, the node IDs, the escaped labels, the arrow operators. Reading the result is a good sanity check, and every recipe above shows the exact syntax it produces, but you never have to memorise the flowchart vs. sequence vs. erDiagram grammar yourself.
Is there an MCP mermaid server I should use instead of the mermaid-gen skill?
There are several, and they do a different job. The `mermaid`, `mermaid-validator`, and `mermaid-chart` MCP servers render or validate Mermaid — they turn syntax into a PNG/SVG or check it parses. The mermaid-gen skill writes the syntax in the first place. The clean split: use the skill to author the diagram from a description, then hand the output to a Mermaid MCP server if you need a static image file or a pre-commit validation gate. For most docs-as-code work the skill alone is enough, because GitHub and Obsidian render the fenced block without any server.
Where does a Mermaid diagram actually render once Claude writes it?
Anywhere that reads Markdown and supports Mermaid: GitHub (READMEs, issues, PR descriptions), GitLab, Azure DevOps wikis, Obsidian, Notion, and the Mermaid Live Editor at mermaid.live. That is the appeal of the diagrams-as-code approach — the diagram is committed text that travels with the doc, so it never goes stale the way an exported PNG does. The skill always wraps its output in a ```mermaid fence so it renders without any extra step.
Can the mermaid skill fix a diagram that won't render, not just create new ones?
Yes — that's use case 10 above. Paste the broken ```mermaid block and the renderer's error ('Parse error on line 4'), and the skill finds the cause: a reserved word like `end` used as a node ID, an unescaped paren in a label, a malformed arrow, or inconsistent mindmap indentation. It returns the corrected block plus a one-line explanation of what was wrong, which is faster than bisecting the syntax by hand.
Mermaid vs Excalidraw — when should I reach for one over the other?
Mermaid is text you describe and the layout is automatic; Excalidraw is a canvas you draw on and every box is where you put it. Reach for Mermaid when the diagram should live in version control and update with the code — flowcharts, sequence diagrams, ERDs in a README. Reach for Excalidraw when the auto-layout fights you or the diagram needs deliberate spatial composition. Many teams use a 90/10 rule: Mermaid by default, Excalidraw for the 10% where the layout matters more than the version history. mcp.directory has an Excalidraw skill too if you want both.
Will Claude invent relationships that aren't in my schema or code?
Not if you ask it not to, and the recipes above all say 'don't invent any.' When you point the mermaid skill at a real `schema.sql`, a live Postgres connection, or a set of source files, the right move is to instruct it to draw only the entities and edges that exist in the source. The ERD and class-diagram recipes do exactly that — the cardinality and the inheritance arrows come from what's actually there, not from a plausible guess.
Why is 'mermaid skill' getting impressions on Google but very few clicks?
The bare 'mermaid' and 'mermaid skill' queries surface the official mermaid.js.org docs and the Mermaid Live Editor as the top results, which absorb most clicks. This post targets the how-to long-tail instead — 'mermaid agent skill', 'mcp mermaid', 'claude mermaid skill', and 'excalidraw vs mermaid' — the queries where a reader wants recipes and a skill-vs-MCP decision, which is what the cookbook above is built to answer.
Sources
Primary
- mermaid-gen skill on mcp.directory (install + details, by vladm3105)
- Mermaid official documentation — intro & diagram types
- Mermaid syntax reference (flowchart, sequence, ERD, gantt, state, class, gitGraph, mindmap)
- Mermaid Live Editor — paste-and-render playground
- GitHub docs — creating Mermaid diagrams in Markdown
Community
- Crier1002 — Hacker News
- mooreds — Hacker News
- GloomyAmoeba6872 — Reddit
- MarkMarine — Hacker News
- murtaza64 — Reddit
- nulone — Hacker News
Critical and contrarian
Internal