Course outline
Agentic Engineering: the hands-on course · Module 2: Context engineering
Repo instruction files that work (AGENTS.md / CLAUDE.md)
Write a short repo instruction file that tells agents how to build, test and behave in your codebase, and keep it lean enough to actually help.
Lesson 6 / 24 · ⏱ 8 min
Every new session, the agent walks into your repo like a contractor on day one. It doesn’t know how you run tests, which folder is legacy, or that you never touch the generated client by hand.
A repo instruction file is the note you tape to the door. Most coding agents look for one (names like AGENTS.md or CLAUDE.md) and load it automatically at the start of each session. Check your tool’s docs for the exact file name and whether it also reads files in subfolders.
How it reaches the agent
- You write itPlain markdown at the repo root
- Session startsThe agent loads it before your brief
- Every stepIt shapes each read, edit and command
- You refine itWhen the agent repeats a mistake
↺ Each repeated mistake is a line you haven’t written yet
That last point matters. Because it loads every time, the file sits in the fixed part of your context budget from lesson 2.1. A bloated file taxes every single task.
What goes in, what stays out
✕ Files that don’t help
- –A copy of the README’s marketing intro
- –“Write clean, maintainable code” and other vague virtues
- –The full architecture doc pasted inline
- –Rules nobody enforces and the linter already covers
- –Contradictions left over from three years of edits
✓ Files that work
- +Exact commands: install, build, test one file, lint
- +Where things live, in five to ten lines
- +Hard rules with a reason: “never edit /gen, it is regenerated”
- +Pointers to deeper docs instead of copies of them
- +How to know you’re done: which checks must pass
Here is the shape I start from. It is short on purpose. Adapt the commands and paths to your stack.
# Agent instructions
## Commands
- Install: pnpm install
- Run one test file: pnpm test path/to/file.test.ts
- Full check before finishing: pnpm lint && pnpm typecheck && pnpm test
## Layout
- apps/web: Next.js front end
- packages/billing: pricing and invoice logic (money in integer cents)
- packages/api-client: GENERATED, never edit by hand, run pnpm gen
## Rules
- Add or update a test for every behavior change.
- Don't add dependencies without saying why in your summary.
- Database migrations live in db/migrations; never edit an applied one.
## More context
- Billing rules: docs/billing.md
- Error handling conventions: docs/errors.md
Quick check
🧠 Instruction file check
Score: 0 / 4
1. Your agent keeps running the whole test suite, which takes 12 minutes. What’s the best fix?
2. Why keep the instruction file short?
3. Which line is most useful?
4. The agent made the same mistake twice this week. What do you do?
Team-wide conventions for these files, and sharing prompts across a team, come back in Module 6.
Before you move on
✅ Key takeaways
0 / 5 completed