Maintain agent instructions
This skill keeps agent guidance consistent while minimizing always-loaded context. It follows a
hub-and-spoke model: one compact, always-loaded entrypoint per agent (CLAUDE.md,
.github/copilot-instructions.md, …) plus detailed, path-scoped or on-demand
instruction files. The model is machine-readable so drift between agent files can be checked by
script instead of by eye — if the project records this decision as an ADR, link it here.
When NOT to Use
- A single-file typo fix in one instruction file — edit it directly
- No drift exists and CI checks pass
- Authoring brand-new policy from scratch — that is content work, not reconciliation
Principles
- Use scripts first; inspect only failing files/rules.
- Keep each agent's always-loaded entrypoint compact. Put detailed guidance in scoped or
on-demand files.
- Update the agent-instructions model (
.ai-badger/agent-instructions/model.json by default; see
references/agent-instruction-model.md) when changing shared policy.
- Treat
.github/instructions/*.instructions.md (or the project's equivalent) as the shared
path-scoped implementation rule source.
- Do not rewrite every agent file just to rephrase. Make the smallest consistency-preserving edit.
- The scripts are check-only by default; the agent handles semantic policy decisions and wording.
Standard workflow
Run validation:
node .ai-badger/skills/maintain-agent-instructions/scripts/validate-agent-instructions.mjs
Run drift detection:
node .ai-badger/skills/maintain-agent-instructions/scripts/check-agent-drift.mjs
Both scripts are #!/usr/bin/env node and import only node:fs / node:path — Node 18+,
no bundler, no dependencies. Run them from the project root; they read process.cwd() and
AGENT_INSTRUCTIONS_DIR (default .ai-badger/agent-instructions). Adjust the path prefix
if the skill was scaffolded elsewhere.
If both pass, report success.
If either fails:
- inspect only the reported files and rules,
- update the model if the policy changed,
- update the smallest affected instruction file(s),
- rerun both scripts.
If the change modifies architecture/process policy, add or update an ADR (if the project keeps
one).
Copilot compatibility
GitHub Copilot CLI and Copilot coding agent discover repository instructions in standard files,
including .github/copilot-instructions.md, .github/instructions/**/*.instructions.md,
AGENTS.md, and CLAUDE.md. Keep Copilot-compatible rules in .github/copilot-instructions.md
and .github/instructions/*; the validation scripts are plain command-line checks so
Copilot-driven automation or CI can run the same checks.
Script style
Scripts are small deterministic helpers. They should:
- avoid LLM calls,
- avoid network calls,
- read the agent-instructions model (path resolved via
AGENT_INSTRUCTIONS_DIR, default
.ai-badger/agent-instructions; read references/agent-instruction-model.md when writing a
script that reads the model),
- report precise file/rule failures,
- exit non-zero on errors,
- keep warnings separate from errors,
- avoid editing files unless a future explicit
--write mode is added.
Read references/agent-instruction-model.md when the model contract is in question and
references/copilot-compatibility.md when phrasing a Copilot-specific rule.
Gotchas
No environment-specific gotchas known.
Verification Checklist
1---2name: maintain-agent-instructions-23description: Use when agent instruction files have drifted from each other or from the policy model — CLAUDE.md, copilot-instructions.md, AGENTS.md, hosted-review and path-scoped instruction files — or when validation/drift checks fail in CI. Reconciles them from the machine-readable model in .ai-badger/agent-instructions/.4license: MIT5---67# Maintain agent instructions89This skill keeps agent guidance consistent while minimizing always-loaded context. It follows a10hub-and-spoke model: one compact, always-loaded entrypoint per agent (`CLAUDE.md`,11`.github/copilot-instructions.md`, …) plus detailed, path-scoped or on-demand12instruction files. The model is machine-readable so drift between agent files can be checked by13script instead of by eye — if the project records this decision as an ADR, link it here.1415## When NOT to Use1617- A single-file typo fix in one instruction file — edit it directly18- No drift exists and CI checks pass19- Authoring brand-new policy from scratch — that is content work, not reconciliation2021## Principles2223- Use scripts first; inspect only failing files/rules.24- Keep each agent's always-loaded entrypoint compact. Put detailed guidance in scoped or25 on-demand files.26- Update the agent-instructions model (`.ai-badger/agent-instructions/model.json` by default; see27 `references/agent-instruction-model.md`) **when** changing shared policy.28- Treat `.github/instructions/*.instructions.md` (or the project's equivalent) as the shared29 path-scoped implementation rule source.30- Do not rewrite every agent file just to rephrase. Make the smallest consistency-preserving edit.31- The scripts are check-only by default; the agent handles semantic policy decisions and wording.3233## Standard workflow34351. Run validation:3637 ```bash38 node .ai-badger/skills/maintain-agent-instructions/scripts/validate-agent-instructions.mjs39 ```40412. Run drift detection:4243 ```bash44 node .ai-badger/skills/maintain-agent-instructions/scripts/check-agent-drift.mjs45 ```4647 Both scripts are `#!/usr/bin/env node` and import only `node:fs` / `node:path` — Node 18+,48 no bundler, no dependencies. Run them from the project root; they read `process.cwd()` and49 `AGENT_INSTRUCTIONS_DIR` (default `.ai-badger/agent-instructions`). Adjust the path prefix50 if the skill was scaffolded elsewhere.51523. If both pass, report success.534. If either fails:54 - inspect only the reported files and rules,55 - update the model if the policy changed,56 - update the smallest affected instruction file(s),57 - rerun both scripts.585. If the change modifies architecture/process policy, add or update an ADR (if the project keeps59 one).6061## Copilot compatibility6263GitHub Copilot CLI and Copilot coding agent discover repository instructions in standard files,64including `.github/copilot-instructions.md`, `.github/instructions/**/*.instructions.md`,65`AGENTS.md`, and `CLAUDE.md`. Keep Copilot-compatible rules in `.github/copilot-instructions.md`66and `.github/instructions/*`; the validation scripts are plain command-line checks so67Copilot-driven automation or CI can run the same checks.6869## Script style7071Scripts are small deterministic helpers. They should:7273- avoid LLM calls,74- avoid network calls,75- read the agent-instructions model (path resolved via `AGENT_INSTRUCTIONS_DIR`, default76 `.ai-badger/agent-instructions`; read `references/agent-instruction-model.md` **when writing a77 script that reads the model**),78- report precise file/rule failures,79- exit non-zero on errors,80- keep warnings separate from errors,81- avoid editing files unless a future explicit `--write` mode is added.8283Read `references/agent-instruction-model.md` **when the model contract is in question** and84`references/copilot-compatibility.md` **when phrasing a Copilot-specific rule**.8586## Gotchas8788No environment-specific gotchas known.8990## Verification Checklist9192- [ ] Both scripts ran from the project root93- [ ] Both exit 0 — or every reported failure was fixed and the re-runs pass94- [ ] Only the reported files and rules were touched95- [ ] The model was updated before any shared-policy change96- [ ] ADR added or updated when architecture/process policy changed