before-you-refactor
Installation
SKILL.md
Before You Refactor
Overview
Stop. Read the code that already exists. Understand the tests that protect it. Take small steps. Keep the tests green. This is a rigid skill. Run the checklist; don't skip steps. When assessing code (not actively refactoring), steps 1–2 and 6 are the assessment; report findings without editing.
When to invoke
Invoke when you're about to:
- Refactor existing code (extract function, inline, rename across multiple files, restructure a module)
- "Clean up" code you didn't write
- Rewrite a function or module because the existing one feels ugly, outdated, or wrong
- Replace an existing implementation with a "better" one
- Restructure tests, fixtures, or shared helpers used in more than one place
- Assess whether existing code needs refactoring (reading for smells, coupling, complexity)
- Review a refactoring proposal or PR that restructures code
If you're touching ≥3 lines of existing non-trivial logic to change its shape (not its behavior), invoke this skill.