skills/mermaid-diagrams/SKILL.md
Create and render Mermaid diagrams with correct syntax and the mmdc CLI. Use when the user asks to "create a diagram", "draw a flowchart", "make a sequence diagram", "render mermaid", "generate a chart", "visualize architecture", "create an ER diagram", mentions "mermaid", asks for any visual diagram (flowchart, sequence, class, state, ER, gantt, git graph, pie, mind map, timeline, quadrant, sankey, XY chart, block, packet, kanban, architecture, radar, treemap, C4, user journey, requirement diagram), or wants to render/export diagrams to SVG/PNG/PDF.
npx skillsauth add mgajewskik/opencode-config mermaid-diagramsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Create Mermaid diagrams with correct syntax and render them via mmdc CLI.
.mmd filemmdc# Write diagram
cat << 'EOF' > /tmp/diagram.mmd
flowchart TD
A[Start] --> B{Decision}
B -->|Yes| C[Do thing]
B -->|No| D[Skip]
C --> E[End]
D --> E
EOF
# Render
mmdc -i /tmp/diagram.mmd -o /tmp/diagram.svg
mmdc -i /tmp/diagram.mmd -o /tmp/diagram.png -b transparent
mmdc -i /tmp/diagram.mmd -o /tmp/diagram.png -t dark -b '#1a1a2e' -s 2
mmdc -i /tmp/diagram.mmd -o /tmp/diagram.pdf -f
| Flag | Description | Default |
|------|-------------|---------|
| -i, --input <file> | Input .mmd or .md file. - for stdin | Required |
| -o, --output [file] | Output file (.svg/.png/.pdf/.md). - for stdout | input.svg |
| -e, --outputFormat [format] | Force output format: svg, png, pdf | From extension |
| -t, --theme [theme] | Theme: default, forest, dark, neutral | default |
| -w, --width [px] | Page width | 800 |
| -H, --height [px] | Page height | 600 |
| -s, --scale [n] | Puppeteer scale factor (for PNG sharpness) | 1 |
| -b, --backgroundColor [color] | Background: transparent, #hex, named | white |
| -c, --configFile [file] | Mermaid JSON config file | none |
| -C, --cssFile [file] | Custom CSS file | none |
| -f, --pdfFit | Scale PDF to fit chart | false |
| -q, --quiet | Suppress log output | false |
| -p, --puppeteerConfigFile [file] | Puppeteer JSON config file | none |
| -I, --svgId [id] | The id attribute for SVG element | none |
| -a, --artefacts [path] | Output artefacts path (Markdown input only) | output dir |
| --iconPacks <icons...> | Iconify icon packs (e.g. @iconify-json/logos) | [] |
{
"theme": "dark",
"themeVariables": {
"primaryColor": "#BB2528",
"primaryTextColor": "#fff",
"lineColor": "#F8B229"
},
"flowchart": { "curve": "basis" }
}
If mmdc fails with sandbox errors:
echo '{"args":["--no-sandbox"]}' > /tmp/puppeteer-config.json
mmdc -i input.mmd -o output.svg -p /tmp/puppeteer-config.json
Before generating, consider:
-s 2 for docs/slides. PDF with -f for print.| Need | Diagram Type | Declaration |
|------|-------------|-------------|
| Process flow, decisions | Flowchart | flowchart TD |
| API calls, actor interactions | Sequence | sequenceDiagram |
| OOP design, domain models | Class | classDiagram |
| State machines, workflows | State | stateDiagram-v2 |
| Database schema | ER | erDiagram |
| Project timeline, scheduling | Gantt | gantt |
| Branch strategy | Git Graph | gitGraph or gitGraph TB: |
| Data distribution | Pie | pie or pie showData |
| Topic hierarchy, brainstorm | Mind Map | mindmap |
| UX flow with satisfaction | User Journey | journey |
| Priority matrix, 2-axis plot | Quadrant | quadrantChart |
| Requirements traceability | Requirement | requirementDiagram |
| Historical events | Timeline | timeline |
| Flow quantities between nodes | Sankey | sankey-beta |
| Bar/line charts | XY Chart | xychart-beta |
| Grid layouts, dashboards | Block | block-beta |
| Network protocol headers | Packet | packet-beta |
| Task boards | Kanban | kanban |
| Infrastructure topology | Architecture | architecture-beta |
| Multi-dimensional comparison | Radar | radar-beta |
| Hierarchical proportions | Treemap | treemap-beta |
| Software architecture (C4) | C4 | C4Context, C4Container, C4Component |
| Alternative sequence syntax | ZenUML | zenuml |
flowchart TD
A[Rectangle] --> B(Rounded)
B --> C{Diamond}
C -->|Yes| D[Result]
C -->|No| E[Other]
subgraph Group
D --> F((Circle))
end
Directions: TD/TB, BT, LR, RL
Node shapes: [rect], (rounded), {diamond}, ((circle)), ([stadium]), [[subroutine]], [(cylinder)], {{hexagon}}, [/parallelogram/], [/trapezoid\], (((double circle)))
Edges:
--> solid arrow, --- solid no arrow-.-> dotted arrow, ==> thick arrow--x cross end, --o circle end<--> bidirectional-->|label| or -- label -->--->, ---->Styling:
style nodeId fill:#f9f,stroke:#333,stroke-width:4px
classDef highlight fill:#f96,stroke:#333
A:::highlight
linkStyle 0 stroke:#ff3,stroke-width:4px
sequenceDiagram
actor User
participant API
participant DB
User ->>+ API: POST /login
API ->> DB: Query user
DB -->> API: User record
alt Valid credentials
API -->>- User: 200 JWT token
else Invalid
API -->> User: 401 Unauthorized
end
Messages: ->> solid arrow, -->> dotted arrow, -x cross, -) async open arrow, <<->> bidirectional
Activations: ->>+ activate, -->>- deactivate
Notes: Note right of A: text, Note over A,B: text
Control flow: loop, alt/else, opt, par/and, critical/option, break, rect rgb() (highlight)
Boxes: box Title ... end to group participants
classDiagram
class Animal {
+String name
+int age
+makeSound()* void
+sleep() void
}
class Dog {
+fetch() void
}
Animal <|-- Dog
Animal "1" --> "*" Food : eats
Visibility: + public, - private, # protected, ~ package
Classifiers: * abstract, $ static
Relationships: <|-- inheritance, *-- composition, o-- aggregation, --> association, ..> dependency, ..|> realization
Cardinality: "1", "0..1", "1..*", "*"
Annotations: <<Interface>>, <<Abstract>>, <<Enumeration>>
stateDiagram-v2
[*] --> Idle
Idle --> Processing : submit
Processing --> Success : valid
Processing --> Error : invalid
Error --> Idle : retry
Success --> [*]
state Processing {
[*] --> Validating
Validating --> Saving
Saving --> [*]
}
Special states: [*] start/end, <<choice>>, <<fork>>, <<join>>
Concurrency: -- separator inside composite state
erDiagram
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ LINE_ITEM : contains
PRODUCT }|..|{ ORDER : "ordered in"
CUSTOMER {
string name PK
string email UK
int age
}
ORDER {
int id PK
date created
int customer_id FK
}
Cardinality: || exactly one, o| zero or one, }| one or more, o{ zero or more
Line type: -- identifying (solid), .. non-identifying (dashed)
Attribute keys: PK, FK, UK (combinable: PK, FK)
gantt
title Project Plan
dateFormat YYYY-MM-DD
excludes weekends
section Phase 1
Research :done, a1, 2024-01-01, 10d
Design :active, a2, after a1, 15d
section Phase 2
Build :crit, a3, after a2, 30d
Test :a4, after a3, 15d
Launch :milestone, after a4, 0d
Task tags: done, active, crit, milestone (combinable)
Duration: 10d, 5h, 2w. Dependencies: after taskId
gitGraph
commit
commit
branch develop
checkout develop
commit
commit
checkout main
merge develop tag: "v1.0"
commit
Commands: commit (optional: id:, type: NORMAL|REVERSE|HIGHLIGHT, tag:), branch name, checkout name, merge name, cherry-pick id:
mindmap
root((Project))
Frontend
React
TypeScript
Backend
Go
PostgreSQL
Infrastructure
Kubernetes
Terraform
Indentation-based. Shapes: [square], (rounded), ((circle)), ))bang((, )cloud(, {{hexagon}}
graph without a direction — always flowchart TD or graph LRstateDiagram — use stateDiagram-v2end as a node ID — it breaks the parser. Use End or finish or wrap in quotes"ordered in"0 as a score in user journey — range is 1–5%%{init:}%% directives in new code — use frontmatter ---\nconfig:\n--- insteadradar-beta without defining axes first — axes are requiredo or x without space — A---oB creates circle edge, use A--- oBcreate or destroy in sequence diagrams without proper message flowFor diagram types beyond the quick syntax above (Sankey, XY Chart, Block, Packet, Kanban, Architecture, User Journey, Quadrant, Requirement, Timeline), or for advanced features (v11+ shapes, edge animations, theming variables, icon/image nodes):
MANDATORY: Read references/syntax-reference.md before generating these diagram types.
documentation
Create senior-level deep research dossiers and roadmap companions. Use when the user asks for a dossier, senior research, deep research, in-depth research, mental models for a topic, senior perspective on a topic, how something actually works, ramp up on a topic, architectural deep dive, tradeoffs, failure modes, or what a senior would notice. Produces current-directory research-* and roadmap-* markdown artifacts, not a tutorial or short summary.
development
Senior-level Knative and OpenShift Serverless guidance for Serving, Eventing, Functions, autoscaling, scale-to-zero, CloudEvents, RabbitMQ/Kafka sources, Lambda migration, Harbor/OCI images, debugging, operations, and production rollout. Use when working with Knative Service, Revision, Route, KPA, activator, queue-proxy, Broker, Trigger, Source, Sink, kn func, OpenShift Serverless, Kourier, eventing-rabbitmq, Knative Kafka, or serverless workloads on Kubernetes/OpenShift.
development
Senior-level RHEL-family Linux operations. Use when running, debugging, hardening, patching, installing, upgrading, or operating Red Hat Enterprise Linux, Rocky Linux, AlmaLinux, CentOS Stream, Fedora-as-upstream, or related enterprise Linux hosts: systemd, RPM/DNF, SELinux, NetworkManager, firewalld, storage, kernel/kdump, FIPS/STIG, Satellite, IdM, Podman, bootc, air-gapped fleets.
development
Senior-level Proxmox VE guidance for VM creation, templates, storage, ZFS, Ceph, networking, clusters, HA, PBS backups, debugging, upgrades, security, and production/homelab operations. Use when working with Proxmox, PVE, Proxmox VE, qm, pct, pvesm, pvecm, pmxcfs, HA manager, Proxmox Backup Server, VM migration, Proxmox incidents, or Ceph/ZFS/Corosync/VLAN bridges in a Proxmox VE context.