When Codex does not execute the rules in AGENTS.md, first check the startup directory and file hierarchy, and avoid repeatedly changing the prompt. Codex starts with global configuration and reads from the project's root directory all the way to the current working directory; Rules closer to the current directory take precedence, and the chain of instruction is rebuilt at each run or start of a TUI session.
First, make sure the file is actually in the search path
Project rules should be placed in the root directory of the Git repository or in the parent directory of the current working directory. If you start from outside the repository, or if the actual working directory is in another subdirectory, Codex may never pass through the files you edit. You can start from the target directory:
codex --cd services/api "列出当前生效的指令文件"If the project is not a Git repository, Codex usually only checks the current directory, so do not place AGENTS.md in an irrelevant parent directory and expect it to take effect automatically.
Then check the coverage relationships
Within the same directory, AGENTS.override.md takes precedence over AGENTS.md, and Codex can read at most one file per layer. The global directory ~/.codex may also contain override files; It's suitable for temporary overriding, but forgetting to delete it makes the project rules seem invalid. Rules in nested directories are ranked after root directory rules; in case of conflict, the content closest to the current directory prevails.
If the content is too long, it will also be cut off
Codex only loads project instructions of limited size by default. Once the merged content reaches its limit, subsequent rules may not enter the context. Keeping the general specification in the root directory and placing service-specific commands in the corresponding subdirectory is usually more reliable than piling all requirements into one large file.
After modification, you must run it again
AGENTS.md Not a configuration that continuously hot-updates while running. After editing the file, restart Codex, or end the current TUI session before starting again; If you are changing a custom alternate filename, also make sure it has been written to the project_doc_fallback_filenames. Finally, have Codex reiterate the effective rules and check the project root directory, global CODEX_HOME, and the nearest override file. Only after all three are consistent, can the formal task begin.