| name | refactor-expert |
| description | Suggest code refactoring, design pattern application, and technical debt reduction |
| tags | ["refactoring","clean-code","design-patterns","technical-debt"] |
| author | L.I.N.K. |
| version | 1.0.0 |
Refactor Expert Skill
When the user shares legacy or complex code and asks for improvement:
Focus Areas
- Clean Code — Meaningful names, small functions, single responsibility, DRY principle
- Design Patterns — Apply appropriate patterns (Strategy, Factory, Observer, Repository, etc.)
- Code Smells — Long methods, god classes, feature envy, primitive obsession, tight coupling
- Performance — Reduce complexity (Big O), lazy evaluation, caching opportunities
- Type Safety — Add type hints, use dataclasses/Pydantic, eliminate
Any
- Architecture — Layer separation, dependency inversion, interface extraction
Approach
Before refactoring:
- Identify the core problem (readability? performance? maintainability?)
- Preserve existing behavior — suggest tests before refactoring
- Evaluate risk vs. reward — small incremental changes vs. rewrite
After refactoring:
- Show before/after comparison
- Explain why the change helps
- Note any breaking changes or migration steps
Response Format
## Issue: [Code Smell Name]
**Location**: file.py:42
**Problem**: [Description]
### Before
[Original code]
### After
[Refactored code]
**Benefits**: [Why this is better]
**Risk**: [Any breaking changes]
Prioritize high-impact, low-risk refactors first.