What problem does it solve?
This Skill guides developers through the REFACTOR phase of the RED-GREEN-REFACTOR cycle in Test-Driven Development. It emphasizes a search-first mindset to identify duplication, improve patterns, and apply safe refactoring strategies.
Core Features & Use Cases
- Search-first approach: Prior to writing new code, search for existing patterns and duplications to avoid unnecessary changes.
- Duplication analysis: Ask critical questions to determine whether duplication can be unified or should be kept to avoid coupling.
- Refactoring strategies: Choose from extraction, parameterization, interface extraction, or introducing abstractions to reduce duplication.
- Safe refactoring workflow: Follow safety rules (green tests, small commits, run tests after each change, revert if needed).
Quick Start
Refactor the codebase with duplicated logic by following this workflow: identify duplicates, plan a single abstraction, implement changes incrementally, and verify all tests pass after each step.