Apply named refactoring transformations to improve code structure without changing behavior. Use when the user mentions "refactor this", "code smells",…
Refactoring Patterns Framework A disciplined approach to improving the internal structure of existing code without changing its observable behavior. Every refactoring follows the same loop: verify tests pass, apply one small structural change, verify tests still pass. Core Principle Refactoring is not rewriting. It is a sequence of small, behavior-preserving transformations, each backed by tests. You never change what the code does — only how it is organized. Big-bang rewrites fail because they combine structural change with behavioral change, making it impossible to know which broke things. The foundation: Bad code is a natural consequence of delivering under time pressure, not a character flaw. Code smells are objective signals of degraded structure; the smell catalog tells you where to look, and the refactoring catalog tells you what to do. Scoring Goal: 10/10. Score structural quality by how many of the eight Quick Diagnostic rows pass — score = round(passed / 8 × 10), adjusting down when a single smell is severe. Bands: 9-10: no obvious smells remain, each function does one thing, names reveal intent, duplication is eliminated, conditionals use polymorphism where apt, and tests cover the refactored paths. 5-6: a few smells remain (a Long Method, some duplication) but structure is mostly sound. ≤3: pervasive smells — tangled conditionals, God classes, duplication everywhere — or no tests to refactor safely. Always state the current score, name the smells driving it down, and list the specific refactorings needed to reach 10/10.
don't have the plugin yet? install it then click "run inline in claude" again.