What problem does it solve? Codebases accumulate complexity as functions grow, conditionals nest, and magic values multiply, making changes risky and reviews painful. This Skill provides specific, named refactoring patterns with explicit trigger conditions so you know exactly when and how to restructure code without changing behavior. ## Core Features & Use Cases - Trigger-Based Patterns: Each pattern (Extract Function, Replace Conditional with Polymorphism, Introduce Parameter Object, Guard Clauses, and more) includes symptoms and thresholds, such as functions over 20-30 lines or switches with 3+ branches. - Test-First Safety Rule: Enforces passing tests or characterization tests before any refactoring, with test runs after every step to guarantee behavior preservation. - Before/After Examples: Concrete TypeScript examples show each transformation, such as converting nested conditionals into guard clauses or replacing magic numbers with named constants. - Use Case: During code review you find a 60-line function mixing validation, calculation, and persistence. Apply the Extract Function pattern to split it into named single-purpose functions while keeping all tests green. ## Quick Start Ask the AI to refactor the long processOrder function using the Extract Function pattern while keeping all existing tests passing.