Diagram Generator
Turn any input into a clean diagram. Supports the full Mermaid diagram set so one skill handles flowcharts, sequence diagrams, state machines, ER diagrams, journeys, mindmaps, timelines, gantt charts, sankey, quadrants, class diagrams, and git graphs.
Inputs
- Ticket / PRD / spec — read it and pick the right diagram type.
- File path — read the file and diagram from contents.
- Verbal description — diagram directly from the prompt.
- Existing diagram — refactor / restyle / fix.
Workflow
Step 1 — Pick the diagram type
If the input is unambiguous, pick directly. Otherwise ask which fits best:
| User intent |
Mermaid type |
| Process flow, decision tree, "if X then Y" |
flowchart |
| API calls, message passing, who-talks-to-whom over time |
sequenceDiagram |
| Object lifecycle, finite-state machine |
stateDiagram-v2 |
| Database schema, entities + relationships |
erDiagram |
| End-to-end customer/user experience with sentiment |
journey |
| Hierarchical brainstorm, taxonomy, idea tree |
mindmap |
| Dated events, milestones |
timeline |
| Project schedule with durations + dependencies |
gantt |
| Flow of quantity between sources/targets |
sankey-beta |
| 2x2 categorization (importance/urgency, effort/impact) |
quadrantChart |
| OOP class hierarchy with methods |
classDiagram |
| Git branching strategy |
gitGraph |
Step 2 — Extract the diagram content
From the input, pull out the right primitives for the chosen type:
- Flowchart: decision points, actions, states, edge cases, scenarios.
- Sequence: actors, messages, ordering, async vs sync.
- State: states, transitions, triggers, terminal states.
- ER: entities, attributes, relationships, cardinality.
- Journey: stages, tasks per stage, sentiment scores.
- Mindmap: root concept + branches.
- Timeline: sections + events per section.
- Gantt: sections + tasks with dates/durations + dependencies.
- Sankey: source → target → value rows.
- Quadrant: axis labels + items with (x, y) scores.
- Class: classes + members + inheritance/composition.
- GitGraph: branches, commits, merges.
If multiple distinct scenarios exist (e.g., happy path + error path), produce SEPARATE diagrams rather than one mega-diagram.
Step 3 — Emit Mermaid syntax
Always wrap output in:
```mermaid
{type-specific code}
```
Follow the type-specific rules below.
Step 4 — Offer a preview file (optional)
After printing the Mermaid block, ask: "Want me to generate a single-file HTML preview that renders this locally?"
If yes, write diagram.html to the current directory using the template under "HTML preview template" below.
Type-specific rules
Flowchart
- Line breaks in labels: ALWAYS
<br>, NEVER \n.
- Node shapes:
([text]) — start / end (stadium)
[text] — action / process
{text} — decision
[[text]] — subroutine
[(text)] — database
((text)) — circle (event)
- Direction:
flowchart TD for processes, flowchart LR for timelines/pipelines.
- Edge labels:
-- text --> for conditional paths.
- Colors (apply via
style lines at the end):
fill:#4CAF50,color:#fff — success / start (green)
fill:#EF5350,color:#fff — error / blocked (red)
fill:#FF9800,color:#fff — warning / modified (orange)
fill:#2196F3,color:#fff — informational (blue)
- Subgraphs: group related items with
subgraph Name ... end.
- No special characters (quotes, colons, pipes) inside node labels.
- Node text: max 4 lines.
Sequence diagram
- Use
participant X as Display Name to set readable labels.
- Use
->> for sync, -->> for async, --x for failed.
- Use
Note over X,Y: text for callouts.
- Use
loop, alt / else, par, opt for control flow.
- Use
activate X / deactivate X to show lifelines.
State diagram (v2)
- Use
[*] --> StateName for start, StateName --> [*] for end.
- Use
state ChoiceName <<choice>> for branching.
- Use composite states for nesting:
state Group { ... }.
ER diagram
- Cardinality glyphs:
||--o{ (one-to-many), }o--o{ (many-to-many), ||--|| (one-to-one).
- Use lowercase plural entity names.
- Attribute lines:
{type} attributeName "comment".
Journey
- Three columns per task:
Task name: <score 1-5>: Actor1, Actor2.
- Group tasks under
section Name.
Mindmap
- Indentation defines hierarchy.
- Node shapes:
((text)), [text], (text), {{text}}.
Timeline
section Name then events as : YYYY : event text.
Gantt
- Always start with
dateFormat YYYY-MM-DD.
- Tasks:
Name :status, id, start, duration or Name :status, id, after otherId, duration.
- Status keywords:
done, active, crit.
Sankey-beta
- One source-target-value row per line:
Source,Target,42.
- No header. Comma-separated. Values numeric.
Quadrant chart
- Required:
title, x-axis Low --> High, y-axis Low --> High, four quadrant labels.
- Items:
Item Name: [x, y] where x and y are 0-1.
Class diagram
Class : +method() for public, - private, # protected.
- Relationships:
<|-- inherits, *-- composition, o-- aggregation, --> association.
GitGraph
commit, branch name, checkout name, merge name.
- Order matters; reads top-to-bottom.
Output structure
## {Diagram Title}
**Summary:** {one-line description of what the diagram shows}
```mermaid
{code}
Key callouts:
- {anything non-obvious about the diagram}
If multiple diagrams (e.g., happy + error paths), use a header per diagram and render each separately.
## HTML preview template
When the user asks for a local preview, write this single file (no build, no npm; mermaid loaded from CDN):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Diagram preview</title>
<style>
body{margin:0;padding:48px;font:16px/1.5 system-ui,sans-serif;background:#F5F1EA;color:#15140F}
.wrap{max-width:1100px;margin:0 auto}
h1{font-weight:500;font-size:28px;margin:0 0 24px}
.mermaid{background:#fff;border:1px solid #D8D2C5;border-radius:10px;padding:24px;overflow:auto}
</style>
</head>
<body>
<div class="wrap">
<h1>{TITLE}</h1>
<pre class="mermaid">
{MERMAID_CODE}
</pre>
</div>
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: true, theme: 'base', themeVariables: {
primaryColor: '#F5F1EA', primaryTextColor: '#15140F', primaryBorderColor: '#15140F',
lineColor: '#15140F', fontFamily: 'system-ui, sans-serif'
}});
</script>
</body>
</html>
Replace {TITLE} and {MERMAID_CODE} with the actual content. Preview opens directly in the browser (file:// works; no server needed).
Anti-Patterns
- Don't pick the wrong diagram type to "force fit" the input — ask if it's ambiguous.
- Don't cram multiple scenarios into one diagram; split them.
- Don't use
\n for line breaks in flowchart node labels — always <br>.
- Don't put quotes, colons, or pipes inside node labels (they break Mermaid).
- Don't skip the
style lines on flowcharts — color coding makes diagrams scannable.
- Don't reach for D3, ReactFlow, or custom HTML; Mermaid is the right tool for almost every case. (If the user wants the magazine-grade animated process flow, point them to the
interactive-flowchart-builder skill instead.)
- Don't auto-generate the HTML preview unless the user asks — most users just want the Mermaid block.
Quality Checklist
1---2name: diagram-generator3description: Generate diagrams of any kind from a description, ticket, spec, or file. Outputs Mermaid syntax (renders natively in GitHub, Notion, Confluence, Obsidian, Slack with apps) plus an optional single-file HTML preview that renders the diagram in the browser. Use this skill when the user says: - "draw a flowchart", "create a diagram", "visualize this flow" - "sequence diagram", "state diagram", "ER diagram", "class diagram" - "user journey", "mindmap", "timeline", "gantt", "org chart" - "sankey", "quadrant chart", "git graph" - or pastes a ticket / spec / description and asks for a visual Picks the right Mermaid diagram type for the input, asks if ambiguous, then emits clean syntax + an optional preview file.4---56# Diagram Generator78Turn any input into a clean diagram. Supports the full Mermaid diagram set so one skill handles flowcharts, sequence diagrams, state machines, ER diagrams, journeys, mindmaps, timelines, gantt charts, sankey, quadrants, class diagrams, and git graphs.910## Inputs1112- **Ticket / PRD / spec** — read it and pick the right diagram type.13- **File path** — read the file and diagram from contents.14- **Verbal description** — diagram directly from the prompt.15- **Existing diagram** — refactor / restyle / fix.1617## Workflow1819### Step 1 — Pick the diagram type2021If the input is unambiguous, pick directly. Otherwise ask which fits best:2223| User intent | Mermaid type |24|---|---|25| Process flow, decision tree, "if X then Y" | `flowchart` |26| API calls, message passing, who-talks-to-whom over time | `sequenceDiagram` |27| Object lifecycle, finite-state machine | `stateDiagram-v2` |28| Database schema, entities + relationships | `erDiagram` |29| End-to-end customer/user experience with sentiment | `journey` |30| Hierarchical brainstorm, taxonomy, idea tree | `mindmap` |31| Dated events, milestones | `timeline` |32| Project schedule with durations + dependencies | `gantt` |33| Flow of quantity between sources/targets | `sankey-beta` |34| 2x2 categorization (importance/urgency, effort/impact) | `quadrantChart` |35| OOP class hierarchy with methods | `classDiagram` |36| Git branching strategy | `gitGraph` |3738### Step 2 — Extract the diagram content3940From the input, pull out the right primitives for the chosen type:41- **Flowchart:** decision points, actions, states, edge cases, scenarios.42- **Sequence:** actors, messages, ordering, async vs sync.43- **State:** states, transitions, triggers, terminal states.44- **ER:** entities, attributes, relationships, cardinality.45- **Journey:** stages, tasks per stage, sentiment scores.46- **Mindmap:** root concept + branches.47- **Timeline:** sections + events per section.48- **Gantt:** sections + tasks with dates/durations + dependencies.49- **Sankey:** source → target → value rows.50- **Quadrant:** axis labels + items with (x, y) scores.51- **Class:** classes + members + inheritance/composition.52- **GitGraph:** branches, commits, merges.5354If multiple distinct scenarios exist (e.g., happy path + error path), produce SEPARATE diagrams rather than one mega-diagram.5556### Step 3 — Emit Mermaid syntax5758Always wrap output in:59````markdown60```mermaid61{type-specific code}62```63````6465Follow the type-specific rules below.6667### Step 4 — Offer a preview file (optional)6869After printing the Mermaid block, ask: *"Want me to generate a single-file HTML preview that renders this locally?"*7071If yes, write `diagram.html` to the current directory using the template under "HTML preview template" below.7273## Type-specific rules7475### Flowchart7677- **Line breaks in labels:** ALWAYS `<br>`, NEVER `\n`.78- **Node shapes:**79 - `([text])` — start / end (stadium)80 - `[text]` — action / process81 - `{text}` — decision82 - `[[text]]` — subroutine83 - `[(text)]` — database84 - `((text))` — circle (event)85- **Direction:** `flowchart TD` for processes, `flowchart LR` for timelines/pipelines.86- **Edge labels:** `-- text -->` for conditional paths.87- **Colors (apply via `style` lines at the end):**88 - `fill:#4CAF50,color:#fff` — success / start (green)89 - `fill:#EF5350,color:#fff` — error / blocked (red)90 - `fill:#FF9800,color:#fff` — warning / modified (orange)91 - `fill:#2196F3,color:#fff` — informational (blue)92- **Subgraphs:** group related items with `subgraph Name ... end`.93- **No special characters** (quotes, colons, pipes) inside node labels.94- **Node text:** max 4 lines.9596### Sequence diagram9798- Use `participant X as Display Name` to set readable labels.99- Use `->>` for sync, `-->>` for async, `--x` for failed.100- Use `Note over X,Y: text` for callouts.101- Use `loop`, `alt / else`, `par`, `opt` for control flow.102- Use `activate X` / `deactivate X` to show lifelines.103104### State diagram (v2)105106- Use `[*] --> StateName` for start, `StateName --> [*]` for end.107- Use `state ChoiceName <<choice>>` for branching.108- Use composite states for nesting: `state Group { ... }`.109110### ER diagram111112- Cardinality glyphs: `||--o{` (one-to-many), `}o--o{` (many-to-many), `||--||` (one-to-one).113- Use lowercase plural entity names.114- Attribute lines: `{type} attributeName "comment"`.115116### Journey117118- Three columns per task: `Task name: <score 1-5>: Actor1, Actor2`.119- Group tasks under `section Name`.120121### Mindmap122123- Indentation defines hierarchy.124- Node shapes: `((text))`, `[text]`, `(text)`, `{{text}}`.125126### Timeline127128- `section Name` then events as `: YYYY : event text`.129130### Gantt131132- Always start with `dateFormat YYYY-MM-DD`.133- Tasks: `Name :status, id, start, duration` or `Name :status, id, after otherId, duration`.134- Status keywords: `done`, `active`, `crit`.135136### Sankey-beta137138- One source-target-value row per line: `Source,Target,42`.139- No header. Comma-separated. Values numeric.140141### Quadrant chart142143- Required: `title`, `x-axis Low --> High`, `y-axis Low --> High`, four quadrant labels.144- Items: `Item Name: [x, y]` where x and y are 0-1.145146### Class diagram147148- `Class : +method()` for public, `-` private, `#` protected.149- Relationships: `<|--` inherits, `*--` composition, `o--` aggregation, `-->` association.150151### GitGraph152153- `commit`, `branch name`, `checkout name`, `merge name`.154- Order matters; reads top-to-bottom.155156## Output structure157158```markdown159## {Diagram Title}160161**Summary:** {one-line description of what the diagram shows}162163```mermaid164{code}165```166167**Key callouts:**168- {anything non-obvious about the diagram}169```170171If multiple diagrams (e.g., happy + error paths), use a header per diagram and render each separately.172173## HTML preview template174175When the user asks for a local preview, write this single file (no build, no npm; mermaid loaded from CDN):176177```html178<!doctype html>179<html lang="en">180<head>181<meta charset="utf-8" />182<title>Diagram preview</title>183<style>184 body{margin:0;padding:48px;font:16px/1.5 system-ui,sans-serif;background:#F5F1EA;color:#15140F}185 .wrap{max-width:1100px;margin:0 auto}186 h1{font-weight:500;font-size:28px;margin:0 0 24px}187 .mermaid{background:#fff;border:1px solid #D8D2C5;border-radius:10px;padding:24px;overflow:auto}188</style>189</head>190<body>191 <div class="wrap">192 <h1>{TITLE}</h1>193 <pre class="mermaid">194{MERMAID_CODE}195 </pre>196 </div>197 <script type="module">198 import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';199 mermaid.initialize({ startOnLoad: true, theme: 'base', themeVariables: {200 primaryColor: '#F5F1EA', primaryTextColor: '#15140F', primaryBorderColor: '#15140F',201 lineColor: '#15140F', fontFamily: 'system-ui, sans-serif'202 }});203 </script>204</body>205</html>206```207208Replace `{TITLE}` and `{MERMAID_CODE}` with the actual content. Preview opens directly in the browser (file:// works; no server needed).209210## Anti-Patterns211212- Don't pick the wrong diagram type to "force fit" the input — ask if it's ambiguous.213- Don't cram multiple scenarios into one diagram; split them.214- Don't use `\n` for line breaks in flowchart node labels — always `<br>`.215- Don't put quotes, colons, or pipes inside node labels (they break Mermaid).216- Don't skip the `style` lines on flowcharts — color coding makes diagrams scannable.217- Don't reach for D3, ReactFlow, or custom HTML; Mermaid is the right tool for almost every case. (If the user wants the magazine-grade animated process flow, point them to the `interactive-flowchart-builder` skill instead.)218- Don't auto-generate the HTML preview unless the user asks — most users just want the Mermaid block.219220## Quality Checklist221222- [ ] Picked the right diagram type for the input (flowchart vs sequence vs state vs ...).223- [ ] Mermaid syntax parses cleanly (no unescaped special chars in labels).224- [ ] Distinct scenarios split into separate diagrams.225- [ ] Color/style applied where the diagram type supports it (flowchart, sequence highlights, journey scores).226- [ ] Node text is concise (≤4 lines).227- [ ] Summary line + key callouts included with the diagram.228- [ ] If preview requested, single-file HTML written and opens directly in browser.