Process Flow Architecture Lens
Cognitive Mode: Physiological
Primary Question: "How does it behave?"
Focus: Runtime Behavior, State Transitions, Decision Points, Control Flow
When to Use
- Need to understand runtime execution paths
- Documenting state machines or workflows
- Analyzing decision points and branching logic
- User invokes
/arch-lens-process-flow or /make-arch-diag process
Critical Constraints
NEVER:
- Modify any source code files
- Include static structure details (that's C4 lens)
- Show data storage details (that's data lineage lens)
ALWAYS:
- Focus on BEHAVIOR and STATE TRANSITIONS
- Show decision points as diamonds
- Include loop mechanisms and retry logic
- BEFORE creating any diagram, LOAD the
/mermaid skill using the Skill tool - this is MANDATORY
Analysis Workflow
Step 1: Launch Parallel Exploration Subagents
Spawn Explore subagents to investigate:
State Machines & Workflows
- Find state definitions and transitions
- Identify workflow orchestration
- Look for: state machine patterns, workflow graphs, FSM implementations, state enum/constants
Entry Points & Triggers
- Find how processes are started
- Identify triggers and events
- Look for: main(), run(), execute(), start(), call, async handlers
Decision Points
- Find conditional logic that affects flow
- Identify routing functions
- Look for: if/else chains, switch/case, route_*, should_*, can_*, is_*
Loop Mechanisms
- Find iteration and retry patterns
- Identify continuation conditions
- Look for: while, for, retry logic, max_iterations, loop constructs
Terminal States
- Find completion conditions
- Identify error termination
- Look for: return, raise/throw, complete, error, success, failure states
Step 2: Map State Transitions
For each workflow/state machine discovered:
- States/Nodes: List all distinct states
- Transitions: Map state-to-state connections
- Guards: Conditions that determine transitions
- Actions: What happens during transitions
Step 3: Identify Flow Patterns
Document key patterns:
- Linear sequences (A -> B -> C)
- Branches (decision points)
- Loops (with termination conditions)
- Error paths
- Parallel paths (if any)
CRITICAL - Analyze Read/Write Direction:
For EVERY node that interacts with state or storage:
- Reads from: What data does this node consume? From where?
- Writes to: What data does this node produce? To where?
- State mutations: Does it modify in-memory state, database, or files?
Label state interactions on edges:
- "reads" / "loads" / "queries" for input
- "writes" / "saves" / "updates" for output
- Distinguish primary storage (read/write) from write-only artifacts
Step 4: Create the Diagram
Use flowchart with:
Direction: TB for hierarchical flow, LR for sequential processes
Node Types:
([Label]) - Rounded: Start/End terminals
{Label} - Diamond: Decision points
[Label] - Rectangle: Process nodes
[[Label]] - Subroutine: Subgraph calls
Subgraphs for Phases:
- Group related states into phases
- Keep START/END outside subgraphs
Node Styling:
terminal class: START, END, ERROR nodes
phase class: Control flow, analysis nodes
handler class: Processing, execution nodes
stateNode class: Decision, routing nodes
detector class: Validation gates, failure handling
Edge Labels:
- Show conditions on decision branches
- Include loop counts where relevant
Step 5: Write Output
Write the diagram to: temp/arch-lens-process-flow/arch_diag_process_flow_{YYYY-MM-DD_HHMMSS}.md
Output Template
# Process Flow Diagram: {Workflow Name}
**Lens:** Process Flow (Physiological)
**Question:** How does it behave?
**Date:** {YYYY-MM-DD}
**Scope:** {What was analyzed}
## Workflow Overview
| Phase | Nodes | Key Decision Points | Loop Mechanism |
|-------|-------|---------------------|----------------|
| {phase} | {count} | {decisions} | {loop info} |
## Flow Diagram
```mermaid
%%{init: {'flowchart': {'nodeSpacing': 40, 'rankSpacing': 50, 'curve': 'basis'}}}%%
flowchart TB
%% CLASS DEFINITIONS %%
classDef terminal fill:#1a237e,stroke:#7986cb,stroke-width:2px,color:#fff;
classDef stateNode fill:#004d40,stroke:#4db6ac,stroke-width:2px,color:#fff;
classDef handler fill:#e65100,stroke:#ffb74d,stroke-width:2px,color:#fff;
classDef phase fill:#6a1b9a,stroke:#ba68c8,stroke-width:2px,color:#fff;
classDef detector fill:#b71c1c,stroke:#ef5350,stroke-width:2px,color:#fff;
%% TERMINALS %%
START([START])
COMPLETE([COMPLETE])
ERROR([ERROR])
subgraph Phase1 ["Phase Name"]
direction TB
N1["Node Name<br/>━━━━━━━━━━<br/>Description"]
N2{"Decision<br/>━━━━━━━━━━<br/>Condition?"}
N3["Process Node<br/>━━━━━━━━━━<br/>Action"]
end
%% FLOW %%
START --> N1
N1 --> N2
N2 -->|"condition A"| N3
N2 -->|"condition B"| ERROR
N3 --> COMPLETE
%% CLASS ASSIGNMENTS %%
class START,COMPLETE,ERROR terminal;
class N1,N3 handler;
class N2 stateNode;
Color Legend:
| Color |
Category |
Description |
| Dark Blue |
Terminal |
Start, complete, and error states |
| Purple |
Phase |
Control flow and analysis nodes |
| Orange |
Handler |
Processing and execution nodes |
| Teal |
State |
Selection and routing decisions |
| Red |
Detector |
Validation gates and failure handling |
State Machine Characteristics
| Aspect |
Value |
Notes |
| Total Nodes |
{count} |
|
| Decision Points |
{count} |
|
| Loop Mechanism |
{description} |
{max iterations} |
| Error Paths |
{count} |
|
Critical Routing Logic
- Condition A: {what triggers this path}
- Condition B: {what triggers this path}
---
## Pre-Diagram Checklist
Before creating the diagram, verify:
- [ ] LOADED `/mermaid` skill using the Skill tool
- [ ] Using ONLY classDef styles from the mermaid skill (no invented colors)
- [ ] Diagram will include a color legend table
---
## Related Skills
- `/make-arch-diag` - Parent skill for lens selection
- `/mermaid` - MUST BE LOADED before creating diagram
- `/arch-lens-concurrency` - For parallel execution details
- `/arch-lens-error-resilience` - For failure handling specifics
1---2name: arch-lens-process-flow3description: Create Process/Execution Flow architecture diagram showing runtime behavior, state transitions, and decision points. Physiological lens answering "How does it behave?"4---56# Process Flow Architecture Lens78**Cognitive Mode:** Physiological9**Primary Question:** "How does it behave?"10**Focus:** Runtime Behavior, State Transitions, Decision Points, Control Flow1112## When to Use1314- Need to understand runtime execution paths15- Documenting state machines or workflows16- Analyzing decision points and branching logic17- User invokes `/arch-lens-process-flow` or `/make-arch-diag process`1819## Critical Constraints2021**NEVER:**22- Modify any source code files23- Include static structure details (that's C4 lens)24- Show data storage details (that's data lineage lens)2526**ALWAYS:**27- Focus on BEHAVIOR and STATE TRANSITIONS28- Show decision points as diamonds29- Include loop mechanisms and retry logic30- BEFORE creating any diagram, LOAD the `/mermaid` skill using the Skill tool - this is MANDATORY3132---3334## Analysis Workflow3536### Step 1: Launch Parallel Exploration Subagents3738Spawn Explore subagents to investigate:3940**State Machines & Workflows**41- Find state definitions and transitions42- Identify workflow orchestration43- Look for: state machine patterns, workflow graphs, FSM implementations, state enum/constants4445**Entry Points & Triggers**46- Find how processes are started47- Identify triggers and events48- Look for: main(), run(), execute(), start(), __call__, async handlers4950**Decision Points**51- Find conditional logic that affects flow52- Identify routing functions53- Look for: if/else chains, switch/case, route_*, should_*, can_*, is_*5455**Loop Mechanisms**56- Find iteration and retry patterns57- Identify continuation conditions58- Look for: while, for, retry logic, max_iterations, loop constructs5960**Terminal States**61- Find completion conditions62- Identify error termination63- Look for: return, raise/throw, complete, error, success, failure states6465### Step 2: Map State Transitions6667For each workflow/state machine discovered:68- **States/Nodes**: List all distinct states69- **Transitions**: Map state-to-state connections70- **Guards**: Conditions that determine transitions71- **Actions**: What happens during transitions7273### Step 3: Identify Flow Patterns7475Document key patterns:76- Linear sequences (A -> B -> C)77- Branches (decision points)78- Loops (with termination conditions)79- Error paths80- Parallel paths (if any)8182**CRITICAL - Analyze Read/Write Direction:**83For EVERY node that interacts with state or storage:84- **Reads from**: What data does this node consume? From where?85- **Writes to**: What data does this node produce? To where?86- **State mutations**: Does it modify in-memory state, database, or files?8788Label state interactions on edges:89- "reads" / "loads" / "queries" for input90- "writes" / "saves" / "updates" for output91- Distinguish primary storage (read/write) from write-only artifacts9293### Step 4: Create the Diagram9495Use flowchart with:9697**Direction:** `TB` for hierarchical flow, `LR` for sequential processes9899**Node Types:**100- `([Label])` - Rounded: Start/End terminals101- `{Label}` - Diamond: Decision points102- `[Label]` - Rectangle: Process nodes103- `[[Label]]` - Subroutine: Subgraph calls104105**Subgraphs for Phases:**106- Group related states into phases107- Keep START/END outside subgraphs108109**Node Styling:**110- `terminal` class: START, END, ERROR nodes111- `phase` class: Control flow, analysis nodes112- `handler` class: Processing, execution nodes113- `stateNode` class: Decision, routing nodes114- `detector` class: Validation gates, failure handling115116**Edge Labels:**117- Show conditions on decision branches118- Include loop counts where relevant119120### Step 5: Write Output121122Write the diagram to: `temp/arch-lens-process-flow/arch_diag_process_flow_{YYYY-MM-DD_HHMMSS}.md`123124---125126## Output Template127128```markdown129# Process Flow Diagram: {Workflow Name}130131**Lens:** Process Flow (Physiological)132**Question:** How does it behave?133**Date:** {YYYY-MM-DD}134**Scope:** {What was analyzed}135136## Workflow Overview137138| Phase | Nodes | Key Decision Points | Loop Mechanism |139|-------|-------|---------------------|----------------|140| {phase} | {count} | {decisions} | {loop info} |141142## Flow Diagram143144```mermaid145%%{init: {'flowchart': {'nodeSpacing': 40, 'rankSpacing': 50, 'curve': 'basis'}}}%%146flowchart TB147 %% CLASS DEFINITIONS %%148 classDef terminal fill:#1a237e,stroke:#7986cb,stroke-width:2px,color:#fff;149 classDef stateNode fill:#004d40,stroke:#4db6ac,stroke-width:2px,color:#fff;150 classDef handler fill:#e65100,stroke:#ffb74d,stroke-width:2px,color:#fff;151 classDef phase fill:#6a1b9a,stroke:#ba68c8,stroke-width:2px,color:#fff;152 classDef detector fill:#b71c1c,stroke:#ef5350,stroke-width:2px,color:#fff;153154 %% TERMINALS %%155 START([START])156 COMPLETE([COMPLETE])157 ERROR([ERROR])158159 subgraph Phase1 ["Phase Name"]160 direction TB161 N1["Node Name<br/>━━━━━━━━━━<br/>Description"]162 N2{"Decision<br/>━━━━━━━━━━<br/>Condition?"}163 N3["Process Node<br/>━━━━━━━━━━<br/>Action"]164 end165166 %% FLOW %%167 START --> N1168 N1 --> N2169 N2 -->|"condition A"| N3170 N2 -->|"condition B"| ERROR171 N3 --> COMPLETE172173 %% CLASS ASSIGNMENTS %%174 class START,COMPLETE,ERROR terminal;175 class N1,N3 handler;176 class N2 stateNode;177```178179**Color Legend:**180| Color | Category | Description |181|-------|----------|-------------|182| Dark Blue | Terminal | Start, complete, and error states |183| Purple | Phase | Control flow and analysis nodes |184| Orange | Handler | Processing and execution nodes |185| Teal | State | Selection and routing decisions |186| Red | Detector | Validation gates and failure handling |187188## State Machine Characteristics189190| Aspect | Value | Notes |191|--------|-------|-------|192| Total Nodes | {count} | |193| Decision Points | {count} | |194| Loop Mechanism | {description} | {max iterations} |195| Error Paths | {count} | |196197## Critical Routing Logic198199- **Condition A**: {what triggers this path}200- **Condition B**: {what triggers this path}201```202203---204205## Pre-Diagram Checklist206207Before creating the diagram, verify:208209- [ ] LOADED `/mermaid` skill using the Skill tool210- [ ] Using ONLY classDef styles from the mermaid skill (no invented colors)211- [ ] Diagram will include a color legend table212213---214215## Related Skills216217- `/make-arch-diag` - Parent skill for lens selection218- `/mermaid` - MUST BE LOADED before creating diagram219- `/arch-lens-concurrency` - For parallel execution details220- `/arch-lens-error-resilience` - For failure handling specifics