Agent Instruction Files
Write one short instruction file that tells an AI coding agent how to run your project, what is off limits, and how to check its work.
Content date: October 15, 2026.
Plain English
An instruction file is a plain text file the agent reads at the start of a session. It holds lasting background: how to start the project, what matters, what is sensitive, and how changes get checked. It guides the agent but does not control it, so it cannot stop anything the tools allow. One agent with a focused task and a review step is a good start. You do not need a team of five roles.
Use this when
Write one when you keep typing the same setup steps or rules into every chat, or when another person or agent starts working in the project.
If you are just starting
Create a short AGENTS.md in your project folder with commands to start and test it (only ones you have run), the limits (for example, never touch the live website), and what you will review. Codex reads AGENTS.md. Claude Code reads CLAUDE.md, and uses AGENTS.md only if there is no CLAUDE.md. Gemini CLI reads GEMINI.md by default. If you use several tools, keep the rules in AGENTS.md and make CLAUDE.md the single line @AGENTS.md. Put long guides in linked documents.
When your project grows
Keep the file short and current, and delete rules the agent already follows. Add a specialist helper only for a real need, such as an independent security review or a job that can run at the same time, with one owner. Enforce permissions with tool settings, sandboxes, and which credentials the agent can see. A written rule is only a request.
Worked example
Dana runs the website for a school robotics club. Her AGENTS.md has six lines: how to start the site, how to build it, how to test sign-up with a made-up name, a rule against using the real parent email list, and a link to a guide for database changes. She also deletes the real email export from the project folder, because a rule in a file would not stop an agent from reading it.
Practice
Orient a fresh agent
- Open your README and any AGENTS.md, CLAUDE.md, or GEMINI.md. Note what is out of date or contradictory.
- Run each setup and check command in a safe local copy. Cross out any that fail.
- Write a short AGENTS.md with working commands, off-limits areas, and links to longer guides. For Claude Code, add a CLAUDE.md containing only @AGENTS.md.
- In a brand-new session, ask: "Describe this project and the checks you would run after a small change."
- Fix every place the agent guessed wrong by improving the file, then ask again.
Deliverable: Your instruction file and a short note showing what the fresh session said before and after your fixes.
Common mistakes to watch for
- CLAUDE.md says npm and AGENTS.md says pnpm, so the agent follows whichever its tool loads.
- You paste in a test command you never ran, and every session wastes time on its error.
- A 600-line file buries the one rule that matters.
- You write "never touch production" but leave production passwords on the computer.
Prompting
A weak prompt
Set up a team of five agents for every change and have them all review everything.
A better prompt
Look through this project and create or update a short AGENTS.md. Include only commands you have run here, the important off-limits areas, and the checks expected before a change counts as done. Link to longer guides instead of copying them. Start with one agent and suggest more only for independent work with a clear owner. Do not claim the file enforces permissions. Tell me what you changed and which commands you could not verify.
Without it you re-explain the project every session and the agent guesses. With it, a new session can start the project and check a change by itself.
Check before you move on
- Every command in the file was run, or is marked as not yet run.
- The file names what the agent must not touch and holds no passwords or customer data.
- A brand-new session described the project correctly using only the file.
You are done when
- A fresh agent session can say how to start the project and check a small change.
- Anything that must be blocked is blocked by a setting or removed access.
Questions to think about
AGENTS.md says "never access production," but the agent's environment holds the production database password. Is production protected?
No. The file states a wish but cannot enforce it. Remove the credential or restrict the tool's permissions.
A 40-step migration procedure matters once a month. Where does it belong?
In a separate document or skill, with one line in AGENTS.md pointing to it. Otherwise every task loads it.
Your project has a CLAUDE.md and an AGENTS.md with different build commands. What does Claude Code read?
Only CLAUDE.md, by default. Keep one set of rules in AGENTS.md and have CLAUDE.md import it with @AGENTS.md.