Guide
How do I know if Codex has loaded my AGENTS.md file?
Last updated
To check if Codex loaded your AGENTS.md file, run codex debug prompt-input from the folder you work in. It prints the exact input Codex would send to the model, including every AGENTS.md file it picked up, without calling the model. If your text is missing, the usual causes are the folder you started in, the file name, an AGENTS.override.md, the size limit or a different Codex home folder.
How to check if Codex loaded your AGENTS.md file
There are three ways, from most to least exact.
1. Print the prompt. OpenAI's command reference says codex debug prompt-input will "Render the exact model-visible prompt input list as JSON. Use this when debugging instruction discovery." The output is long, so search it for a line you know is in your file:
cd path/to/your/project
codex debug prompt-input > /tmp/codex-prompt.json
grep -o 'AGENTS.md instructions for[^\\]*' /tmp/codex-prompt.json
grep -c 'a phrase from your AGENTS.md' /tmp/codex-prompt.json
In Codex CLI 0.166.0 the instructions appear in a block headed AGENTS.md instructions for <your folder>. The global file comes first, then a --- project-doc --- line, then the project files from the repository root down. A count of 0 means Codex did not load that text.
2. Ask Codex. The Codex docs suggest:
codex --ask-for-approval never "Summarize the current instructions."
codex --cd services/payments --ask-for-approval never "List the instruction sources you loaded."
Codex should repeat your rules, global file first. This calls the model, so it costs a request, and the answer is the model's summary rather than the raw input.
3. Read the log. The docs say you can turn on a plain-text log with codex -c log_dir=./.codex-log and read ./.codex-log/codex-tui.log.
These commands are for the CLI. OpenAI's docs say the CLI and the Codex IDE extension share the same configuration layers in ~/.codex, so you can run the check from the CLI in the folder the extension has open.
Codex started outside your project folder
Codex finds the project root by walking up from the folder you start in until it finds a .git folder. It then checks each folder from that root down to your current folder, and goes no deeper. So:
- A file in a subfolder you are not in is not read. Start Codex in that folder, or use
--cd. - A file above the repository root is not read.
- Outside a Git repository, Codex checks only the current folder. In a test without
.git, a parent folder's AGENTS.md was skipped.
Other markers can count as a root: set project_root_markers = [".git", ".hg", ".sl"] in ~/.codex/config.toml. An empty list makes the current folder the root.
The file name is wrong
Codex looks for exactly AGENTS.override.md, then AGENTS.md, in each folder. AGENT.md, codex.md and CLAUDE.md are not read. The agents.md site suggests renaming and keeping a link: mv AGENT.md AGENTS.md && ln -s AGENTS.md AGENT.md.
To keep another name, add it to ~/.codex/config.toml:
project_doc_fallback_filenames = ["AGENT.md", "TEAM_GUIDE.md"]
The docs say "Filenames not on this list are ignored for instruction discovery." Entries must be plain file names, not paths.
An AGENTS.override.md takes its place
Codex reads at most one file per folder. If a folder has AGENTS.override.md, its AGENTS.md is ignored. The same holds for the global files: ~/.codex/AGENTS.override.md replaces ~/.codex/AGENTS.md. The docs' advice when the wrong guidance appears: "Look for an AGENTS.override.md higher in the directory tree or under your Codex home."
find "$(git rev-parse --show-toplevel)" -name AGENTS.override.md
ls -la "${CODEX_HOME:-$HOME/.codex}"
The file is empty or too large
Codex skips empty files. It also stops adding project files once their combined size reaches project_doc_max_bytes, 32 KiB (32768 bytes) by default. A file that crosses the limit is cut off and later files are skipped, so the deepest, most specific files are the ones lost. In Codex CLI 0.166.0 the global file in ~/.codex did not count toward this limit, and project_doc_max_bytes = 0 turned off project files completely.
List the sizes of the instruction files in your repository. Only the ones on the path from the root to your current folder count toward the limit:
find "$(git rev-parse --show-toplevel)" \( -name AGENTS.md -o -name AGENTS.override.md \) -not -path '*/node_modules/*' -print0 | xargs -0 wc -c
Raise the limit in ~/.codex/config.toml (project_doc_max_bytes = 65536) or move rules into the folders that need them.
Codex is reading a different home folder
The global file lives in your Codex home, ~/.codex unless the CODEX_HOME environment variable is set. The docs: "Run echo $CODEX_HOME before launching Codex. A non-default value points Codex at a different home directory than the one you edited." This catches WSL setups that point CODEX_HOME at the Windows folder.
The project is marked untrusted
If ~/.codex/config.toml has trust_level = "untrusted" for the project under [projects."<path>"], Codex skips that project's own settings. In the current Codex source and in a test with Codex CLI 0.166.0, it skipped the project's AGENTS.md files too, while the global file still loaded.
You edited the file during a session
Codex builds its instructions when a session starts. The docs: "If instructions look stale, restart Codex in the target directory." There is no cache to clear. The same goes for changes to config.toml.
Keep AGENTS.md small
AGENTS.md is for rules every task needs. Decisions, past fixes and notes that only some tasks need can go in a memory server that Codex searches when it needs them, which also keeps you under the size limit. See how to give Codex memory between sessions and what AGENTS.md is and how Codex reads it. With Memlo connected, one line in ~/.codex/AGENTS.md asks Codex to load your memory first: "At the start of every session, call the memlo MCP tool get_prime_directive and follow what it returns." Then run codex debug prompt-input to confirm that line loaded.
Frequently asked questions
Does Codex read AGENTS.md?
Yes. Codex reads your global ~/.codex/AGENTS.md and the AGENTS.md files from your repository root down to your current folder, at the start of each session. The Codex IDE extension shares the CLI's configuration in ~/.codex.
Where does the global AGENTS.md for Codex go?
In ~/.codex/AGENTS.md, or in the folder CODEX_HOME points to. An AGENTS.override.md in the same folder replaces it.
What is AGENTS.override.md in Codex?
A file that takes the place of the AGENTS.md in the same folder. Use it for a temporary or local change without editing the shared file, and delete it to go back.
Does Codex read codex.md or AGENT.md?
Not by default. Add the name to project_doc_fallback_filenames in ~/.codex/config.toml, or rename the file to AGENTS.md.
How do I make an AGENTS.md file for Codex?
Type /init in a Codex session. It writes an AGENTS.md scaffold in the current folder for you to edit. For what to put in it, see CLAUDE.md and AGENTS.md vs a memory server.
Sources
Checked on November 18, 2026:
- Custom instructions with AGENTS.md, OpenAI Codex docs (the old developers.openai.com address redirects here)
- Command line options and slash commands, OpenAI Codex docs
- Advanced configuration and Configuration reference, OpenAI Codex docs
- Config basics and Environment variables, OpenAI Codex docs
- agents_md.rs, the AGENTS.md loader in the openai/codex repository
- AGENTS.md, the format's site
- Tests with
codex debug prompt-inputin Codex CLI 0.166.0
Give every agent the same memory
Ask your agent to add Memlo, or get started below. Memlo is invitation only for now.
Memlo is invitation only for now. We'll email you when your invitation is ready.
By joining, you agree to our Privacy Policy and to occasional emails from us about Memlo. Unsubscribe anytime.