Project instructions
Customizing agents · topic customizing-agents/instructions
Project instructions are the standing brief an agent reads at the start of every session in a repository. This topic covers the instruction file and its conventions, which sections earn their place, how instructions layer in a monorepo, and the point where a rule needs a hook or a tool instead of a sentence.
Concepts
- AGENTS.md / CLAUDE.md
- The instruction file coding agents load automatically from a repository root. Several tools read a shared name and others read their own; a symlink lets one file serve both. It holds what the agent must know every session: commands, conventions, boundaries. It is not documentation for people and is read on every turn, so every line costs context. glossary
- Sections
- The recurring parts of a good instruction file: what the project is, how to build, test and lint, the layout of the code, the conventions to follow, the things never to do, and how to finish a piece of work. Each section answers a question the agent would otherwise guess at. Remove anything the agent can discover cheaply itself, and keep examples concrete. glossary
- Monorepo hierarchy
- In a repository with many packages, instruction files can sit at the root and inside subdirectories; the agent reads the ones on the path to the files it is working on. Root holds what is true everywhere, subdirectory files hold what differs. The hierarchy keeps each file short and lets teams own their own rules without conflicting. glossary
- When instructions are not enough
- Instructions are requests; a model follows them most of the time and forgets them as context fills. A rule that must hold every time, such as never committing secrets or always running the formatter, belongs in a hook or a permission setting that enforces it mechanically. A capability the agent lacks belongs in a tool or a skill, not in a longer paragraph. glossary
- Loading versus pointing
- Two ways to give an agent guidance. Loading puts the text in the instruction file, so it is in the context of every session whether the task needs it or not. Pointing puts one line there that says where the detail is, such as a file path or a skill, and the agent reads it when a task calls for it. Load what nearly every task needs and point at the rest. An import that pulls a file in at start-up still loads it. glossary
- Pruning instructions
- Removing the lines of an instruction file that no longer earn their place: a rule the agent already follows without being told, a fact it can work out from the code, a line that conflicts with another, a rule for a problem that has gone away. The test for each line is whether removing it would cause a mistake. Rules in a long file get ignored, so pruning makes the remaining rules work better. glossary
Links
- Builds on: nothing
- Leads to: Hooks, permissions, settings, Connecting tools with MCP, Agent skills
- Related: Context engineering for code
- Competencies drawing on it: Adopts a published skill set without giving up control of the project, Configures an agent for a project, Writes a reusable agent skill
Lessons
- Project instructions: AGENTS.md (tutorial)
- Load it, point at it, or cut it (tutorial)
Your reference
Each lesson above adds its takeaways and its example here once you finish it. Your reference lists every lesson you have finished.
Project instructions: AGENTS.md
Unlocks when you finish Project instructions: AGENTS.md.
Takeaways
- The agent reads
AGENTS.md(orCLAUDE.md; same content, different tool convention) at the start of every session; it is the briefing for a capable contractor's first morning. - Put in it what the agent can't read from the code: commands, structure, conventions, and one line for every mistake it keeps making.
- Leave out what the code already says, long prose, and rules that apply to every project on earth. Short files get followed; long ones get skimmed.
- In a monorepo, the root file holds what's shared and each project's file holds only what differs. Keep the two from contradicting each other, because tools differ on which one applies.
- A rule you can't afford to have skipped belongs in a hook rather than in prose, and a procedure the agent should repeat belongs in a skill.
Example
This lesson has no runnable example or prompt block.
Load it, point at it, or cut it
Unlocks when you finish Load it, point at it, or cut it.
Takeaways
- Every line in an instruction file is in context for every task, and a long file gets followed less well than a short one.
- Load what nearly every task needs, and point at the rest with one line that says when to read the file and where it is.
- An
@pathimport expands the file into the context at start-up, so it makes the file tidier without making it cheaper. - Prune by asking of each line whether the agent would get something wrong without it. Cut rules the agent follows anyway, facts the code states, problems that have gone away, and one of every pair of lines that contradict each other.
- After a cut, run the usual tasks and add back only the line whose absence caused a mistake.
Example
How many lines load? · open in the lesson
AGENTS.long.md has 57 lines and imports nothing. AGENTS.pruned.md and AGENTS.imports.md have 20 lines each. docs/templates.md has 7 lines and docs/release.md has 11. The script prints one line per file, in the order long, imports, pruned, in the form AGENTS.long.md: 57 lines at start. What does it print?
Prints the lines below (verified in CI from site/examples/customizing-agents/load-point-prune/startup.py)
AGENTS.long.md: 57 lines at start AGENTS.imports.md: 38 lines at start AGENTS.pruned.md: 20 lines at start
Sources
AEC-15AGENTS.md: contents, monorepo hierarchies, with a builder widget, Agent Engineer Course (course)Academy claude-code-101Claude Code 101, Claude Academy (course)Academy claude-code-in-actionClaude Code in action, Claude Academy (course)Claude Code memoryHow Claude remembers your project, Claude Code documentation (reference)Claude Code best practicesBest practices for Claude Code, Claude Code documentation (reference)Anthropic context engineeringEffective context engineering for AI agents, Anthropic Engineering (reference)