Install
openclaw skills install skill-mermaid-diagramsGenerate consistent, template-based Mermaid diagrams for technical content. Supports 12 diagram types (architecture, flowchart, sequence, concept-map, radial-concept, timeline, comparison, comparison-table, gantt, mindmap, class-diagram, state-diagram) with automatic template selection, LLM-powered content generation, syntax validation, and error handling. Use when creating technical illustrations, system architecture visuals, project timelines, class diagrams, state machines, or documentation requiring uniform styling. Triggers on "mermaid diagram", "generate diagram", "create flowchart", "architecture diagram", "sequence diagram", "concept map", "gantt chart", "mind map", "class diagram", "UML diagram", "project timeline", "state diagram", "technical illustration".
openclaw skills install skill-mermaid-diagramsGenerate professional, consistently-styled Mermaid diagrams for technical content with automatic template selection, content generation, and quality validation.
Subagent Pattern (Recommended):
When user requests diagram generation, spawn a subagent:
Generate 3 Mermaid diagrams for /path/to/chapter-01.md and save to diagrams/chapter-01/
The subagent will:
Manual Pattern:
# 1. Create content.json (see assets/example-content.json)
# 2. Render diagrams
node scripts/generate.mjs --content content.json --out diagrams/chapter-01
# 3. Validate
node scripts/validate.mjs --dir diagrams/chapter-01
Run the installation script to automatically install and verify mermaid-cli:
cd $SKILL_DIR # Path to skill-mermaid-diagrams directory
./scripts/install-deps.sh
The script will:
Alternatively, install Mermaid CLI globally:
npm install -g @mermaid-js/mermaid-cli
Verify installation:
mmdc --version # Should be >= 11.0.0
When a user requests diagram generation, spawn a subagent to handle the complete workflow:
Task: Generate 3 Mermaid diagrams for chapter 5
Steps:
1. Read $CONTENT_DIR/chapters/chapter-05.md
2. Analyze content and select 3 appropriate diagram templates from: architecture, flowchart, sequence, concept-map, timeline, comparison
3. For each selected template:
- Read template from $SKILL_DIR/assets/
- Extract placeholders ({{PLACEHOLDER_NAME}} format)
- Generate concise labels (max 8 words each) based on chapter content
4. Create content.json with structure:
{
"chapter": "chapter-05.md",
"diagrams": [
{
"template": "architecture",
"placeholders": { "SYSTEM_NAME": "...", ... }
},
...
]
}
5. Save to $CONTENT_DIR/diagrams/chapter-05/content.json
6. Run: node $SKILL_DIR/scripts/generate.mjs --content content.json --out $CONTENT_DIR/diagrams/chapter-05
7. Validate: node $SKILL_DIR/scripts/validate.mjs --dir $CONTENT_DIR/diagrams/chapter-05
8. Report success with file count
Note: Replace $SKILL_DIR and $CONTENT_DIR with actual paths:
- SKILL_DIR: Path to skill-mermaid-diagrams directory
- CONTENT_DIR: Path to your content/project directory
If generating content.json manually:
# 1. Create content.json (see assets/example-content.json)
# 2. Render
cd $SKILL_DIR # Path to skill-mermaid-diagrams directory
node scripts/generate.mjs \
--content /path/to/content.json \
--out /path/to/output
# 3. Validate
node scripts/validate.mjs --dir /path/to/output
Parameters:
--content / -c: Content JSON file (required)--out / -o: Output directory (default: ./diagrams)for dir in diagrams/chapter-*/; do
node scripts/validate.mjs --dir "$dir"
done
The skill includes 12 professionally-themed templates with consistent color schemes:
architecture.mmd - System architecture, component diagrams, tool integration
flowchart.mmd - Decision flows, processes, workflows, debugging steps
sequence.mmd - Actor interactions, message passing, session patterns
concept-map.mmd - Key concepts, mental models, paradigms, relationships
radial-concept.mmd - Layered concepts radiating from center - Use for: Progressive summarization, abstraction layers, hierarchical models
timeline.mmd - Temporal progression, optimization stages, evolution
comparison.mmd - Trade-offs, quadrant analysis (2D plotting)
comparison-table.mmd - Side-by-side feature comparison
gantt.mmd - Project timelines, task scheduling - Use for: Project planning, milestone tracking, task dependencies
mindmap.mmd - Organic radial mind maps - Use for: Brainstorming, organic thought structures, free-form concept mapping
class-diagram.mmd - UML class diagrams
state-diagram.mmd - State machines, lifecycle diagrams
Each template requires specific placeholders. All placeholders must be provided to avoid rendering errors.
| Template | Placeholders | Complexity | Required Fields |
|---|---|---|---|
| architecture | 10 | Medium | SYSTEM_NAME, COMPONENT_1-3_LABEL, EXTERNAL_1-2_LABEL, FLOW_1-4 |
| flowchart | 11 | Medium | START_LABEL, DECISION_1-2, ACTION_1-4, CHOICE_1-2_YES/NO, END_LABEL |
| sequence | 8 | Medium | ACTOR_1-3, MESSAGE_1-5 |
| concept-map | 15 | High | CENTRAL_CONCEPT, BRANCH_1-4, BRANCH_X_SUB_1-3 |
| radial-concept | 13 | Medium | CENTRAL_CONCEPT, LEVEL_1-4_LABEL, LEVEL_X_NODE_1-3 |
| timeline | 6 | Low | EVENT_1-6, DATE_1-6 |
| comparison | 18 | High | COMPARISON_TITLE, X/Y_AXIS_LOW/HIGH, QUADRANT_1-4_LABEL, ITEM_1-5 + X/Y coords |
| comparison-table | 10 | Low | OPTION_1-2_TITLE, OPTION_X_CRITERION_1-4 |
| gantt | 14 | High | CHART_TITLE, SECTION_1-3_TITLE, TASK_X_Y (name/id/start/duration) |
| mindmap | 13 | Medium | ROOT_CONCEPT, BRANCH_1-4, BRANCH_X_CHILD_1-3 |
| class-diagram | 21 | High | CLASS_1-3_NAME, CLASS_X_ATTR_1-3, CLASS_X_METHOD_1-3, REL_1-3_TYPE/LABEL |
| state-diagram | 18 | Medium | STATE_1-8, TRANSITION_1-7_LABEL, STATE_1/4/7_NOTE |
Important Notes:
done, active, crit, or blank. Date format: YYYY-MM-DD. Duration: Nd (days) or YYYY-MM-DD.<|-- (inheritance), *-- (composition), o-- (aggregation), --> (association), ..> (dependency).stateDiagram-v2 syntax. States are simple identifiers (no spaces). Notes attach to states 1, 4, and 7.Placeholder Naming Convention:
COMPONENT_1_LABEL, COMPONENT_2_LABELBRANCH_1, BRANCH_1_SUB_1, BRANCH_1_SUB_2LEVEL_1_LABEL, LEVEL_1_NODE_1Breaking Changes:
architecture.mmd - Fixed node ID handling (space-safe)
concept-map.mmd - Replaced mindmap with graph-based version
All changes target root causes (template design flaws, missing validation) rather than surface symptoms.
#4A90E2 - Main components, actions#7B68EE - Supporting elements#90EE90 - External actors, success states#FFD700 - Decisions, cautions#FF6B6B - Failures, critical pathsAfter generation, each chapter directory contains:
diagrams/chapter-01/
├── diagram-01-architecture.mmd # Mermaid source
├── diagram-01-architecture.svg # Vector output
├── diagram-01-architecture.png # Raster output (1200px wide)
├── diagram-02-flowchart.mmd
├── diagram-02-flowchart.svg
├── diagram-02-flowchart.png
├── diagram-03-concept-map.mmd
├── diagram-03-concept-map.svg
├── diagram-03-concept-map.png
└── summary.json # Generation metadata
The generator includes robust error handling:
The validator checks each diagram for:
Validation workflow:
# Generate diagrams
node scripts/generate.mjs --content content.json --out diagrams/chapter-01
# Validate output
node scripts/validate.mjs --dir diagrams/chapter-01
# Fix any failures and re-run
Per Chapter (3 diagrams):
At scale (e.g. 14 chapters × 3 diagrams = 42 diagrams):
Comparison to AI image generation (42 images):
Edit theme variables in any template file (assets/*.mmd):
%%{init: {'theme':'base', 'themeVariables': {
'primaryColor':'#NEW_COLOR',
'secondaryColor':'#NEW_COLOR',
...
}}}%%
assets/new-template.mmd with theme and placeholdersTEMPLATES object in scripts/generate.mjs:const TEMPLATES = {
...
"new-template": "Description of when to use this template",
};
node scripts/generate.mjs --content test-content.json --out test-output
"mmdc not found"
npm install -g @mermaid-js/mermaid-cliwhich mmdc"Template not found"
"Rendering failed"
mmdc -i diagram.mmd -o test.svgnode scripts/validate.mjs --dir output_dirUnresolved placeholders in output ({{PLACEHOLDER}})
Subagent failed
%%{init: {'theme':'base', ...}}%%
graph TB
subgraph "Agent System"
Gateway[Gateway Process]
Session[Session Manager]
Tools[Tool Registry]
end
User((User))
Provider((LLM Provider))
User -->|Request| Gateway
Gateway -->|Route| Session
Session -->|Select Tool| Tools
Tools -->|Execute| Provider
Output: Clean, consistent, professional diagram with uniform styling across all chapters.
--max value for all chapters (e.g., 3)mmdc./scripts/install-deps.sh
Verifies that mermaid-cli is installed and meets version requirements.
assets/example-content.json (already included)node scripts/generate.mjs --content assets/example-content.json --out test-outputnode scripts/validate.mjs --dir test-outputreferences/mermaid-syntax.md - Quick reference for diagram syntax, theming, and common patternsassets/example-content.json - Real-world content structure example