From superpowers
Validate mermaid diagram syntax after writing mermaid code blocks. Use this skill whenever you generate, write, or edit mermaid diagrams in markdown files — including flowcharts, sequence diagrams, class diagrams, state diagrams, ER diagrams, gantt charts, pie charts, mindmaps, gitgraph, and any other mermaid diagram type. Even if the diagram looks correct, always validate — subtle syntax errors silently break rendering. Trigger on any task that produces or modifies mermaid code blocks.
How this skill is triggered — by the user, by Claude, or both
Slash command
/superpowers:mermaid-validationThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Validate mermaid diagram syntax immediately after generating or modifying mermaid code blocks in markdown files, and auto-fix any issues found.
Validate mermaid diagram syntax immediately after generating or modifying mermaid code blocks in markdown files, and auto-fix any issues found.
Mermaid diagrams have strict syntax rules that are easy to get subtly wrong — missing semicolons, incorrect arrow syntax, unquoted labels with special characters, mismatched brackets in subgraphs. Invalid diagrams silently fail to render, leaving the user with a broken code block they have to debug themselves. Validating every diagram before delivering it catches these issues early.
After writing or editing any mermaid code block in a markdown file:
```mermaid and ``` fences, not the fences themselves)The script uses merval, a lightweight mermaid parser (~552KB, ~32ms). It auto-installs on first run to ~/.cache/claude-plugins/merval/.
Pipe raw mermaid content (without the fences) to stdin:
echo 'flowchart TD
A[Start] --> B[End]' | bash ${CLAUDE_PLUGIN_ROOT}/skills/mermaid-validation/scripts/validate-mermaid.sh
The script outputs JSON. The key fields to check are isValid and errors:
{
"isValid": false,
"diagramType": "flowchart",
"errors": [
{
"line": 2,
"column": 5,
"message": "Expected closing bracket ]",
"code": "PARSE_ERROR"
}
]
}
When the validator reports errors, use the line/column info and message to fix the issue in the original mermaid block, then re-validate. Common pitfalls:
(, ), [, ], {, } need quoting — e.g., A["Process (step 1)"]--> for flowcharts, ->> for sequence diagrams)flowchart TD, sequenceDiagram, classDiagram, etc.)subgraph needs a corresponding endnpx claudepluginhub asermax/claude-plugins --plugin superpowersCreates, validates, and troubleshoots Mermaid.js diagrams including flowcharts, sequence diagrams, class diagrams, ER diagrams, Gantt charts, and state diagrams via CLI tool.
Enforces syntax rules for Mermaid diagrams in documentation: quote labels with special chars, avoid <br/> and hardcoded colors, use themes. Validates via check-mermaid.sh.
Creates and validates Mermaid diagrams (flowcharts, sequences, states, ER) in markdown files with syntax checking.