Home / Skills / slopus/happy

control-flow

>

skillLicense: MIT Source: slopus/happy

Install

Copy this folder into your Claude Code project (needs Node.js):

npx degit slopus/happy/.agents/skills/control-flow .claude/skills/control-flow

Or install it for every project:

npx degit slopus/happy/.agents/skills/control-flow ~/.claude/skills/control-flow

File 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