Course contents
Codex AGENTS.md and skills: setup guide
On this page
How Codex finds AGENTS.md
Codex builds an instruction chain once per run, or once per session in the TUI (Codex AGENTS.md guide):
- Global: in
~/.codex(orCODEX_HOME), it readsAGENTS.override.mdif it exists, otherwiseAGENTS.md. - Project: from the repo root down to your current directory, it checks each folder for
AGENTS.override.md, thenAGENTS.md, then any names inproject_doc_fallback_filenames. At most one file per folder. - Merge: files are joined root first, so files closer to your working directory come later and win on conflicts.
Codex skips empty files and stops adding files once the combined size reaches project_doc_max_bytes, which is 32 KiB by default.
repo/
├── AGENTS.md # loaded
└── services/
└── payments/
├── AGENTS.md # ignored: an override exists here
└── AGENTS.override.md # loaded last when you start in services/payments
Codex stops at your current directory, so a file in a sibling folder isn't read. Put specialized guidance as close to the work as possible.
A good root AGENTS.md
# Repository expectations
## Commands
- Install: `pnpm install`
- Lint: `pnpm lint`
- Test: `pnpm test`
## Rules
- Document public utilities in `docs/` when you change behavior.
- Ask before adding a production dependency.
## Code Review Rules
- Flag any query built by string concatenation. Safe path: the query builder in `src/db/`.
The ## Code Review Rules heading is how you give Codex code review on GitHub repo-specific checks. Keep formatting and lint checks in CI instead.
Run /init in Codex to generate a starter AGENTS.md for the current folder.
Config knobs
project_doc_fallback_filenames = ["TEAM_GUIDE.md"]
project_doc_max_bytes = 65536
Raise the limit or split guidance into nested files if you hit the cap.
Skills: .agents/skills/
Codex scans .agents/skills/ in every folder from your current directory up to the repo root, plus ~/.agents/skills/ for you, /etc/codex/skills for admins, and bundled system skills (Codex skills docs).
---
name: changelog
description: "Write a CHANGELOG.md entry for the current branch. Use when the user asks for a changelog entry or release notes for a PR. Not for version bumps."
---
1. Diff the branch against `main` and group changes by area.
2. Add an entry under "Unreleased" in `CHANGELOG.md` in the existing style.
3. Show the diff of `CHANGELOG.md` only.
Invoke a skill explicitly with $changelog in your prompt, or browse with /skills. Codex can also pick a skill on its own when the task matches its description.
Two details that affect triggering:
- The initial skills list uses at most 2% of the model's context window (or 8,000 characters when the window size is unknown). With many skills installed, Codex shortens descriptions first, so front-load the key use case.
- To stop implicit use of a skill, add
agents/openai.yamlin the skill folder withpolicy: allow_implicit_invocation: false. Explicit$skillstill works.
$skill-creator helps you draft a new skill, and $skill-installer installs curated ones.
Install a preset
npx presets-dev add nextjs --tool codexcreated AGENTS.md
created .agents/skills/nextjs-code-review/SKILL.md
2 file action(s), 0 skipped. https://presets.dev
If you already have an AGENTS.md, the CLI appends a section instead of replacing your file, wrapped in markers:
# Team notes
Keep this.
<!-- presets.dev:nextjs:start -->
...Next.js section...
<!-- presets.dev:nextjs:end -->
Running the command again skips the stack because its markers are present. With --force, only the text between the markers is replaced.
Preview: Next.js instructions for Codex and Next.js code review skill for Codex.
Check that it loaded
- Ask:
codex --ask-for-approval never "Summarize the current instructions." - From a subfolder:
codex --cd services/payments --ask-for-approval never "List the instruction sources you loaded." /statusshows session configuration and context usage.
Common mistakes
- An
AGENTS.override.mdyou forgot about. It replacesAGENTS.mdin that folder (or globally in~/.codex). - Starting Codex in the wrong folder. Nested files only load on the path from the root to where you started.
- Going over 32 KiB. Later files, usually the most specific ones, get cut.
- Empty
AGENTS.md. Codex skips empty files.
Recap
- Codex reads
AGENTS.mdfrom the repo root down to your working directory, one file per folder. AGENTS.override.mdreplacesAGENTS.mdat the same level.- The combined limit is 32 KiB by default (
project_doc_max_bytes). - Skills live in
.agents/skills/; call them with$nameor/skills.