Use this skill to produce Mermaid diagrams that render cleanly in Markdown, documentation, Obsidian, GitHub, and similar tools.
flowchart: workflows, decisions, systems, pipelines, cause-effect paths.sequenceDiagram: conversations, API calls, handoffs, time-ordered interactions.classDiagram: object models, interfaces, inheritance, module relationships.stateDiagram-v2: state machines, lifecycle transitions, app or order states.erDiagram: database entities and relationships.gantt: schedules and delivery plans.mindmap: topic breakdowns and idea trees.Labels containing :, (), [], {}, @, ;, or , should be wrapped in double quotes.
flowchart LR
A["Function: process(input)"]
B["Array [1, 2, 3]"]
A --> B
end As A Node Idend is a reserved word in flowcharts. Use End, END, or another id.
flowchart TD
Start --> End
Use subgraph ID["Title"], not only subgraph "Title".
flowchart TD
subgraph AUTH["Authentication"]
A["Login"]
B["Check session"]
end
A --> B
Note Only In Sequence DiagramsNote right of A: is valid in sequenceDiagram, but not in flowchart.
sequenceDiagram
participant User
participant API
User->>API: Request
Note right of API: Validate input
For flowcharts, use a normal node instead:
flowchart TD
A["Request"]
N["Note: validate input"]
A --> N
In classDiagram, define referenced classes before relationships.
classDiagram
class Animal {
+String name
+makeSound()
}
class Dog {
+bark()
}
Animal <|-- Dog
flowchart TD
Start["Start"]
Check{"Valid input?"}
Fix["Ask for correction"]
Done["Done"]
Start --> Check
Check -->|Yes| Done
Check -->|No| Fix
Fix --> Check
sequenceDiagram
participant User
participant App
participant API
User->>App: Submit form
App->>API: Send request
API-->>App: Return result
App-->>User: Show status
erDiagram
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ ORDER_ITEM : contains
CUSTOMER {
string id
string name
}
ORDER {
string id
date created_at
}
Before returning a diagram:
subgraph ID["Title"].end.Note appears only inside sequenceDiagram.For common parse errors and fixes, read references/common-errors.md when needed.
共 1 个版本