AgentSkillsCN

beautiful-mermaid-diagrams

使用 Mermaid 语法创建精美的图表,包括流程图、时序图、类图、ER 图以及状态图。当用户提出绘制图表、进行可视化、建立模型、梳理架构或展示系统、流程、架构及交互逻辑的运行路径时,可选用此技能。

SKILL.md
--- frontmatter
name: beautiful-mermaid-diagrams
description: Create beautiful diagrams using Mermaid syntax including flowcharts, sequence diagrams, class diagrams, ER diagrams, and state diagrams. Use when users ask to diagram, visualize, model, map out, or show the flow of systems, processes, architectures, or interactions.

Beautiful Mermaid Diagrams

Conventions

  • MUST use English for all text in the diagram.

Quick syntax reference

Flowcharts

mermaid
graph TD
  A[Start] --> B[Process] --> C[End]

Sequence diagrams

mermaid
sequenceDiagram
  Alice->>Bob: Hello
  Bob-->>Alice: Hi

Class diagrams

mermaid
classDiagram
  Animal <|-- Duck
  Animal : +String name
  Animal : +int age

ER diagrams

mermaid
erDiagram
  CUSTOMER ||--o{ ORDER : places
  CUSTOMER {int id PK}

Diagram types by use case

Use caseDiagram typeKeywords
Process flowsgraph TD/LRjourneys, algorithms, workflows
API interactionssequenceDiagramrequests, OAuth, transactions
System designclassDiagrammodels, MVC, patterns
Database schemaserDiagramentities, relationships, tables
State machinesstateDiagram-v2lifecycle, workflows, states

Common shapes

ShapeSyntaxDescription
Rectangle[text]Default node
Rounded(text)Rounded corners
Diamond{text}Decision/condition
Stadium([text])Start/end/process
Circle((text))Endpoint
Database[(text)]Data store
Hexagon{{text}}Alternative decision

Edge styles

StyleSyntaxUse case
Solid-->Default flow
Dotted-.->Optional/dashed
Thick==>Highlighted
No arrow---Related only

Examples by type

Styling options

Inline styles

mermaid
graph TD
  A[Node] --> B[Custom]
  style B fill:#3b82f6,stroke:#1d4ed8

Class definitions

mermaid
graph TD
  A:::highlight --> B:::default
  classDef highlight fill:#fbbf24,stroke:#d97706
  classDef default fill:#f4f4f5,stroke:#a1a1aa

Preset color themes

Semantic colors

Use colors to convey meaning consistently across diagrams.

ColorHexMeaningUse for
Green#10b981 / #059669Success, positiveCompleted, approved, active
Red#ef4444 / #dc2626Error, dangerFailed, rejected, error states
Yellow/Orange#f59e0b / #d97706Warning, cautionPending, review needed, alerts
Blue#3b82f6 / #1d4ed8Information, actionLinks, processes, buttons
Gray#6b7280Neutral, disabledInactive, optional, background

Database brand colors

Use brand colors for common database systems.

DatabaseShapeBrand ColorExample
MongoDB[(name)]Green #00ED64DB[(MongoDB)]
PostgreSQL[(name)]Blue #4169E1DB[(PostgreSQL)]
MySQL[(name)]Orange #F29111DB[(MySQL)]
Redis[(name)]Red #DC382DDB[(Redis)]
Elasticsearch[(name)]Yellow #F4B400DB[(Elasticsearch)]
SQLite[(name)]Blue #003B57DB[(SQLite)]

Quick theme presets

Copy these classDef statements for common themes.

Modern blue theme (default for most diagrams):

mermaid
graph TD
  A[Start]:::blue --> B[Process]:::blue --> C[End]:::blue
  classDef blue fill:#3b82f6,stroke:#1d4ed8,color:#fff

Status theme (success/warning/error):

mermaid
graph TD
  A[Success]:::success --> B[Warning]:::warning --> C[Error]:::error
  classDef success fill:#10b981,stroke:#059669,color:#fff
  classDef warning fill:#f59e0b,stroke:#d97706,color:#fff
  classDef error fill:#ef4444,stroke:#dc2626,color:#fff

Architecture theme (frontend/backend/data layers):

mermaid
graph LR
  A[Frontend]:::frontend --> B[Backend]:::backend --> C[(Database)]:::database
  classDef frontend fill:#3b82f6,stroke:#1d4ed8,color:#fff
  classDef backend fill:#8b5cf6,stroke:#7c3aed,color:#fff
  classDef database fill:#00ED64,stroke:#00b33c,color:#000