Skip to content

How to keep AGENTS.md and CLAUDE.md up to date

Coding agents follow AGENTS.md and CLAUDE.md literally, so a renamed script or a moved folder turns into a failed command in every session. Keep the files short, check every command and path they name in CI, give them owners, and review them on the pull requests that change what they describe.

Updated 5 min read

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.md and GEMINI.md, at the root and in subfolders.
  • .cursor/rules/**/*.mdc, .cursorrules, .windsurfrules, .windsurf/rules/*.md and .clinerules.
  • .github/copilot-instructions.md, .github/instructions/*.instructions.md and .github/prompts/*.prompt.md.
  • SKILL.md files in a skills/<name>/ folder, including under .claude/skills and .agents/skills.
Terminal
git ls-files | grep -E '(^|/)(AGENTS|CLAUDE|GEMINI|SKILL)\.md$|\.cursorrules$|\.windsurfrules$|\.clinerules$|\.cursor/rules/|copilot-instructions\.md$|\.instructions\.md$|\.prompt\.md$'

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.

scripts/check-agent-files.mjs
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 checksWhat must be true
CommandsEach 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.
PathsA path in backticks exists in the repository.
Env varsA variable in backticks is in an env example file or read by your code.
ImportsA @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.

Watch for hidden instructions

An instruction file is also a way into your agent's session. Rimfe scans docs and agent files for text aimed at an agent rather than a reader: invisible characters, HTML comments that give orders or name secrets, images in agent files, and links whose text names a different host from the address. On a pull request it checks only the lines that pull request added, and reports each page as a Hidden instruction finding. Review any edit to these files from an outside contributor with the same care.

Common mistakes

  • Keeping the same build steps in CLAUDE.md, .cursorrules and AGENTS.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.