One source of truth for AI coding tool instructions
Claude Code, Cursor, Copilot and Codex each read rules, skills, commands and hooks from different files. Keep one folder, generate the rest, and let CI fail when a copy drifts.
On a project I worked on in June 2026, the developers were free to pick their AI coding tool: Cursor, Claude Code, GitHub Copilot or Codex. We had written a careful set of instructions for the AI in Cursor’s format: 22 skills, 17 commands, 9 subagents (helper agents the main one hands tasks to) and 13 rules. Then we noticed it only worked in the tool we had written it for. The same repository, opened in Claude Code, ignored almost all of it.
Every tool reads its instructions from its own folder in its own format. If you copy files by hand, the copies drift the first time someone edits one and forgets the others. This post explains what those files are, where each tool looks, and the fix we built: one source folder, a script that writes every tool’s layout from it, and two checks that fail when a generated file is stale.
Five kinds of file an AI coding tool reads
If you have not set these up yet, here is what each one is. They look alike (mostly Markdown), but they load at different moments and carry different weight.
- Instructions are the always-on briefing: how to build, what to avoid, where things live. The tool puts them in every conversation.
- Rules are instructions with a scope. A rule says “when you edit a React component, use theme tokens, not hex colours”, and the tool loads it only when a matching file is involved. I wrote about turning PR review comments into rules an AI coding assistant checks.
- Skills are playbooks in a folder with a
SKILL.mdfile. The tool reads only the name and a one-line description up front, and loads the body when the task matches. That keeps long procedures out of the context until they are needed. - Commands are saved prompts you start by typing
/name. They are shortcuts, not enforcement. - Hooks are scripts the tool runs at fixed moments, such as before a shell command or after a file edit. A hook can block an action. Everything above is advice the model may ignore; a hook is not advice.
The first diagram shows where each tool looks for each kind.
Where each tool looks
I checked each of these against the vendor docs on 21 October 2026. Most of those pages do not pin a tool version, so treat this as a snapshot and check again before you rely on it.
- Cursor reads
.cursor/rules/*.mdcwithdescription,globsandalwaysApplyin the front matter (a plain.mdfile there is ignored), and readsAGENTS.mdin the root and in subfolders. Subagents live in.cursor/agents/, skills in.cursor/skills/or.agents/skills/(plus.claude/agents/and.claude/skills/for compatibility), and hooks in.cursor/hooks.json. In June we kept commands in.cursor/commands/; the current docs no longer give that path and offer a/migrate-to-skillsstep that turns commands into skills. - Claude Code reads
CLAUDE.md, and.claude/rules/*.mdwhere an optionalpaths:list scopes a rule to matching files. Skills are in.claude/skills/, the older.claude/commands/files still work as commands, and hooks sit under ahookskey in.claude/settings.json. Version 2.1.277 and later readAGENTS.mddirectly, but only when noCLAUDE.mdexists. If you keep both, put the line@AGENTS.mdinsideCLAUDE.mdto import it. - GitHub Copilot reads
.github/copilot-instructions.mdfor the whole repository and.github/instructions/NAME.instructions.mdfor scoped ones, with anapplyToglob in the front matter. It also readsAGENTS.md. Skills can live in.github/skills,.claude/skillsor.agents/skills, and hook files go in.github/hooks/*.json(VS Code support for hooks is in preview). Prompt files, its commands, are.github/prompts/*.prompt.md. - Codex reads
AGENTS.md, combining the files from the repository root down to the current folder, and stops at a size limit (32 KiB by default). Project skills live in.agents/skills/<name>/SKILL.md, Model Context Protocol (MCP) servers (tool connections the AI can call) in.codex/config.tomland hooks in.codex/hooks.json, the last two only in a project you have marked as trusted. It has no scoped-rule file (the substitute is anAGENTS.mdin the subfolder), and no project commands: its old custom prompts lived in your home folder and are deprecated in favour of skills.
One honest note: this is not what our research said in June 2026, when we built the generator. Our notes then said Copilot had no skills and no hooks, Claude Code had no scoped rules, Codex had no project hooks, and Cursor did not read .claude/. Some of that was already out of date when we wrote it: GitHub announced skills for Copilot in December 2025, and Claude Code’s paths: rules were in bug reports by January 2026. Check the docs yourself rather than trusting a summary, including this one.
The tools agree on very little. AGENTS.md and SKILL.md are the two shared formats, and every other kind of file still has a different home. That is why copying by hand does not scale.
The fix: one folder, one script
The idea is the same as a build step. You edit a source folder. A script derives each tool’s files. Nobody edits the derived files.
In our project the source was the existing .cursor/ folder, because the work already lived there and Cursor users needed no build step. The sample below uses a neutral agent-config/ folder instead, which is what I would pick on a new project. The mapping is the same either way.
Here is one rule in the source folder. The team’s files had Windows line endings, which matters later.
---description: Use theme tokens, not hard-coded valuesglobs: - "src/components/**/*.tsx" - "src/core/**/*.tsx"alwaysApply: false---# Design tokens
- Use theme classes, never a hex colour.The script below turns each rule into a Copilot instructions file and a Claude Code rule file, and copies each skill’s SKILL.md to the two shared skill locations. It has no dependencies. Without --check it writes files; with --check it writes nothing and exits with 1 if any file differs.
import fs from 'node:fs';import path from 'node:path';
const CHECK = process.argv.includes('--check');const SOURCE = 'agent-config';const MARK = '# GENERATED from agent-config/. Edit the source, then run: node scripts/sync-agent-config.mjs';const outputs = new Map(); // path -> wanted content
// CRLF files must not break the front-matter regex.const lf = (text) => text.replace(/\r\n/g, '\n');
function parse(text) { const match = lf(text).match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/); if (!match) return { data: {}, body: lf(text).trim() }; const data = {}; let list = null; for (const line of match[1].split('\n')) { const item = line.match(/^\s+-\s+(.*)$/); const pair = line.match(/^(\w+):\s*(.*)$/); if (item && list) list.push(item[1].replace(/^["']|["']$/g, '')); else if (pair) { list = pair[2] === '' ? [] : null; data[pair[1]] = list ?? (pair[2] === 'true' ? true : pair[2] === 'false' ? false : pair[2]); } } return { data, body: match[2].trim() };}
const files = (dir) => (fs.existsSync(dir) ? fs.readdirSync(dir, { withFileTypes: true }) : []);
// Rule -> Copilot instructions file (applyTo) and Claude Code rule file (paths)for (const file of files(`${SOURCE}/rules`).filter((f) => f.name.endsWith('.md'))) { const name = file.name.replace(/\.md$/, ''); const { data, body } = parse(fs.readFileSync(`${SOURCE}/rules/${file.name}`, 'utf8')); const globs = data.alwaysApply === true ? ['**'] : data.globs ?? []; if (globs.length === 0) continue; // nothing to scope the rule to outputs.set( `.github/instructions/${name}.instructions.md`, `---\n${MARK}\napplyTo: "${globs.join(',')}"\n---\n${body}\n`, ); const paths = globs.map((g) => ` - "${g}"`).join('\n'); outputs.set(`.claude/rules/${name}.md`, `---\n${MARK}\npaths:\n${paths}\n---\n${body}\n`);}
// Skill folder -> the same folder under .claude/skills and .agents/skillsfor (const dir of files(`${SOURCE}/skills`).filter((f) => f.isDirectory())) { const text = lf(fs.readFileSync(`${SOURCE}/skills/${dir.name}/SKILL.md`, 'utf8')); const marked = text.replace(/^---\n/, `---\n${MARK}\n`); for (const target of ['.claude/skills', '.agents/skills']) { outputs.set(`${target}/${dir.name}/SKILL.md`, marked); }}
let drift = 0;for (const [file, wanted] of outputs) { const current = fs.existsSync(file) ? lf(fs.readFileSync(file, 'utf8')) : null; if (current === wanted) continue; drift++; if (CHECK) console.error(`DRIFT: ${file}`); else { fs.mkdirSync(path.dirname(file), { recursive: true }); fs.writeFileSync(file, wanted); }}if (CHECK && drift) process.exit(1);console.log(CHECK ? `${outputs.size} outputs up to date` : `${drift} written, ${outputs.size - drift} unchanged`);Running it once on the rule above gives the two files below. The marker is a YAML comment inside the front matter, so it does not break the tools’ own parsing.
---# GENERATED from agent-config/. Edit the source, then run: node scripts/sync-agent-config.mjsapplyTo: "src/components/**/*.tsx,src/core/**/*.tsx"---# Design tokens
- Use theme classes, never a hex colour.---# GENERATED from agent-config/. Edit the source, then run: node scripts/sync-agent-config.mjspaths: - "src/components/**/*.tsx" - "src/core/**/*.tsx"---# Design tokens
- Use theme classes, never a hex colour.The real generator did more. It turned commands into Copilot prompt files, copied subagents with their front matter reworked (a readonly: true flag became tools: Read, Grep, Glob), mapped Cursor hook events to Claude Code ones (afterFileEdit to PostToolUse, stop to Stop), rewrote the MCP server list for each tool’s schema, and built AGENTS.md and CLAUDE.md from the always-on rules. Adding a tool meant adding one function to a list of emitters. The first full run wrote 167 files, and adding Codex (its skills folder and its MCP config) took the total to 243.
Make it impossible to drift
A generator on its own fixes nothing. The first time someone hand-edits a generated file, or edits the source and forgets to run the script, the copies disagree again. So two checks run --check, which writes nothing.
The first is a pre-commit hook, so the developer finds out before the commit exists.
# Generated agent config must match the source folder (read-only check).node scripts/sync-agent-config.mjs --check || { echo "Agent config drift: run 'node scripts/sync-agent-config.mjs' and stage the result." exit 1}The second is a CI job, because a hook can be skipped with --no-verify and a developer may not have it installed.
name: Config checkson: pull_request: push: branches: [main]
jobs: agent-config: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 24.x - name: Agent config in sync run: node scripts/sync-agent-config.mjs --checkThese two checks are the part that works for everyone. Per-tool hooks differ in format and in where they run (our June notes said Copilot had none at all). The git hook and CI run no matter which assistant wrote the change, so the rules that must hold belong there. The tool-specific hooks stay as an early warning that calls the same scripts. The general case for this is in why the model never marks its own work.
We committed the generated files, so a Copilot or Codex user gets everything after a plain clone. The other choice is to ignore them in git and generate them in a setup step. Committing is less friction, and the CI gate is what keeps it safe.
What the proof of concept found
We ran the generator on a small slice first. It exposed three problems, and none of them was in the idea.
Line endings broke the front-matter regex. The first run wrote 7 Copilot instruction files and skipped the other 6 rules as “manual”, although they had front matter. Those files had Windows (CRLF) line endings, and the regex expected \n straight after the opening ---. It found no front matter, so the rules looked like they had no globs, and only the “skip” lines in the output gave it away.
The fix is the lf() helper in the sample: normalise line endings before you parse. After it, 12 rules produced Copilot files and one true manual rule was left. A parser that treats “no match” as “nothing to do” is the dangerous kind, so print what you skip.
Skill links used a prefix that did not exist. The review before the generator found that all 9 subagents named skills with a sitecore- prefix, such as sitecore-quality-gate. The skill folders had no prefix at all. Nothing failed, because a link in a Markdown file is just text, so the agent would have been told to use a skill that was not there. We fixed the names in the source, once, and the generator copied the fix to every tool.
Rules pointed at a file that did not exist. About twenty skills, commands and rules, plus a hook, told the AI to read a per-component context file named <Name>.Context.md. The component generator had stopped producing it, and the real file was a manifest.json. A generator is a copier. Had it run first, it would have put the broken pointer into four tools instead of one.
That is why the order mattered: audit the source for dead references, then generate. A cheap check for the last two bugs is a script that walks every path-like token in the source and confirms the file exists. We did these audits by hand in a review pass; I have not seen that script run.
How to check it worked
- Run
node scripts/sync-agent-config.mjs, then run it again. The second run should say0 written; if it writes anything, the output depends on something other than the source, such as a timestamp. We hit this with a separate manifest generator that stamped the current time on every run, and made it keep the old value when nothing else had changed. - Run
node scripts/sync-agent-config.mjs --checkand expect exit code 0. - Add a line to any generated file by hand and run
--checkagain. It must printDRIFT:and the file name, and exit with 1. - Open the repository in each tool and ask it to list its rules and skills. No script does this check for you.
I ran steps 1 to 3 on the sample in this post: the first run wrote four files, the second wrote none, and --check failed on the hand-edited file.
Takeaways
- Instructions, rules, skills, commands and hooks all differ by tool.
AGENTS.mdandSKILL.mdare the only formats most of them share. - Keep one source folder and generate the rest. Never edit a generated file.
- Mark generated files, and give the script a
--checkmode that writes nothing. - Run the check in pre-commit and in CI. CI is the one that cannot be skipped.
- Normalise line endings before parsing front matter, and report what you skip.
- Audit the source for dead links before you generate, because the script copies mistakes as faithfully as it copies good rules.
- Recheck vendor docs now and then. Some gaps we built around in June had already closed, and more closed by October.