
Preview (WebP). Download the PDF for print.
Claude Code · request lifecycle
What happens next…
That prompt, through hooks and context, to the message you see.
A2 · 420 × 594 mm · print-first
This poster follows a single Claude Code turn from cold start to the answer you see — using the example prompt “create me a cool homepage.” Black surfaces mark where a hook fires. Greys on the context stack show what is stable in the prompt cache versus what changes every turn.
Hook strength is labeled H (Hard — can block), S (Scoped — plan / permission), and A (Advisory — observe / report). Session end is not the same event as Stop.
0 · Session load
Once · before the homepage prompt · plugins + CLAUDE.md enter
Before you type anything, the session boots. SessionStart runs first (a hook) so plugins such as ponytail, caveman, and memory can register. Then settings, plugins, and registries load into the runtime.
CLAUDE.md and related instruction surfaces come in last. InstructionsLoaded marks that the instruction set is present. Nothing in this band is “your message” yet — it is the room the model will walk into.
- SessionStart → settings → plugins → registries → CLAUDE.md
- Happens once per session, not once per turn
1 · You press Enter
Once per turn · “create me a cool homepage”
When you submit, UserPromptExpansion runs upstream: slash commands and skills can rewrite or expand what you typed before hooks see it.
UserPromptSubmit is a Hard hook. Plugins on that path (ponytail, caveman, mem, and peers) can inject context or refuse the turn. If the path continues, you reach Prompt ready — the text plus any hook context that will enter the stack.
- UserPromptExpansion → UserPromptSubmit (H) → Prompt ready
- An arrow from Prompt ready feeds the top of the context stack (System prompt)
2 · Context stack
Prompt cache · light = stable top · dark = changes each turn
The model does not see a flat blob. It sees a stack. Light layers at the top change rarely; dark layers at the bottom change every turn. That is the prompt-cache story on the poster.
Top to bottom: System prompt, CLAUDE.md, Plugins · MCP, Skills (descriptions always present; bodies load on trigger), History (compacts — not forever), and This turn (your prompt plus submit-hook context).
Side callouts show how plugins attach: rules into the system layer; claude-mem, caveman, and bonsai as “your plugins”; ponytail into Plugins; blog-write as a skill example. History does not grow unbound — PreCompact (H) can run when the window is full (manual or auto), then compact, then PostCompact before the turn continues.
- sys → turn gradient matches stack faces
- in / out rails mark entry from §1 and exit toward §3 Model
- PreCompact → compact → PostCompact · then resume
3 · Agentic loop
Repeats · deny / fail → Model · never Stop
Once context is assembled, the model may call tools. The happy path is Model → Tool propose → PermissionRequest (S) → PreToolUse (H) → Run → PostToolUse (A). On success, PostToolBatch can inject or halt, then control returns to Model.
PermissionDenied returns to Model — it does not jump to Stop. PostToolUseFailure is a separate advisory path that also returns to Model. A Task can open SubagentStart with its own stack; that subagent’s Stop becomes SubagentStop, not your outer Stop.
If the model produces no more tools, the poster exits toward Stop. Until then, the loop is allowed to repeat. Deny and fail are model returns, not terminal exits.
- PermissionDenied → Model
- PostToolUseFailure · A → Model
- PostToolBatch · inject · halt · then Model
- no tools → Stop
4 · Stop — not the end
The answer on screen is not the same as session exit
Stop is a Hard hook and can refuse — sending control back toward Model. If Stop allows the turn to finish, the UI answer is shown (the poster’s “Here is a cool homepage!” bubble).
SessionEnd is a later, separate event for true session exit. StopFailure is advisory and is not a mode of Stop. Done is the quiet end of this turn’s visible path, not proof the session closed.
- Stop (H) → UI answer → (later) SessionEnd → done
- refuse → Model
- StopFailure · A sits beside Stop, not inside it
Read the sheet top to bottom as time. Read the stack as cache. Read black as “a hook fired.” That is the whole process the poster is defending in one A2 page.
Sources
- code.claude.com/docs/en/hooks
- Phosphor icons
- Plugins: ponytail · caveman · bonsai · claude-mem
Propose a topic
Suggest the next AI infographic. One topic, one glance — what should it make obvious?