AgentSkillsCN

mermaid

根据用户需求生成Mermaid图表。支持流程图、序列图、类图、ER图、甘特图以及18种以上的图表类型。

SKILL.md
--- frontmatter
name: mermaid
description: Generate Mermaid diagrams from user requirements. Supports flowcharts, sequence diagrams, class diagrams, ER diagrams, Gantt charts, and 18 more diagram types.
allowed-tools: Read Write Edit
metadata:
  argument-hint: "[diagram description or requirements]"

Mermaid Diagram Generator

Generate high-quality Mermaid diagram code based on user requirements.

Workflow

  1. Understand Requirements: Analyze user description to determine the most suitable diagram type
  2. Read Documentation: Read the corresponding syntax reference for the diagram type
  3. Generate Code: Generate Mermaid code following the specification
  4. Apply Styling: Apply appropriate themes and style configurations

Diagram Type Reference

Select the appropriate diagram type and read the corresponding documentation:

TypeDocumentationUse Cases
Flowchartflowchart.mdProcesses, decisions, steps
Sequence DiagramsequenceDiagram.mdInteractions, messaging, API calls
Class DiagramclassDiagram.mdClass structure, inheritance, associations
State DiagramstateDiagram.mdState machines, state transitions
ER DiagramentityRelationshipDiagram.mdDatabase design, entity relationships
Gantt Chartgantt.mdProject planning, timelines
Pie Chartpie.mdProportions, distributions
Mindmapmindmap.mdHierarchical structures, knowledge graphs
Timelinetimeline.mdHistorical events, milestones
Git Graphgitgraph.mdBranches, merges, versions
Quadrant ChartquadrantChart.mdFour-quadrant analysis
Requirement DiagramrequirementDiagram.mdRequirements traceability
C4 Diagramc4.mdSystem architecture (C4 model)
Sankey Diagramsankey.mdFlow, conversions
XY ChartxyChart.mdLine charts, bar charts
Block Diagramblock.mdSystem components, modules
Packet Diagrampacket.mdNetwork protocols, data structures
Kanbankanban.mdTask management, workflows
Architecture Diagramarchitecture.mdSystem architecture
Radar Chartradar.mdMulti-dimensional comparison
Treemaptreemap.mdHierarchical data visualization
User JourneyuserJourney.mdUser experience flows
ZenUMLzenuml.mdSequence diagrams (code style)

Configuration & Themes

Output Specification

Generated Mermaid code should:

  1. Be wrapped in ```mermaid code blocks
  2. Have correct syntax that renders directly
  3. Have clear structure with proper line breaks and indentation
  4. Use semantic node naming
  5. NO COLOR STYLING - Keep diagrams clean and simple without colors
  6. Use minimal, professional style focusing on clarity

Default Style Guidelines

IMPORTANT: Follow these style rules for all diagrams:

  • NO custom colors - Use default styling only
  • White/transparent background - Clean and professional
  • Minimal nodes - Only essential information
  • Clear labels - Concise text without redundancy
  • Simple structure - Linear flows preferred over complex graphs

Gantt Chart Style (Recommended for timelines and schedules):

  • Use gantt type for project timelines, schedules, roadmaps
  • Clean section-based organization
  • Milestones for key achievements
  • No custom colors needed

When generating PNG with mmdc:

bash
# Use professional theme with config
mmdc -i diagram.mmd -o diagram.png -w 1200 -H 600 -b white -c config.json

Professional Theme Config (create as config.json):

Option 1: Clean Business Style (Recommended)

json
{
  "theme": "base",
  "themeVariables": {
    "primaryColor": "#ffffff",
    "primaryTextColor": "#333333",
    "primaryBorderColor": "#1976d2",
    "lineColor": "#888888",
    "secondaryColor": "#f5f5f5",
    "tertiaryColor": "#e3f2fd",
    "tertiaryBorderColor": "#1976d2",
    "tertiaryTextColor": "#1565c0",
    "fontFamily": "Inter, Segoe UI, Roboto, sans-serif",
    "fontSize": "12px"
  },
  "flowchart": {
    "curve": "cardinal",
    "nodeSpacing": 50,
    "rankSpacing": 50,
    "padding": 20
  },
  "gantt": {
    "titleTopMargin": 25,
    "barGap": 4,
    "topPadding": 50,
    "sidePadding": 75,
    "gridLineStartPadding": 10,
    "fontSize": 12,
    "sectionFontSize": 14
  }
}

Option 2: Neutral Print Style (For PDF/Print)

json
{
  "theme": "neutral",
  "themeVariables": {
    "fontFamily": "Inter, sans-serif",
    "fontSize": "12px"
  },
  "flowchart": {
    "curve": "basis",
    "nodeSpacing": 50,
    "padding": 20
  }
}

Advanced Styling with classDef:

mermaid
%%{init: {'theme':'base', 'themeVariables': {'primaryColor':'#fff','primaryBorderColor':'#1976d2','fontFamily':'Inter'}}}%%
graph LR
    A[Input] --> B[Process]
    B --> C[Output]

    classDef clean fill:#ffffff,stroke:#1976d2,stroke-width:2px,color:#333
    classDef highlight fill:#e3f2fd,stroke:#1976d2,stroke-width:2px,color:#1565c0

    class A,C clean
    class B highlight

This creates modern, polished diagrams with:

  • ✨ Professional Neo-inspired look
  • 📐 Optimal spacing and padding
  • 🎨 Subtle blue accent (#1976d2)
  • 🔤 Modern typography (Inter font)
  • 📊 Clean gantt chart styling

Avoid:

  • ❌ Multiple colors (style fill:#color)
  • ❌ Complex nested subgraphs
  • ❌ Excessive node styling
  • ❌ Decorative elements

Example Output

Simple Flowchart (No colors):

mermaid
flowchart LR
    A[Start] --> B[Process]
    B --> C[End]

Gantt Chart (Recommended for timelines):

mermaid
gantt
    title Project Timeline
    dateFormat YYYY-MM
    section Phase 1
    Task 1           :2026-02, 2026-03
    Task 2           :2026-03, 2026-04
    section Phase 2
    Task 3           :2026-04, 2026-05
    Milestone        :milestone, 2026-05, 0d

Simple Process Flow:

mermaid
graph LR
    A[Input] --> B[Process]
    B --> C[Output]

User requirements: $ARGUMENTS