Sub topic 2
Persistent project instructions as a baseline
This chapter assumes you have used an AI coding assistant in an editor or terminal, can read Markdown, and know basic Git. It covers the file that every other mechanism in this tutorial builds on: the persistent project instruction file.
What persistent instructions are
A persistent instruction file is a Markdown file in your repository that the agent reads at the start of every session. A common name is AGENTS.md. Some tools use their own file name, so check your tool's documentation for the name and location.
Because the file is loaded every time, its text sits in the context window for the whole session. The context window is the limited amount of text the model can consider at once. Every line in the file takes space from your conversation, the code the agent reads, and the tool output it receives. Treat the file as a budget you spend on every task, not as free documentation.
What belongs in the file
Put in facts that are true for almost every task in the repository and that the agent cannot easily infer from the code:
- Commands to build, test, and lint the project.
- Conventions that differ from the language default, such as a naming rule or an import order.
- Layout notes, such as where tests live or which folders are generated.
- Hard limits, such as "never edit files under
migrations/by hand."
Leave out anything that applies to only one workflow. A ten-step release procedure does not belong here, because the agent would carry it while fixing a typo. That material fits a prompt file or a skill, which later chapters cover.
A worked example
# Project instructions
## Commands
- Install: `npm ci`
- Test all: `npm test`
- Test one file: `npm test -- path/to/file.test.ts`
- Lint: `npm run lint`
## Conventions
- Use TypeScript strict mode. Do not use `any`.
- Name test files `<module>.test.ts`, next to the module.
## Boundaries
- Never edit files in `src/generated/`. Run `npm run codegen` instead.
- Ask before adding a new dependency.The file is short and every line is checkable. The agent can run each command, and a reviewer can tell when a rule is broken.
How the file loads
Some tools also read files from subfolders when the agent works in them. That lets a packages/api/ folder carry its own rules without adding them to every session. Whether your tool does this varies, so verify it before you rely on it.
Common errors
| Problem | Effect | Fix |
|---|---|---|
| File grows by accretion | Important rules get buried and context shrinks | Review it regularly and delete stale lines |
| Vague rules | The agent cannot tell when it has followed them | Rewrite as commands or checkable statements |
| Task-specific procedures included | Cost on every task, benefit on few | Move them to a prompt file or a skill |
| Conflicting rules | The agent picks one unpredictably | Keep a single source of truth for each rule |
| Secrets or private URLs | The file is committed and shared | Keep credentials out of it entirely |
Role in the larger design
The instruction file is the baseline. Prompt files, custom agents, and skills each add something on top of it for a narrower purpose. A good rule of thumb is to keep the baseline small, so the specialized mechanisms have room to work.
Exercise
A teammate adds a 40-step database migration checklist to AGENTS.md. Why is this a poor fit, and where should the checklist go instead?
Show answer
The file loads into the context window at the start of every session, so the checklist costs space even when the agent is doing unrelated work. It applies to only one workflow. It belongs in a reusable prompt file or a skill, which load only when invoked or needed. AGENTS.md should keep only a short pointer or boundary, such as "Ask before changing the schema."
Exercise
Rewrite the vague rule "Make sure the code is tested" as a specific, checkable instruction for a project that uses pytest.
Show answer
"Run pytest before finishing a task, and add a test in tests/ for any new public function." This gives a command to run and a condition a reviewer can check.