Prompt & Context Engineering·Question 35 of 68Intermediate

What belongs in a repository instruction file such as AGENTS.md or CLAUDE.md for a coding agent, and what should stay out?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

The file is loaded into every one of the coding agent's sessions. So it should hold only what the agent cannot cheaply discover from the code and would otherwise get wrong: how to build, test and lint, the conventions no tool enforces, and the traps. Everything else is a cost paid on every request.

Full worked answer

The file is loaded into every one of the coding agent's sessions. So it should hold only what the agent cannot cheaply discover from the code and would otherwise get wrong: how to build, test and lint, the conventions no tool enforces, and the traps. Everything else is a cost paid on every request.

What earns a place:

  • Exact commands. How to run the full suite, a single test, the linter and the type checker. Agents waste whole turns guessing between npm test and pnpm vitest run.
  • Non-obvious conventions. "New endpoints go through the service layer, never call the ORM from a handler." Things a reviewer would reject that no linter catches.
  • Landmines. Generated files not to edit, the slow integration suite to skip locally, the migration that must never be rerun.
  • Pointers, not payloads. "Architecture notes live in docs/architecture.md" lets the agent read on demand instead of paying for the content in every session.

What stays out: rules a linter or formatter already enforces (the tool will tell the agent, and a duplicated rule drifts), long architecture essays, generic advice like "write clean code", and secrets. Keep it short, because it sits in the cached prefix of every session.

In a monorepo, a nested file in each package lets the closest one add local rules, so frontend conventions are not loaded while the agent works on the billing service.

People miss two risks:

  • Staleness. A file naming a command that was removed last quarter is worse than no file, because the agent follows it confidently. Review it in pull requests and update it when the build changes.
  • Injection. An agent working in a cloned third-party repo reads that repo's instruction file with the same trust as yours, so its permissions must not depend on the file being harmless.

Measure changes to the file the way you would any prompt change: run a fixed set of representative agent tasks before and after, and compare success rate and turns used.

What a good answer covers

  • The file is loaded into every one of the coding agent's sessions
  • So it should hold only what the agent cannot cheaply discover from the code and would otherwise get wrong
  • Everything else is a cost paid on every request
  • Exact commands
  • Non-obvious conventions

Key terms: Exact commands · Non-obvious conventions · Landmines · Pointers, not payloads · Staleness · Injection

Interviewer follow-ups to expect

  1. How would you decide whether a rule belongs in the instruction file, a linter config, or a skill loaded on demand?

  2. How would you detect that the file has gone stale?

  3. What permissions would you give an agent working in an untrusted repository?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep