Pattern Index
Reading Contract: Use this reference as a decision checklist. Start from the problem you are solving, then jump back to the chapter that explains the pattern and its failure mode.
This page collects the reusable design patterns that appear across the book. They are not Codex-only tricks. They are architectural moves that matter whenever an LLM product can inspect files, run commands, call external tools, or serve multiple clients.
The Patterns
Typed Boundary First
Read enums and structs before long functions. In Codex, `Op`, `Submission`, `Event`, and app-server requests reveal the product contract.
Queue Pair Runtime
Clients submit operations and listen for events. That shape lets TUI, exec, and app-server clients share one core runtime.
Turn as Control Unit
A turn is the unit where context, model sampling, tools, hooks, compaction, and completion come together.
Tools as Product Contracts
A tool is not just a function. It carries schema, mutability, hooks, cancellation, output formatting, and user-visible effects.
Patch Instead of Blind Write
Structured patches make edits reviewable, approvable, diffable, and easier to attribute to a turn.
Approval as Control Plane
Approval policy, permission hooks, Guardian review, and network amendments sit above individual tools instead of being scattered through them.
Sandbox as Runtime Transform
Codex treats sandboxing as a transformation of execution requests, selected by platform, policy, permissions, and retry semantics.
Extension by Injection
Skills, plugins, app mentions, and MCP inventory become turn-scoped context and tools rather than separate agent loops.
One Runtime, Many Surfaces
The TUI and app-server differ at presentation time, but both consume structured events from the same session model.
Reading the Patterns Safely
Patterns are only useful when they stay attached to evidence. For each pattern, the chapter provides an evidence map with pinned source links, an explanation for beginners, and a small reading exercise. If you want the complete map in one place, use the Source Atlas.