home / skills / shotaiuchi / dotclaude / refactor-pattern
This skill analyzes current design patterns and anti-patterns, recommends target patterns, and guides pattern migration to align with codebase conventions.
npx playbooks add skill shotaiuchi/dotclaude --skill refactor-patternReview the files below or copy the command above to add this skill to your agents.
---
name: refactor-pattern
description: >-
Design pattern analysis for refactoring. Apply when identifying current
patterns, anti-patterns, recommending target patterns, and evaluating
pattern fit with codebase conventions.
user-invocable: false
---
# Pattern Analyst Analysis
Identify current design patterns and anti-patterns, and recommend target patterns for the refactoring.
## Analysis Checklist
### Current Pattern Identification
- Classify design patterns in use (creational, structural, behavioral)
- Map how patterns interact across module boundaries
- Identify implicit patterns not formally documented
- Check pattern consistency across similar components
### Anti-Pattern Detection
- Detect god classes or functions with too many responsibilities
- Find feature envy (methods using other class data excessively)
- Identify shotgun surgery (changes requiring edits in many places)
- Look for primitive obsession and data clumps
### Target Pattern Selection
- Recommend patterns that match the refactoring goal
- Evaluate pattern fit with existing codebase conventions
- Consider team familiarity and learning curve
- Assess pattern complexity vs benefit tradeoff
### Pattern Migration Path
- Define steps to transform current pattern to target pattern
- Identify intermediate states that remain functional
- Check for pattern conflicts during transition
- Verify the target pattern supports future extensibility
### Codebase Convention Alignment
- Check consistency with patterns used elsewhere in the project
- Verify naming conventions match the target pattern idioms
- Ensure error handling style aligns with project standards
- Validate that the target pattern fits the project's testing approach
## Output Format
Report findings with impact ratings:
| Impact | Description |
|--------|-------------|
| Breaking | Anti-pattern causing active defects or blocking changes |
| High | Pattern mismatch creating significant maintenance burden |
| Medium | Suboptimal pattern that should improve with migration |
| Low | Minor pattern inconsistency, cosmetic improvement |
This skill analyzes existing code to identify design patterns, anti-patterns, and recommended target patterns for refactoring. It produces a prioritized, impact-rated report and a practical migration path aligned with codebase conventions and team constraints. The goal is to reduce maintenance cost and enable safer, incremental refactors.
The skill scans modules to classify creational, structural, and behavioral patterns and maps their interactions across boundaries. It detects anti-patterns like god classes, feature envy, shotgun surgery, primitive obsession, and data clumps. For each finding it assigns an impact rating and recommends target patterns, evaluates fit with conventions, and outlines stepwise migration paths and intermediate safe states.
How are impact ratings determined?
Ratings reflect urgency and scope: Breaking indicates active defects or blockers; High signals major maintenance burden; Medium suggests meaningful improvement; Low is cosmetic or stylistic.
Will the migration plan break the build?
No. Plans emphasize incremental, backward-compatible steps and highlight intermediate states that remain functional while changes roll out.