What problem does it solve? Codebases accumulate technical debt, duplication, and complexity over time, and unstructured cleanup attempts often change behavior or stall without tests. This Skill provides a disciplined decision framework for refactoring existing code safely and incrementally. ## Core Features & Use Cases - Quality Thresholds: Concrete metrics for when to refactor, including cyclomatic complexity, function length, file length, nesting depth, and duplication limits. - Refactoring Catalog: Maps common code smells (long functions, deep nesting, duplication, large files, complex conditionals, dead code) to specific refactoring techniques. - Anti-Pattern Guardrails: Warns against refactoring without test coverage, changing behavior mid-refactor, and over-abstraction, with rebuttals to common rationalizations. - Use Case: When a module grows past 800 lines with deeply nested conditionals, use this Skill to split it by responsibility, apply guard clauses, and verify the test suite stays green after each small step. ## Quick Start Ask the agent to refactor the selected module to reduce complexity and duplication while preserving existing behavior and keeping all tests passing.