Diagram Generator Skill
Overview
This skill generates professional technical diagrams in multiple formats: DrawIO (XML-based), Mermaid, and Excalidraw (hand-drawn style). Choose the format based on use case needs.
Diagram Generator MCP Tools
The following MCP tools are available:
generate_diagram- Generate diagram from structured JSON specget_config- Get current diagram configurationset_output_path- Set default output pathvalidate_diagram_spec- Validate diagram specification
Supported Formats
| Format | Best For | File Extension |
|---|---|---|
| DrawIO | Technical diagrams, architecture | .drawio |
| Mermaid | Flowcharts, simple diagrams | .mmd or embedded |
| Excalidraw | Hand-drawn style, collaborative | .excalidraw |
Diagram Specification Structure
{
"format": "drawio",
"elements": [
{
"type": "rectangle",
"x": 100,
"y": 100,
"width": 200,
"height": 100,
"label": "Process",
"style": "fillColor=#f3f3f3;strokeColor=#363636"
},
{
"type": "arrow",
"from": "node1",
"to": "node2",
"style": "endArrow=classic"
}
],
"theme": {
"background": "#ffffff",
"primary": "#0070c0"
}
}
Element Types
Basic Shapes
rectangle- Rounded rectangleellipse- Circle/ovaldiamond- Decision rhombusparallelogram- Data/processcylinder- Databasehexagon- Preparation
Connectors
arrow- Directed arrowline- Simple linedashed_arrow- Dashed connector
Text
text- Standalone text label
Usage Guidelines
When to Use Each Format
| Diagram Type | Format | Example |
|---|---|---|
| Architecture | DrawIO | Microservices, network topology |
| Simple flowchart | Mermaid | Quick process visualization |
| Brainstorming | Excalidraw | Collaborative sketching |
| Technical spec | DrawIO | Detailed component diagrams |
| Presentation | Excalidraw | Hand-drawn aesthetic |
Recommended Parameters
format: "drawio" # or "mermaid", "excalidraw"
output_path: "Obsidian-Vault/6️⃣ 工具/visualizations/"
Example Diagrams
Optical System Architecture (DrawIO)
{
"format": "drawio",
"elements": [
{
"type": "rectangle",
"id": "laser",
"x": 50,
"y": 100,
"width": 80,
"height": 60,
"label": "Ti:Sapphire\nLaser",
"style": "fillColor=#e1e1e1;strokeColor=#000000"
},
{
"type": "rectangle",
"id": "pca",
"x": 200,
"y": 100,
"width": 80,
"height": 60,
"label": "PCA\nEmitter",
"style": "fillColor=#f3f3f3;strokeColor=#000000"
},
{
"type": "arrow",
"from": "laser",
"to": "pca",
"label": "Pump",
"style": "endArrow=classic;strokeColor=#ff0000"
}
]
}
Research Workflow (Excalidraw)
{
"format": "excalidraw",
"elements": [
{
"type": "rectangle",
"x": 100,
"y": 100,
"width": 150,
"height": 80,
"label": "Literature Review"
}
]
}
Best Practices
- Use DrawIO for technical precision - Coordinates, styles, exact shapes
- Use Excalidraw for collaborative brainstorming - Hand-drawn aesthetic
- Validate specs - Use
validate_diagram_specbefore generation - Set output path - Configure once, reuse for consistency
- Combine with Mermaid - For complex diagrams, use Mermaid for parts
Integration with Project
- Generate diagram with
generate_diagram - Save to:
Obsidian-Vault/6️⃣ 工具/visualizations/ - Filename:
{type}_{topic}_{date}.{format} - Insert in Obsidian:
- DrawIO/Mermaid:
```mermaidor link to .drawio - Excalidraw:
![[visualizations/diagram.excalidraw]]
- DrawIO/Mermaid:
- Run sync script if needed
Error Handling
If diagram generation fails:
- Validate spec with
validate_diagram_spec - Check element types are supported
- Verify coordinates are valid numbers
- Simplify - reduce number of elements
- Try different format
Notes
- DrawIO files can be edited in draw.io app or VS Code extension
- Excalidraw supports collaboration
- For simple diagrams, Mermaid skill may be faster
- diagram-generator MCP can also output Mermaid format