Skill Tracer
Skills › Scientific Agent Skills › markdown-mermaid-writing › flowchart.md

flowchart.md

182 lines · skills/markdown-mermaid-writing/references/diagrams/flowchart.md at 5f2bc03

Open on GitHub
1<!-- Source: https://github.com/SuperiorByteWorks-LLC/agent-project | License: Apache-2.0 | Author: Clayton Young / Superior Byte Works, LLC (Boreal Bytes) -->
2
3# Flowchart
4
5> **Back to [Style Guide](../mermaid_style_guide.md)** — Read the style guide first for emoji, color, and accessibility rules.
6
7**Syntax keyword:** `flowchart`
8**Best for:** Sequential processes, workflows, decision logic, troubleshooting trees
9**When NOT to use:** Complex timing between actors (use [Sequence](sequence.md)), state machines (use [State](state.md))
11---

<!-- Source: https://github.com/SuperiorByteWorks-LLC/agent-project | License: Apache-2.0 | Author: Clayton Young / Superior Byte Works, LLC (Boreal Bytes) -->

Flowchart

Back to Style Guide — Read the style guide first for emoji, color, and accessibility rules.

Syntax keyword: flowchart Best for: Sequential processes, workflows, decision logic, troubleshooting trees When NOT to use: Complex timing between actors (use Sequence), state machines (use State)


Raw lines 1 to 12
13## Exemplar Diagram
15```mermaid
16flowchart TB
17 accTitle: Feature Development Lifecycle
18 accDescr: End-to-end feature flow from idea through design, build, test, review, and release with a revision loop on failed reviews
20 idea([💡 Feature idea]) --> spec[📋 Write spec]
21 spec --> design[🎨 Design solution]
22 design --> build[🔧 Implement]
23 build --> test[🧪 Run tests]
24 test --> review{🔍 Review passed?}
25 review -->|Yes| release[🚀 Release to prod]
26 review -->|No| revise[✏️ Revise code]
27 revise --> test
28 release --> monitor([📊 Monitor metrics])
30 classDef start fill:#ede9fe,stroke:#7c3aed,stroke-width:2px,color:#3b0764
31 classDef process fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#1e3a5f
32 classDef decision fill:#fef9c3,stroke:#ca8a04,stroke-width:2px,color:#713f12
33 classDef success fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d
35 class idea,monitor start
36 class spec,design,build,test,revise process
37 class review decision
38 class release success
39```
41---

Exemplar Diagram

flowchart TB
    accTitle: Feature Development Lifecycle
    accDescr: End-to-end feature flow from idea through design, build, test, review, and release with a revision loop on failed reviews

    idea([💡 Feature idea]) --> spec[📋 Write spec]
    spec --> design[🎨 Design solution]
    design --> build[🔧 Implement]
    build --> test[🧪 Run tests]
    test --> review{🔍 Review passed?}
    review -->|Yes| release[🚀 Release to prod]
    review -->|No| revise[✏️ Revise code]
    revise --> test
    release --> monitor([📊 Monitor metrics])

    classDef start fill:#ede9fe,stroke:#7c3aed,stroke-width:2px,color:#3b0764
    classDef process fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#1e3a5f
    classDef decision fill:#fef9c3,stroke:#ca8a04,stroke-width:2px,color:#713f12
    classDef success fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d

    class idea,monitor start
    class spec,design,build,test,revise process
    class review decision
    class release success

Raw lines 13 to 42
43## Tips
45- Use `TB` (top-to-bottom) for processes, `LR` (left-to-right) for pipelines
46- Rounded rectangles `([text])` for start/end, diamonds `{text}` for decisions
47- Max 10 nodes — split larger flows into "Phase 1" / "Phase 2" diagrams
48- Max 3 decision points per diagram
49- Edge labels should be 1–4 words: `-->|Yes|`, `-->|All green|`
50- Use `classDef` for **semantic** coloring — decisions in amber, success in green, actions in blue

Tips

  • Use TB (top-to-bottom) for processes, LR (left-to-right) for pipelines
  • Rounded rectangles ([text]) for start/end, diamonds {text} for decisions
  • Max 10 nodes — split larger flows into "Phase 1" / "Phase 2" diagrams
  • Max 3 decision points per diagram
  • Edge labels should be 1–4 words: -->|Yes|, -->|All green|
  • Use classDef for semantic coloring — decisions in amber, success in green, actions in blue
Raw lines 43 to 51
52## Subgraph Pattern
54When you need grouped stages:
56```mermaid
57flowchart TB
58 accTitle: CI/CD Pipeline Stages
59 accDescr: Three-stage pipeline grouping code quality checks, testing, and deployment into distinct phases
61 trigger([⚡ Push to main])
63 subgraph quality ["🔍 Code Quality"]
64 lint[📝 Lint code] --> format[⚙️ Check formatting]
65 end
67 subgraph testing ["🧪 Testing"]
68 unit[🧪 Unit tests] --> integration[🔗 Integration tests]
69 end
71 subgraph deploy ["🚀 Deployment"]
72 build[📦 Build artifacts] --> ship[☁️ Deploy to staging]
73 end
75 trigger --> quality
76 quality --> testing
77 testing --> deploy
78 deploy --> done([✅ Pipeline complete])
80 classDef trigger_style fill:#ede9fe,stroke:#7c3aed,stroke-width:2px,color:#3b0764
81 classDef success fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d
83 class trigger trigger_style
84 class done success
85```
87---

Subgraph Pattern

When you need grouped stages:

flowchart TB
    accTitle: CI/CD Pipeline Stages
    accDescr: Three-stage pipeline grouping code quality checks, testing, and deployment into distinct phases

    trigger([⚡ Push to main])

    subgraph quality ["🔍 Code Quality"]
        lint[📝 Lint code] --> format[⚙️ Check formatting]
    end

    subgraph testing ["🧪 Testing"]
        unit[🧪 Unit tests] --> integration[🔗 Integration tests]
    end

    subgraph deploy ["🚀 Deployment"]
        build[📦 Build artifacts] --> ship[☁️ Deploy to staging]
    end

    trigger --> quality
    quality --> testing
    testing --> deploy
    deploy --> done([✅ Pipeline complete])

    classDef trigger_style fill:#ede9fe,stroke:#7c3aed,stroke-width:2px,color:#3b0764
    classDef success fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d

    class trigger trigger_style
    class done success

Raw lines 52 to 88
89## Template
91```mermaid
92flowchart TB
93 accTitle: Your Title Here (3-8 words)
94 accDescr: One or two sentences explaining what this diagram shows and what insight the reader gains
96 start([🏁 Starting point]) --> step1[⚙️ First action]
97 step1 --> decision{🔍 Check condition?}
98 decision -->|Yes| step2[✅ Positive path]
99 decision -->|No| step3[🔧 Alternative path]
100 step2 --> done([🏁 Complete])
101 step3 --> done
102```
104---

Template

flowchart TB
    accTitle: Your Title Here (3-8 words)
    accDescr: One or two sentences explaining what this diagram shows and what insight the reader gains

    start([🏁 Starting point]) --> step1[⚙️ First action]
    step1 --> decision{🔍 Check condition?}
    decision -->|Yes| step2[✅ Positive path]
    decision -->|No| step3[🔧 Alternative path]
    step2 --> done([🏁 Complete])
    step3 --> done

Raw lines 89 to 105
106## Complex Example
108A 20+ node e-commerce order pipeline organized into 5 subgraphs, each representing a processing phase. Subgraphs connect through internal nodes, decision points route orders to exception handling, and color classes distinguish phases at a glance.
110```mermaid
111flowchart TB
112 accTitle: E-Commerce Order Processing Pipeline
113 accDescr: Full order lifecycle from intake through fulfillment, shipping, and notification with exception handling paths for payment failures, stockouts, and delivery issues
115 order_in([📥 New order]) --> validate_pay{💰 Payment valid?}
117 subgraph intake ["📥 Order Intake"]
118 validate_pay -->|Yes| check_fraud{🔐 Fraud check}
119 validate_pay -->|No| pay_fail[❌ Payment declined]
120 check_fraud -->|Clear| check_stock{📦 In stock?}
121 check_fraud -->|Flagged| manual_review[🔍 Manual review]
122 manual_review --> check_stock
123 end
125 subgraph fulfill ["📦 Fulfillment"]
126 pick[📋 Pick items] --> pack[📦 Pack order]
127 pack --> label[🏷️ Generate shipping label]
128 end
130 subgraph ship ["🚚 Shipping"]
131 handoff[🚚 Carrier handoff] --> transit[📍 In transit]
132 transit --> deliver{✅ Delivered?}
133 end
135 subgraph notify ["📤 Notifications"]
136 confirm_email[📧 Order confirmed]
137 ship_update[📧 Shipping update]
138 deliver_email[📧 Delivery confirmed]
139 end
141 subgraph exception ["⚠️ Exception Handling"]
142 pay_fail --> retry_pay[🔄 Retry payment]
143 retry_pay --> validate_pay
144 out_of_stock[📦 Backorder created]
145 deliver_fail[🔄 Reattempt delivery]
146 end
148 check_stock -->|Yes| pick
149 check_stock -->|No| out_of_stock
150 label --> handoff
151 deliver -->|Yes| deliver_email
152 deliver -->|No| deliver_fail
153 deliver_fail --> transit
155 check_stock -->|Yes| confirm_email
156 handoff --> ship_update
157 deliver_email --> complete([✅ Order complete])
159 classDef intake_style fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#1e3a5f
160 classDef fulfill_style fill:#ede9fe,stroke:#7c3aed,stroke-width:2px,color:#3b0764
161 classDef ship_style fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d
162 classDef warn_style fill:#fef9c3,stroke:#ca8a04,stroke-width:2px,color:#713f12
163 classDef danger_style fill:#fee2e2,stroke:#dc2626,stroke-width:2px,color:#7f1d1d
165 class validate_pay,check_fraud,check_stock,manual_review intake_style
166 class pick,pack,label fulfill_style
167 class handoff,transit,deliver ship_style
168 class confirm_email,ship_update,deliver_email warn_style
169 class pay_fail,retry_pay,out_of_stock,deliver_fail danger_style
170```

Complex Example

A 20+ node e-commerce order pipeline organized into 5 subgraphs, each representing a processing phase. Subgraphs connect through internal nodes, decision points route orders to exception handling, and color classes distinguish phases at a glance.

flowchart TB
    accTitle: E-Commerce Order Processing Pipeline
    accDescr: Full order lifecycle from intake through fulfillment, shipping, and notification with exception handling paths for payment failures, stockouts, and delivery issues

    order_in([📥 New order]) --> validate_pay{💰 Payment valid?}

    subgraph intake ["📥 Order Intake"]
        validate_pay -->|Yes| check_fraud{🔐 Fraud check}
        validate_pay -->|No| pay_fail[❌ Payment declined]
        check_fraud -->|Clear| check_stock{📦 In stock?}
        check_fraud -->|Flagged| manual_review[🔍 Manual review]
        manual_review --> check_stock
    end

    subgraph fulfill ["📦 Fulfillment"]
        pick[📋 Pick items] --> pack[📦 Pack order]
        pack --> label[🏷️ Generate shipping label]
    end

    subgraph ship ["🚚 Shipping"]
        handoff[🚚 Carrier handoff] --> transit[📍 In transit]
        transit --> deliver{✅ Delivered?}
    end

    subgraph notify ["📤 Notifications"]
        confirm_email[📧 Order confirmed]
        ship_update[📧 Shipping update]
        deliver_email[📧 Delivery confirmed]
    end

    subgraph exception ["⚠️ Exception Handling"]
        pay_fail --> retry_pay[🔄 Retry payment]
        retry_pay --> validate_pay
        out_of_stock[📦 Backorder created]
        deliver_fail[🔄 Reattempt delivery]
    end

    check_stock -->|Yes| pick
    check_stock -->|No| out_of_stock
    label --> handoff
    deliver -->|Yes| deliver_email
    deliver -->|No| deliver_fail
    deliver_fail --> transit

    check_stock -->|Yes| confirm_email
    handoff --> ship_update
    deliver_email --> complete([✅ Order complete])

    classDef intake_style fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#1e3a5f
    classDef fulfill_style fill:#ede9fe,stroke:#7c3aed,stroke-width:2px,color:#3b0764
    classDef ship_style fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d
    classDef warn_style fill:#fef9c3,stroke:#ca8a04,stroke-width:2px,color:#713f12
    classDef danger_style fill:#fee2e2,stroke:#dc2626,stroke-width:2px,color:#7f1d1d

    class validate_pay,check_fraud,check_stock,manual_review intake_style
    class pick,pack,label fulfill_style
    class handoff,transit,deliver ship_style
    class confirm_email,ship_update,deliver_email warn_style
    class pay_fail,retry_pay,out_of_stock,deliver_fail danger_style
Raw lines 106 to 171
172### Why this works
174- **5 subgraphs map to real business phases** — intake, fulfillment, shipping, notification, and exceptions are how operations teams actually think about orders
175- **Exception handling is its own subgraph** — not scattered across phases. Agents and readers can see all failure paths in one place
176- **Color classes reinforce structure** — blue for intake, purple for fulfillment, green for shipping, amber for notifications, red for exceptions. Even without reading labels, the color pattern tells you which phase you're looking at
177- **Decisions route between subgraphs** — the diamonds (`{Payment valid?}`, `{In stock?}`, `{Delivered?}`) are the points where flow branches, and each branch leads to a clearly-labeled destination

Why this works

  • 5 subgraphs map to real business phases — intake, fulfillment, shipping, notification, and exceptions are how operations teams actually think about orders
  • Exception handling is its own subgraph — not scattered across phases. Agents and readers can see all failure paths in one place
  • Color classes reinforce structure — blue for intake, purple for fulfillment, green for shipping, amber for notifications, red for exceptions. Even without reading labels, the color pattern tells you which phase you're looking at
  • Decisions route between subgraphs — the diamonds ({Payment valid?}, {In stock?}, {Delivered?}) are the points where flow branches, and each branch leads to a clearly-labeled destination
Raw lines 172 to 179
180## Verified reference
182Syntax examples reviewed against [official Mermaid documentation](https://mermaid.js.org/syntax/flowchart.html) and rendered with Mermaid 12.0.0 (2026-10-01). Check the destination version; appearance and accessibility are not guaranteed by a successful parse.

Verified reference

Syntax examples reviewed against official Mermaid documentation and rendered with Mermaid 12.0.0 (2026-10-01). Check the destination version; appearance and accessibility are not guaranteed by a successful parse.

Raw lines 180 to 182