creating-mermaid-diagrams
agents365-ai/365-skills
Generate Mermaid diagrams (.mmd) and export to PNG/SVG/PDF with automatic layout.
What is creating-mermaid-diagrams?
Creates text-based Mermaid diagrams (flowcharts, sequence, class, ER, state machines, and 6+ other types) and exports them to PNG/SVG/PDF using either local mmdc CLI or the Kroki API. Use this when visualizing system architecture, API flows, database schemas, state machines, or any multi-component system.
- Generate 11+ diagram types: flowchart, sequence, class, ER, state machine, Gantt, pie, git graph, C4 context, and mind map
- Export to PNG, SVG, or PDF with configurable width and themes
- Validate diagrams before export to catch syntax errors early
- Support both local mmdc CLI and Kroki API (no install required)
- Automatic layout—no manual x/y coordinates needed
- Handle special characters and complex labels with proper quoting
How to install creating-mermaid-diagrams
npx skills add https://github.com/agents365-ai/365-skills --skill creating-mermaid-diagrams- Option A (local): npm install -g @mermaid-js/mermaid-cli
- Option B (Kroki API): curl (usually pre-installed)
How to use creating-mermaid-diagrams
- 1.Choose a diagram type from the supported list (flowchart, sequence, class, ER, state, etc.)
- 2.Write the diagram syntax in a .mmd text file using Mermaid syntax
- 3.Validate the diagram using mmdc or Kroki before export
- 4.Export to PNG/SVG/PDF using either mmdc CLI or Kroki API
- 5.Retrieve the generated output file from the specified path
Use cases
- Visualize JWT authentication flows and API message sequences between services
- Document microservices architecture with multiple components and databases
- Model order lifecycle or state machine transitions
- Create database schema diagrams (ER models)
- Generate project timelines and Gantt charts
- Backend engineers designing system architecture
- API developers documenting authentication and service flows
- Database designers creating schema diagrams
- Project managers planning timelines
- Technical writers explaining complex systems
creating-mermaid-diagrams FAQ
No. If mmdc is unavailable, the skill automatically falls back to Kroki API, which only requires curl.
11+ types: flowchart, sequence, class, ER, state machine, Gantt, pie, git graph, C4 context, mind map, and others. See the diagram types table in the skill documentation.
Validation catches syntax errors (wrong arrow syntax, missing quotes, undeclared participants) early, preventing invalid or blank output files.
Yes. mmdc supports width, background color, and themes (default, dark, neutral, forest, base). Kroki also supports these options via API parameters.
Wrap labels in quotes: A["Label: value"] to properly escape special characters and spaces.
Full instructions (SKILL.md)
Source of truth, from agents365-ai/365-skills.
name: creating-mermaid-diagrams description: 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. homepage: https://github.com/Agents365-ai/creating-mermaid-diagrams metadata: {"openclaw":{"requires":{"bins":["curl"]},"emoji":"📊"}}
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.
Prerequisites
Option A: Local (mmdc)
npm install -g @mermaid-js/mermaid-cli
mmdc --version
Option B: Kroki API (no install)
curl --version # Just need curl
Workflow
-
Update check (notify, don't pull) — first use per conversation. Throttle to once per 24 h via
<this-skill-dir>/.last_update; never mutate the skill directory without explicit user consent.-
If
.last_updateexists and is <24 h old, skip this step entirely. -
Otherwise, fetch the latest tag from upstream:
git -C <this-skill-dir> ls-remote --tags origin 'v*' 2>/dev/null \ | awk '{print $2}' | sed 's|refs/tags/||' | sort -V | tail -1 -
Compare with this skill's
metadata.versionfrom the frontmatter. If the upstream tag is strictly newer (semver), tell the user one line and ask:"A newer version of this skill is available: vX.Y.Z → vA.B.C. Want me to
git pull?"If they say yes, run
git -C <this-skill-dir> pull --ff-only. Refresh.last_updateeither way so the prompt doesn't repeat for 24 hours. -
If upstream is the same or older, refresh
.last_updatesilently and continue. -
On any failure (offline, not a git checkout — e.g. ClawHub-installed copy, read-only path, no permission), swallow the error silently and continue with the user's task. Do not mention the failure.
-
-
Check deps — try
mmdc --version, fallback to Kroki if unavailable -
Pick diagram type — choose from table below
-
Generate — write
.mmdfile to disk -
Validate — run validation (REQUIRED before export)
-
Export — use
mmdcor Kroki API to produce PNG/SVG/PDF -
Report — tell user the output file paths
Validation (Required)
NEVER export a diagram without validating first.
# Validate with mmdc (local)
mmdc -i diagram.mmd -o /tmp/test.png 2>&1
# Validate with Kroki (if mmdc unavailable)
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"
# 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
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 architecture |
| Mind Map | mindmap | topic breakdowns |
Syntax Reference
Flowchart: See reference/FLOWCHART.md Sequence: See reference/SEQUENCE.md Class & ER: See reference/CLASS-ER.md Other types: See reference/OTHER-TYPES.md
Examples
Example 1: API Authentication Flow
User prompt:
Create a sequence diagram for JWT authentication
Generated .mmd:
sequenceDiagram
participant C as Client
participant G as API Gateway
participant A as Auth Service
participant D as Database
C->>G: POST /login {email, password}
G->>A: validate(credentials)
A->>D: SELECT user WHERE email=?
D-->>A: user record
A-->>A: verify password hash
A-->>G: 200 OK + JWT token
G-->>C: {token: "eyJhbG..."}
Output files: auth-flow.mmd + auth-flow.png
Example 2: Microservices Architecture
User prompt:
Draw an e-commerce microservices architecture
Generated .mmd:
flowchart TD
subgraph Clients
M[Mobile App]
W[Web App]
end
GW[API Gateway]
subgraph Services
US[User Service]
OS[Order Service]
PS[Product Service]
PAY[Payment Service]
end
subgraph Data
UDB[(User DB)]
ODB[(Order DB)]
PDB[(Product DB)]
REDIS[(Redis Cache)]
end
M & W --> GW
GW --> US & OS & PS & PAY
US --> UDB
OS --> ODB
PS --> PDB
PAY --> REDIS
Output files: ecommerce-arch.mmd + ecommerce-arch.png
Example 3: Order State Machine
User prompt:
Show order lifecycle states
Generated .mmd:
stateDiagram-v2
[*] --> Pending : order created
Pending --> Confirmed : payment success
Pending --> Cancelled : timeout/cancel
Confirmed --> Shipped : dispatched
Shipped --> Delivered : received
Delivered --> [*]
Cancelled --> [*]
Output files: order-states.mmd + order-states.png
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 (default | dark | neutral | forest | base)
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 via Kroki
curl -X POST -H "Content-Type: text/plain" --data-binary @diagram.mmd https://kroki.io/mermaid/pdf -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 |
| 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" |
Related skills
More from agents365-ai/365-skills and the wider catalog.

drawio-skill
Generate polished diagrams, flowcharts, and architecture visualizations as editable PNG/SVG/PDF/JPG using draw.io desktop CLI.

excalidraw
Generate hand-drawn style diagrams, flowcharts, and architecture visualizations as .excalidraw files with PNG/SVG export.

plantuml-skill
Generate PlantUML diagrams (sequence, class, component, ER, architecture) and export to PNG/SVG via Kroki API—no local install required.

tldraw-skill
Generate hand-drawn whiteboard-style diagrams as .tldr JSON, export to PNG/SVG locally.

semanticscholar-skill
Search academic papers, citations, and authors via Semantic Scholar API with structured workflows.

paper-fetch
Fetch PDFs for papers via DOI, arXiv ID, title, or batch—trying Unpaywall, Semantic Scholar, arXiv, PMC, bioRxiv, and Sci-Hub.