How Codex assembles its instructions
- Your global file,
~/.codex/AGENTS.md. AnAGENTS.override.mdthere is used in its place. - The
AGENTS.mdat the repository root. - An
AGENTS.mdin each directory below that, down to the one you are working in.
Codex stops adding files once the combined text reaches project_doc_max_bytes, which is 32 KiB unless you change it. A deep monorepo with a long root file can hit that ceiling before the most specific directory gets read. Raising the setting is possible, but every byte you add rides along on every request.
What earns a place in AGENTS.md
- The commands Codex should run: install, test, lint, typecheck, and the order that matters.
- Conventions you'd otherwise repeat in review, such as where new modules go or how errors are returned.
- Lines it must not cross. Generated files stay untouched; secrets never get logged.
- Short pointers into deeper docs, so the detail loads only for tasks that need it.
AGENTS.md, Codex memories or Glen
| AGENTS.md | Codex memories | Glen | |
|---|---|---|---|
| Written by | People, by hand | Codex, once enabled | Glen's hooks, every turn |
| Stored in | The repo and ~/.codex | $CODEX_HOME/memories/ | Your organization's hosted memory |
| Enabled | Always | Off by default (memories = true) | After glen install |
| Reaches | Everyone with the repo | One machine | Teammates, filtered by what each may see |
| Good for | Rules that must always hold | Your own habits | Why past work went the way it did |
OpenAI recommends keeping required team guidance in AGENTS.md, and that advice holds with Glen installed. Recall from Glen depends on a prompt matching past work. A rule in AGENTS.md applies whether or not anything matches.
One file, several agents
AGENTS.md is not Codex-only. Cursor reads it alongside its rules, and Grok Build reads it too. A team that mixes agents can commit one AGENTS.md and get the same rules everywhere, instead of keeping three files in sync.
Knowledge that doesn't fit in a file
The 32 KiB cap is a good discipline, and it also means most of what a team learns never makes it in. Which fix was tried first, why a timeout is 45 seconds, what a reviewer objected to: all of that lives in session transcripts. Glen records those for the organization and returns the relevant part with the prompt that needs it, so AGENTS.md can stay lean. When something recalled from Glen proves to be a standing rule, promote it into AGENTS.md.
Frequently asked questions
Where does Codex look for AGENTS.md?
In ~/.codex for your global file (AGENTS.override.md takes its place if present), then in the repository root and each directory below it down to where you are working.
What is project_doc_max_bytes in Codex?
The limit on how much AGENTS.md text Codex loads, 32 KiB by default. Files past that budget are not read.
Should I use AGENTS.md or Codex memories?
AGENTS.md for anything the team needs, because it is shared through git. Codex memories stays on one machine, which suits personal preferences.
Can other coding agents read AGENTS.md?
Yes. Cursor and Grok Build both read AGENTS.md, so a single committed file can carry the same rules to several agents.