Split one large file into small modules without changing behaviour
Breaks one oversized file into focused modules while every test stays green.
/goal [src/big-file.ts] is split into focused modules under [src/big-file/] where no file is longer than 300 lines, every caller imports from the new modules, and the old file is gone or is a re-export of under 20 lines. To prove it: run `npm test` and the type check (`npx tsc --noEmit`) and show both exit 0, then run `wc -l` on every new file and show the output. Constraints: no behaviour change, no test file is modified except import paths, no new dependencies, public exports keep their names. Commit nothing. Or stop after 30 turns and list what is left.How to use it
- Replace the parts in square brackets with your own paths, names and commands.
- Open Claude Code in your project and paste the whole prompt, starting with /goal.
- Claude works until the evaluator sees the check pass, or until the turn bound. It proves the result with:
npm test
Last checked against the current Claude Code facts on 2026-11-07.
More refactor prompts
New to /goal? Read Let Claude run until it is done with /goal.