Harness Notes

Instructions

Updated 2026-11-22,

On this page

Instruction files are guidance you write once and every session reads, such as AGENTS.md, CLAUDE.md or Cursor rules. Notes a harness saves on its own are on the Memories page.

What gets loaded

QuestionCodex CLIchecked at 0.162.1
Which files it reads

Codex reads AGENTS.md, plus AGENTS.override.md, which takes the place of AGENTS.md in the same directory. Extra names listed in project_doc_fallback_filenames (e.g. ["TEAM_GUIDE.md", "CLAUDE.md"]) are tried only in project directories that have neither file. There is no rules directory, and it does not read CLAUDE.md unless you list it.

Fallback names apply only to project directories, not to ~/.codex.

Fallback entries must be plain file names; entries containing / are ignored.

Where it looks, and when nested files load

Global: ~/.codex (or $CODEX_HOME). Project: every directory from the project root (the nearest parent containing .git, or any marker set in project_root_markers) down to the current working directory; with no root found, only the working directory is checked. Files are read when the session starts. Files in subdirectories below the working directory are never loaded automatically. Codex's built-in prompt only tells the model to look for them itself when it works there.

In an untrusted project Codex skips project AGENTS.md files entirely and keeps only the global file.

project_root_markers = [] stops the upward search, so only the working directory is checked.

Codex reads project_root_markers from user, system and managed config only; a project's own .codex/config.toml can't change it.

When several apply, which wins

All applicable files are concatenated: the global file first, then project files from the root down to the working directory, separated by blank lines (with a --- project-doc --- marker before the first project file). Nothing is merged or deduplicated. Closer files appear later and win by convention, and in each directory only the first of AGENTS.override.md, AGENTS.md and fallback names is used.

Instructions you type in the prompt, and developer_instructions, take precedence over AGENTS.md according to Codex's built-in prompt.

Size limits

Project files share a combined budget of project_doc_max_bytes (default 32 KiB = 32768 bytes). The file that crosses the limit is cut off at the byte limit, and any later, deeper files are dropped. The only notice is a warning in the log. The global ~/.codex/AGENTS.md doesn't count toward this budget.

Raise it with project_doc_max_bytes = 65536 in config.toml or -c project_doc_max_bytes=65536.

Because the root file is read first, an oversized root file can push out deeper, more specific files.

Some config docs describe the limit as per file; in 0.162.1 the budget is shared by all project files.

Writing them

QuestionCodex CLIchecked at 0.162.1
One file for several harnesses

Partly

Codex natively reads only AGENTS.md, which other harnesses also read. To reuse another tool's file, add it to project_doc_fallback_filenames (e.g. project_doc_fallback_filenames = ["CLAUDE.md"]); it is used only in directories without an AGENTS.md. /import can also make a one-time copy of CLAUDE.md into AGENTS.md, renaming Claude references to Codex.

/import writes only if the target AGENTS.md is missing or empty, and it doesn't keep the files in sync afterwards.

Rules for some paths, or only on request

Partly

The only scoping is by directory: put an AGENTS.md or AGENTS.override.md in a subdirectory and it applies when you start Codex in or below that directory. There are no globs, no frontmatter, and no @-mention rules that load on demand.

Files deeper than the working directory are not injected; the model is only told to look for them itself.

Include other files

Not supported

No. Codex inserts each file's text exactly as written, so @path or include lines are not expanded. You can still tell the model to read another file, and it will do so with its normal tools.

Add instructions from config or flags

Set developer_instructions = "..." in ~/.codex/config.toml (or a profile) to add a separate developer message, or pass it for one run with -c developer_instructions='"..."'. model_instructions_file = "/abs/path.md" replaces Codex's built-in base instructions entirely, and OpenAI strongly discourages this. CODEX_HOME changes which global AGENTS.md is used; there is no flag or URL source for instruction files.

The older experimental_instructions_file key is gone in 0.162.1; use model_instructions_file.

Generate a starter file

Yes: /init in the TUI asks Codex to write a contributor-guide AGENTS.md ("Repository Guidelines") in the current directory. It won't overwrite an AGENTS.md that already exists there. /import can also create AGENTS.md from a Claude Code CLAUDE.md.

/init only asks the model to write the file, so the result varies; review it before committing.

Control

QuestionCodex CLIchecked at 0.162.1
See what loaded, and apply edits

Run /status in the TUI; its Agents.md line lists the loaded files (e.g. ~/.codex/AGENTS.md, AGENTS.md). You can also ask Codex to list its instruction sources, or check the TUI log or session .jsonl. Edits to ~/.codex/AGENTS.md are picked up on the next turn, but project files are only re-read when the working directory or trust level changes (e.g. /cd). Otherwise restart Codex.

When instructions change mid-session, Codex sends the model a note that the new AGENTS.md text replaces the old one.

The docs say to restart Codex to pick up changes; there's no reload command.

Turn them off or skip some

Partly

There's no dedicated flag. -c project_doc_max_bytes=0 turns off all project AGENTS.md files for a run, and leaving a project untrusted also skips them. The global file still loads; to avoid it, point CODEX_HOME at another directory or remove/rename ~/.codex/AGENTS.md. You can't exclude individual files or directories.

--ignore-user-config skips config.toml but still loads ~/.codex/AGENTS.md.

Enforce instructions for an organisation

Yes. Admins set additional_developer_instructions in requirements.toml (/etc/codex/requirements.toml, %ProgramData%\OpenAI\Codex\requirements.toml, cloud-managed requirements, or the macOS MDM key requirements_toml_base64). Codex adds it as its own developer message, separate from user files. Codex refuses to start if it exceeds about 10,000 estimated tokens. managed_config.toml can set defaults such as developer_instructions, but users can change those during a run.

Admins can't lock or block a repository's own AGENTS.md files; the managed text is added alongside them.

Notes and sources

Codex CLI, 17 sources
  • At each level, an override file wins over AGENTS.md and configured fallback names.
  • Codex skips empty files and applies a configurable combined-byte limit.
  • Instructions are persistent context, not skills and not permission grants.
Which files it reads, 3
Where it looks, and when nested files load, 4
When several apply, which wins, 3
Size limits, 3
One file for several harnesses, 3
Rules for some paths, or only on request, 3
Include other files, 2
Add instructions from config or flags, 4
Generate a starter file, 3
See what loaded, and apply edits, 5
Turn them off or skip some, 3
Enforce instructions for an organisation, 4