Sub topic 13
Common pitfalls
This chapter assumes you have read the earlier chapters. You should know the AGENTS.md format, how nested files and precedence work, and how to write concrete instructions. Here we collect the mistakes that most often make an AGENTS.md ineffective or harmful, and show how to fix each one.
Pitfall 1: Vague guidance
An instruction such as "write clean code" gives an agent nothing to act on and gives a reviewer nothing to check. Replace it with a command or a location.
<!-- Vague: hard to act on or check -->
- Write clean code and test it properly.
<!-- Concrete: an agent can follow it and a reviewer can verify it -->
- Run `npm run lint && npm test` before finishing; fix any failures you introduced.
- New public functions in `src/services/` need a unit test in the matching `*.test.ts` file.A quick test: could a teammate tell, from the diff alone, whether the rule was followed? If not, rewrite it.
Pitfall 2: Too long, too general
A file that tries to document everything buries the rules that matter. Agents read the whole file on each task, so every line competes for attention. Keep general programming advice out. The agent already knows it. Include only what is specific to this repository: commands, conventions that differ from defaults, and traps.
Pitfall 3: Secrets and risky guidance
AGENTS.md is committed to the repository and read by tools and people. Do not put tokens, passwords, private keys or internal URLs in it. Point to where secrets live instead, for example "Copy .env.example to .env and ask the team lead for the API key."
Also avoid guidance that weakens safety, such as "skip tests if they are slow" or "force push to fix history".
Pitfall 4: Stale instructions
Commands change. If the file says yarn test and the project moved to npm test, the agent will fail or, worse, work around the failure in unexpected ways. Treat AGENTS.md like code:
- Update it in the same pull request that changes a build command or directory layout.
- Review it when you upgrade major tools.
- Remove rules that no longer apply.
Pitfall 5: Misreading scope and precedence
Two common errors come from scope. First, putting package-specific rules in the root file, so every agent run sees rules that do not apply. Second, forgetting that the nearest file wins. If packages/web/AGENTS.md conflicts with the root file, the nested one applies to files under packages/web/. An explicit instruction in the user's prompt overrides both.
repo/
├── AGENTS.md # repo-wide rules
└── packages/
└── web/
├── AGENTS.md # wins for files under packages/web/
└── src/Do not duplicate the same rule in both files. Duplicates drift apart, and then the two files disagree.
Pitfall 6: Duplicate files for different tools
Maintaining separate AGENTS.md and CLAUDE.md files with copied content leads to drift. Keep one source of truth.
# Keep one source of truth for tools that read a different filename
ln -s AGENTS.md CLAUDE.mdIf one tool needs extra notes, import the shared file and add only the differences.
# CLAUDE.md
@AGENTS.md
## Claude-specific notes
- Prefer running the single-file test command while iterating.Pitfall 7: Never checking the result
Writing the file is not the same as it working. If you never test it, you will not know that the agent ignores a rule or follows an outdated one. Give the agent a small task that touches your rules, such as adding a function and its test, and check whether it used the right commands and put code in the right place.
Pitfall summary
| Pitfall | Symptom | Fix |
|---|---|---|
| Vague rules | Agent guesses or ignores them | Name exact commands and paths |
| Overlong file | Key rules are missed | Keep only repo-specific content |
| Secrets in file | Credentials in version control | Reference where secrets live |
| Stale commands | Agent runs failing commands | Update with the code change |
| Wrong scope | Rules apply where they should not | Move rules into nested files |
| Copied files | Files disagree over time | Symlink or import |
| No verification | Unknown whether rules work | Run a test task and inspect it |
Exercise
Your root AGENTS.md says "Run yarn test", but the project switched to npm last month. Agents keep failing at the test step. Name the pitfall and give two practices that prevent it.
Show answer
The pitfall is stale instructions. Prevent it by updating AGENTS.md in the same pull request that changes the command, and by running a small test task with an agent after major tooling changes to confirm the commands still work.
Exercise
Rewrite this rule so an agent can follow it and a reviewer can check it: "Make sure the code is well tested."
Show answer
For example: "Add or update tests for every behavior change. Run npm test before finishing and fix any failures you introduced." Any version that names a command, a location, or a checkable condition is acceptable.