refactor-instructions
Refactor Instructions
Refactor monolithic instruction files into a minimal root, scoped .claude/rules/ files, and reference docs.
Why this matters
- The root file loads on every request. A bloated file steals tokens from the actual task and pushes the agent past its effective instruction budget (~150–200 rules before attention drops).
.claude/rules/files withpaths:globs load only when matching files are touched — scoped rules keep the base context lean without losing coverage.- Stale docs poison context. File paths rot fastest — describe capabilities, not structure.
- Instruction files grow as balls of mud when rules are added reactively after every agent misstep. Small and focused beats comprehensive.
Process
-
Detect scope. If a path argument was given (
$ARGUMENTS), use that file as the target. Otherwise, useAskUserQuestionto ask which scope to refactor: project-level.claude/CLAUDE.md, user-level~/.claude/CLAUDE.md, or both. Then scan forCLAUDE.md,AGENTS.md, and.claude/rules/*.mdat the chosen scope. In monorepos, also check**/CLAUDE.md. If bothCLAUDE.mdandAGENTS.mdexist with different content, surface this — they may want a symlink. Determine docs location: use existingdocs/if present at repo root, else default to.claude/docs/. When working at project level, also read~/.claude/CLAUDE.mdand~/.claude/rules/*.mdread-only for contradiction checking. -
Read every target file in full — root files and every
.claude/rules/file — before proposing anything. Do not rely on skimming. -
Find contradictions. Check across all sources: root vs rules, rules vs rules, project-level vs user-level. List every conflicting pair. For each, use
AskUserQuestionto ask which version to keep. Do not silently pick.