This skill should be used when the user asks about "refactoring", "code smells", "extract method", "extract class", "rename refactoring", "move method", or when improving code structure without changing behavior. Provides Martin Fowler's refactoring catalog and code smell detection.
Detects code smells and applies Martin Fowler's refactoring patterns like Extract Method and Extract Class. Use when users request refactoring, mention code smells, or need to improve structure without changing behavior.
/plugin marketplace add shabaraba/shabaraba-cc-plugins/plugin install dev-org@shabaraba-cc-pluginsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/fowler-catalog.mdRefactoring is the process of improving code structure without changing its external behavior. This skill provides guidance based on Martin Fowler's refactoring catalog and industry best practices for detecting code smells and applying appropriate refactoring patterns.
Code that has grown too large:
| Smell | Indicators | Refactoring |
|---|---|---|
| Long Method | >20 lines, multiple concerns | Extract Method |
| Large Class | >300 lines, many fields | Extract Class |
| Primitive Obsession | Overuse of primitives for data | Replace with Object |
| Long Parameter List | >3-4 parameters | Introduce Parameter Object |
| Data Clumps | Same data groups repeated | Extract Class |
Incorrect OO design:
| Smell | Indicators | Refactoring |
|---|---|---|
| Switch Statements | Type-based switching | Replace with Polymorphism |
| Parallel Inheritance | Matching class hierarchies | Move Method, Collapse Hierarchy |
| Refused Bequest | Subclass doesn't use inherited | Replace Inheritance with Delegation |
| Temporary Field | Fields only sometimes used | Extract Class |
Code that resists modification:
| Smell | Indicators | Refactoring |
|---|---|---|
| Divergent Change | Class changes for multiple reasons | Extract Class |
| Shotgun Surgery | One change affects many classes | Move Method, Inline Class |
| Parallel Inheritance | Adding subclass requires another | Move Method |
Unnecessary code:
| Smell | Indicators | Refactoring |
|---|---|---|
| Comments | Explaining bad code | Extract Method (self-documenting) |
| Duplicate Code | Same code in multiple places | Extract Method/Class |
| Dead Code | Unreachable code | Delete |
| Lazy Class | Class does too little | Inline Class |
| Speculative Generality | Unused abstraction | Collapse Hierarchy |
Excessive coupling:
| Smell | Indicators | Refactoring |
|---|---|---|
| Feature Envy | Method uses other class's data | Move Method |
| Inappropriate Intimacy | Classes know too much about each other | Move Method, Extract Class |
| Message Chains | a.b().c().d() chains | Hide Delegate |
| Middle Man | Class only delegates | Remove Middle Man |
Transform code fragment into a method with descriptive name.
When to apply:
Process:
Move related fields and methods to a new class.
When to apply:
Process:
Move method to the class that uses its data most.
When to apply:
Group related parameters into an object.
When to apply:
Replace type-based switching with inheritance.
When to apply:
Before refactoring:
During refactoring:
After refactoring:
For comprehensive pattern catalog and detection scripts:
references/fowler-catalog.md - Complete refactoring pattern catalogreferences/smell-detection.md - Code smell detection techniquesCombine with:
solid-principles for design principle guidancecode-quality-metrics for quantitative analysisUse when working with Payload CMS projects (payload.config.ts, collections, fields, hooks, access control, Payload API). Use when debugging validation errors, security issues, relationship queries, transactions, or hook behavior.
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright violations.