Repo instructions for AI agents
Write repo instructions that help AI coding agents respect architecture, tests, security rules and local workflows.

Put it into practice
What you will produce
A concise instruction file with architecture pointers, commands, protected areas and change-specific quality expectations.
- 01
Collect durable repository facts
Inspect the package scripts, directory structure, architecture notes and protected paths; include only conventions that are evidenced and likely to remain useful across tasks.
Expected result: A fact base that points agents toward the right code and commands.
- 02
Write concise task boundaries
Document file ownership or protected areas, input validation and data-scope rules relevant to the project, plus when a change requires human review or clarification.
Expected result: Instructions that prevent common scope and safety mistakes without dictating an implementation for every task.
- 03
Make checks discoverable
List the actual commands for type checks, lint, build or focused verification, explain which change types need which command, and link detailed rules to their maintained source.
Expected result: A usable route from a task to the correct project check, with no guessed commands.
- 04
Test with a fresh task
Give the file to a fresh agent on a small repository question; check whether it finds the right path and command, then compare every instruction against current project sources for drift.
Expected result: A concise instruction file validated against both agent discovery and repository reality.
Acceptance checks
- Commands, architecture pointers and protected paths match current repository sources.
- Instructions distinguish stable project rules from task-specific decisions.
- Detailed rules link to an identified source of truth instead of duplicating it.
- A fresh agent can find the relevant code and correct check using the file.
Limits and trade-offs
Instructions drift. Keep them short, link to source-of-truth docs and periodically remove obsolete rules.
Official sources
Write better repo instructions
Related guides
CLAUDE.md: A Guide for Every Developer
One markdown file that makes AI coding assistants actually understand your codebase. Here's what to put in it.
There's a reason Claude Code writes great code in some projects and generic boilerplate in others. It's not the model. It's CLAUDE.md . It is one part of my Claude Code workflow: project conventions reduce guesswork, but they do not guarantee a speedup or remove the need to review the change. What it is CLAUDE.md is a plain markdown file that Claude Code reads at the start of every session. Think of it as the onboarding doc you'd give a senior contractor on day one: stack, conventions, rules, context. Without it, Claude infers patterns from what it sees in the codebase. Sometimes it infers correctly. Often it doesn't especially for implicit conventions your team just "knows". A CLAUDE.md makes your rules available without repeating them, but does not guarantee compliance: review the diff and run the checks. What to put in it 1. Stack and versions Simple but important. These…
Read the guideClaude Code Subagents: Parallel Agents
Learn when Claude Code subagents help, how to split parallel work, and how to configure a focused custom subagent without creating conflicts.
Subagents are useful when a task can be split cleanly: one agent searches the authentication code, another traces the database path, and the main conversation compares what they found. They add little to "read this file" or to work where every step depends on the same context. Short version: delegate independent research or a separate review when the results are worth the extra context and usage. Give each agent a narrow scope, the files or area to inspect, and a specific report format. Keep dependent work in the main conversation. Claude Code agents vs subagents Claude Code's documentation calls delegated workers subagents and uses Agent for the tool that starts them. When people search for Claude Code agents in this context, they usually mean subagents: workers that handle a delegated task in their own context and return a result to the main conversation. Claude Code's subagent documentation uses this terminology.…
Read the guide