xjli1972/the-codex-book-public
Tentang
The Codex Book: a free educational study of the open-source Codex coding agent (openai/codex). EPUB, PDF, Word, and web.
Pembelajaran dan pendidikanPertumbuhan bintang terukur
- dalam 24 jam
- Mengumpulkan riwayat
- dalam 7 hari
- Mengumpulkan riwayat
- dalam 15 hari
- Mengumpulkan riwayat
- dalam 1 bulan
- Mengumpulkan riwayat
Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.
README.md
AsliThe Codex Book
Inside the Engine, Runtime, and Harness of an Open-Source Coding Agent, by Claudex Agent

A free, book-length study of how the open-source Codex coding agent works inside. It follows the code at commit 081295be9d (December 3, 2026). It covers the Rust engine and its turn loop, the model client and context window, and compaction. It covers the tool harness, command execution, and apply_patch. It covers approvals, operating-system sandboxes, execpolicy, and the network proxy. It also covers MCP, skills, plugins, hooks, extensions, multi-agent orchestration, the app server and its clients, persistence, configuration, and the build.
[!IMPORTANT] For education and learning only. This book is an independent, non-commercial study. It is not affiliated with, sponsored by, or endorsed by OpenAI. Do not sell it, and do not use it for any commercial purpose or to misuse the software it describes. The authoritative source is always the original repository, github.com/openai/codex.
Read it
| Format | Where | Notes |
|---|---|---|
| Web (HTML) | Read online or docs/ |
One page per chapter, with previous, next, and contents links |
| EPUB 3 | books/the-codex-book.epub |
Best on Apple Books and other e-readers |
books/the-codex-book.pdf |
216 pages, with page numbers and a document outline | |
| Word | books/the-codex-book.docx |
Update the table of contents field after opening |
Contents
Each link opens that chapter's web page.
Part I. The Agent and Its Shape What Codex is, how its crates fit together, and what happens between a keystroke and a finished change.
Part II. The Engine The Rust core that owns a conversation: threads, sessions, the turn loop, the model client, the context window, and compaction.
- 4. Threads, Sessions, and the Protocol
- 5. The Turn Loop
- 6. Talking to the Model
- 7. Building the Context Window
- 8. Compaction and the Token Budget
Part III. The Harness The tools the model can call, and the machinery that turns a tool call into a command, an edit, or a result.
- 9. The Tool System
- 10. Running Commands
- 11. Editing Files with apply_patch
- 12. Code Mode and the Other Tools
Part IV. Safety Approvals, sandboxes, command rules, network control, and the reviewer that decides what an agent may do on your machine.
- 13. Approvals and Permission Profiles
- 14. Operating-System Sandboxes
- 15. Execpolicy and Command Safety
- 16. The Network Proxy and the Guardian
Part V. Extending Codex MCP servers, skills, plugins, hooks, extensions, and agents that spawn other agents.
- 17. MCP: Tools from Other Processes
- 18. Skills, Plugins, and Hooks
- 19. The Extension API
- 20. Many Agents, One Tree
Part VI. The Runtime and Its Surfaces The app server that hosts threads, and the terminal, headless, and SDK clients that talk to it.
Part VII. Operating Codex Where a thread is stored, how configuration and sign-in resolve, and how the project observes, tests, and ships itself.
- 24. Rollouts, State, and Resume
- 25. Configuration, Features, and Sign-In
- 26. Observing, Testing, and Shipping
Part VIII. Reference The design patterns that recur across the code base, and a glossary of the terms this book uses.
How this book was made
The book was researched and written by AI agents, under the pen name Claudex Agent, using Anthropic's Claude in Claude Code. A person directed the work and reviewed the output. The aim was a book that reads like a well-edited technical title and that you can check line by line against the code.
- Fresh source. The Codex repository was pulled and pinned at commit
081295be9d. That pin is about 175 Rust crates and about 2.5 million lines of Rust. Every statement in the book describes that commit, not a later version. - Research. Eight research agents each read one area of the code: architecture and surfaces, the engine, the model client and context, tools, safety, extensions, state and configuration, and public OpenAI writing. Together they recorded about 1,240 facts, each tied to a file path and an identifier.
- Writing. Ten writer agents each drafted two or three chapters from those notes. They re-checked every fact they used in the code and corrected about 45 notes that turned out wrong. A shared style guide set the voice: plain words, active voice, one idea per sentence.
- Adversarial audit. Seven auditor agents tried to refute about 1,140 load-bearing claims by reading the actual function bodies. They fixed about 100 errors, including several wrong defaults that ran through many chapters.
- Mechanical checks. A script confirms that every identifier in the 215 code-map rows still exists at its stated path in the pinned commit. Other checks cover figures, math, cross-references, and style. The EPUB passes EPUBCheck with no errors.
- Production. The book was written in Markdown and built with Pandoc. It has 27 architecture, data-flow, sequence, and lifecycle diagrams drawn with archify, and about 40 numbered equations typeset from TeX to SVG. Chrome printed the PDF.
The result is about 74,000 words of prose in 29 chapters and eight parts. Each chapter opens with a one-paragraph big idea and a diagram. It ends with "What breaks", a code map of the files it discussed, and recall questions.
[!NOTE] Checks reduce errors but do not remove them. Codex changes quickly, and some details here will drift from the current code. When the book and the code disagree, trust the code, and use each chapter's code map to find the current source.
The original project
- Repository: github.com/openai/codex
- The exact version this book describes: tree/081295be9d
- Codex license: Apache License 2.0; a copy is in
licenses/
If this book helps you, star and contribute to the original project.
Licenses and rights
| Part | Rights |
|---|---|
| Book text, diagrams, and web pages | CC BY-NC-SA 4.0: share and adapt with credit, for non-commercial use only, under the same license |
| Code excerpts quoted from Codex | Copyright OpenAI, used under the Apache License 2.0; see also the Codex NOTICE |
| Cover art | Plate 10, le Pagure strié, from Polydore Roux, Crustacés de la Méditerranée et de son littoral (Marseille, 1828). Public domain; scanned copy at the Internet Archive |
| Names | "OpenAI" and "Codex" are trademarks of OpenAI. They appear here only to identify the project this book describes. |
See NOTICE.md for the full attribution. This book is provided as is, without warranty of any kind.
Jelajahi proyek terkait
Memuat…