AgentSkillsCN

mermaid

利用内置的 render_mermaid MCP 工具渲染 Mermaid 图表。支持绘制流程图、时序图、状态图、类图以及 ER 图。当用户提出绘制可视化图表、流程图,或架构示意图时,即可调用此工具。输出结果可选择 SVG 格式或 ASCII 文本格式,并支持自定义主题配色。

SKILL.md
--- frontmatter
name: mermaid
version: 1.0.0
description: |
  Render Mermaid diagrams using the built-in render_mermaid MCP tool.
  Supports flowcharts, sequence diagrams, state diagrams, class diagrams,
  and ER diagrams. Use when the user asks for any visual diagram, flowchart,
  or architecture visualization. Produces SVG or ASCII output with theming.
allowed-tools:
  - mcp__ageaf-mermaid__render_mermaid
  - mcp__ageaf-mermaid__list_mermaid_themes

Mermaid Diagram Rendering

You have access to a built-in MCP tool called render_mermaid that renders Mermaid diagrams to SVG or ASCII.

When to Use

Use this skill when the user asks for:

  • Flowcharts or process diagrams
  • Sequence diagrams
  • State diagrams
  • Class diagrams
  • ER (Entity-Relationship) diagrams
  • Any visual representation of a process, architecture, or relationship

How to Use

  1. Write valid Mermaid syntax for the requested diagram.
  2. Call the render_mermaid MCP tool with the Mermaid code.
  3. Present the result using this exact format:

Output Format (CRITICAL)

Always structure your response like this:

code
Here's the diagram:

```ageaf-diagram
<svg ...>...</svg>
```

```mermaid
graph TD
    A[Start] --> B[End]
```
  • First include the rendered SVG output from the tool in an ```ageaf-diagram fence. The Ageaf extension will render this as a visual diagram with a download button.
  • Then include the Mermaid source in a ```mermaid fence (for the user to copy/reference).
  • Do NOT escape or modify the SVG output from the tool — paste it exactly as returned.
  • If the tool returns an error, skip the ageaf-diagram fence and explain the error instead.

Tool Parameters

  • code (required): The Mermaid diagram source code
  • format (optional): "svg" (default) or "ascii"
  • theme (optional): Color theme name. Defaults to "zinc-dark". Available themes include: zinc-dark, tokyo-night, tokyo-night-storm, tokyo-night-light, catppuccin-mocha, catppuccin-latte, nord, nord-light, dracula, github-light, github-dark, solarized-light, solarized-dark, one-dark

Example

For a user asking "draw a flowchart of the compilation process":

  1. Generate the Mermaid code:
mermaid
graph TD
    A[Source .tex] --> B[LaTeX Compiler]
    B --> C{Errors?}
    C -->|Yes| D[Fix Errors]
    D --> B
    C -->|No| E[PDF Output]
  1. Call render_mermaid with the code above.
  2. Show the rendered result to the user.

Diagram Types

Flowchart

code
graph TD
    A[Start] --> B{Decision}
    B -->|Yes| C[Action]
    B -->|No| D[Other]

Sequence Diagram

code
sequenceDiagram
    Alice->>Bob: Hello
    Bob-->>Alice: Hi back

State Diagram

code
stateDiagram-v2
    [*] --> Active
    Active --> Inactive
    Inactive --> [*]

Class Diagram

code
classDiagram
    Animal <|-- Duck
    Animal : +String name
    Duck : +swim()

ER Diagram

code
erDiagram
    USER ||--o{ ORDER : places
    ORDER ||--|{ LINE-ITEM : contains

Fallback

If the render_mermaid tool is NOT available, just output the Mermaid code in a ```mermaid fence. The Ageaf host will render it automatically.

Tips

  • Keep diagrams focused and readable; avoid excessive nesting.
  • Use descriptive node labels rather than short cryptic IDs.
  • For dark-themed panels, zinc-dark, tokyo-night, or dracula work well.
  • If the user asks for ASCII output (e.g., for pasting in plain text), set format: "ascii".