refactor-instructions
Refactor Instructions
Refactor a monolithic CLAUDE.md or AGENTS.md into a small, focused root file that points to topic-specific files via progressive disclosure.
Why this matters
- The root file loads on every agent 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).
- Stale docs poison context. File paths rot fastest — if the root says
"auth lives in src/auth/handlers.ts"and that file moved, the agent confidently looks in the wrong place. 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. Reference nested docs instead of inlining.
Process
-
Detect target files. Run
ls CLAUDE.md AGENTS.mdat the repo root. Handle whichever exist. In monorepos, also check**/AGENTS.mdand**/CLAUDE.md— nested files merge with the root at their scope. If bothCLAUDE.mdandAGENTS.mdexist with different content, surface this to the user: they may want a symlink (ln -s AGENTS.md CLAUDE.md) so every tool sees the same file. -
Read every target file in full before proposing anything. Do not rely on skimming.
-
Find contradictions. List every pair of instructions that conflict. For each, use
AskUserQuestionto ask which version to keep. Do not silently pick. -
Identify essentials for the root. Keep only what applies to every single task:
- One-sentence project description (anchors the agent's role)
- Package manager, only if non-default (
pnpm,yarn,bun,uv, etc.) - Non-standard build / typecheck / test commands
- Truly universal rules (e.g., "never commit to
main")
-
Group everything else by domain. Typical buckets: TypeScript conventions, testing patterns, API design, git workflow, styling, state management, deployment. One file per domain under
docs/. -
Flag for deletion. Mark instructions that are:
- Redundant — the agent already knows this (e.g., "write readable code")
- Too vague to be actionable
- Overly obvious (e.g., "use descriptive variable names")
- Inferable from the codebase or standard docs (e.g., "run
npm installto install dependencies", "this project uses TypeScript", "this project uses Playwright for e2e testing") - Structural — documents file paths or directory layouts that will rot (convert to capability descriptions or delete entirely)
-
Propose the structure before writing. Output:
- The new minimal root file (with links to topic files)
- Each topic file's content
- The full
docs/folder tree - A deletion list with a one-line rationale per item
Use
AskUserQuestionto confirm the plan before writing anything to disk. -
Write the files once approved. Use a light touch in the root — conversational references, not all-caps commands:
For TypeScript conventions, see docs/TYPESCRIPT.md.
Topic files can themselves reference deeper documents — progressive disclosure nests.
Where each rule belongs
| Rule scope | Goes in |
|---|---|
| Relevant to every task in the repo | Root file |
| Relevant to one domain (TS, testing, API…) | docs/<TOPIC>.md |
| Large body of reference material | Nested tree under docs/ |
| Package-specific in a monorepo | packages/<pkg>/AGENTS.md (merges with root) |
| Invokable procedure / playbook | Agent skill, not a doc |
Avoid
- Documenting file-system paths in the root — they rot.
- Forceful tone (
"ALWAYS","NEVER", caps) for rules that don't truly need emphasis. Save shouting for the few rules that must not be broken. - Auto-regenerating the root via
initscripts. Generated files prioritize comprehensiveness over restraint. - Ignoring the
AGENTS.md↔CLAUDE.mdsymlink option when the repo is used by multiple agents. - Writing files before the user has approved the proposed structure.
More from benjaming/ai-skills
confluence-cli
Use confluence-cli (NPM package) to manage Confluence content, pages, and spaces from the command line. Ideal for documentation workflows, bulk content operations, page migration, and when users request CLI-based Confluence interactions. Trigger on requests like "use Confluence CLI", "create Confluence pages via CLI", "migrate Confluence content", "automate documentation workflows", or when users want to script Confluence operations.
43atlassian-cli-jira
Use Atlassian CLI (acli) to manage Jira work items, projects, and workflows from the command line. Ideal for bulk operations, automation, scripting, and when users request CLI-based Jira interactions. Trigger on requests like "use Jira CLI", "create Jira issues via CLI", "bulk update Jira tickets", "automate Jira workflows", or when users want to script Jira operations.
29ralph-loop
Create autonomous iterative loops (Ralph Wiggum pattern) for multi-step tasks. Use when setting up automated workflows that iterate over a backlog of tasks with clear acceptance criteria. Triggers on requests like "create a ralph loop", "set up an iterative agent", "automate this migration", or "create an autonomous loop".
21interview
Interview user to clarify any topic - exploring codebase, investigating issues, planning features, understanding requirements, or drilling into plans. Socratic questioning to uncover details.
20codex-cli
Use OpenAI Codex CLI in non-interactive mode for automated code analysis, review, and programmatic task execution. Trigger on requests like "use Codex to analyze", "run codex exec", "codex code review", or when users want AI-powered code analysis without interactive prompts. Ideal for automation workflows, code quality checks, and generating structured analysis reports.
19daily-standup
Daily standup assistant for Benjamin that compiles work priorities from Jira and Slack into a single prioritized task list. This skill should be used when Benjamin asks for morning standup, daily priorities, what to work on today, or needs to compile work items.
18