Skip to main content
Moxie Docs
All guides

Agent instructions

How to keep AGENTS.md and CLAUDE.md up to date when conventions change

The short answer

Make AGENTS.md the one canonical file and have CLAUDE.md import it with @AGENTS.md. Move every rule a linter, formatter or type checker can enforce out of prose and into config. Put package-specific rules in nested files. Then treat the files like code: CODEOWNERS, a pull request checklist item, and a CI check that the commands and paths they mention still exist.

Agent instruction files go stale the same way docs do: someone changes a convention in code review, and the file that tells agents how to work never hears about it. These are the practices that keep them current, most of which need no extra tooling.

Last reviewed: December 2026

Need living codebase context for Claude Code or Cursor?

Moxie Docs indexes your codebase and serves verified conventions and docs over MCP. Free on 1 repo.

Connect 1 repo free

1. Keep one source of truth

AGENTS.md is read by Codex, Cursor, Copilot's coding agent, Gemini CLI, Windsurf and many other tools (agents.md lists them). Claude Code reads CLAUDE.md, and recent versions also read AGENTS.md, but by default only when there is no CLAUDE.md (Claude Code memory docs).

The simplest setup is AGENTS.md as the canonical file and a CLAUDE.md that imports it, with Claude-only notes underneath:

MARKDOWN
@AGENTS.md

## Claude Code

Use plan mode for changes under `src/billing/`.

Now a convention change is an edit to one file. Claude Code's docs also mention a symlink (ln -s AGENTS.md CLAUDE.md) but advise against it if anyone on the team uses Windows.

2. Move enforceable rules into tools

Every rule a tool can check is a rule that can't drift in prose. Import order, naming, formatting, banned APIs, test file locations: put them in ESLint, Biome, Ruff, a type checker or a custom lint rule. The agent gets the error message when it breaks the rule, and the instruction file only needs to say which command to run.

Keep in the file what tools can't check: architecture boundaries, which package owns what, how to run things, and the reasons behind non-obvious choices.

3. Scope rules to where they apply

A root file that covers every package is long and mostly irrelevant to any one change. Put package rules next to the package: agents.md says the closest AGENTS.md to the edited file wins, and Claude Code loads a subdirectory's CLAUDE.md when it reads or edits a file there. Claude Code also supports .claude/rules/*.md files with a paths: list in frontmatter, loaded only when a matching file is touched. See Claude Code and Cursor ignore monorepo conventions for the full setup.

4. Make convention changes update the file

Conventions usually change in a code review comment or a refactor PR. Catch that moment:

  • CODEOWNERS: Give AGENTS.md, CLAUDE.md and .claude/rules an owner so changes get a reviewer who knows the conventions.
  • Pull request template: Add one checkbox: 'This PR changes a convention, command or directory layout, and AGENTS.md is updated.'
  • Same-PR rule: When a refactor changes how something should be done, the instruction file changes in the same PR, not a follow-up.
  • Ask the agent: At the end of a session, ask the agent to propose edits to AGENTS.md based on corrections you gave it. In Claude Code, /init on a repo that already has a CLAUDE.md suggests improvements instead of overwriting it, and /memory opens the files for editing.

5. Check the file in CI

The cheapest stale-instruction check is mechanical: every command and path the file mentions should exist. A short script can pull npm run <x> or make <x> references out of AGENTS.md and fail if the script or target is gone, and check that referenced directories exist. It won't catch a wrong rule, but it catches renamed scripts and moved folders, which are the most common breakage.

Where a tool helps

The practices above keep the files honest but still depend on people noticing changes. Tools that read the code can take some of that work. Moxie Docs is one option: instead of writing every convention into AGENTS.md, it adds a short managed section that points agents at its MCP server, which serves conventions detected from the code and re-indexed on every merge. If that section drifts, it opens a pull request to fix it. Your hand-written rules stay yours. It's free for one GitHub repository.

The short version

One canonical AGENTS.md, imported by CLAUDE.md. Enforce what you can with tools, scope the rest to where it applies, and make the instruction files part of code review and CI.

FAQ

Frequently asked questions

Quick answers to the questions developers ask about Keep AGENTS.md and CLAUDE.md up to date.

Get started

Give your agents real codebase context.

Connect a repository and Moxie Docs generates living documentation and serves it to your agents over MCP. Free on 1 repository, no card required.