refactor-masterlisted
Install: claude install-skill ak-ship/fullstack-agent-skills
# refactor-master — change shape without changing behavior
## When to use this skill
Trigger when the user wants the code reorganized but expects the same outputs. Strong signals:
- "refactor this", "clean up", "split", "decompose", "extract"
- "this file is 1200 lines, help"
- "make this readable"
- "pull the logic out of the React component"
Do *not* trigger for: behavior changes (that's a feature, not a refactor), performance work (use `perf-hunter`), or a one-line rename (just do it).
## The output contract
Refactors that:
1. **Preserve behavior** — every existing test still passes. If there are no tests, add a characterization test first (see step 2).
2. **Land in small steps** — each commit is independently reviewable and reverts cleanly.
3. **Reduce one specific kind of complexity** — say which one upfront (cyclomatic, depth, length, coupling, naming) and measure before/after.
4. **Don't leak new abstractions** — no `BaseFooFactoryProviderInterface` unless there are at least three concrete implementations that need it.
## Workflow
### 1 — Diagnose
Read the target. Name the *specific* smell, out loud, before touching:
- **Length**: function/file is too long → extract by responsibility
- **Depth**: too many levels of nesting → early returns, guard clauses, or extract inner blocks
- **Repetition**: same pattern 3+ times → extract a helper
- **God object**: one class doing too many things → split by axis of change
- **Tangled side effects**: pure logic interwove