Codex documentation
Official Codex documentation from OpenAI.
How Codex reads AGENTS.md
Codex readsAGENTS.md automatically when it starts working in a repository. No configuration file or flag is required — if an AGENTS.md file exists at the repository root or in a parent directory of the code being edited, Codex will read it before taking any action.
In a monorepo, Codex follows the standard precedence rule: the closest AGENTS.md to the code being edited wins. A file at packages/api/AGENTS.md takes precedence over the root AGENTS.md for work done inside that package.
User chat prompts always override instructions in AGENTS.md. AGENTS.md sets the default context; explicit instructions from the user take precedence.
What to put in AGENTS.md for Codex
Codex uses the full contents of AGENTS.md to guide its work. The most useful sections are:- Build and test commands — Codex will run these automatically to verify its changes
- Code style rules — formatting conventions, naming patterns, preferred libraries
- Repository structure — where packages live, how the monorepo is organized
- PR and commit conventions — message format, branch naming, review expectations
- Security notes — files or areas that require extra care
Example AGENTS.md for a Codex project
AGENTS.md
