From declutter
Code smell detection based on Martin Fowler's refactoring catalog - identifies quality issues and refactoring opportunities
How this skill is triggered — by the user, by Claude, or both
Slash command
/declutter:declutter-smell-detectionThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
This skill provides a systematic approach to identifying code smells based on Martin Fowler's refactoring catalog.
This skill provides a systematic approach to identifying code smells based on Martin Fowler's refactoring catalog.
Code that has grown too large to handle effectively.
Signs:
Detection Pattern:
- Count lines in method
- Count nesting depth
- Look for inline comments explaining code blocks
Refactoring: Extract Method
Signs:
Detection Pattern:
- Count methods and fields
- Identify cohesion (do fields relate to each other?)
- Check for multiple domains in one class
Refactoring: Extract Class, Extract Subclass
Signs:
Detection Pattern:
- Count parameters
- Look for boolean flags
- Identify parameter groups
Refactoring: Introduce Parameter Object, Replace Parameter with Method Call
Signs:
Detection Pattern:
- Find repeated parameter combinations
- Look for similar field groups
Refactoring: Extract Class, Introduce Parameter Object
Incomplete or incorrect application of OO principles.
Signs:
Detection Pattern:
- Find switch statements
- Look for type checking patterns
- Identify polymorphism opportunities
Refactoring: Replace Conditional with Polymorphism, Replace Type Code with Subclasses
Signs:
Detection Pattern:
- Compare class hierarchies
- Look for matching prefixes
Refactoring: Move Method, Move Field to consolidate hierarchies
Signs:
Detection Pattern:
- Find empty method overrides
- Look for NotImplemented patterns
- Check inheritance usage
Refactoring: Replace Inheritance with Delegation
Patterns that make code hard to modify.
Signs:
Detection Pattern:
- Analyze git history for change patterns
- Identify unrelated modifications
- Check commit messages for variety
Refactoring: Extract Class (one per change reason)
Signs:
Detection Pattern:
- Trace feature implementation across files
- Count files touched per feature
Refactoring: Move Method, Move Field, Inline Class
Unnecessary code that can be removed.
Signs:
Detection Pattern:
- Static analysis for unused symbols
- Find unreachable code paths
- Detect TODO/FIXME/deprecated markers
Refactoring: Delete (safely, with tests)
Signs:
Detection Pattern:
- Token-based similarity detection
- AST comparison
- Manual inspection of related code
Refactoring: Extract Method, Extract Class, Template Method
Signs:
Detection Pattern:
- Find abstract types with one implementation
- Check parameter usage
- Analyze call sites
Refactoring: Collapse Hierarchy, Inline Class, Remove Parameter
Excessive coupling between classes.
Signs:
Detection Pattern:
- Count references to other classes vs own fields
- Identify data access patterns
Refactoring: Move Method, Extract Method then Move
Signs:
Detection Pattern:
- Analyze access patterns
- Check for circular dependencies
Refactoring: Move Method, Move Field, Hide Delegate
Signs:
a.getB().getC().getD().doSomething()Detection Pattern:
- Find long method chains
- Count dots in expressions
Refactoring: Hide Delegate, Extract Method
When analyzing code, check for each smell category:
## Bloaters
- [ ] Long Method (>20 lines)
- [ ] Large Class (>200 lines, >10 methods)
- [ ] Long Parameter List (>3 params)
- [ ] Data Clumps
## OO Abusers
- [ ] Switch Statements on type
- [ ] Parallel Inheritance
- [ ] Refused Bequest
## Change Preventers
- [ ] Divergent Change
- [ ] Shotgun Surgery
## Dispensables
- [ ] Dead Code
- [ ] Duplicate Code
- [ ] Speculative Generality
## Couplers
- [ ] Feature Envy
- [ ] Inappropriate Intimacy
- [ ] Message Chains
Classify each smell by impact:
| Level | Impact | Action |
|---|---|---|
| Critical | Blocks development, causes bugs | Fix immediately |
| High | Significantly slows development | Fix in current sprint |
| Medium | Causes friction | Schedule for refactoring |
| Low | Minor inconvenience | Address opportunistically |
Report findings in this format:
# Smell Detection Report
## Summary
- Total smells found: N
- Critical: X
- High: Y
- Medium: Z
- Low: W
## Findings
### [CRITICAL] Long Method in UserService.processOrder
- **Location:** src/services/user_service.py:145-287
- **Lines:** 142
- **Issue:** Method handles order validation, payment, inventory, and notification
- **Recommendation:** Extract into separate methods per responsibility
- **Refactoring:** Extract Method (4-5 extractions needed)
### [HIGH] Feature Envy in OrderController.calculateTotal
- **Location:** src/controllers/order_controller.py:78
- **Issue:** Method accesses 8 fields from PricingService, only 1 from self
- **Recommendation:** Move method to PricingService
- **Refactoring:** Move Method
npx claudepluginhub joshuarweaver/cascade-code-general-misc-1 --plugin joowankim-declutterGuides 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.