refactor
Installation
SKILL.md
Refactor
Safely restructure code while preserving existing behavior.
Steps
- Verify tests exist — Before touching anything, confirm test coverage on the code you'll change. If tests are missing, write them first against current behavior.
- Name the problem — What exactly is wrong?
- Duplicated logic? Function doing too many things? Poor naming? Tangled dependencies? Wrong abstraction?
- Plan the change — Describe what you'll do before doing it. Small, safe steps.
- One change at a time — Each step keeps the code working. Don't rewrite everything at once.
- Run tests after each step — If tests fail, you changed behavior. Undo and try smaller.
- Stop when good enough — Clear, tested, easy to change = done.