AGENTS.md Project Instructions
AGENTS.md is an open standard shared by Codex, Cursor, Gemini CLI, and others. It injects persistent, version-controlled project rules before a task starts.
Why AGENTS.md?
Problems with chat-only prompts:
- Every session repeats “run eslint” and “tests are
pnpm test” - Team rules never go through code review
- Agents mis-navigate large monorepos
AGENTS.md turns new-hire onboarding docs into default agent context.
Discovery and merge rules
Load order
- Global
~/.codex/AGENTS.override.mdor~/.codex/AGENTS.md - Project from Git root → current working directory, at most one file per level:
AGENTS.override.md>AGENTS.md> custom fallback names
- Merge: root first, subdirectories later → closer to CWD = higher priority
Size limit
Default merged cap 32 KiB (project_doc_max_bytes). Overflow is truncated—by design, to keep rules concise.
What to include (and avoid)
Good content:
- Build / test / lint commands (one copy-paste line each)
- Directory layout (“business logic in
internal/, do not editvendor/”) - PR and commit conventions
- Security red lines (no secrets in commits, no
git push --forceto main)
Poor content:
- Full design docs (put them in
docs/; link from AGENTS.md) - Temporary task notes that change daily
- Long prose unrelated to code
Example: root AGENTS.md
Nested directory override
In services/payments/AGENTS.override.md:
Launch from that directory:
Loads: global → root AGENTS.md → payments override.
Global personal preferences
Example ~/.codex/AGENTS.md:
Custom fallback filenames
If the team already uses TEAM_GUIDE.md:
Feedback loop (important)
When Codex repeats the same mistake:
- Correct it in the conversation
- Say explicitly: “Add this rule to AGENTS.md”
- Merge via code review
On GitHub PRs you can delegate: @codex add this to AGENTS.md.
Pair with pre-commit, lint, and typecheck to turn soft rules into hard checks.
Verify what loaded
Or enable logging:
Troubleshooting
Next steps
- Agent Skills: reusable SOPs
- Architecture & Runtime: instruction chain in the agent loop