Create, validate, and troubleshoot Mermaid.js diagrams. Use when generating flowcharts, sequence diagrams, class diagrams, ER diagrams, Gantt charts, state diagrams, or any visualization. Handles diagram validation, syntax errors, broken diagrams, and automatic repair. Trigger terms - mermaid, diagram, flowchart, sequence, class diagram, ER diagram, entity relationship, state machine, gantt, visualization, chart, graph.
/plugin marketplace add rp1-run/rp1/plugin install rp1-run-rp1-base-plugins-base-2@rp1-run/rp1This skill is limited to using the following tools:
EXAMPLES.mdreference.mdCreate valid, well-formed Mermaid.js diagrams with automatic validation and error repair guidance.
Requirement: rp1 CLI v0.3.0 or later (includes
agent-tools mmd-validatecommand)
rp1 agent-tools mmd-validate CLI tool for verificationActivate this skill when:
Trigger phrases: "create a diagram", "draw a flowchart", "visualize this process", "sequence diagram for", "ER diagram", "class diagram", "fix this mermaid", "validate diagram"
CRITICAL: Every diagram MUST be validated before being considered complete.
# Validate markdown file (all embedded diagrams)
rp1 agent-tools mmd-validate path/to/document.md
# Validate standalone mermaid file
rp1 agent-tools mmd-validate path/to/diagram.mmd
# Validate from stdin (for inline diagrams)
echo 'flowchart TD
A --> B' | rp1 agent-tools mmd-validate
The CLI tool outputs structured JSON in a ToolResult envelope:
Success (all diagrams valid):
{
"success": true,
"tool": "mmd-validate",
"data": {
"diagrams": [
{ "index": 0, "valid": true, "diagramType": "flowchart", "startLine": 5 }
],
"summary": { "total": 1, "valid": 1, "invalid": 0 }
}
}
Failure (contains invalid diagrams):
{
"success": false,
"tool": "mmd-validate",
"data": {
"diagrams": [
{
"index": 0,
"valid": false,
"diagramType": "stateDiagram-v2",
"startLine": 10,
"errors": [{
"diagramIndex": 0,
"message": "Parse error on line 2: Expecting '-->', got 'MINUS'",
"line": 2,
"context": "[*] -> State1"
}]
}
],
"summary": { "total": 1, "valid": 0, "invalid": 1 }
},
"errors": [{
"message": "Parse error on line 2: Expecting '-->', got 'MINUS'",
"line": 2,
"context": "[*] -> State1"
}]
}
Parsing the Response:
success: true AND data.summary.invalid == 0 -> All diagrams validsuccess: false -> Extract errors from data.diagrams[].errors[]diagramIndex: Which diagram has the error (0-based)message: Full error message for category detectionline: Line within the diagram (for targeted fix)context: Problematic code snippetDetect error categories by pattern matching the message field in validation errors. See EXAMPLES.md for detailed examples of each category.
| Category | Detection Patterns | Quick Fix |
|---|---|---|
ARROW_SYNTAX | got 'MINUS', got 'GT', expecting.*LINK | Replace -> with --> in state/flowchart |
QUOTE_ERROR | unterminated string, got 'STR', lexical error.*string | Wrap label in double quotes |
CARDINALITY | cardinality, relationship, erDiagram | Use valid notation: ||--o{ |
LINE_BREAK | expecting.*(NEWLINE|NL|EOF) | Each statement on its own line |
DIAGRAM_TYPE | unknown diagram type, UnknownDiagramError | Correct spelling, add declaration |
NODE_SYNTAX | got 'PS', got 'PE', got 'SQS', got 'SQE', unclosed | Match all opening and closing brackets |
Parse the message field from validation errors to detect category:
ARROW_SYNTAX: message contains "got 'MINUS'" or "got 'GT'" or "expecting.*LINK"
QUOTE_ERROR: message contains "unterminated string" or "got 'STR'" or "lexical error.*string"
CARDINALITY: message contains "cardinality" or "relationship"
LINE_BREAK: message contains "expecting.*NEWLINE" or "expecting.*NL" or "expecting.*EOF"
DIAGRAM_TYPE: message contains "unknown diagram type" or "UnknownDiagramError"
NODE_SYNTAX: message contains "got 'PS'" or "got 'SQS'" or "unclosed"
UNKNOWN: default (no pattern matched)
ARROW_SYNTAX: Check diagram type and use correct arrows:
-->, ---, ==>, -.->, --o, --x--> only (not ->)->>, -->>, -x, --x, -), --)QUOTE_ERROR: Quote labels containing:
["Start Process (init)"]["Time: 10:30 AM"]["Value [optional]"]CARDINALITY: Use proper ER notation:
||--o{||--|||o--o|LINE_BREAK: Separate statements:
sequenceDiagram
Alice->>Bob: Hello
Bob->>Alice: Hi
DIAGRAM_TYPE: Valid types:
flowchart, graph, sequenceDiagram, classDiagram, stateDiagram, stateDiagram-v2, erDiagram, gantt, pie, journey, gitGraph, mindmap, timeline, quadrantChart, xychart-beta, block-beta, sankey-beta, kanban, radar-beta
NODE_SYNTAX: Balance all brackets:
[text](text){text}([text]){{text}}For bulk diagram repair across markdown files, use the mermaid-fixer agent via the /fix-mermaid command:
# Fix all diagrams in a markdown file
/fix-mermaid path/to/document.md
# Fix a single diagram from stdin
/fix-mermaid -
The fixer agent:
rp1 agent-tools mmd-validate on the filedata.diagrams[].errors[]JSON Response Parsing for Fixer:
1. Run: rp1 agent-tools mmd-validate /path/to/file.md
2. Parse JSON output
3. If success == true AND data.summary.invalid == 0:
-> All diagrams valid, done
4. If success == false:
-> For each diagram in data.diagrams where valid == false:
-> Extract errors[].message, errors[].line, errors[].context
-> Detect error category from message patterns
-> Apply category-specific fix
5. Re-validate and repeat (max 3 iterations)
Placeholder format for unfixable diagrams:
<!-- MERMAID FIX NEEDED: {diagram_type}
Error: {error_message}
Line: {line_number}
Attempts: 3
Original diagram could not be auto-repaired.
Please fix manually and remove this comment block.
-->
rp1 agent-tools mmd-validate provides structured JSON outputdata.diagrams[].errors[]Tool Not Available?
If rp1 agent-tools mmd-validate returns "command not found":
Mermaid validation requires rp1 v0.3.0 or later.
Please update rp1 using your package manager:
macOS: brew upgrade rp1
Windows: scoop update rp1
Or visit https://rp1.run for installation instructions.
When presenting diagrams to users:
## Diagram Title
Brief description of what the diagram represents.
\`\`\`mermaid
flowchart TD
A[Start] --> B[Process]
B --> C[End]
\`\`\`
**Validation Status**: Validated successfully
| Type | Use Case | Declaration |
|---|---|---|
| Flowchart | Process flows, decision trees | flowchart TD/LR/RL/BT |
| Sequence | API interactions, message flows | sequenceDiagram |
| Class | Object relationships, architecture | classDiagram |
| ER | Database schemas, data models | erDiagram |
| State | State machines, workflow states | stateDiagram-v2 |
| Gantt | Project timelines, schedules | gantt |
| Git Graph | Branch strategies, commit history | gitGraph |
| Pie | Proportional data | pie |
| Journey | User experience flows | journey |
| Mindmap | Hierarchical concepts | mindmap |
| Timeline | Chronological events | timeline |
| Quadrant | 2D categorization | quadrantChart |
| XY Chart | Bar/line charts | xychart-beta |
| Block | Grid layouts | block-beta |
| Sankey | Flow quantities | sankey-beta |
| Kanban | Task boards | kanban |
| Radar | Multi-axis comparison | radar-beta |
# Validate markdown file (all embedded diagrams)
rp1 agent-tools mmd-validate document.md
# Validate standalone mermaid file
rp1 agent-tools mmd-validate diagram.mmd
# Validate from stdin
echo 'flowchart TD; A-->B' | rp1 agent-tools mmd-validate
Simple flowchart:
flowchart TD
A[Start] --> B{Decision}
B -->|Yes| C[Action]
B -->|No| D[End]
Sequence diagram:
sequenceDiagram
Client->>Server: Request
Server-->>Client: Response
ER diagram:
erDiagram
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ LINE_ITEM : contains
A diagram is complete when:
rp1 agent-tools mmd-validateMaster authentication and authorization patterns including JWT, OAuth2, session management, and RBAC to build secure, scalable access control systems. Use when implementing auth systems, securing APIs, or debugging security issues.