Skip to content

Claude Code Master Loop

The master loop (internally reportedly called nO) is the core of claude-code and, per jared-zoneraich's reverse engineering, is roughly four lines of code: while there are tool calls, run the tool, give the tool results to the model, loop; when there are no tool calls, ask the user what to do.

Why it matters

  • Single-threaded, synchronous, no DAG — replaces the brittle classifier-and-branch workflows the field built for ~2 years.
  • Relies entirely on the model's instruction following + tool-calling quality, not on orchestration code. This is the structural reason "better models → better agents" works 1:1 here.
  • Zoneraich: "less scaffolding, more model." The same master-loop shape is adopted by Codex, Cursor Composer, Amp — "that's just the winning architecture."

Contrast with DAG agents

Before 2024–25, customer-support and coding agents were built as hundreds of classifier-routed nodes (cf. subagent-architecture pre-2025 era). That style trades flexibility for determinism. The master loop reverses the trade: one flexible model + a small rigorous tool set (see bash-as-universal-tool, claude-code-todo-tool).