← ClaudeAtlas

dev-refactorlisted

Code refactoring to improve quality. Trigger when the user wants to clean up, restructure, or improve existing code.
christopherlouet/claude-base · ★ 4 · AI & Automation · score 83
Install: claude install-skill christopherlouet/claude-base
# Code Refactoring ## Principles 1. **Tests pass BEFORE and AFTER** 2. **Small incremental changes** 3. **One type of change at a time** 4. **Commit after each refactoring** ## Common techniques ### Extract Function ```typescript // Before function processOrder(order) { // 20 lines of validation // 30 lines of calculation // 10 lines of sending } // After function processOrder(order) { validateOrder(order); const total = calculateTotal(order); sendConfirmation(order, total); } ``` ### Extract Variable ```typescript // Before if (user.age >= 18 && user.country === 'FR' && !user.banned) { } // After const isAdult = user.age >= 18; const isFrench = user.country === 'FR'; const isActive = !user.banned; if (isAdult && isFrench && isActive) { } ``` ### Replace Conditional with Polymorphism ```typescript // Before function getPrice(type) { switch(type) { case 'basic': return 10; case 'premium': return 20; } } // After interface Plan { getPrice(): number } class BasicPlan implements Plan { getPrice() { return 10; } } class PremiumPlan implements Plan { getPrice() { return 20; } } ``` ## Code Smells to detect | Smell | Refactoring | |-------|-------------| | Long method | Extract Method | | Large class | Extract Class | | Duplicate code | Extract + Reuse | | Long parameter list | Parameter Object | | Feature envy | Move Method | | Primitive obsession | Value Object | ## Reducing Entropy (Complexity reduction) ### Complexity metrics | Metric | A