
mermaid-skill
Generate Mermaid diagrams (.mmd) and export to PNG/SVG/PDF using mmdc CLI or Kroki API. USE THIS SKILL when user mentions diagram, flowchart, sequence diagram, class diagram, ER diagram, state machine, architecture, visualize, git graph, 画图, 架构图, 流程图, 时序图, 类图, ER图, 甘特图, 状态机. PROACTIVELY USE when explaining ANY system with 3+ components, API flows, authentication sequences, class hierarchies, database schemas, or state machines. Supports 17+ diagram types with fully automatic layout.
- Installs
- 585
- Last 24h
- +8
- Trending rank
- #9568
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/agents365-ai/365-skills --skill mermaid-skill- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads mermaid-skill automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Mermaid Diagrams
Generate .mmd text files and export to PNG/SVG/PDF using mmdc (local) or Kroki API (no install).
Key advantage: Text-based syntax with fully automatic layout — no x/y coordinates needed.
When to use / when NOT to use
Use this skill for: diagrams-as-code with automatic layout (flowchart, sequence, class, state, ER, gantt, mindmap, architecture) — text source that lives in git and embeds in Markdown.
Do NOT use it — route elsewhere — for:
- Pixel-precise placement, custom layout, branded icons, or heavy styling → drawio.
- A hand-drawn / sketchy aesthetic → excalidraw or tldraw.
- A freeform whiteboard or freehand strokes → tldraw.
- Strict, conventional UML notation → plantuml.
Prerequisites
Option A: Local (mmdc) — also needs a headless Chrome (mmdc renders via Puppeteer)
npm install -g @mermaid-js/mermaid-cli
npx puppeteer browsers install chrome-headless-shell # required — mmdc has no bundled browser
mmdc --version
mmdc --versionsucceeds even with no Chrome installed, but every export then fails withCould not find Chrome. Install the browser above (or setPUPPETEER_EXECUTABLE_PATHto a system Chrome). If you can't, use Kroki (Option B) — it needs no browser.
CI / Docker: mmdc crashes with Running as root without --no-sandbox in containers. Pass the bundled puppeteer config (see scripts/puppeteer-config.json):
mmdc -p scripts/puppeteer-config.json -i diagram.mmd -o diagram.png
Option B: Kroki API (no install)
curl --version # Just need curl
Workflow
- Check deps — validate via Kroki (needs only
curl); checkmmdc --versionand a headless Chrome only when local export (PNG quality / PDF) is wanted - Pick diagram type — choose from table below
- Generate — write
.mmdfile to disk - Validate — Kroki-first (see Validation; REQUIRED before export)
- Export — use
mmdcor Kroki API to produce PNG/SVG/PDF - Self-check (vision) — read the exported PNG and fix readability/layout defects that automatic layout can't prevent (clipped labels, cramped density, wrong orientation), then re-validate + re-export. Max 2 rounds; skip if no vision. See Self-Check (vision) below.
- Review loop — show the image to the user, apply the minimal
.mmdedit per request, re-export until approved (5-round safety valve). See Review Loop below. - Report — tell user the output file paths
Validation (Required)
NEVER export a diagram without validating first.
Prefer Kroki for validation — it needs no browser and sidesteps the Could not find Chrome trap entirely. Use mmdc for validation only when offline.
# Validate with Kroki (preferred — no browser needed)
curl -s -X POST -H "Content-Type: text/plain" --data-binary @diagram.mmd https://kroki.io/mermaid/svg -o /tmp/test.svg && echo "Valid" || echo "Invalid"
# Validate with mmdc (offline fallback — requires headless Chrome)
mmdc -i diagram.mmd -o /tmp/test.svg 2>&1
# If error, fix the .mmd file and validate again
# Only proceed to export after validation passes
Common validation errors:
- Missing quotes around labels with special characters
- Wrong arrow syntax (use
->>for sequence,-->for flowchart) - Undeclared participants in sequence diagrams
A
Could not find Chrome(or puppeteer) error frommmdcis a setup problem, not a diagram error — the.mmdmay be perfectly valid. Validate via Kroki instead of "fixing" correct syntax.
Self-Check (vision)
Zero-cost pre-check: before spending a vision call, read the PNG dimensions (sips -g pixelWidth -g pixelHeight diagram.png on macOS, file diagram.png elsewhere). An extreme aspect ratio (longer side > 8x the shorter) is a "wrong orientation" defect — fix it without vision.
Validation (above) only proves the syntax is legal — it says nothing about whether the rendered diagram is readable. After exporting, use the agent's vision capability to read the PNG and catch what automatic layout can't prevent. Mermaid positions everything itself, so the failures here are about content and readability, not overlaps:
| Check | What to look for | Fix |
|---|---|---|
| Label truncation | Node / edge text clipped or cut off | Shorten the label, or wrap it with <br/> |
| Cramped, unreadable density | Too many nodes crammed together; tangled lines | Flip direction (TD↔LR), split into subgraphs, or reduce nodes |
| Wrong orientation / aspect | Diagram far too wide or too tall to read | Change flowchart TD↔LR (or set direction in class/state) |
| Edge spaghetti | Many edges crossing, hard to follow | Reorder node declarations so connected nodes sit adjacent; group with subgraph |
| Wrong diagram type | Type doesn't suit the content (e.g. flowchart for a timeline) | Switch type (gantt, sequenceDiagram, stateDiagram-v2, …) |
| Low contrast | Text blends into the node fill | Adjust classDef / theme so text contrasts the fill |
- Max 2 self-check rounds — if issues remain after 2 fixes, show the user anyway.
- Re-validate (syntax) and re-export after every fix.
- If vision is unavailable, skip self-check and show the PNG directly.
Review Loop
After self-check, show the exported image and collect feedback. Apply the minimal .mmd edit for each request, then re-validate and re-export:
| User request | Edit action |
|---|---|
| Change a label | Edit the node / edge text in the .mmd |
| Add / remove a node or edge | Add or delete the matching line |
| Change a color | Add / adjust a classDef and class <node> <className> |
| Change layout direction | Swap TD↔LR (flowchart) or set direction (class / state) |
| Restructure / group | Wrap related nodes in a subgraph, or regenerate |
- Overwrite the same
diagram.mmd/diagram.pngeach round — don't createv1,v2, … - Safety valve: after 5 rounds, generate a mermaid.live handoff link (see next section) so the user fine-tunes the current diagram in the browser.
Mermaid.live Handoff
When the review loop ends (approved or safety-valve), generate a one-click link that opens the current .mmd in the mermaid.live editor for interactive fine-tuning:
python3 scripts/mermaid_live_link.py diagram.mmd
# -> https://mermaid.live/edit#pako:...
Pure zlib + base64 (raw-deflate + URL-safe base64, same encoding mermaid.live uses), works offline. The script self-verifies with a round-trip decode before printing.
Batch Mode (Repo Survey)
When the user asks to diagram a whole repo ("survey this codebase", "map the architecture"):
- Scan — locate schemas (SQL / ORM models), API routes, and state machines / lifecycle enums in the codebase
- Propose — one diagram per finding: ER for the schema, sequence for a main API flow, state for a lifecycle, flowchart for overall service layout; confirm the set with the user before generating
- Generate + export — run the standard workflow per diagram into one output folder
- Overview page — inline every exported SVG into a single self-contained
index.html(title + one section per diagram, no CDN), so the user opens one file
Same validation and self-check rules apply to every diagram in the batch.
Diagram Types
| Type | Keyword | Use for |
|---|---|---|
| Flowchart | flowchart TD/LR | processes, pipelines, decisions |
| Sequence | sequenceDiagram | API calls, message passing |
| Class | classDiagram | OOP models, data structures |
| ER | erDiagram | database schemas |
| State | stateDiagram-v2 | state machines, lifecycle |
| Gantt | gantt | project timelines |
| Pie | pie | proportions |
| Git Graph | gitGraph | branch strategies |
| C4 Context | C4Context | high-level system context |
| Architecture | architecture-beta | cloud / CI/CD service layouts |
| Mind Map | mindmap | topic breakdowns |
| User Journey | journey | user-experience flows |
| Use Case | usecase-beta | actor–system interactions (UML) |
| Cynefin | cynefin-beta | sense-making / complexity domains |
| Event Modeling | eventmodeling | event-driven system timelines |
| Tree View | treeView-beta | file / directory hierarchies |
| Wardley Maps | wardley-beta | business strategy / value chains |
Syntax Reference
Flowchart: See reference/FLOWCHART.md Sequence: See reference/SEQUENCE.md Class & ER: See reference/CLASS-ER.md Architecture: See reference/ARCHITECTURE.md Use Case: See reference/USECASE.md Other types: See reference/OTHER-TYPES.md Themes & styling: See reference/THEMES.md
Examples
See reference/EXAMPLES.md for four worked examples (JWT auth sequence, microservices architecture, order state machine, cloud architecture) — each with the user prompt, the generated .mmd, and the output files.
Export Commands
Option 1: Local Export (mmdc)
Requires mmdc installed locally. Best for offline use.
# PNG (recommended: 2048px wide, white background)
mmdc -i diagram.mmd -o diagram.png -w 2048 --backgroundColor white
# PNG with theme — valid -t values: default | dark | neutral | forest
# (`base` is NOT a valid -t value; it only works inside a %%{init: {'theme':'base'}}%% directive)
mmdc -i diagram.mmd -o diagram.png -w 2048 --backgroundColor white --theme neutral
# SVG
mmdc -i diagram.mmd -o diagram.svg
# PDF
mmdc -i diagram.mmd -o diagram.pdf
Option 2: Kroki API (No Install Required)
Use Kroki when mmdc is not available. No local dependencies needed.
# SVG via Kroki
curl -X POST -H "Content-Type: text/plain" --data-binary @diagram.mmd https://kroki.io/mermaid/svg -o diagram.svg
# PNG via Kroki
curl -X POST -H "Content-Type: text/plain" --data-binary @diagram.mmd https://kroki.io/mermaid/png -o diagram.png
# PDF is NOT supported by Kroki for Mermaid — POSTing to /mermaid/pdf returns
# HTTP 400 ("Unsupported output format: pdf for mermaid. Must be one of png or svg").
# For PDF, use the local mmdc path instead: mmdc -i diagram.mmd -o diagram.pdf
Kroki advantages:
- No local installation required
- Works on any system with
curl - Supports 20+ diagram types (PlantUML, GraphViz, D2, etc.)
When to use Kroki:
mmdcinstallation fails- Quick one-off diagrams
- CI/CD pipelines without Node.js
Common Mistakes
| Mistake | Fix |
|---|---|
mmdc not found | npm install -g @mermaid-js/mermaid-cli |
mmdc error Could not find Chrome | Install the headless browser: npx puppeteer browsers install chrome-headless-shell (or use Kroki) |
| Kroki PDF fails with HTTP 400 | Kroki does PNG/SVG only for Mermaid; use local mmdc for PDF |
Valid diagram reported "invalid" by mmdc | The error is a Chrome/puppeteer setup failure, not a syntax error — don't rewrite correct .mmd; fix the browser or validate via Kroki |
| Wrong arrow in sequence | Use ->> for request, -->> for response |
| Special chars in label | Wrap in quotes: A["Label: value"] |
| Blank/small output | Add -w 2048 flag |
| Participant order wrong | Declare participant explicitly at top |
| Subgraph name with spaces | Wrap in quotes: subgraph "My Layer" |
FAQ
What does the mermaid-skill skill do?
Generate Mermaid diagrams (.mmd) and export to PNG/SVG/PDF using mmdc CLI or Kroki API. USE THIS SKILL when user mentions diagram, flowchart, sequence diagram, class diagram, ER diagram, state machine, architecture, visualize, git graph, 画图, 架构图, 流程图, 时序图, 类图, ER图, 甘特图, 状态机. PROACTIVELY USE when explaining ANY system with 3+ components, API flows, authentication sequences, class hierarchies, database schemas, or state machines. Supports 17+ diagram types with fully automatic layout.
How do I install mermaid-skill?
Run npx skills add https://github.com/agents365-ai/365-skills --skill mermaid-skill in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/mermaid-skill/ (personal) or .claude/skills/mermaid-skill/ (project).
Which AI agents can use mermaid-skill?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is mermaid-skill safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains mermaid-skill?
It is published by agents365-ai in agents365-ai/365-skills. It has 585 recorded installs.
More from agents365-ai/365-skills
drawio-skill
agents365-ai/365-skills
Create, edit, synchronize, inspect, test, and publish editable draw.io diagrams. Use when the user explicitly requests draw.io/diagrams.net, needs a polished architecture, ERD, UML, sequence, C4, SysML, BPMN, network, swimlane, ML, or infrastructure diagram, wants code/IaC/SQL/OpenAPI/AsyncAPI/Protobuf converted into a diagram, or wants an existing diagram queried, reviewed, diffed, restyled, kept in sync, or made interactive. Prefer Mermaid/PlantUML elsewhere when the requested artifact is diagrams-as-code rather than an editable draw.io file.
excalidraw
agents365-ai/365-skills
Use when user requests diagrams, flowcharts, architecture charts, or visualizations. Also use proactively when explaining systems with 3+ components, complex data flows, or relationships that benefit from visual representation. Generates .excalidraw files and exports to PNG/SVG via Kroki API or locally using excalidraw-brute-export-cli.
creating-mermaid-diagrams
agents365-ai/365-skills
Generate Mermaid diagrams (.mmd) and export to PNG/SVG/PDF using mmdc CLI or Kroki API. USE THIS SKILL when user mentions diagram, flowchart, sequence diagram, class diagram, ER diagram, state machine, architecture, visualize, git graph, 画图, 架构图, 流程图, 时序图. PROACTIVELY USE when explaining ANY system with 3+ components, API flows, authentication sequences, class hierarchies, database schemas, or state machines. Supports 11+ diagram types with fully automatic layout.
plantuml-skill
agents365-ai/365-skills
Use when user requests diagrams, flowcharts, sequence diagrams, class diagrams, component diagrams, ER diagrams, architecture charts, or visualizations — including generating a diagram from existing source code, or rendering/extracting PlantUML embedded in a Markdown file to images (e.g. preparing docs for Confluence/Notion). Also use proactively when explaining systems with 3+ components, APIs, data flows, or class hierarchies. Generates .puml files and exports to PNG/SVG via Kroki API (no local install required).
tldraw-skill
agents365-ai/365-skills
Use when user requests diagrams, flowcharts, architecture charts, or visualizations. Also use proactively when explaining systems with 3+ components, complex data flows, or relationships that benefit from visual representation. Generates .tldr JSON files and exports to PNG/SVG locally using @kitschpatrol/tldraw-cli.
paper-fetch
agents365-ai/365-skills
Use whenever the user wants to obtain, download, or fetch a paper's PDF — given a DOI, an arXiv id, a paper title, a citation, or a list of DOIs. Trigger on phrases like "download this paper", "find the PDF for [DOI]", "grab me the [Nature/bioRxiv/arXiv] paper on X", "get the open-access version", "I need this article", or any bulk/batch paper download request, even when the user doesn't explicitly say "PDF" or "DOI". Resolves via Unpaywall → Semantic Scholar → arXiv → PubMed Central → bioRxiv/medRxiv → publisher direct (institutional opt-in) → Sci-Hub mirrors as last-resort fallback.
Popular docs & writing skills
grill-with-docs
mattpocock/skills
A relentless interview to sharpen a plan or design, which also creates docs (ADR's and glossary) as we go.
lark-markdown
open.feishu.cn
飞书 Markdown:查看、创建、上传、编辑和比较飞书中的原生 Markdown 文件。当用户要操作飞书 Markdown 文件,或比较其远端版本及本地草稿时使用。纯本地 Markdown 文件操作不触发本 skill。不负责将 Markdown 导入为飞书在线文档,也不负责文件搜索、权限、评论、移动、删除等云空间管理操作。
writing-beats
mattpocock/skills
Writing, exploit; assemble raw material into a journey of beats, grounding each term before a beat leans on it.
writing-shape
mattpocock/skills
Writing, exploit: shape raw material into an article, paragraph by paragraph.
writing-fragments
mattpocock/skills
Writing, explore: mine raw fragments, no structure yet.
writing-for-agents
mattpocock/skills
Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.