← 返回
未分类

mermaid-maker

Generate, validate, render, and export Mermaid diagrams (.mmd) — flowchart, sequence, class, ER, state, gantt, git graph, mindmap, C4, pie, journey. Three ba...
生成、校验、渲染并导出 Mermaid 图表(.mmd),支持流程图、时序图、类图、ER 图、状态图、甘特图、Git 图、脑图、C4 图、饼图、旅程图。三项基本功能。
junwugit junwugit 来源
未分类 clawhub v1.0.0 1 版本 98550.7 Key: 无需
★ 0
Stars
📥 68
下载
💾 1
安装
1
版本
#latest

概述

Mermaid Maker

Turn intent into .mmd text, then render it as themed SVG, ASCII, PNG, or PDF.

Key advantage: text-based syntax with fully automatic layout — no x/y coordinates. Source lives in git and embeds in Markdown.

When to use / when NOT to use

Use this skill for: diagrams-as-code with automatic layout (flowchart, sequence, class, state, ER, gantt, mindmap, C4, …) — and for producing polished, themed, or terminal-friendly output from that source.

Do NOT use it — route elsewhere — for:

  • Pixel-precise placement, custom layout, branded icons, heavy styling → drawio.
  • A hand-drawn / sketchy aesthetic → excalidraw or tldraw.
  • A freeform whiteboard or freehand strokes → tldraw.
  • Strict, conventional UML notation → plantuml.

Workflow

  1. Pick diagram type — from the table below.
  2. Generate — write the .mmd to disk (start from assets/templates/ if helpful).
  3. Validate — REQUIRED before export: trial-render with your chosen backend (see Validation).
  4. Choose a backend & render/export — themed SVG / ASCII / batch → beautiful-mermaid; PNG / PDF → mmdc; no install → Kroki (see Rendering).
  5. Self-check (vision) — read the rendered image and fix readability defects automatic layout can't prevent; re-validate + re-export. Max 2 rounds; skip if no vision.
  6. Review loop — show the image, apply the minimal .mmd edit per request, re-export until approved (5-round safety valve).
  7. Report — tell the user the output file paths.

Diagram Types

TypeKeywordUse forSyntax
--------------------------------
Flowchartflowchart TD/LRprocesses, pipelines, decisionsFLOWCHART.md
SequencesequenceDiagramAPI calls, message passingSEQUENCE.md
ClassclassDiagramOOP models, data structuresCLASS-ER.md
ERerDiagramdatabase schemasCLASS-ER.md
StatestateDiagram-v2state machines, lifecycleOTHER-TYPES.md
Ganttganttproject timelinesOTHER-TYPES.md
Git GraphgitGraphbranch strategiesOTHER-TYPES.md
PiepieproportionsOTHER-TYPES.md
Mind Mapmindmaptopic breakdownsOTHER-TYPES.md
C4 ContextC4Contexthigh-level architectureOTHER-TYPES.md
User JourneyjourneyUX flowsOTHER-TYPES.md

Reusable starters live in assets/templates/ (flowchart, sequence, state, class, er, gantt, gitgraph).

Rendering

Pick the backend by what you need to ship. Full flags, install, and troubleshooting are in RENDERING.md.

NeedBackendOne-line command
---------------------------------
Themed SVG, ASCII, or batchbeautiful-mermaidnode scripts/render.mjs -i d.mmd -o d.svg --theme tokyo-night
PNG or PDF, offlinemmdcmmdc -i d.mmd -o d.png -w 2048 --backgroundColor white
No install (just curl)Krokicurl -X POST -H "Content-Type: text/plain" --data-binary @d.mmd https://kroki.io/mermaid/svg -o d.svg
  • ASCII (terminal / README): node scripts/render.mjs -i d.mmd -f ascii --use-ascii
  • Batch a folder: node scripts/batch.mjs -i ./diagrams -o ./out --theme dracula -w 4
  • beautiful-mermaid emits SVG/ASCII only; for PNG/PDF use mmdc. Its dependency auto-installs on first run.

Theming

beautiful-mermaid ships 15 themes. Quick picks:

  • Dark docs → tokyo-night ⭐ · github-dark · dracula
  • Light docs → github-light · zinc-light · catppuccin-latte

List all: node scripts/themes.mjs. Full catalog, custom palettes, and a decision tree: THEMES.md.

mmdc uses its own standard themes (default/dark/neutral/forest) via --theme.

Validation (Required)

Never export without validating first. Trial-render with the backend you'll use:

node scripts/render.mjs -i diagram.mmd -o /tmp/test.svg          # beautiful-mermaid
mmdc -i diagram.mmd -o /tmp/test.png 2>&1                        # mmdc
curl -s -X POST -H "Content-Type: text/plain" --data-binary @diagram.mmd https://kroki.io/mermaid/svg -o /tmp/test.svg && echo Valid || echo Invalid

A Could not find Chrome error from mmdc is a setup problem, not a syntax error — don't rewrite valid .mmd; fix the browser or validate via another backend.

Self-Check (vision)

Validation proves syntax is legal — not that the render is readable. After exporting, read the image and catch what auto-layout can't prevent (these are about content, not overlaps):

CheckLook forFix
---------
Label truncationNode/edge text clippedShorten, or wrap with
Cramped densityToo many nodes, tangled linesFlip TDLR, split into subgraphs, reduce nodes
Wrong orientationFar too wide or too tallChange flowchart TDLR (or direction in class/state)
Edge spaghettiMany crossing edgesReorder declarations so connected nodes are adjacent; group with subgraph
Wrong typeType doesn't suit contentSwitch (gantt, sequenceDiagram, stateDiagram-v2, …)
Low contrastText blends into fillAdjust theme / classDef, or pick a higher-contrast theme

Max 2 rounds; re-validate and re-export after every fix. If vision is unavailable, skip and show the image directly.

Review Loop

Show the image, collect feedback, apply the minimal .mmd edit, then re-validate + re-export:

User requestEdit action
------
Change a labelEdit the node/edge text
Add/remove a node or edgeAdd/delete the matching line
Change a colorSwitch --theme, or add classDef + class
Change layout directionSwap TDLR, or set direction (class/state)
Restructure / groupWrap related nodes in a subgraph, or regenerate

Overwrite the same diagram.mmd / output each round — don't create v1, v2, …. After 5 rounds, suggest fine-tuning at mermaid.live.

Examples

Example 1 — API authentication (sequence)

sequenceDiagram
  participant C as Client
  participant G as API Gateway
  participant A as Auth Service
  participant D as Database

  C->>G: POST /login {email, password}
  G->>A: validate(credentials)
  A->>D: SELECT user WHERE email=?
  D-->>A: user record
  A-->>G: 200 OK + JWT token
  G-->>C: {token: "eyJhbG..."}

Render: node scripts/render.mjs -i auth-flow.mmd -o auth-flow.svg --theme tokyo-night

Example 2 — Microservices architecture (flowchart)

flowchart TD
  subgraph Clients
    M[Mobile App]
    W[Web App]
  end
  GW[API Gateway]
  subgraph Services
    US[User Service]
    OS[Order Service]
    PAY[Payment Service]
  end
  subgraph Data
    UDB[(User DB)]
    ODB[(Order DB)]
    REDIS[(Redis Cache)]
  end
  M & W --> GW
  GW --> US & OS & PAY
  US --> UDB
  OS --> ODB
  PAY --> REDIS

Export PNG: mmdc -i ecommerce-arch.mmd -o ecommerce-arch.png -w 2048 --backgroundColor white

Example 3 — Order lifecycle (state)

stateDiagram-v2
  [*] --> Pending : order created
  Pending --> Confirmed : payment success
  Pending --> Cancelled : timeout/cancel
  Confirmed --> Shipped : dispatched
  Shipped --> Delivered : received
  Delivered --> [*]
  Cancelled --> [*]

ASCII for a README: node scripts/render.mjs -i order-states.mmd -f ascii --use-ascii

Common Mistakes

MistakeFix
--------------
mmdc error Could not find Chromenpx puppeteer browsers install chrome-headless-shell (or use Kroki)
Cannot find module 'beautiful-mermaid'Auto-installs on first run; else npm install in the skill root
Kroki PDF fails HTTP 400Kroki does PNG/SVG only for Mermaid; use mmdc for PDF
Wrong arrow in sequence->> request, -->> response
Special chars in labelQuote it: A["Label: value"]
Blank / tiny PNGAdd -w 2048 (mmdc)
Participant order wrongDeclare participant explicitly at top
Subgraph name with spacesQuote it: subgraph "My Layer"

Full backend flags and troubleshooting: RENDERING.md.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-06-09 19:28

安全检测

腾讯云安全 (Keen)

队列中

腾讯云安全 (Sanbu)

队列中

🔗 相关推荐

intimate-ch12-power-violence

junwugit
在对话中辅助学习《亲密关系》第12章“权力与暴力”。基于 Rowland S. Miller《亲密关系》教材第6版,当用户讨论、提问或尝试应用本章核心概念(如社交权力、较少兴趣原则等)时提供帮助。
★ 0 📥 441

intimate-ch02-research-methods

junwugit
在对话中辅助学习《亲密关系》第2章“研究方法”,基于Rowland S. Miller《Intimate Relationships》第6版教材。当用户讨论、提问、复习或尝试应用本章方法论概念(如研究设计、相关分析)时提供帮助。
★ 0 📥 445

job-analysis-intro

junwugit
在对话中帮助学习《工作分析》导论章节,参照 Brannick、Levin、Morgeson 等人的《工作分析》教材第1章。当用户讨论、提问或尝试运用工作分析基础概念(job vs. position、KSAO、duty/task/activ
★ 0 📥 529