Home › Codex lesson 2: AGENTS.md
Codex lesson 2: AGENTS.md
Codex reads AGENTS.md files before it starts work, so your test commands, tools and boundaries apply to every task without repeating them.
Step by step
- Create ~/.codex/AGENTS.md for preferences that apply to every project.
- Add an AGENTS.md at the project root for that repository's rules.
- Add more AGENTS.md files in sub-folders when one part of the code needs different rules; the closest file wins.
- Check it loaded: codex --ask-for-approval never "Summarize the current instructions."
- Keep the files short and specific.
Try it: examples
- AGENTS.md example
## Working agreements - Always run npm test after modifying JavaScript files. - Prefer pnpm when installing dependencies. - Ask for confirmation before adding new production dependencies.
Good to know
- Use AGENTS.override.md for a temporary override without editing the main file.
- Codex stops adding instructions at 32 KiB by default; split large files across folders.
- Empty files are skipped.
Sources (official pages, read Nov 8, 2026)
Written from OpenAI's official documentation and product pages; we don't run hands-on tests. Features and limits vary by plan and country.