← ClaudeAtlas

principle-refactoringlisted

Refactoring discipline — Fowler's catalog of behavior-preserving moves (Extract Function, Inline Variable, Move Function, Replace Conditional with Polymorphism, Introduce Parameter Object, Extract Class), the smell→move mapping (Long Method, Large Class, Feature Envy, Data Clumps, Primitive Obsession, Shotgun Surgery, Divergent Change, Speculative Generality), the rule of three, characterization-tests-before-touching-legacy, and small-steps-with-green-between discipline. Distinct from principle-clean-code (naming/length aesthetics) and principle-design-patterns (GoF catalog selection). Auto-load when discussing refactoring strategy, code smells, when to extract, characterization tests for legacy code, or behavior-preserving structural change.
lugassawan/swe-workbench · ★ 2 · Code & Development · score 68
Install: claude install-skill lugassawan/swe-workbench
# Refactoring Discipline Structural change without behavior change. For the GoF pattern catalog, see `principle-design-patterns`. For naming and function-length aesthetics, see `principle-clean-code`. ## The discipline Four non-negotiable rules: - **Every step preserves behavior.** Tests must pass before and after each step. - **No feature changes during refactoring.** Find a bug? Note it — fix it in a separate commit. - **Small steps.** Each step is independently reviewable and revertable. - **Green between steps.** Run tests after each move. If red, revert immediately. ## Smells → moves | Smell | Triggering move(s) | |---|---| | Long Method | Extract Function, Decompose Conditional, Replace Temp with Query — *Quality stage (`workflow-development`) gives the objective trigger via cyclomatic / cognitive complexity thresholds* | | Large Class | Extract Class, Extract Interface, Move Function — *Quality stage (`workflow-development`) gives the objective trigger via file / class length* | | Feature Envy | Move Function, Move Field | | Data Clumps | Introduce Parameter Object, Extract Class | | Primitive Obsession | Replace Primitive with Object, Introduce Parameter Object | | Shotgun Surgery | Move Function, Move Field, Inline Function | | Divergent Change | Extract Class (split responsibilities) | | Speculative Generality | Inline Function, Collapse Hierarchy, Remove Middle Man | ## Fowler's catalog (key moves) - **Extract Function** — when a block of code has a name th