| name | control-flow |
| description | Analyze and design control flows and data structures. Produces compact ASCII tree diagrams showing triggers, call chains, payload shapes, state mutations, and re-render effects. Use when user asks to diagram, trace, visualize, or design a flow or data structure.
|
/control-flow ā Analyze and design control flows and data structures
Read the relevant source code and produce ASCII tree diagrams inside ```txt blocks.
Format
- Each user action or IO event is a separate tree root
- Real function names and types ā never invent
- Payload shapes as TypeScript types, not prose
- State mutations: which fields change, what triggers
- Re-render chain: which components and why
- Cross-package when the flow spans app ā CLI ā server
- Compact ā skip trivial pass-throughs, show decisions
Example:
User taps "Archive"
ā
āā handleActionPress(action: SessionActionItem)
ā āā onClose() ā setActionsAnchor(null)
ā
āā sessionKill(sessionId: string)
ā āā POST /api/sessions/:id/kill
ā āā ā { success: boolean, message?: string }
ā
āā deleteSession(sessionId)
āā mutates: sessions, sessionMessages, gitStatus, fileCache
āā rebuilds: sessionListViewData
āā re-renders: SessionsListWrapper (data ref changed)
For data structures, show the shape and what depends on it:
SessionRowData (flat primitives, cheap deep-equal)
āā id, name, subtitle, avatarId ā identity + display
āā state: SessionState ā collapsed from presence + agentState + thinking
āā hasDraft: boolean ā collapsed from draft string
āā activeAt?: number ā only inactive sessions (avoids heartbeat diffs)
āā machineId, path, homeDir ā grouping in ActiveSessionsGroup
āā completedTodosCount, totalTodosCount
ā
consumed by:
āā SessionItem ā renders purely from props, no store hooks
āā ActiveSessionsGroup ā groups by machineId + path
āā useDeepEqual ā 12 primitive comparisons vs full Session tree
Principles
- Expressive yet compact ā every line earns its place
- Show payload SHAPE not description
- Show state mutations ā which store fields, what rebuilds
- Show re-render chain ā component + reason
- Pseudo code only for branching logic between nodes
- Always output inside ```txt for alignment
- File:line refs when helpful, not mandatory ā the flow matters more than the location
Process
- Parse topic into entry points
- Grep/Explore to find the call chain
- Read each step at the relevant lines
- Build tree from trigger ā final effect
- Output as ```txt blocks