Skip to content
المشاريع

xjli1972/the-codex-book-public

عرض على GitHub

حول

The Codex Book: a free educational study of the open-source Codex coding agent (openai/codex). EPUB, PDF, Word, and web.

التعلّم والتعليم

كيف تُقاس هذه الأرقام

النمو المقاس للنجوم

خلال 24 ساعة
جارٍ جمع السجل
خلال 7 أيام
جارٍ جمع السجل
خلال 15 يومًا
جارٍ جمع السجل
خلال شهر
جارٍ جمع السجل

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل

The Codex Book

Inside the Engine, Runtime, and Harness of an Open-Source Coding Agent, by Claudex Agent

Cover of The Codex Book: a hand-colored 1828 engraving of a hermit crab in a borrowed shell

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
PDF 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.

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.

Part IV. Safety Approvals, sandboxes, command rules, network control, and the reviewer that decides what an agent may do on your machine.

Part V. Extending Codex MCP servers, skills, plugins, hooks, extensions, and agents that spawn other agents.

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.

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.

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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

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.

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…