Topic 5 of 5 · 5 min read
One instruction file across many agents
Goal: Set up project rules so Claude Code, Codex, Gemini CLI and Copilot read the same instructions, and spot drift between copies.
Keep one file as the source of truth and make every other tool's file point to it, so the rules cannot drift apart. Each tool has its own filename, and copies pasted between them will disagree within weeks.
Check yourself · 1 of 3
Why do separate hand-maintained copies of the rules for each agent cause trouble?
Why it matters
Teams use more than one agent: Claude Code for one task, Codex or Copilot for another, Gemini CLI for a third. Each reads a different file. If you maintain four, you update one and forget three, and the tools then behave differently on the same repo.
Who reads what
- AGENTS.md is an open, plain-markdown format that many coding agents read, including Codex and Copilot's coding agent. See agents.md.
- CLAUDE.md is read by Claude Code. The Claude Code docs describe importing an AGENTS.md from CLAUDE.md so both tools share one file.
- GEMINI.md is read by Gemini CLI by default. Its docs describe a setting to name other context files, so it can read AGENTS.md as well.
- Copilot reads
.github/copilot-instructions.mdfor the repository, and supports path-specific instruction files.
Filenames and support change quickly, so check each tool's current docs before relying on this list.
A setup that does not drift
- Write the real rules once in
AGENTS.mdat the repo root. - Make each tool-specific file a thin pointer. For Claude Code,
CLAUDE.mdcan import it, and hold only Claude-specific lines below. - For tools that cannot import, use a symlink or a small script that fails CI when the copies differ.
- Keep tool-specific rules in the tool file: "Claude: use plan mode before large edits".
<!-- CLAUDE.md -->
@AGENTS.md
## Claude Code only
- Use plan mode before changes that touch more than three files.
# CI check: fail if the Copilot file is a stale copy
diff -q AGENTS.md .github/copilot-instructions.md || {
echo "copilot-instructions.md differs from AGENTS.md"; exit 1; }
Before and after
Before: four separate files, each about 120 lines. Three say npm test; one, updated after a move to pnpm, says pnpm test. Codex runs the wrong command and reports a failure that is not real.
After: one AGENTS.md, two short pointer files and a CI diff. The command is changed in one place.
What goes wrong
- Silent drift. Copies diverge with no error, and each agent follows different rules.
- Imports that one tool ignores. An
@import works in Claude Code; another tool may show it as plain text. Test each tool. - Tool-specific features in the shared file. "Use plan mode" is meaningless to Codex and wastes its context.
Examples
Claude Code and Codex on one repo
The repo has AGENTS.md with commands and boundaries. CLAUDE.md contains @AGENTS.md and two Claude-only lines. Codex reads AGENTS.md directly. A command change is one edit.
A drift check in CI
A team keeps .github/copilot-instructions.md as a copy because Copilot needs that path. A CI step runs diff -q against AGENTS.md. When someone edits only one file, the build fails with the filename.
Key points
- Keep one source of truth, commonly AGENTS.md, and make each tool's own file point to it.
- Use an import, a symlink or a CI diff check so copies cannot silently drift apart.
- Put tool-specific instructions only in that tool's file, below the shared content.
- Test that each tool really loads the shared file, since import support differs between tools.
- Check each tool's current docs for filenames, because support changes quickly.
Common mistakes
- Maintaining a separate full copy for each tool by hand.
- Assuming every tool understands the same import syntax.
- Putting one tool's commands or features in the shared file.
- Having no check, so a stale copy is found only when an agent behaves oddly.
Check yourself · 2 of 3
A repo has AGENTS.md and a CLAUDE.md. What is a common way to avoid duplicate rules?
Check yourself · 3 of 3
A tool needs its own file copy at a fixed path and cannot import. What helps stop it going stale?
Practice items, not counted towards your mastery.
Start here
- AGENTS.md (opens in a new tab)DocsFree
The open format for a plain-markdown instruction file that many coding agents read, with examples.
- How Claude remembers your project (Claude Code docs) (opens in a new tab)DocsFree
Where CLAUDE.md files load from, the under-200-lines target, imports, rules and troubleshooting.
- Custom instructions with AGENTS.md (OpenAI Codex docs) (opens in a new tab)DocsFree
How Codex finds and layers AGENTS.md files from the global folder down to the working directory.
More for this topic
- Provide context with GEMINI.md files (Gemini CLI docs) (opens in a new tab)DocsFree
How Gemini CLI loads GEMINI.md files hierarchically and lets you import other files.
- Adding repository custom instructions for GitHub Copilot (opens in a new tab)DocsFree
Where Copilot reads repository-wide and path-specific instruction files.