Loading...
Loading...
Systematic code refactoring while preserving all external behavior. Use when identifying code smells, planning refactoring sequences, executing safe structural improvements, or validating behavior preservation. Includes code smell catalog (reference.md) and refactoring execution protocol.
npx skill4agent add rsmdt/the-startup safe-refactoring📊 Refactoring Baseline
Tests: [X] passing, [Y] failing
Coverage: [Z]%
Uncovered areas: [List critical paths]
Baseline Status: [READY / TESTS FAILING / COVERAGE GAP]📋 Refactoring Plan
1. [Refactoring] - [Risk: Low/Medium/High] - [Target file:line]
2. [Refactoring] - [Risk: Low/Medium/High] - [Target file:line]
3. [Refactoring] - [Risk: Low/Medium/High] - [Target file:line]
Dependencies: [Any ordering requirements]
Estimated changes: [N] files🔄 Refactoring Execution
Step: [N] of [Total]
Refactoring: [Name]
Target: [file:line]
Status: [Applying / Testing / Complete / Reverted]
Tests: [Passing / Failing]✅ Refactoring Complete
Refactorings Applied: [N]
Tests: All passing
Behavior: Preserved ✓
Changes Summary:
- [File 1]: [What changed]
- [File 2]: [What changed]
Quality Improvements:
- [Improvement 1]
- [Improvement 2]reference.md| Smell | Refactoring |
|---|---|
| Long Method | Extract Method |
| Duplicate Code | Extract Method, Pull Up Method |
| Long Parameter List | Introduce Parameter Object |
| Complex Conditional | Decompose Conditional, Guard Clauses |
| Large Class | Extract Class |
| Feature Envy | Move Method |
Before: Long method with embedded logic
After: Short method calling well-named extracted methods
Safety: Run tests after each extractionBefore: Unclear names (x, temp, doIt)
After: Intention-revealing names (userId, cachedResult, processPayment)
Safety: Use IDE refactoring tools for automatic updatesBefore: Method in class A uses mostly class B's data
After: Method moved to class B
Safety: Update all callers, run testsFOCUS: [Specific refactoring]
- Apply [refactoring technique] to [target]
- Preserve all external behavior
- Run tests after change
EXCLUDE: [Other code, unrelated improvements]
- Stay within specified scope
- Preserve existing feature set
- Maintain identical behavior
CONTEXT:
- Baseline tests passing
- Target smell: [What we're fixing]
- Expected improvement: [What gets better]
OUTPUT:
- Refactored code
- Test results
- Summary of changes
SUCCESS:
- Tests still pass
- Smell eliminated
- Behavior preserved
TERMINATION: Refactoring complete OR tests fail⚠️ Refactoring Failed
Refactoring: [Name]
Reason: Tests failing
Reverted: ✓ Working state restored
Options:
1. Try alternative approach
2. Add missing tests first
3. Skip this refactoring
4. Get guidance
Awaiting your decision...🔄 Refactoring Status
Phase: [Baseline / Analysis / Planning / Execution / Validation]
Current Refactoring: [N] of [Total]
Target: [file:line]
Technique: [Refactoring name]
Tests: [Passing / Failing]
Behavior: [Preserved / Changed]
Next: [What happens next]