Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Create flowcharts, sequence diagrams, and architecture diagrams with Mermaid
.claude/skills/brycewang-stanford-mermaid-diagram-guide/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-18 | ✗→✓ | ▲ Improved | 119% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 326% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 508% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 363% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 859% | 0% |
Mermaid is a text-based diagramming tool that renders diagrams from Markdown-like syntax. For researchers, Mermaid offers a unique combination of version-controllable source code, instant rendering in documentation platforms (GitHub, GitLab, Notion, Obsidian), and enough expressiveness to create flowcharts, sequence diagrams, class diagrams, Gantt charts, and more.
Unlike graphical tools like draw.io or Lucidchart, Mermaid diagrams live as plain text in your documentation, making them easy to maintain alongside code and papers. They are especially valuable for research documentation, README files, software architecture diagrams in methods sections, and graphical abstracts.
This guide covers the most useful Mermaid diagram types for academic work, with complete syntax references and real-world examples from research contexts. Each diagram type includes a template you can copy and modify for your specific needs.
Flowcharts are the most common diagram type for describing algorithms, experimental procedures, and data processing pipelines.
mermaidflowchart TD A[Start] --> B{Decision} B -->|Yes| C[Process A] B -->|No| D[Process B] C --> E[End] D --> E
| Shape | Syntax | Use Case | |-------|--------|----------| | Rectangle | A[text] | Process step | | Rounded | A(text) | Start/end | | Diamond | A{text} | Decision | | Hexagon | A{{text}} | Preparation | | Parallelogram | A[/text/] | Input/output | | Circle | A((text)) | Connector | | Stadium | A([text]) | Terminal |
mermaidflowchart TD subgraph Data Collection A[Raw Data] --> B[Quality Check] B --> C{Pass QC?} C -->|No| D[Exclude] C -->|Yes| E[Clean Data] end subgraph Analysis E --> F[Feature Extraction] F --> G[Model Training] G --> H[Cross-Validation] end subgraph Evaluation H --> I{Significant?} I -->|Yes| J[Report Results] I -->|No| K[Revise Hypothesis] K --> F end style A fill:#3B82F6,color:#fff style J fill:#16A34A,color:#fff style D fill:#EF4444,color:#fff
| Direction | Code | Description | |-----------|------|-------------| | Top to bottom | TD or TB | Default, vertical | | Bottom to top | BT | Vertical, upward | | Left to right | LR | Horizontal | | Right to left | RL | Horizontal, reversed |
Sequence diagrams show interactions between components over time. They are ideal for describing API calls, protocol steps, and system interactions.
mermaidsequenceDiagram participant U as User participant F as Frontend participant A as API Server participant DB as Database U->>F: Submit experiment F->>A: POST /experiments A->>DB: INSERT experiment DB-->>A: experiment_id A->>A: Queue processing job Note over A: Async processing begins A-->>F: 202 Accepted {id} F-->>U: "Experiment submitted" loop Every 5 seconds F->>A: GET /experiments/{id}/status A-->>F: {status: "running"} end A-->>F: {status: "complete", results: {...}} F-->>U: Display results
| Arrow | Syntax | Meaning | |-------|--------|---------| | Solid with arrowhead | ->> | Synchronous call | | Dotted with arrowhead | -->> | Response/return | | Solid | -> | Message | | Dotted | --> | Optional message | | Cross | -x | Failed message |
Class diagrams document code architecture and data models:
mermaidclassDiagram class Experiment { +String id +String name +DateTime created_at +Status status +run() +get_results() Results } class Dataset { +String path +int n_samples +int n_features +load() DataFrame +split(ratio) TrainTest } class Model { +String architecture +Dict hyperparams +train(Dataset) +predict(Dataset) Array +evaluate(Dataset) Metrics } Experiment "1" --> "1..*" Dataset : uses Experiment "1" --> "1..*" Model : trains Model ..> Dataset : depends on
Gantt charts are useful for project timelines and research plans:
mermaidgantt title Research Project Timeline dateFormat YYYY-MM-DD axisFormat %b %Y section Literature Review Survey existing work :done, lit1, 2026-01-01, 30d Identify research gap :done, lit2, after lit1, 14d section Methodology Design experiments :active, meth1, after lit2, 21d Implement baseline :meth2, after meth1, 14d section Experiments Run baseline experiments :exp1, after meth2, 21d Run proposed method :exp2, after exp1, 21d Ablation studies :exp3, after exp2, 14d section Writing Draft paper :write1, after exp2, 30d Internal review :write2, after write1, 14d Submit to conference :milestone, after write2, 0d
State diagrams model entity lifecycles:
mermaidstateDiagram-v2 [*] --> Draft Draft --> UnderReview : Submit UnderReview --> MinorRevision : Reviewer feedback UnderReview --> MajorRevision : Reviewer feedback UnderReview --> Rejected : Reviewer feedback MinorRevision --> UnderReview : Resubmit MajorRevision --> UnderReview : Resubmit UnderReview --> Accepted : Final decision Accepted --> Published : Camera-ready Rejected --> Draft : Revise for new venue Published --> [*]
Both platforms render Mermaid natively in Markdown files:
`markdown
flowchart LR A --> B --> C
bash# Install Mermaid CLI npm install -g @mermaid-js/mermaid-cli # Render to PNG mmdc -i diagram.mmd -o diagram.png -w 1200 # Render to SVG (preferred for papers) mmdc -i diagram.mmd -o diagram.svg # Render to PDF mmdc -i diagram.mmd -o diagram.pdf
latex% Include the SVG generated by mmdc \usepackage{svg} \begin{figure}[h] \centering \includesvg[width=0.8\textwidth]{diagram} \caption{System architecture overview.} \end{figure}
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | pass→pass | 4,185 | 33,464 | +700% | 1 | 1 | 0% | 583 | 2,484 | +326% | 0 | 0 | — |
case-02 | pass→pass | 2,866 | 32,806 | +1045% | 1 | 1 | 0% | 399 | 2,425 | +508% | 0 | 0 | — |
case-03 | pass→pass | 33,366 | 3,989 | -88% | 1 | 1 | 0% | 541 | 2,507 | +363% | 0 | 0 | — |
case-04 | pass→pass | 1,730 | 3,518 | +103% | 1 | 1 | 0% | 260 | 2,493 | +859% | 0 | 0 | — |
case-05 | pass→pass | 1,712 | 1,962 | +15% | 1 | 1 | 0% | 260 | 2,208 | +749% | 0 | 0 | — |
case-06 | pass→pass | 2,765 | 1,633 | -41% | 1 | 1 | 0% | 314 | 2,248 | +616% | 0 | 0 | — |
case-07 | pass→pass | 3,517 | 4,965 | +41% | 1 | 1 | 0% | 536 | 2,573 | +380% | 0 | 0 | — |
case-08 | pass→pass | 3,264 | 2,025 | -38% | 1 | 1 | 0% | 497 | 2,364 | +376% | 0 | 0 | — |
case-09 | pass→pass | 4,048 | 4,552 | +12% | 1 | 1 | 0% | 522 | 2,563 | +391% | 0 | 0 | — |
case-10 | pass→pass | 35,635 | 2,396 | -93% | 1 | 1 | 0% | 793 | 2,347 | +196% | 0 | 0 | — |
case-11 | pass→pass | 4,285 | 3,666 | -14% | 1 | 1 | 0% | 764 | 2,572 | +237% | 0 | 0 | — |
case-12 | pass→pass | 32,399 | 2,505 | -92% | 1 | 1 | 0% | 409 | 2,431 | +494% | 0 | 0 | — |
case-13 | pass→pass | 3,060 | 4,531 | +48% | 1 | 1 | 0% | 534 | 2,804 | +425% | 0 | 0 | — |
case-14 | pass→pass | 2,149 | 2,491 | +16% | 1 | 1 | 0% | 250 | 2,354 | +842% | 0 | 0 | — |
case-15 | pass→pass | 7,900 | 5,305 | -33% | 1 | 1 | 0% | 1,366 | 2,909 | +113% | 0 | 0 | — |
case-16 | pass→pass | 6,679 | 3,593 | -46% | 1 | 1 | 0% | 992 | 2,727 | +175% | 0 | 0 | — |
case-17 | pass→pass | 5,941 | 3,886 | -35% | 1 | 1 | 0% | 840 | 2,557 | +204% | 0 | 0 | — |
case-18 | fail→pass | 10,118 | 8,626 | -15% | 1 | 1 | 0% | 1,583 | 3,469 | +119% | 0 | 0 | — |
case-19 | pass→pass | 2,309 | 3,017 | +31% | 1 | 1 | 0% | 500 | 2,400 | +380% | 0 | 0 | — |
case-20 | pass→pass | 3,274 | 2,568 | -22% | 1 | 1 | 0% | 569 | 2,451 | +331% | 0 | 0 | — |
case-21 | pass→pass | 5,646 | 3,798 | -33% | 1 | 1 | 0% | 791 | 2,590 | +227% | 0 | 0 | — |
case-22 | pass→pass | 12,165 | 2,685 | -78% | 1 | 1 | 0% | 1,637 | 2,310 | +41% | 0 | 0 | — |
case-23 | pass→pass | 2,489 | 3,804 | +53% | 1 | 1 | 0% | 413 | 2,450 | +493% | 0 | 0 | — |
case-24 | pass→pass | 2,064 | 2,036 | -1% | 1 | 1 | 0% | 328 | 2,309 | +604% | 0 | 0 | — |
case-25 | fail→fail | 6,806 | 4,100 | -40% | 1 | 1 | 0% | 885 | 2,711 | +206% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 25 cases were attempted. The headline lift of +4 percentage points is the difference between those two pass rates over the 25 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.