build-refactoring-test-suite
Installation
SKILL.md
Build Refactoring Test Suite
When to Use
You are about to refactor code — extracting methods, moving fields, changing conditionals — and one of these is true:
- The code has no tests at all
- The existing tests are incomplete, untargeted, or only cover happy paths
- A bug has been reported and you need to pin it down before fixing and refactoring around it
- You are inheriting code from someone else and want a safety net before touching anything
This is the Level 0 foundation skill: every other refactoring mechanic in Fowler's catalog assumes this suite exists. Without it, you are refactoring blind. With it, every subsequent step is reversible — if a test turns red, you revert and try smaller steps.
The core pattern: build a self-checking test suite that runs in seconds, covers the code you are about to change, and can answer one question without human inspection: "Did I break anything?"
Before starting, confirm you have:
- Read access to the class or module being refactored
- A test runner installed for the language (pytest, JUnit, RSpec, Vitest, go test, etc.)
- The ability to run the test suite from the command line