A Minimal AGENTS.md Example for Codex
A small table booking service: a FastAPI API and a PostgreSQL database. Every time, Codex asks how to run the tests, or runs the wrong thing. Bit by bit, everything ends up in AGENTS.md, including "this week we're building booking cancellation". A month later the file is long, and half of it is about tasks closed long ago.
A simple split helps. AGENTS.md holds what's true for any task in the repository. The task holds what's true only for this change. In Tascue that second part lives exactly there: each task has its own text with expectations, and the shared rules sit once in the repository.
A file you can start from
# AGENTS.md
## Project
Table booking service: FastAPI API, PostgreSQL database.
Code in app/, tests in tests/.
## Commands
- Dependencies: `uv sync`
- Tests: `uv run pytest`
- Linter: `uv run ruff check .`
- Local server: `uv run fastapi dev app/main.py`
## Rules
- Endpoints in app/api/, logic in app/services/.
- Don't add new dependencies unless asked.
- Don't create migrations unless the task asks for one.
- Before saying "done", run the tests and the linter.
Four commands and four rules. There are no required sections, it's plain Markdown. Codex reads the file before it starts working. If it lists check commands, the agent runs them and fixes what fails.
A task that uses it
Allow cancelling a booking no later than 2 hours before its time.
Expected behavior:
- before that, POST /bookings/{id}/cancel returns 200, status cancelled;
- after that, 409 and the message "A booking can be cancelled no later than 2 hours before";
- exactly 2 hours before, cancelling is still allowed;
- an already cancelled booking returns 409, as it does now.
Don't touch: creating and rescheduling bookings.
Acceptance: tests for 2:01, 2:00 and 1:59 before the booking pass.
The task has no commands and no rules about folders: the agent takes those from AGENTS.md. It only has what can't be in the file: what exactly should change, where the boundary is and how to tell it's done.
How to decide what goes where
| What | Where |
|---|---|
| How to install dependencies and run tests | AGENTS.md |
| Where code lives and how to lay it out | AGENTS.md |
| What to do before "done" in any task | AGENTS.md |
| How this feature should behave | Task |
| What not to touch in this task | Task |
| Which tests accept this change | Task |
The check is simple: will this rule be needed in the next task, which is about something else? If yes, it belongs in AGENTS.md. If not, it will clutter the file and start getting in the way within a week.
A few details on how Codex reads the file:
- Codex collects AGENTS.md files from the project root down to the current folder. A file in a subfolder, such as
app/api/AGENTS.md, adds to the root one and takes precedence over it. - The combined size is capped at 32 KiB by default. A short file won't come close.
- Files are read at startup. An edit to AGENTS.md is picked up in the next session.
Where to keep the other half
AGENTS.md stays short only if behavior and acceptance criteria have somewhere else to live.
In Tascue the task "Cancel a booking no later than 2 hours before" sits in the backlog with its expectations until you get to it. Requirements that repeat across tasks of one type, such as "check in the browser", are attached as an include and stay out of AGENTS.md. When the task is done, its expectations leave with it, and AGENTS.md stays the same: it holds what's true for any next task.