Help us improve
Share bugs, ideas, or general feedback.
From mermaid-preview
Authoring guidelines for Mermaid diagrams in Claude-generated markdown. Triggers when writing, fixing, or validating mermaid charts; choosing between mermaid and ASCII graphs; embedding diagrams in docs, READMEs, or design notes. Covers validation via mcp__mermaider__validate_syntax, fencing conventions, preview pipeline, and iterate-until-clean discipline.
npx claudepluginhub xiaolai/claude-plugin-marketplace --plugin mermaid-previewHow this skill is triggered — by the user, by Claude, or both
Slash command
/mermaid-preview:mermaid-chartsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Apply these rules whenever producing Mermaid diagrams.
Guides Next.js Cache Components and Partial Prerendering (PPR): 'use cache' directives, cacheLife(), cacheTag(), revalidateTag() for caching, invalidation, static/dynamic optimization. Auto-activates on cacheComponents: true.
Migrates code, prompts, and API calls from Claude Sonnet 4.0/4.5 or Opus 4.1 to Opus 4.5, updating model strings on Anthropic, AWS, GCP, Azure platforms.
Breaks plans, specs, or PRDs into thin vertical-slice issues on the project issue tracker using tracer bullets. Useful for converting high-level work into grabbable implementation tickets.
Share bugs, ideas, or general feedback.
Apply these rules whenever producing Mermaid diagrams.
mcp__mermaider__validate_syntax MCP tool before writing it to any file or presenting it inline.mermaid info string: ```mermaid.mermaid-preview hook (PostToolUse, on Write|Edit|MultiEdit|NotebookEdit) detects these fences in files with extensions .md|.mmd|.mdx|.markdown|.ipynb and renders a live browser preview.~/.claude/previews/scratch-*.md.\n is NOT a line break. Mermaid renders \n as the two literal characters \ and n. Never emit \n inside a node, edge, or subgraph label. This is the single most common mermaid authoring mistake.<br/> (or <br>): A["Line one<br/>Line two"].", <, >, (, ), {, }, [, ], &, |, #, :), wrap the whole label in double quotes: B["risky: a<b & c>d"]. Unquoted labels break the parser on these.A -- "deliberate dose" --> B or the pipe form A -->|"deliberate dose"| B.Wrong (renders \n as literal characters):
A[Doctor's office\n— hold the needle —]
Right (renders as two lines):
A["Doctor's office<br/>— hold the needle —"]
prefers-color-scheme.~/.claude/previews/preview.log; LRU retention keeps the newest 20 previews.securityLevel: 'loose'The preview initialises Mermaid with securityLevel: 'loose' so common label markup (<br/>, <b>, etc.) renders. This is safe because the pipeline is strictly local — the script tag is inlined from a vendored bundle, never fetched at runtime.
```mermaid
flowchart LR
A["Doctor's office<br/>— hold the needle —"] -->|deliberate dose| B["Threat met<br/>at low strength"]
B --> C["Pattern built"]
C --> D["Full challenge arrives<br/>body is ready"]
```
Key habits visible above: double-quoted labels, <br/> (not \n) for line breaks, quoted edge label with spaces.
Call the MCP tool with the raw diagram body (no fence lines). Empty response = valid; any non-empty response is an error that must be fixed before writing.
mcp__mermaider__validate_syntax({
"diagram_code": "flowchart LR\n A --> B\n B --> C"
})
Iterate: if the response lists an error, adjust the diagram and re-invoke until the response is empty.
If a chart is not destined for a durable document, still write it to a file so the preview hook fires:
scratch=~/.claude/previews/scratch-$(date -u +%Y%m%dT%H%M%S).md
printf '%s\n' '```mermaid' 'flowchart LR' ' A --> B' '```' > "$scratch"
mermaid-preview plugin — PostToolUse hook + vendored Mermaid bundle at vendor/mermaid.min.js.mcp__mermaider__validate_syntax — the validator MCP tool used in the workflow above.~/.claude/previews/preview-<slug>.html; hook log: ~/.claude/previews/preview.log.