Step 1. Find every instruction file
Agent instructions spread across more files than most teams expect. One tool reads CLAUDE.md, another reads .cursor/rules, a third reads .github/copilot-instructions.md, and each can say something different about how to run the tests. List them before you try to keep them right.
AGENTS.md,CLAUDE.mdandGEMINI.md, at the root and in subfolders..cursor/rules/**/*.mdc,.cursorrules,.windsurfrules,.windsurf/rules/*.mdand.clinerules..github/copilot-instructions.md,.github/instructions/*.instructions.mdand.github/prompts/*.prompt.md.SKILL.mdfiles in askills/<name>/folder, including under.claude/skillsand.agents/skills.
git ls-files | grep -E '(^|/)(AGENTS|CLAUDE|GEMINI|SKILL)\.md$|\.cursorrules$|\.windsurfrules$|\.clinerules$|\.cursor/rules/|copilot-instructions\.md$|\.instructions\.md$|\.prompt\.md$'Step 2. Keep one source and link to it
Two files that state the same command drift apart the first time someone edits one of them. Pick one file as the source, usually AGENTS.md, and make the others point to it. CLAUDE.md can import it with a single line, @AGENTS.md.
Then cut. Keep what an agent cannot work out from the code: the commands to build, test and lint, where things live, the conventions that are not visible in a file, and the mistakes to avoid. Link to a docs page instead of copying it, so there is one place to fix.
Step 3. Check commands and paths in CI
Most stale instructions are mechanical: a script that was renamed, a path that moved. A short script catches those on every pull request. This one reads AGENTS.md and CLAUDE.md, checks each npm run, pnpm run, yarn run or bun run command against the scripts in the root package.json, and checks that every path in backticks exists.
import { existsSync, readFileSync } from "node:fs";
const files = ["AGENTS.md", "CLAUDE.md"].filter((file) => existsSync(file));const pkg = JSON.parse(readFileSync("package.json", "utf8"));const scripts = Object.keys(pkg.scripts ?? {});const problems = [];
for (const file of files) { const text = readFileSync(file, "utf8"); for (const [, name] of text.matchAll(/\b(?:npm|pnpm|yarn|bun) run ([\w:.-]+)/g)) { const script = name.replace(/\.+$/, ""); if (!scripts.includes(script)) problems.push(`${file}: no "${script}" script`); } for (const [, path] of text.matchAll(/`(\.{0,2}\/?[\w.-]+\/[\w./-]*)`/g)) { if (!existsSync(path)) problems.push(`${file}: ${path} does not exist`); }}
if (problems.length > 0) { console.error(problems.join("\n")); process.exit(1);}Run it and extend it
Run it from the repository root with node scripts/check-agent-files.mjs and add that command as a step in your CI workflow. It exits with status 1 and prints one line per problem, such as AGENTS.md: no "test:unit" script.
It is deliberately narrow. It skips short forms such as pnpm test, scripts in workspace packages, Makefile targets and globs. Add the patterns your files use, and keep the check strict enough that a failure always means a real problem.
Step 4. Give the files owners
Add the instruction files to CODEOWNERS so the team that maintains the build and tooling reviews every edit. A line without a leading slash, such as AGENTS.md @acme/platform, matches the file in every folder.
Add one line to the pull request template's docs checklist: this change renames a script, moves a folder or changes a convention, and I updated AGENTS.md. The author is the person who knows the old name.
Step 5. Review them on the pull requests that break them
The file goes stale in a pull request that never touches it: the one that renames test:unit to test. A check that reads the instructions alongside the code catches it there. Rimfe reads every file in the list above on each review, even when your docs globs leave them out, and checks them without an AI model. A path listed in docsIgnorePaths is still skipped.
| Rimfe checks | What must be true |
|---|---|
| Commands | Each pnpm, npm, yarn or bun script exists in the package.json of the file's folder or the root, each make target in the Makefile, each just recipe in the justfile and each cargo alias in .cargo/config.toml. |
| Paths | A path in backticks exists in the repository. |
| Env vars | A variable in backticks is in an env example file or read by your code. |
| Imports | A @path import such as @AGENTS.md points at a file. |
What a finding looks like
A failed lookup becomes a Wrong agent instruction finding that quotes the line and says what was looked up. On a pull request Rimfe reports it when the pull request edited that line, or removed the script, target or path the line names. Audits report every one. Claims about behavior, such as which command runs the unit tests, go to the model review, which reads these files with the rest of your docs.
A Rimfe patch to an agent instruction file always waits for a repository admin or maintainer to approve it with @rimfe approve patch. To leave the files out of review, set "agentContext": false in .rimfe.json.
Common mistakes
- Keeping the same build steps in
CLAUDE.md,.cursorrulesandAGENTS.md, so a change lands in one of three. - Writing the file once at project start and treating it as finished.
- Copying whole docs pages into the file, so the agent reads a stale copy of a page that someone fixed.
- Leaving rules for tools or folders the project no longer uses. Delete them.
Takeaway
Keep one short source file, check its commands and paths on every pull request, and give it owners. An agent will run whatever the file says.