Four runs, one CLAUDE.md, zero obeyed. In three of them Codex CLI 0.172.0 ran cat on the file, had my rule in front of it in plain text (every Python file you edit starts with # reviewed-by: dp), and wrote the patch without that line. Same rule in a file called AGENTS.md: followed, every time.
That was one slice of 17 runs I made on the morning of 1 December 2026, one tiny task each, in a Linux container. My verdict: Codex CLI is a good agent whose rules live in a file with one exact name and a hard size cap, and neither the name nor the cap tells you when it bites. Two lines in config.toml fix both, and you want them in before the first run.

What is Codex CLI for?
Codex CLI is OpenAI’s coding agent for the terminal: you give it a sentence, it reads the folder, runs shell commands, edits files and reports back. It is Apache-2.0 licensed and written in Rust. The openai/codex repository showed 136,932 stars when I read the GitHub API (api.github.com/repos/openai/codex) at 05:05 UTC on 1 December 2026. The latest stable release is rust-v0.172.0, from 24 November. Alpha rust-v0.174.0-alpha.12 landed at 03:32 UTC today; I stayed on the stable tag.
It earns its place on work that comes with house rules: run the tests with this command, never touch that folder, start every file with this line. You do not want those in every prompt, so Codex reads them from a file. OpenAI’s AGENTS.md page says it checks each directory from the project root down to the current one, takes at most one file per directory, and joins them root first. “Files closer to your current directory override earlier guidance”. The format is shared: the AGENTS.md site describes itself as “a README for agents” and says it is used by over 60k open-source projects.
Me, I think of that file as the one part of an agent setup that outlives the person who wrote it: the model changes every month, the rules file is what the next developer inherits. I covered the other half of the setup, the sandbox, in Codex CLI idles in a container until you drop its sandbox.
How do you set Codex CLI up to follow your rules?
It runs wherever Node runs. I used a Linux container, with the binary from npm i -g --prefix ./npm-prefix2 @openai/codex, which keeps it out of /usr/local.
$ codex --version
codex-cli 0.172.0
The key is one environment variable, CODEX_API_KEY, set in front of the command; the non-interactive docs recommend it for automation, set only on the command that needs it. Each run was the non-interactive form, codex exec, with -s danger-full-access because the container cannot start the default sandbox, and < /dev/null so it never waits on stdin. The rule file is three lines:
# Team rules
Every Python file you edit must start with the exact line `# reviewed-by: dp`.
The task was always the same one sentence, and the check is dull on purpose: line 1 of util.py after the run.
The config that matters sits in ~/.codex/config.toml, and the AGENTS.md page quotes both keys:
project_doc_fallback_filenames = ["CLAUDE.md"]
project_doc_max_bytes = 65536
The first one tells Codex to treat a CLAUDE.md as rules when a directory has no AGENTS.md. The second raises the cap from its default of 32 KiB, which is 32,768 bytes. I passed them with -c on the command line in the runs below, and the same keys in the file do the same job.
What goes wrong with Codex CLI rule files?
Two things, each one measured below, and neither makes the exit code anything but 0.
A CLAUDE.md is read like any other file, not loaded as rules
Plenty of repos already carry a CLAUDE.md, and Codex does not pick it up. The docs say so: “Filenames not on this list are ignored for instruction discovery.”
In three of my four runs the model went further than the docs require. It listed the folder, spotted CLAUDE.md, and printed it with cat; the fourth looked only for AGENTS.md. The rule sat in its context as plain text, and the patch still had no header line. The model printed the file with cat, the patch still skipped the rule, and nothing on screen said why. With project_doc_fallback_filenames = ["CLAUDE.md"] the same folder produced the header in 2 of 2 runs.
A long AGENTS.md is cut at 32 KiB and the run still exits 0
I padded an AGENTS.md to 49,291 bytes with 519 style notes and put the rule on the last line, at byte 49,212. Codex 0.172.0 does warn, and the warning is good:
warning: Loaded only 32768 of 49291 bytes from `.../AGENTS.md` in environment `local` under the 32768-byte project instruction budget. Trim your project instructions to fit the budget. If you need to keep them all, increase `project_doc_max_bytes`.
What happens next depends on the model. In three of four runs the model ran tail on AGENTS.md, found the cut rule and followed it. In the fourth the same warning sat on screen, the model ran cat util.py, and it patched the file with no header. The run exited 0 like the others and nothing in a CI log would flag it. A rule that holds three times in four is the worst kind, because it passes the review and fails on a Friday.
If you run Codex in CI, --json is where you can catch it. The same cut arrives in the event stream as an item with "type":"error" and the message above, ahead of the first command, while the process still exits 0. A one-line grep '"type":"error"' on the stream turns a quiet cut into a red build.
The big file also costs you on every launch. The one-line file ran 15,327 to 15,463 tokens a run. The padded file, cut to 32 KiB, ran 23,285 to 23,864. With project_doc_max_bytes = 65536 the whole file loads, the warning disappears and the run costs 27,254 to 27,318 tokens. GitHub’s search shows 50 issues and pull requests that mention project_doc_max_bytes, 32 of them open this morning, so the limit surprises a lot of people.
The cheaper cure than raising the cap is a shorter file. Put the three rules that matter at the top, where a cut cannot reach them.
What did I actually run?
Seventeen runs of codex exec, model gpt-6.2-sol as Codex picked it, all in separate git folders with the same util.py and the same one-sentence task. Every run exited 0 and took 6 to 13 seconds by the clock where I timed it.
| Rule file | Config | Header written |
|---|---|---|
AGENTS.md, 93 bytes | none | 3 of 3 |
AGENTS.md, 49,291 bytes, rule at the end | none (32 KiB cap) | 3 of 4, warning every time |
| same file | project_doc_max_bytes=65536 | 3 of 3, no warning |
CLAUDE.md, 93 bytes | none | 0 of 4 |
| same file | project_doc_fallback_filenames=["CLAUDE.md"] | 2 of 2 |
| none | none | 0 of 1 |
Every launch had this shape, with only the -c flags changing:
$ codex exec --skip-git-repo-check -s danger-full-access -c project_doc_max_bytes=65536 \
"add a function double(x) to util.py that returns x times two" < /dev/null
OpenAI Codex v0.172.0
model: gpt-6.2-sol
The thirteen runs where I kept the plain-text output used 261,088 tokens between them. The one I keep thinking about is the missed run under the cap. Its first command was git status --short && rg --files | head -30 && cat util.py, with the warning printed above it, and it finished in 8 seconds with "Verified with positive, negative, zero, and fractional inputs", a confident summary of a patch that broke a rule it had been given.
Use Codex CLI if your team already writes rules down. Name the file AGENTS.md, keep it under 32 KiB with the rules that matter first, and put both config lines in config.toml the day you adopt it. When rust-v0.174.0 leaves alpha I will rerun the 49,291-byte file, since a cut that fails the run instead of warning would be the change I want.