What problem does it solve?
This Skill prevents accidental introduction of bugs during code improvements by enforcing strict rules: tests first, one change at a time, and never mixing refactoring with bug fixes or new features. It ensures structural changes don't alter behavior, making refactoring a low-risk activity.
Core Features & Use Cases
- Tests-First Mandate: Requires passing automated tests before any refactoring begins, guaranteeing behavior preservation.
- Atomic Changes: Enforces making only one structural change (e.g., extract one method, rename one variable) per test-and-commit cycle.
- Separation of Concerns: Strictly forbids combining refactoring (changing HOW) with bug fixes or feature additions (changing WHAT) in the same commit.
- Use Case: When you find a bug while extracting a method from a large function, this skill guides you to
git stash your refactoring, fix the bug in a separate commit with its own test, then git stash pop and continue refactoring.
Quick Start
I need to refactor a complex Python function. Guide me through the safe refactoring process, ensuring I have tests, make one change at a time, and know what to do if I discover a bug.