control-flow
>
Install
Copy this folder into your Claude Code project (needs Node.js):
npx degit slopus/happy/.agents/skills/control-flow .claude/skills/control-flowOr install it for every project:
npx degit slopus/happy/.agents/skills/control-flow ~/.claude/skills/control-flowFile content
Made by its original authors and shared under MIT. We show it unchanged, with credit and a link to the source. Source β
---
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:
```txt
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:
```txt
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
1. Parse topic into entry points
2. Grep/Explore to find the call chain
3. Read each step at the relevant lines
4. Build tree from trigger β final effect
5. Output as ```txt blocks