What problem does it solve?
This Skill helps you refactor legacy code without breaking behavior, weakening security controls, or losing confidence when tests are missing or incomplete.
Core Features & Use Cases
- Safe transformation guidance: Preserves existing security controls and core behavior while improving structure and maintainability.
- Test-first refactoring workflow: Emphasizes running tests before and after each small change to prevent regressions.
- Atomic refactoring patterns: Ensures each refactor is a single, complete transformation, avoiding inconsistent intermediate states.
- Practical refactoring tactics: Uses proven approaches like extracting focused methods, breaking up large responsibilities, replacing long conditionals with polymorphism/strategy, and using early returns and dependency injection to reduce complexity.
Use case examples:
- Modernizing a legacy service by extracting validation into dedicated units and keeping security guarantees intact.
- Reducing a “god class” by splitting responsibilities into smaller testable components while maintaining behavior.
- Replacing deep if/elif chains with a strategy pattern to improve extensibility and readability.
Quick Start
Use the refactoring-expert skill to refactor a legacy module by running the test suite, applying one atomic change at a time, and preserving all validation and security checks.