← ClaudeAtlas

refactoringlisted

Changes code structure without changing behaviour. Use when the user asks to refactor, clean up, restructure, extract, rename across files, reduce duplication, or improve the architecture. Not for features, bug fixes or reviews.
t8jwscc7qy-sketch/foma-skills · ★ 2 · AI & Automation · score 78
Install: claude install-skill t8jwscc7qy-sketch/foma-skills
Restructure code in small steps with the tests green after each one, so behaviour stays identical. Uses: foma-skills:tdd (add a characterisation test when coverage is missing). Path: a rename or extract inside one file → steps 1, 2, 4, 5; a change across modules, public interfaces or many call sites → all steps, and confirm the plan with the user before step 4. Say which path in one line. ## Steps 1. Read the CLAUDE.md conventions and test/lint/build commands, and match existing patterns and names. Scope: the user's target; with none, start from files that change often (`git log --oneline --name-only`). 2. Run the suite first and note the result as the baseline. Already-failing tests stay the baseline: the refactor may not change that set. If they fail in the code you are about to change, stop and report. 3. No tests around the code to change: write characterisation tests that pin current behaviour (including odd behaviour) through foma-skills:tdd, and see them pass before touching the code. 4. Plan (full path): list the steps, each small and independently green, with the end shape. Prefer deleting a shallow wrapper or merging scattered logic behind one interface (deletion test: does removing it concentrate complexity or just move it?). Skip changes that contradict a recorded decision (`docs/decisions.md`, ADRs) unless the friction is real; say so. 5. Apply one step, run the tests (the targeted ones; the whole suite after the last step), then the typecheck or lint. Repeat.