Sub topic 8
Project instruction files for stable conventions
This chapter assumes you have written a spec (requirements, design, tasks) and have used a coding agent in a Git repository. You should also know how to run a test suite from the command line.
What an instruction file does
A project instruction file is a Markdown file in your repository that the agent reads at the start of every session. Common names are AGENTS.md, CLAUDE.md, or a tool-specific rules folder. Check your tool's documentation for the exact filename and location it loads.
The spec describes one feature. The instruction file describes how work is done in this project, for every feature. Without it, you repeat the same sentences in each prompt: where specs live, which command runs the tests, which directories are off limits. Prompts get shortened, details get dropped, and the agent's behavior drifts.
| Artifact | Scope | Changes | Example content |
|---|---|---|---|
| Instruction file | Whole project | Rarely | "Run `pytest` before reporting done" |
| Spec (requirements, design, tasks) | One feature | Per feature | "Reset link expires after 30 minutes" |
| Prompt | One session | Every time | "Do task 2 from the password-reset tasks" |
A working example
# AGENTS.md
## Workflow
- Read the relevant spec in `specs/<feature>/` before changing code.
- Work on one task from `tasks.md` at a time and stop for review after each.
- Do not change requirements. If one looks wrong, say so and ask.
## Conventions
- Run `pytest` before reporting a task as done.
- Keep new modules under `src/` and tests under `tests/`.Each line does one of three jobs:
- Points to the spec. The first line tells the agent where to find its source of truth, so you do not paste requirements into prompts.
- Sets the pace. "One task at a time, then stop" creates a review gate without you having to ask each time.
- Defines done. Running
pytestgives the agent a check it can run itself, and gives you a claim you can verify.
The line "Do not change requirements" protects the spec from silent edits. If the agent finds a conflict, it reports it and you decide.
What belongs in the file
Put in rules that are stable, specific, and checkable:
- Commands for building, testing, and linting.
- Directory layout and naming conventions.
- The spec workflow: where specs live and how tasks are executed.
- Hard constraints, such as "never edit generated files" or "do not add dependencies without asking".
Leave out anything that belongs to a single feature. A rule like "reset links expire after 30 minutes" goes in the requirements, where it can be tested. Leave out vague advice too. "Write clean code" gives the agent nothing to act on, while "Public functions have type hints" does.
Common errors
- Too long. The file competes with the spec and the code for the agent's context. A long file buries the rules that matter. Keep it to what you would tell a new teammate on day one.
- Duplicated spec content. If the same requirement lives in both places, they will diverge. Link to the spec instead of copying it.
- Stale commands. If the test command changes and the file does not, the agent runs the wrong thing, or reports success from a check that no longer exists. Update the file in the same commit that changes the tooling.
- Rules nobody enforces. An instruction is a request, not a guarantee. Back important rules with a check, such as a CI job, a linter, or a test.
Treat the file like code
Because the file is in Git, review changes to it like any other change. When the agent repeats a mistake, ask whether a missing rule caused it. If so, add one line to the file and commit it. Over time, the file records the lessons your team has learned about working with the agent.
Exercise
A teammate adds "Password reset links must expire after 30 minutes" to AGENTS.md. Where should this rule live instead, and why?
Show answer
It belongs in the feature's requirements as an acceptance criterion, ideally backed by a test. It is specific to one feature, so it does not fit a file of project-wide conventions. Keeping it in the spec also gives it one source of truth that can be reviewed and tested.
Exercise
Your instruction file says "Run make test before finishing", but the project switched to pytest last month. What goes wrong, and how do you prevent it?
Show answer
The agent runs a command that fails or does nothing useful, and may report a task as verified without a real check. Prevent it by updating the file in the same commit that changes the tooling, and by checking the file's commands during review.