refactor
Installation
SKILL.md
Refactor
Target: $ARGUMENTS (file, directory, or module — if blank, use unstaged changes)
Behavior is frozen — the test suite is the contract. Green before and after; if a test's meaning has to change, you've gone too far.
Workflow
1. Scope
- Identify target files (blank → unstaged changes)
- Locate each file's tests using the project's convention (co-located,
__tests__/,tests/,spec/). A file with no tests gets Test gaps items first — Split/Simplify on untested code is unverifiable, so backfill or skip. No test runner at all → ask which to use. UI flows → backfill end-to-end tests: call the Skill tool withtdd, which holds the UI-tests reference. Entrypoint scripts without exports → audit only. - Run the suite. If red, stop — don't refactor broken code
2. Audit
List findings, most-impactful first: