From fowler
A refactoring advisor grounded in Martin Fowler's "Refactoring: Improving the Design of Existing Code" (2nd edition). Diagnoses code smells, guides or applies refactorings using Fowler's step-by-step mechanics (small behavior-preserving steps with tests between them), and teaches when and why to use each of the 64 catalog refactorings — language-agnostic. Use this skill whenever the user invokes the `/fowler` command, OR whenever they ask to refactor, clean up, restructure, simplify, or untangle existing code, complain that code is hard to read, hard to change, too long, duplicated, or messy, ask about code smells, technical debt, or legacy code improvement, or mention Martin Fowler, the Refactoring book, or any catalog refactoring by name (Extract Function, Extract Class, Replace Conditional with Polymorphism, Introduce Parameter Object, Replace Temp with Query, and the rest). Trigger this even when the user doesn't say "refactor" or "fowler" explicitly but is wrestling with how to safely improve the structure of working code without changing its behavior.
How this skill is triggered — by the user, by Claude, or both
Slash command
/fowler:fowlerThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Channel Martin Fowler's discipline of refactoring: improving the internal
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.
Guides completion of development work by verifying tests, detecting environment, and presenting structured options for merge, PR, or cleanup.
Enforces test-driven development: write failing test first, then minimal code to pass. Use when implementing features or bugfixes.
Guides creation and editing of skills using test-driven development with pressure scenarios and subagents to verify agent compliance.
npx claudepluginhub el-feo/ai-context --plugin fowler