← 返回
AI智能 中文

Mermaid Diagrams

Generate and render diagrams from Mermaid syntax into PNG, SVG, or PDF using customizable themes and various diagram types.
根据 Mermaid 语法生成并渲染图表为 PNG、SVG 或 PDF,支持自定义主题和多种图表类型。
jarekbird
AI智能 clawhub v1.0.0 1 版本 99882.5 Key: 无需
★ 1
Stars
📥 2,530
下载
💾 153
安装
1
版本
#latest

概述

Mermaid Diagrams Skill

Generate diagrams from text using Mermaid.

Requirements

  • @mermaid-js/mermaid-cli (npm install -g @mermaid-js/mermaid-cli)

Usage

  1. Write Mermaid syntax to a .mmd file
  2. Run mmdc to render PNG/SVG
  3. Return the image to the user

Basic Command

mmdc -i input.mmd -o output.png -t dark -b transparent

Options

FlagDescription
------
-iInput .mmd file
-oOutput file (.png, .svg, .pdf)
-tTheme: default, dark, forest, neutral
-bBackground color (transparent, hex)
-wWidth in pixels (default: 800)
-HHeight in pixels
-sScale factor (default: 1, use 2-3 for high-res)
-cConfig JSON file for advanced theming

Supported Diagram Types

  • Flowchart: graph TD / graph LR
  • Sequence: sequenceDiagram
  • Class: classDiagram
  • State: stateDiagram-v2
  • ER: erDiagram
  • Gantt: gantt
  • Pie: pie
  • Mindmap: mindmap
  • Timeline: timeline
  • Git graph: gitGraph
  • Quadrant: quadrantChart
  • Block: block-beta

Workflow

  1. Determine the best diagram type for what the user wants
  2. Write the .mmd file to /tmp/mermaid-.mmd
  3. Render: mmdc -i /tmp/mermaid-.mmd -o /tmp/mermaid-.png -t dark -b transparent -s 2
  4. Show the image to the user via Read tool
  5. Clean up temp files if not needed

Example: Architecture Diagram

graph TD
    A[Client] -->|HTTPS| B[API Gateway]
    B --> C[Auth Service]
    B --> D[App Server]
    D --> E[(PostgreSQL)]
    D --> F[(Redis Cache)]

Example: Sequence Diagram

sequenceDiagram
    participant U as User
    participant A as API
    participant DB as Database
    U->>A: POST /login
    A->>DB: Validate credentials
    DB-->>A: User record
    A-->>U: JWT token

Tips

  • Use graph LR for left-to-right flow, graph TD for top-down
  • Keep node labels short — detail goes in tooltips or notes
  • Use subgraphs to group related components
  • For dark backgrounds, use -t dark -b transparent
  • Scale -s 2 or -s 3 for sharp images on retina displays
  • Always use pty: false when calling mmdc

Theming

For custom colors, create a config JSON:

{
  "theme": "base",
  "themeVariables": {
    "primaryColor": "#f59e0b",
    "primaryTextColor": "#1a1a1a",
    "primaryBorderColor": "#d97706",
    "lineColor": "#6b7280",
    "secondaryColor": "#10b981",
    "tertiaryColor": "#3b82f6"
  }
}

Then: mmdc -i input.mmd -o output.png -c config.json

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-28 22:59 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-intelligence

ontology

oswalpalash
类型化知识图谱,用于结构化智能体记忆与可组合技能。支持创建/查询实体(人员、项目、任务、事件、文档)及关联...
★ 714 📥 244,006
ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,362 📥 318,770
ai-intelligence

Proactive Agent

halthelobster
将AI智能体从任务执行者升级为主动预判需求、持续优化的智能伙伴。集成WAL协议、工作缓冲区、自主定时任务及实战验证模式。Hal Stack核心组件 🦞
★ 837 📥 213,305