name: mermaid-coding-standard description: > Enforce Mermaid diagram coding standards. Use this skill when the user explicitly calls mermaid-coding-standard, or when the task asks to create, edit, review, explain, or output Mermaid code, including flowcharts, sequence diagrams, class diagrams, state diagrams, ER diagrams, architecture diagrams, or any Markdown document containing Mermaid fenced code blocks. Whenever the model determines that it needs to generate Mermaid syntax, it should automatically load this skill even if the user did not mention it.
Mermaid Coding Standard
Use this skill whenever you need to generate or modify Mermaid code. The goal is to produce Mermaid diagrams that are easy to read, stable in diffs, and compatible across common Markdown renderers.
Triggering
This skill has two entry points:
- The user explicitly calls
mermaid-coding-standard. - The model automatically determines that the current task requires generating, modifying, or returning Mermaid code.
Load this skill whenever the response will contain a Mermaid fenced code block, or whenever the task requires Mermaid syntax that can be pasted into Markdown. This includes requirements documents, architecture explanations, flowcharts, sequence diagrams, class diagrams, state diagrams, ER diagrams, and any scenario that uses Mermaid to express logical relationships.
Output Formatting
- Put every Mermaid diagram inside a fenced code block with the
mermaidlanguage tag. - Keep one Mermaid statement per line.
- Use blank lines to separate logical groups in large diagrams.
- Do not use
\ninside Mermaid labels; use<br>when a label needs a visible line break. - Prefer concise labels. If a label becomes long, split it with
<br>instead of making the diagram line unreadable.
Example
```mermaid
flowchart TD
User["User"] --> Service["Application<br>Service"]
```
Node Naming
- Node ID must use only alphanumeric characters and underscores (
A-Z,a-z,0-9,_). - Node ID should be concise and stable.
- Node ID and displayed label must be separated.
- Do not use spaces, punctuation, paths, URLs, or localized text as Node IDs.
Example
UserProfile["User Profile"]
UserProfile= Node IDUser Profile= Node Label
Node Label
- All Node Labels must be enclosed in double quotes (
"). - Do not omit quotes even if the label contains only alphanumeric characters.
- This rule applies to English, Chinese, paths, URLs, and all other text.
- Escape literal double quotes inside labels when needed.
Example
A["User"]
B["User Profile"]
C["/content/site/page"]
D["cq:dialog"]
E["User Settings"]
Edge Label
- All Edge Labels must be enclosed in double quotes (
"). - Never use unquoted edge labels.
- Keep edge labels short and action-oriented.
- When the relationship is obvious, omit the edge label instead of adding noise.
Example
A -- "sling:resourceType" --> B
A -- "Load User Data" --> B
Diagram Layout
- Declare the diagram type first, then put all nodes and edges below it.
- Use indentation consistently inside subgraphs.
- Name subgraphs with quoted labels.
- Keep related nodes close together in the source order.
- Prefer stable ordering over visually clever ordering; stable source makes future edits easier.
Example
flowchart LR
subgraph Backend["Backend"]
Api["API"]
Database["Database"]
end
Client["Client"] --> Api
Api -- "read/write" --> Database
Review Checklist
Before returning Mermaid code, verify:
- Every Node Label is quoted.
- Every Edge Label is quoted.
- Every Node ID uses only letters, numbers, or underscores.
- No label uses
\n; use<br>instead. - The diagram is inside a
mermaidfenced code block when returned in Markdown. - The source order is readable and grouped by purpose.
Rationale
Using double quotes consistently:
- Prevents Mermaid parse errors.
- Improves compatibility across GitHub, GitLab, Azure DevOps, Confluence, VS Code, and Mermaid Live Editor.
- Reduces maintenance overhead.
- Eliminates the need to remember special-character rules.
- Produces more stable diffs when labels change.