Expert knowledge for creating print-ready Mermaid diagrams -- syntax, styling, theming, and print optimization. Use when generating or reviewing any Mermaid diagram.
From cortex-engineeringnpx claudepluginhub nathanvale/side-quest-marketplace --plugin cortex-engineeringThis skill uses the workspace's default tool permissions.
references/blueprint-theme.jsonreferences/config-engineering.mdreferences/default-theme.jsonreferences/default-theme.mdreferences/pdf-print-fix.cssreferences/print-optimization.mdreferences/sketch-theme.jsonreferences/styling-patterns.mdreferences/syntax-reference.mdGuides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
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.
Orchestrates phased implementation plans with subagent documentation discovery, verification checklists, and anti-pattern guards for features or tasks.
Background knowledge for producing clean, readable, print-ready Mermaid diagrams. This skill provides the craft -- the visualize skill provides the workflow.
Scope: Mermaid is the engine for all non-mind-map diagram types. Mind maps auto-route to Markmap via the visualize skill. Users can override to Mermaid for mind maps if they prefer themed presets over Markmap's visual quality.
Curated visual identity: All diagrams use one of three preset configs. Each preset pairs a theme, look mode, and layout engine. See default-theme.md for the full specification.
Minimal correct diagram (Classic preset, the default):
flowchart LR
classDef primary fill:#0072B2,color:#fff,stroke:#005a8c,stroke-width:2px
classDef success fill:#009E73,color:#fff,stroke:#006B4F,stroke-width:2px
classDef warning fill:#E69F00,color:#000,stroke:#B37A00,stroke-width:2px
A[Input]:::primary --> B{Valid?}:::warning
B -->|Yes| C[Process]:::primary
B -->|No| D[Error]:::warning
C --> E[Done]:::success
Export with Classic preset (default):
bunx @mermaid-js/mermaid-cli -i input.mmd -o output.svg \
-c "$CLAUDE_PLUGIN_ROOT/skills/mermaid-diagrams/references/default-theme.json" \
-b white
Non-negotiable rules for every diagram:
classDef, not inline styles. Keeps diagrams consistent and maintainable.-c flag for all visualize-skill output. Never put %%{init:}%% directives in generated diagrams -- the config file handles theming. Three presets: default-theme.json (Classic), sketch-theme.json (Sketch), blueprint-theme.json (Blueprint).Pick the right diagram for the job. Default to the simplest type that communicates the idea.
| Diagram | Keyword | Best for |
|---|---|---|
| Flowchart | flowchart TD | Processes, workflows, decision trees |
| Sequence | sequenceDiagram | Interactions between components/actors over time |
| Mind map | mindmap | Brainstorms, topic exploration, hierarchical ideas |
| Class | classDiagram | Object models, type hierarchies, interfaces |
| State | stateDiagram-v2 | Lifecycles, state machines, status transitions |
| ER | erDiagram | Data models, database schemas, entity relationships |
| Gantt | gantt | Timelines, project schedules, phased plans |
| Pie | pie | Proportions, distributions, simple breakdowns |
| Timeline | timeline | Chronological events, history, roadmaps |
| Architecture | architecture-beta | System components and their connections |
| Block | block-beta | Generic block diagrams, layout-driven visuals |
| Quadrant | quadrantChart | 2x2 matrices, priority/effort grids |
| Sankey | sankey-beta | Flow volumes, resource distribution |
| XY chart | xychart-beta | Line/bar charts with axes |
| Treemap | treemap-beta | Hierarchical data as nested rectangles |
| Kanban | kanban | Board-style task tracking |
| Packet | packet-beta | Network packet structures |
| Requirement | requirementDiagram | Requirements traceability |
| Radar | radar-beta | Multi-axis comparison (v11.6.0+) |
| Git graph | gitGraph | Branch/commit visualization |
| C4 Context | C4Context | System context (C4 model) |
Decision heuristic: If you're unsure, start with flowchart TD. It handles 70% of use cases. Upgrade to a specialized type only when the data demands it.
<br/> over backtick markdown-string syntax for line breaks -- backtick labels cause dagre layout cramping with 10+ nodes.| Direction | Code | When to use |
|---|---|---|
| Top-down | TD or TB | Hierarchies, org charts, inheritance |
| Left-right | LR | Pipelines, sequences, timelines |
| Right-left | RL | Reverse flows, rollback processes |
| Bottom-up | BT | Dependency trees (leaf to root) |
Use subgraph to visually cluster related nodes. Label every subgraph. Keep nesting to 2 levels max -- deeper nesting kills readability at print scale.
subgraph "API Layer"
A[REST Controller] --> B[Service]
B --> C[Repository]
end
Label every edge that isn't self-explanatory. Use -->|label| syntax. Keep labels to 1-3 words.
Place at the top of any diagram to configure theme and variables:
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A --> B
| Theme | Use for |
|---|---|
base | Default choice. Blank slate with custom themeVariables. Used by default-theme.json. |
neutral | Black on white, high contrast, no colored fills. Good for B&W printing. |
default | Screen viewing. Mermaid's standard blue palette |
dark | Dark backgrounds. Inverted colors |
forest | Green palette. Good for environmental/organic topics |
Use base with default-theme.json for all visualize skill output. The neutral theme silently ignores themeVariables (GitHub #4264), so base is the only option for custom palettes.
Override specific colors via themeVariables in the init directive:
%%{init: {'theme': 'base', 'themeVariables': {
'primaryColor': '#4a90d9',
'primaryTextColor': '#ffffff',
'primaryBorderColor': '#2c5f8a',
'lineColor': '#333333',
'secondaryColor': '#f0f4f8',
'tertiaryColor': '#e8e8e8',
'fontSize': '16px'
}}}%%
Important: Mermaid only recognizes hex colors (#4a90d9), not color names (blue).
Flowcharts support many shapes. Use them semantically:
| Shape | Syntax | Semantic meaning |
|---|---|---|
| Rectangle | [text] | Process, action, step |
| Rounded | (text) | Start/end, terminal |
| Stadium | ([text]) | Start/end (alternative) |
| Diamond | {text} | Decision, condition |
| Hexagon | {{text}} | Preparation, setup |
| Circle | ((text)) | Connector, junction |
| Cylinder | [(text)] | Database, data store |
| Parallelogram | [/text/] | Input/output |
| Subroutine | [[text]] | Predefined process, function call |
| Trapezoid | [/text\] | Manual operation |
| Double circle | (((text))) | Double-click event, emphasis |
Rule of thumb: Use max 3 different shapes per diagram. More than that and the visual language becomes noise.
When color is needed on print diagrams, use this accessible palette. Based on the Wong palette (Nature Methods, 2011) -- the standard for colorblind-safe scientific visualization. All colors maintain WCAG AA contrast against white.
| Role | Hex | classDef name | Usage |
|---|---|---|---|
| Primary | #0072B2 | primary | Main nodes, primary flow |
| Info | #56B4E9 | info | Information, notes |
| Success | #009E73 | success | Success states, completed |
| Warning | #E69F00 | warning | Warnings, decision points (dark text) |
| Danger | #D55E00 | danger | Error states, failures |
| Highlight | #F0E442 | highlight | Emphasis, callouts |
| Accent | #CC79A7 | accent | Tertiary accent |
The full classDef block is in default-theme.md. Apply with ::::
classDef primary fill:#0072B2,color:#fff,stroke:#005a8c
classDef secondary fill:#009E73,color:#fff,stroke:#007a5a
classDef accent fill:#E69F00,color:#000,stroke:#b87d00
A[Start]:::primary --> B{Check}:::accent
B -->|Pass| C[Done]:::secondary
These minimums ensure readability at 1-2 meters viewing distance on A3/A2 paper:
| Element | Minimum |
|---|---|
| Node labels | 14pt |
| Edge labels | 12pt |
| Subgraph titles | 16pt |
| Root/title nodes | 18pt |
Set via init directive:
%%{init: {'theme': 'base', 'themeVariables': {'fontSize': '16px'}}}%%
The @mermaid-js/mermaid-cli (mmdc) is the primary export path. Use with -c <preset>-theme.json for the curated visual identity. The MCP server's export_diagram_formats produces placeholder files -- do not use it for export.
bunx @mermaid-js/mermaid-cli -i input.mmd -o output.svg \
-c "$CLAUDE_PLUGIN_ROOT/skills/mermaid-diagrams/references/default-theme.json" \
-b white
| Flag | Purpose | Default |
|---|---|---|
-i | Input file | (required) |
-o | Output file (.svg, .pdf, .png) | (required) |
-t | Theme | default |
-b | Background color | white |
-w | Width in pixels | 800 |
-H | Height in pixels | auto |
--scale | Scale factor | 1 |
-c | Config JSON file | none |
# A4 landscape SVG (default)
bunx @mermaid-js/mermaid-cli -i input.mmd -o diagram.svg \
-c "$CLAUDE_PLUGIN_ROOT/skills/mermaid-diagrams/references/default-theme.json" \
-b white -w 3508 -H 2480
# A3 landscape SVG (wall poster)
bunx @mermaid-js/mermaid-cli -i input.mmd -o diagram.svg \
-c "$CLAUDE_PLUGIN_ROOT/skills/mermaid-diagrams/references/default-theme.json" \
-b white -w 4961 -H 3508
# PDF for direct printing (add --pdfFit)
bunx @mermaid-js/mermaid-cli -i input.mmd -o diagram.pdf \
-c "$CLAUDE_PLUGIN_ROOT/skills/mermaid-diagrams/references/default-theme.json" \
-b white -w 3508 -H 2480 --pdfFit
A4 landscape = 3508 x 2480px at 300 DPI. A3 landscape = 4961 x 3508px.
Verify before finalizing any diagram:
<br/> (not backtick syntax)%%{init:}%% in visualize-skill output| Don't | Do instead |
|---|---|
| 20+ nodes in one diagram | Split into 2-3 focused diagrams |
| Crossing edges everywhere | Restructure node order to minimize crossings |
| Rainbow colors | Max 3-4 colors with semantic meaning |
Tiny text with fontSize: '10px' | Minimum 14pt for nodes, 12pt for edges |
| Unlabeled edges | Label every non-obvious connection |
| Deep subgraph nesting (3+) | Flatten to max 2 levels |
| Color as only differentiator | Combine color with shape or label prefix |
default theme for print | Use neutral -- saves ink, better contrast |
| Inline styles on every node | Use classDef for consistent, reusable styles |
| Giant node labels | 30 chars max, use abbreviations + legend |
| Backtick markdown-string labels | <br/> for line breaks (dagre calculates width correctly) |
The diagram is complete when every item in the Quality Checklist above passes and the exported file (SVG/PDF/PNG) renders correctly at the target paper size.
For comprehensive details, see:
-c)