Project Instructions
Use AGENTS.md for rules that should carry across tasks in a repository, such as validation commands and the files a task is expected to preserve. Use the task prompt for the current request. Official AGENTS.md guide
Give the example repo a reusable rule
Section titled “Give the example repo a reusable rule”In the scratch repo from Your First Session, create an AGENTS.md at the repository root.
# Score reporting
- Treat scores outside the inclusive range [0, 1] as invalid.- Exclude invalid scores from the mean and round the result to two decimal places.- Report the file name and the invalid row IDs.Start a new run from that repository. The prompt can now ask for the report without repeating the validation rule.
codex exec --sandbox read-only 'Give me the score report for scores.csv.'For the running example, compare the result with r2 as the invalid row and 0.60 as the valid mean. If you are testing instruction discovery, check whether the answer follows the rule and whether the run started in the directory you intended.
Understand the loading order
Section titled “Understand the loading order”For an explicitly untrusted project, the loader skips repository instructions. In a trusted project, Codex collects global guidance, then starts at the project root and walks down to the current working directory. It picks at most one instructions file per directory. AGENTS.override.md takes precedence over AGENTS.md in the same directory, and configured fallback filenames come after them. More specific guidance appears later in the combined instructions. Trust and size gate · Discovery and overrides
If one part of a larger repository has its own validation command, give that directory its own instructions and start the run there. An instruction file in a child directory lies outside the startup discovery path when Codex starts at the root. Project instruction scope
Inspect a nested instruction
Section titled “Inspect a nested instruction”From the scratch repo root, make a subdirectory with a single extra instruction. The debug command prints the input assembled locally for the supplied prompt in Codex CLI 0.172.0. Debug command implementation
mkdir reportsprintf 'Include a summary table in score reports.\n' > reports/AGENTS.mdcodex debug prompt-input 'Give me the score report.' > root-input.json(cd reports && codex debug prompt-input 'Give me the score report.') > nested-input.jsonSearch both JSON files for Include a summary table in score reports. Expect one capture containing that sentence, nested-input.json. You should see the root’s score-reporting rule in both. In a local 0.172.0 check, the trusted root and nested captures followed that pattern. With the scratch repository explicitly marked untrusted in the temporary home’s config, both rules were absent from the nested capture. This checks the input available to the agent. To check whether the model follows the instruction, evaluate its report separately.
Diagnose unexpected behavior
Section titled “Diagnose unexpected behavior”Check the working directory, any AGENTS.override.md along its path, and the instructions-size budget if a file is long. Start a fresh run in the target directory when comparing different instruction files. Discovery troubleshooting
Read Tools and Approvals for runtime permissions or Configuration and Skills to turn the score-report procedure into a reusable skill.