Back to Skills

creating-mermaid-diagrams

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.

16stars3forksUpdated 6/29/2026

Security Assessment

Safe(100/100)
Security Score100/100

About creating-mermaid-diagrams

A skill for generating Mermaid diagrams as .mmd text files and exporting them to PNG, SVG, or PDF, using either the local mmdc CLI or the no-install Kroki API. Its core advantage is text-based syntax with fully automatic layout, so no x/y coordinates are needed. It is intended to be used whenever a user mentions a diagram, flowchart, sequence, class, ER, or state diagram, architecture, or visualization (including Chinese terms), and to be applied proactively when explaining any system with three or more components, API flows, authentication sequences, class hierarchies, database schemas, or state machines. More than eleven diagram types are supported, including flowchart, sequence, class, ER, state, Gantt, pie, git graph, C4 context, and mind map.

The workflow runs from an optional update check through choosing a diagram type, writing the .mmd file, validating, exporting, and reporting output paths. The update check is conservative: it notifies but does not pull, throttles to once per 24 hours via a .last_update file, never mutates the skill directory without explicit consent, and silently swallows failures in non-git or read-only installs. Validation is mandatory before export — a diagram is never exported without first validating it, either by rendering through mmdc or by posting to Kroki — and the doc lists common validation errors such as missing quotes around labels with special characters, wrong arrow syntax, and undeclared sequence-diagram participants.

Two export paths are documented. The local path installs @mermaid-js/mermaid-cli and runs mmdc with options for width, background color, and themes (default, dark, neutral, forest, base). The Kroki path needs only curl and posts the .mmd file to endpoints like https://kroki.io/mermaid/svg or /png, which is recommended when mmdc installation fails, for quick one-off diagrams, or in CI/CD pipelines without Node.js. The skill includes worked examples for a JWT authentication sequence, an e-commerce microservices architecture flowchart, and an order-lifecycle state machine, plus a common-mistakes table covering issues like mmdc not found, wrong sequence arrows, special characters in labels, blank or small output (fix with a wider width flag), participant ordering, and subgraph names containing spaces.

FAQ

Do I need to install anything to use this skill?

Not necessarily. You can install the local mmdc CLI (@mermaid-js/mermaid-cli) for offline use, or use the Kroki API which only requires curl and needs no local installation.

Which diagram types are supported?

Over eleven types, including flowchart, sequence, class, ER, state, Gantt, pie, git graph, C4 context, and mind map, all with fully automatic layout.

Is validation required before export?

Yes. A diagram is never exported without validating first, by rendering with mmdc or posting to Kroki. If validation fails, the .mmd file is fixed and re-validated before export.

When should I use Kroki instead of mmdc?

When mmdc installation fails, for quick one-off diagrams, or in CI/CD pipelines without Node.js. Kroki works on any system with curl and supports many diagram types.

Does the skill modify its own files when checking for updates?

No. The update check notifies but does not pull, throttles to once per 24 hours, never mutates the skill directory without explicit consent, and silently continues on any failure such as offline or read-only installs.

All Files

5 files
reference/CLASS-ER.md2.0 KB
View
reference/FLOWCHART.md1.5 KB
View
reference/OTHER-TYPES.md1.8 KB
View
SKILL.md7.3 KB
View
reference/SEQUENCE.md1.6 KB
View

Install creating-mermaid-diagrams

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill