Skip to content
mentoor

Topic 2 of 4 · 4 min read

Keeping one source of truth for instructions

Goal: Restructure duplicated instruction files into one source with thin tool-specific wrappers and review the diff for lost rules.

Write each rule once, in one file, and make every other agent file a thin pointer to it, because hand-kept copies drift apart within weeks.

Check yourself · 1 of 3

Why are hand-kept copies of instructions risky?

Choose one answer

Why it matters

Say you keep CLAUDE.md, GEMINI.md and .github/copilot-instructions.md, each 80 lines, each pasted from the others. Someone changes the test command in one file. The other two are now wrong, and nobody notices until an agent runs the old command. Duplicated rules are a bug that does not fail a build.

Three ways to share

  1. Import. CLAUDE.md contains a line such as @AGENTS.md, and Claude Code pulls that file in. Gemini CLI also supports @file imports in its context file.
  2. Symlink. CLAUDE.md is a symbolic link to AGENTS.md. There is no copy, so no drift. Check that your tools and your Windows machines follow links.
  3. Generated copies. A small script writes each tool's file from one source and a CI check fails if they differ. Use this when a tool needs its own format, such as front matter.

Prefer the first two. Use generation only when a tool cannot read the shared file.

How to restructure

  1. Diff the existing files. List rules that appear in only one of them.
  2. Merge every rule into AGENTS.md. Decide on each conflict. Do not silently pick one.
  3. Replace each tool file with a wrapper: an import or link, plus only the rules that tool needs, such as a Claude-only hook note.
  4. Review the diff for lost rules. Every line deleted from a tool file must exist in AGENTS.md.
  5. Test each agent: ask it for the test command and one forbidden path.

Before and after

Before: three files, 240 lines, two different test commands.

After: AGENTS.md has the shared rules. CLAUDE.md is two lines: an import of AGENTS.md and a note that Claude-specific hooks live in settings. The other agents read AGENTS.md directly.

What goes wrong

  • Losing a rule in the merge. The tool-specific file had a rule the shared one never got. Review the removed lines, not just the added ones.
  • A link that breaks on checkout. Some Windows setups turn symlinks into plain text files. Test on each platform your team uses.
  • A wrapper that grows back. Over time people add shared rules to the wrapper. Add a review rule: shared rules go in AGENTS.md only.

Examples

A wrapper diff

--- a/CLAUDE.md
+++ b/CLAUDE.md
@@
-# Project rules
-Run `pnpm test` before finishing.
-Never edit `generated/`.
-Use named exports.
+@AGENTS.md
+
+Claude-specific: hooks are configured in `.claude/settings.json`.

Check that all three removed rules now exist in AGENTS.md. If Use named exports does not, it was lost.

Conflicting commands

CLAUDE.md says npm test and GEMINI.md says pnpm test. The repository uses a pnpm-lock.yaml. The merge keeps pnpm test and notes the decision in the pull request, so nobody has to guess later.

Key points

  • Write each rule once in a shared file, and keep tool files as thin wrappers.
  • Imports and symlinks avoid copies; generated copies need a CI check that they match the source.
  • When merging, resolve conflicting rules on purpose and never keep both silently.
  • Review the deleted lines of the diff to catch rules that were lost, not only the added lines.
  • Test every agent after the change by asking it for a command and a forbidden path.

Common mistakes

  • Copying the same rules into every tool file by hand.
  • Reviewing only the added lines of a consolidation diff and missing deleted rules.
  • Merging two conflicting rules without choosing one.
  • Using a symlink without testing it on every platform the team uses.

Check yourself · 2 of 3

CLAUDE.md should share rules with AGENTS.md without a copy. Which approach does that?

Choose one answer

Check yourself · 3 of 3

You replaced three duplicate files with one AGENTS.md and thin wrappers. What should you check in the diff?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic