What problem does it solve? Restructuring working code without breaking it is risky: hidden behaviors get lost, unrelated changes get swept into commits, and failed refactors become long debugging sessions. This Skill provides a disciplined workflow for refactoring code that already passes its tests, ensuring observable behavior stays identical. ## Core Features & Use Cases - Reversible Baseline Workflow: Records a restorable state and the known test result (green or a documented failing set) before any structural change, so a broken slice costs one restore instead of a debugging session. - Characterization Tests: Traces call paths and pins observable behaviors (signatures, error types, ordering, retry counts) with passing tests before moving any code. - Priority Classification: Categorizes findings as Critical, High, Nice, or Skip so only worthwhile structural improvements are made, and blocks speculative code and behavior changes disguised as refactors. - Use Case: After a TDD green phase, you notice magic numbers and a 40-line function. The Skill guides you to record the baseline, pin behavior with tests, extract constants and helpers in one slice, and verify the suite matches the recorded result. ## Quick Start Ask the AI to plan a safe refactoring of the working code in your current module using the refactoring skill, keeping all observable behavior unchanged.