Refactor Skill When refactoring code, follow this structured process. The golden rule: change structure without changing behavior. Every refactoring should be verifiable by existing tests — if there are no tests, write them first. 1. Pre-Refactor Analysis Before changing anything, understand the current state: Read and Map the Code Measure Current Complexity Verify Test Coverage CRITICAL : If no tests cover the code being refactored, the FIRST step is to add characterization tests that capture the current behavior. Never refactor untested code. 2. Code Smell Detection Scan for these common sm…