Loading...
Loading...
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.
npx skill4agent add agents365-ai/365-skills creating-mermaid-diagrams.mmdmmdcnpm install -g @mermaid-js/mermaid-cli
mmdc --versioncurl --version # Just need curl<this-skill-dir>/.last_update.last_updategit -C <this-skill-dir> ls-remote --tags origin 'v*' 2>/dev/null \
| awk '{print $2}' | sed 's|refs/tags/||' | sort -V | tail -1metadata.version"A newer version of this skill is available: vX.Y.Z → vA.B.C. Want me to?"git pull
git -C <this-skill-dir> pull --ff-only.last_update.last_updatemmdc --version.mmdmmdc# 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->>-->| Type | Keyword | Use for |
|---|---|---|
| Flowchart | | processes, pipelines, decisions |
| Sequence | | API calls, message passing |
| Class | | OOP models, data structures |
| ER | | database schemas |
| State | | state machines, lifecycle |
| Gantt | | project timelines |
| Pie | | proportions |
| Git Graph | | branch strategies |
| C4 Context | | high-level architecture |
| Mind Map | | topic breakdowns |
Create a sequence diagram for JWT authentication
.mmdsequenceDiagram
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..."}auth-flow.mmdauth-flow.pngDraw an e-commerce microservices architecture
.mmdflowchart 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 --> REDISecommerce-arch.mmdecommerce-arch.pngShow order lifecycle states
.mmdstateDiagram-v2
[*] --> Pending : order created
Pending --> Confirmed : payment success
Pending --> Cancelled : timeout/cancel
Confirmed --> Shipped : dispatched
Shipped --> Delivered : received
Delivered --> [*]
Cancelled --> [*]order-states.mmdorder-states.pngmmdc# 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.pdfmmdc# 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.pdfcurlmmdc| Mistake | Fix |
|---|---|
| |
| Wrong arrow in sequence | Use |
| Special chars in label | Wrap in quotes: |
| Blank/small output | Add |
| Participant order wrong | Declare |
| Subgraph name with spaces | Wrap in quotes: |