/diagrams:mermaidfrom diagrams
Writes Mermaid diagrams that render across GitLab, GitHub, Linear, and IDE previews. Guides whether to draw, which diagram type to pick, and validates syntax through a subagent.
Ships in diagrams. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
A diagram in a plan, an MR description or a review comment is a sketch: selective, carrying one idea, thrown away when the work lands. It is not a specification of the system, and completeness is not the goal — "comprehensiveness is the enemy of comprehensibility" (Fowler).
The unit of work is a standalone .mmd file in the scratchpad, one diagram per file, with no code fence around it. Write it, validate it there, then hand the file content to whatever document needs it inside a mermaid code fence. Inlining is the calling command's last step, not this skill's.
Write text instead when the relationship is linear (a numbered list), there are fewer than about three nodes (a sentence), the content is a payload or a data structure (a code fence), the reader needs exact values such as timeouts or error codes (a table), or you cannot say in one sentence what the reader should conclude. A picture with no conclusion is decoration.
Draw when a flow crosses three or more components, an entity has a lifecycle with guarded transitions, the point is ordering — a race, a retry, a handshake — or a structure changes and the before/after difference is the finding.
flowchart — the path a request takes through components, a decision with branches. The default when nothing more specific fits.sequenceDiagram — who calls whom in what order, two to six participants. The only type that shows time.stateDiagram-v2 — one entity's lifecycle: order status, job state, a saga. Not a process with no return.erDiagram — tables and cardinality for a schema change. Not an object model.Secondary, when they clearly fit: classDiagram, gitGraph, timeline. Every type with -beta in its keyword, every C4* type and mindmap are opt-in only — use one when the user asks for it by name. references/diagram-types.md has the per-type "use when / do not use when / pitfalls" table, including the reasons the beta types are excluded.
neutral, or dark when the reader is in dark mode, and GitHub follows the reader's light/dark setting. A config: theme: line in the diagram overrides that choice, because theme is not one of mermaid's secure options, and the result is a light diagram on a dark page: the title and the sequence-diagram message labels are painted straight onto the transparent background and drop to about 1.3:1 contrast. Text inside a filled shape — node labels, notes, edge-label boxes, subgraph titles — carries its own background and survives either way. Write no config: block at all unless something genuinely needs one, and never theme.title: renders correctly as long as no theme is pinned, so it is a fallback, not the default.writes, invalidates, polls every 30s. An unlabeled arrow means "related somehow", which is worth nothing.[A-Za-z0-9 _-]. A["Cache (Redis)"], never A[Cache (Redis)]. This one rule prevents most parse errors.<br> for a line break, never <br/>. GitLab rewrites <br/>; GitHub does not.flowchart, not graph, and -->|label| for edge labels. %% starts a comment; a single % does not.classDef or styling on the first pass. GitHub applies its own theme to match the reader's light or dark setting, so colors are not yours to control there.->>+ and -->>- rather than bare activate / deactivate, so activation is balanced by construction — unbalanced activation is the most-failed dimension in the one published benchmark of LLM-generated sequence diagrams (MermaidSeqBench). Draw the error path, not only the happy path; missing failure branches is the second-most-failed dimension there.How it lands in the document — a heading, then the fence, and no frontmatter:
### Cart checkout
```mermaid
flowchart LR
%% one idea: where the reservation is written before payment
Client -->|POST /orders| API["Order API"]
API -->|reserves lines| Stock["Stock service (Redis)"]
API -->|publishes OrderPlaced| Bus{{Event bus}}
Bus -->|charges| Billing["Billing worker"]
```
references/pitfalls.md is the broken/fixed table. Read it when a render fails, not before.
GitLab auto-renders at most 2000 characters of mermaid per page, counted as a running total across every fence on the page, and at most 50 blocks. MR descriptions, MR comments, issues and epics are not exempt — only wikis, the repo landing README and the file view are. Over budget nothing errors: the diagram is replaced by a yellow "Displaying this diagram might cause performance issues on this page" warning with a Display button the reader has to click, which is worse than no diagram.
Keep each diagram under about 700 characters (wc -c <slug>.mmd) and put at most three on one page. GitHub documents no such limit. Linear renders mermaid natively since November 2025. Anywhere else — npm, PyPI, PDF export, most static site generators — the fence degrades to a plain code block, so the source should still read acceptably as text.
Check the renderer is there: command -v mmdc >/dev/null && mmdc --version || echo "mmdc missing". If it is missing, read references/install.md, propose the install to the user, and stop. Never ship an unvalidated diagram in silence. npx finding a cached copy does not count — the validator subagent runs mmdc, so mmdc is what has to be on PATH.
Write <scratchpad>/<slug>.mmd — bare mermaid source, no code fence, no surrounding markdown.
Spawn a validator subagent (model sonnet) and wait for it. Its prompt is exactly this, with the absolute path filled in:
First, invoke the diagrams:mermaid-validate skill to load its usage guidance before running any commands. Validate <absolute path>.mmd.
It reports the render status, then what it sees in the picture, then a verdict of "clear" or "confusing because …" with concrete suggestions.
Read the report. If the render failed, read references/pitfalls.md and fix the source from the reported error. If the picture is confusing, decide whether to change it — you own the diagram, and not every remark needs a change.
After a change, message the same validator subagent ("check again") instead of spawning a new one. It still holds the previous render and its own earlier remarks, so it can say what actually changed.
Done when the render passes and you accept the picture. Then hand the .mmd content to the document that needs it, wrapped in a mermaid code fence.
What SKILL.md sets; muted values are Claude Code's defaults
2 skills in this plugin
npx claudepluginhub fprochazka/claude-code-plugins --plugin diagramsOther plugins' skills for the same job