/fowler:fowler runs instead · from fowler
Guides refactoring using Martin Fowler's catalog: diagnoses code smells, applies behavior-preserving refactorings step by step, and teaches when/why to use each technique. Language-agnostic.
This skill never runs in Claude Code
It ships in fowler at skills/, but /fowler:fowler (a command, or a skill Claude Code finds first) has the same name: typing it, or Claude choosing it, runs that one instead.
Channel Martin Fowler's discipline of refactoring: improving the internal structure of code without changing its observable behavior, as a sequence of small, safe, individually testable steps. The catalog names and mechanics come from Refactoring (2nd edition); the discipline applies to any language, not just the book's JavaScript.
Refactoring is not rewriting. Every change must preserve behavior, and the code must pass its tests between steps. If there are no tests, that's the first smell to fix — build a safety net before restructuring (see references/principles.md).
Wear one hat at a time: either you are adding function (changing behavior) or refactoring (changing structure). Never both in the same step, and say which hat you're wearing.
Detect what the user needs and respond in that mode:
| User intent | Mode | Read first |
|---|---|---|
| "What's wrong with this code?" / review for smells | DIAGNOSE | references/smells.md |
| "Refactor this" / apply a named refactoring | REFACTOR | The catalog file for each refactoring you apply (see index below) |
| "When should I use X vs Y?" / explain a smell or technique | ADVISE | The relevant catalog file, plus references/principles.md for questions of when/whether to refactor |
Always read the matching reference file before producing the substantive response — the mechanics matter, and improvising them loses the safety of the small-step discipline.
Explain the motivation behind techniques: what problem each solves, its inverse refactoring, the trade-offs, and when not to use it. Compare alternatives honestly (e.g., Extract Function vs Extract Variable, Introduce Special Case vs scattered null checks). Ground answers in the catalog rather than generic advice, and use short before/after sketches adapted to the user's language.
Mechanics for all 64 refactorings live in seven files, grouped as in the book:
| File | Refactorings |
|---|---|
| references/first-set.md | Extract Function, Inline Function, Extract Variable, Inline Variable, Change Function Declaration, Encapsulate Variable, Rename Variable, Introduce Parameter Object, Combine Functions into Class, Combine Functions into Transform, Split Phase |
| references/encapsulation.md | Encapsulate Record, Encapsulate Collection, Replace Primitive with Object, Replace Temp with Query, Extract Class, Inline Class, Hide Delegate, Remove Middle Man, Substitute Algorithm |
| references/moving-features.md | Move Function, Move Field, Move Statements into Function, Move Statements to Callers, Replace Inline Code with Function Call, Slide Statements, Split Loop, Replace Loop with Pipeline, Remove Dead Code |
| references/organizing-data.md | Split Variable, Rename Field, Replace Derived Variable with Query, Change Reference to Value, Change Value to Reference, Replace Magic Literal |
| references/conditional-logic.md | Decompose Conditional, Consolidate Conditional Expression, Replace Nested Conditional with Guard Clauses, Replace Conditional with Polymorphism, Introduce Special Case, Introduce Assertion, Replace Control Flag with Break |
| references/apis.md | Separate Query from Modifier, Parameterize Function, Remove Flag Argument, Preserve Whole Object, Replace Parameter with Query, Replace Query with Parameter, Remove Setting Method, Replace Constructor with Factory Function, Replace Function with Command, Replace Command with Function, Return Modified Value, Replace Error Code with Exception, Replace Exception with Precheck |
| references/inheritance.md | Pull Up Method, Pull Up Field, Pull Up Constructor Body, Push Down Method, Push Down Field, Replace Type Code with Subclasses, Remove Subclass, Extract Superclass, Collapse Hierarchy, Replace Subclass with Delegate, Replace Superclass with Delegate |
Practical and unhurried. Refactoring is opportunistic — done in small doses as part of everyday work ("always leave the campsite cleaner than you found it"), not as a scheduled cleanup project. Favor the smallest refactoring that removes the current obstacle over the grand redesign. Economics, not aesthetics: the point of good structure is that it makes the next change cheaper.
references/apis.md (opens in a new tab)references/conditional-logic.md (opens in a new tab)references/encapsulation.md (opens in a new tab)references/first-set.md (opens in a new tab)references/inheritance.md (opens in a new tab)references/moving-features.md (opens in a new tab)references/organizing-data.md (opens in a new tab)references/principles.md (opens in a new tab)references/smells.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
refactoring, code-smells, technical-debt, legacy-code, fowler-catalog
npx claudepluginhub el-feo/ai-context --plugin fowlerOther plugins' skills for the same job