Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Use this skill when you need to draw diagrams including: Flowchart, Sequence Diagram, Class Diagram, State Diagram, ER Diagram, User Journey, Gantt Chart, Pie Chart, Quadrant Chart, Requirement Diagram, Gitgraph, Mindmap, Timeline, Sankey, XY Chart (Bar/Line), Block Diagram, Packet Diagram, Kanban, Architecture Diagram, C4 Diagram, Radar Chart, Treemap, and ZenUML. You MUST use this skill BEFORE outputting any mermaid code block.
.claude/skills/wecode-ai-diagram-visualization-with-mermaid/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-10 | ✗→✓ | ▲ Improved | 63% | 0% |
| case-13 | ✓→✓ | = Same ✓ | 92% | 0% |
| case-14 | ✓→✓ | = Same ✓ | 158% | 0% |
| case-15 | ✓→✓ | = Same ✓ | 294% | 0% |
| case-11 | ✗→✗ | = Same ✗ | 99% | 0% |
When you need to visualize concepts, workflows, architectures, or relationships, use Mermaid diagram syntax.
To create mermaid diagrams, follow this two-step workflow:
render_mermaid tool - Use the tool to validate your mermaid syntaxThis ensures:
Call the render_mermaid tool with the following parameters:
| Parameter | Type | Required | Description | | -------------- | ------ | -------- | --------------------------------------------------------- | | code | string | Yes | The mermaid diagram code (without the mermaid wrapper) | | diagram_type | string | No | Diagram type hint (flowchart, sequence, etc.) | | title | string | No | Optional title for the diagram |
json{ "name": "render_mermaid", "arguments": { "code": "flowchart TD\n A[Start] --> B{Decision}\n B -->|Yes| C[Action 1]\n B -->|No| D[Action 2]\n C --> E[End]\n D --> E", "title": "Decision Flow" } }
When the render_mermaid tool returns success, it will include the mermaid code that you should output. Simply include the mermaid code block in your response:
mermaidflowchart TD A[Start] --> B{Decision} B -->|Yes| C[Action 1] B -->|No| D[Action 2] C --> E[End] D --> E
This mermaid code block will be:
If the diagram has syntax errors, the tool will return detailed error information including:
When you receive an error, you should:
render_mermaid again with the corrected codeExample error response:
Mermaid diagram rendering failed.
Error: Parse error on line 3: Unexpected token 'invalid'
Suggestions:
- Check the syntax at line 3
- Ensure all node IDs use alphanumeric characters and underscores
- Verify arrow syntax (-->, ---, -.->)
Please fix the error and try again.The render_mermaid tool includes an automatic correction system that:
This means most syntax errors will be automatically corrected without your intervention. However, if all automatic retries fail, you will receive a special response.
If you receive a response containing "final_instruction", this means:
YOU MUST follow these rules when receiving a final_instruction response:
When you receive a response with final_instruction, respond to the user like this:
I apologize, but I was unable to render the Mermaid diagram after multiple attempts.
The automatic correction system tried to fix the syntax errors but was unsuccessful.
**Error Details:**
- Error: [error message from response]
- Line: [line number if available]
**Original Code:**
[show the original code for reference]
**What you can do:**
1. Check the Mermaid syntax documentation at https://mermaid.js.org/
2. Simplify the diagram structure
3. Provide a corrected version of the code
4. Try a different diagram type that might better suit your needs
Would you like me to help you troubleshoot the specific syntax issue?final_instruction ensures a good user experiencerender_mermaid tool with the code to validate syntaxIMPORTANT: Only output the mermaid code block AFTER successful validation with the render_mermaid tool.
Use the read_mermaid_reference tool to read the specific documentation for syntax details and examples. Pass the filename (e.g., flowchart.md) as the reference argument.
flowchart.md): Process flows, decision trees, workflowssequenceDiagram.md): Interaction sequences between participantsclassDiagram.md): Class structures and object-oriented relationshipsstateDiagram.md): State machines and state transitionserDiagram.md): Database schemas and relationshipsblock.md): Block diagrams for high-level structurezenuml.md): Alternative sequence diagram syntaxgantt.md): Project timelines and scheduleskanban.md): Work items and project status boardstimeline.md): Chronological events visualizationjourney.md): User flows and experience mappingrequirementDiagram.md): Requirements traceability and riskgitgraph.md): Git branching and merging visualizationpie.md): Proportional data distributionxyChart.md): Bar and line chartsquadrantChart.md): Strategic planning matrices (2x2)radar.md): Multivariate data comparisonsankey.md): Flow volume visualizationtreemap.md): Hierarchical data treemapsarchitecture.md): Cloud and system architecture diagramsc4.md): C4 model for software architecturepacket.md): Network packet structure visualizationexamples.md): Collection of various diagram examplesA["用户"]).Start, User, DB) to avoid parsing errors.render_mermaid tool.ID["Label"] format.Other measured skills in the registry, with their headline benchmark lift.