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
/autoskillit:arch-lens-process-flow or /autoskillit: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
/autoskillit: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 (relative to the current working directory)
After writing the diagram file, emit a structured output line:
diagram_path = {absolute_path_to_diagram_file}
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 `/autoskillit: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
- `/autoskillit:make-arch-diag` - Parent skill for lens selection
- `/autoskillit:mermaid` - MUST BE LOADED before creating diagram
- `/autoskillit:arch-lens-concurrency` - For parallel execution details
- `/autoskillit: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---5
6# Process Flow Architecture Lens
7
8**Cognitive Mode:** Physiological
9**Primary Question:** "How does it behave?"
10**Focus:** Runtime Behavior, State Transitions, Decision Points, Control Flow
11
12## When to Use
13
14- Need to understand runtime execution paths
15- Documenting state machines or workflows
16- Analyzing decision points and branching logic
17- User invokes `/autoskillit:arch-lens-process-flow` or `/autoskillit:make-arch-diag process`
18
19## Critical Constraints
20
21**NEVER:**
22- Modify any source code files
23- Include static structure details (that's C4 lens)
24- Show data storage details (that's data lineage lens)
25
26**ALWAYS:**
27- Focus on BEHAVIOR and STATE TRANSITIONS
28- Show decision points as diamonds
29- Include loop mechanisms and retry logic
30- BEFORE creating any diagram, LOAD the `/autoskillit:mermaid` skill using the Skill tool - this is MANDATORY
31
32---
33
34## Analysis Workflow
35
36### Step 1: Launch Parallel Exploration Subagents
37
38Spawn Explore subagents to investigate:
39
40**State Machines & Workflows**
41- Find state definitions and transitions
42- Identify workflow orchestration
43- Look for: state machine patterns, workflow graphs, FSM implementations, state enum/constants
44
45**Entry Points & Triggers**
46- Find how processes are started
47- Identify triggers and events
48- Look for: main(), run(), execute(), start(), __call__, async handlers
49
50**Decision Points**
51- Find conditional logic that affects flow
52- Identify routing functions
53- Look for: if/else chains, switch/case, route_*, should_*, can_*, is_*
54
55**Loop Mechanisms**
56- Find iteration and retry patterns
57- Identify continuation conditions
58- Look for: while, for, retry logic, max_iterations, loop constructs
59
60**Terminal States**
61- Find completion conditions
62- Identify error termination
63- Look for: return, raise/throw, complete, error, success, failure states
64
65### Step 2: Map State Transitions
66
67For each workflow/state machine discovered:
68- **States/Nodes**: List all distinct states
69- **Transitions**: Map state-to-state connections
70- **Guards**: Conditions that determine transitions
71- **Actions**: What happens during transitions
72
73### Step 3: Identify Flow Patterns
74
75Document key patterns:
76- Linear sequences (A -> B -> C)
77- Branches (decision points)
78- Loops (with termination conditions)
79- Error paths
80- Parallel paths (if any)
81
82**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?
87
88Label state interactions on edges:
89- "reads" / "loads" / "queries" for input
90- "writes" / "saves" / "updates" for output
91- Distinguish primary storage (read/write) from write-only artifacts
92
93### Step 4: Create the Diagram
94
95Use flowchart with:
96
97**Direction:** `TB` for hierarchical flow, `LR` for sequential processes
98
99**Node Types:**
100- `([Label])` - Rounded: Start/End terminals
101- `{Label}` - Diamond: Decision points
102- `[Label]` - Rectangle: Process nodes
103- `[[Label]]` - Subroutine: Subgraph calls
104
105**Subgraphs for Phases:**
106- Group related states into phases
107- Keep START/END outside subgraphs
108
109**Node Styling:**
110- `terminal` class: START, END, ERROR nodes
111- `phase` class: Control flow, analysis nodes
112- `handler` class: Processing, execution nodes
113- `stateNode` class: Decision, routing nodes
114- `detector` class: Validation gates, failure handling
115
116**Edge Labels:**
117- Show conditions on decision branches
118- Include loop counts where relevant
119
120### Step 5: Write Output
121
122Write the diagram to: `temp/arch-lens-process-flow/arch_diag_process_flow_{YYYY-MM-DD_HHMMSS}.md` (relative to the current working directory)
123
124After writing the diagram file, emit a structured output line:
125
126```
127diagram_path = {absolute_path_to_diagram_file}
128```
129
130---
131
132## Output Template
133
134```markdown
135# Process Flow Diagram: {Workflow Name}
136
137**Lens:** Process Flow (Physiological)
138**Question:** How does it behave?
139**Date:** {YYYY-MM-DD}
140**Scope:** {What was analyzed}
141
142## Workflow Overview
143
144| Phase | Nodes | Key Decision Points | Loop Mechanism |
145|-------|-------|---------------------|----------------|
146| {phase} | {count} | {decisions} | {loop info} |
147
148## Flow Diagram
149
150```mermaid
151%%{init: {'flowchart': {'nodeSpacing': 40, 'rankSpacing': 50, 'curve': 'basis'}}}%%
152flowchart TB
153 %% CLASS DEFINITIONS %%
154 classDef terminal fill:#1a237e,stroke:#7986cb,stroke-width:2px,color:#fff;
155 classDef stateNode fill:#004d40,stroke:#4db6ac,stroke-width:2px,color:#fff;
156 classDef handler fill:#e65100,stroke:#ffb74d,stroke-width:2px,color:#fff;
157 classDef phase fill:#6a1b9a,stroke:#ba68c8,stroke-width:2px,color:#fff;
158 classDef detector fill:#b71c1c,stroke:#ef5350,stroke-width:2px,color:#fff;
159
160 %% TERMINALS %%
161 START([START])
162 COMPLETE([COMPLETE])
163 ERROR([ERROR])
164
165 subgraph Phase1 ["Phase Name"]
166 direction TB
167 N1["Node Name<br/>━━━━━━━━━━<br/>Description"]
168 N2{"Decision<br/>━━━━━━━━━━<br/>Condition?"}
169 N3["Process Node<br/>━━━━━━━━━━<br/>Action"]
170 end
171
172 %% FLOW %%
173 START --> N1
174 N1 --> N2
175 N2 -->|"condition A"| N3
176 N2 -->|"condition B"| ERROR
177 N3 --> COMPLETE
178
179 %% CLASS ASSIGNMENTS %%
180 class START,COMPLETE,ERROR terminal;
181 class N1,N3 handler;
182 class N2 stateNode;
183```
184
185**Color Legend:**
186| Color | Category | Description |
187|-------|----------|-------------|
188| Dark Blue | Terminal | Start, complete, and error states |
189| Purple | Phase | Control flow and analysis nodes |
190| Orange | Handler | Processing and execution nodes |
191| Teal | State | Selection and routing decisions |
192| Red | Detector | Validation gates and failure handling |
193
194## State Machine Characteristics
195
196| Aspect | Value | Notes |
197|--------|-------|-------|
198| Total Nodes | {count} | |
199| Decision Points | {count} | |
200| Loop Mechanism | {description} | {max iterations} |
201| Error Paths | {count} | |
202
203## Critical Routing Logic
204
205- **Condition A**: {what triggers this path}
206- **Condition B**: {what triggers this path}
207```
208
209---
210
211## Pre-Diagram Checklist
212
213Before creating the diagram, verify:
214
215- [ ] LOADED `/autoskillit:mermaid` skill using the Skill tool
216- [ ] Using ONLY classDef styles from the mermaid skill (no invented colors)
217- [ ] Diagram will include a color legend table
218
219---
220
221## Related Skills
222
223- `/autoskillit:make-arch-diag` - Parent skill for lens selection
224- `/autoskillit:mermaid` - MUST BE LOADED before creating diagram
225- `/autoskillit:arch-lens-concurrency` - For parallel execution details
226- `/autoskillit:arch-lens-error-resilience` - For failure handling specifics