One file to rule your AI instructions.
Keep your assistant guidance in one canonical place, then fan it out to the files each tool expects.
- Edit
.ai/INSTRUCTIONS.md - Run
npm run ai:sync - Commit generated files
- Enforce with
npm run ai:checkin CI
If you use multiple AI tools, instruction drift is almost guaranteed. This repo removes that drift by making one source of truth and generating the rest.
- Canonical file:
.ai/INSTRUCTIONS.md - Sync script:
scripts/ai-sync.mjs
Generated outputs:
| Tool | File |
|---|---|
| Claude | CLAUDE.md |
| Gemini | GEMINI.md |
| Codex/Agents (and Warp) | AGENTS.md |
| GitHub Copilot | .github/copilot-instructions.md |
npm install
npm run ai:syncCheck for drift (safe for CI):
npm run ai:checkWatch and auto-sync on source changes:
npm run ai:watchRun tests:
npm test- Update
.ai/INSTRUCTIONS.md. - Run
npm run ai:sync. - Review changes in generated files.
- Commit everything together.
Important:
- Do not hand-edit generated files. They will be overwritten.
Source file: docs/flow.mmd
flowchart TD
A["Edit canonical instructions<br/>.ai/INSTRUCTIONS.md"] --> B["Run sync<br/>npm run ai:sync"]
B --> C["scripts/ai-sync.mjs reads source"]
C --> D["Prepends GENERATED header"]
D --> E["Writes targets"]
E --> E1["CLAUDE.md"]
E --> E2["GEMINI.md"]
E --> E3["AGENTS.md"]
E --> E4[".github/copilot-instructions.md"]
A --> F["Validate without writing<br/>npm run ai:check"]
F --> G["Compare generated files to expected content"]
G --> H{"In sync?"}
H -->|Yes| I["Exit 0<br/>CI passes"]
H -->|No| J["Exit 1<br/>CI fails"]
K["Pull request opened"] --> L["GitHub Action<br/>AI Sync Check"]
L --> F
Pre-commit with Husky:
npm i -D husky
npx husky initSuggested .husky/pre-commit:
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npm run ai:sync
git add CLAUDE.md GEMINI.md AGENTS.md .github/copilot-instructions.mdPR safety net:
- GitHub Actions workflow:
.github/workflows/ai-sync-check.yml - Runs
npm installandnpm run ai:checkon pull requests
- Keep a single canonical instructions file
- Generate tool-specific files predictably
- Make drift obvious in local dev and CI
- Calling AI CLIs directly
- Supporting every possible tool convention
