Write a Context File (AGENTS.md)
The single highest-leverage thing you can do is write a context file the AI reads automatically. Different tools look for different names — AGENTS.md, CLAUDE.md, .cursorrules, or a .github/copilot-instructions.md — but the idea is identical: a living document that tells the AI how your project works and how you want it to behave.
Without it, the AI guesses. With it, the AI stops reformatting your code, stops inventing libraries you don't use, and stops re-explaining decisions you already made. Think of it as onboarding documentation for a new teammate who is brilliant but has total amnesia between sessions — everything they need to be productive has to live somewhere they'll read every time.
A practical starter file:
# Project: Invoice Manager
## What this is
A small web app for freelancers to create and track invoices.
## Tech stack
- TypeScript + React (Vite)
- Tailwind for styling
- SQLite via Prisma
- Vitest for tests
## Commands
- Install: `npm install`
- Run dev server: `npm run dev`
- Run tests: `npm test`
- Lint: `npm run lint`
## Conventions
- Use functional components and hooks; no class components.
- Keep components small; one component per file.
- Write a test for every new function in `src/lib`.
- Never edit files in `src/generated/` — they are auto-generated.
## Don'ts
- Don't add new dependencies without flagging it first.
- Don't commit secrets; use environment variables.
Keep it short and keep it current. A context file that grows to a thousand lines stops being read carefully — by you or the model — so prune it as aggressively as you add to it. When the AI repeatedly makes the same wrong assumption, that's your signal to add a line; when a rule no longer matches reality, delete it before it starts actively misleading the .
A few patterns separate a context file that works from one that's ignored:
- Be specific and concrete. "Use our conventions" is useless. "Use
zodfor validation; we don't useyup" is a rule the AI can actually follow. - State the don'ts as loudly as the do's. Models are eager to help, which means they'll happily add a or rewrite a config unless you tell them not to.
- Point to examples. "Match the style of
src/features/invoices" gives the AI a concrete model to copy instead of a vague instruction to interpret.
Treat the context file as a record of every lesson you'd otherwise have to repeat. It is the cheapest, most durable investment in this entire chapter.