← ClaudeAtlas

refactoringlisted

Use when restructuring code without changing behavior -- extracting functions, renaming, moving files, reducing duplication, migrating between patterns (JS to TS, CJS to ESM), or addressing code smells. Covers safe refactoring workflows for any language.
Sagargupta16/claude-skills · ★ 3 · Code & Development · score 71
Install: claude install-skill Sagargupta16/claude-skills
# Refactoring Patterns ## Quick Reference | Task | Approach | |------|----------| | Extract function/method | Identify repeated or complex block, extract with clear name | | Rename safely | Find all references first, rename, run tests | | Move file/module | Update all imports, check for re-exports, run tests | | Reduce duplication | Extract shared logic only when used 3+ times | | Migrate JS -> TS | File by file, start with strictest config, add types gradually | | Migrate CJS -> ESM | Update require/module.exports to import/export, fix package.json | | Simplify conditionals | Replace nested if/else with early returns or guard clauses | ## Safe Refactoring Workflow 1. **Verify tests pass** before touching anything 2. **Make one change at a time** -- don't combine refactors 3. **Run tests after each change** to catch regressions immediately 4. **Commit frequently** -- each refactor step gets its own commit 5. **Never mix refactoring with behavior changes** in the same commit ## Code Smell Detection | Smell | Symptom | Refactoring | |-------|---------|-------------| | Long function | > 30 lines or does multiple things | Extract method | | Duplicate code | Same logic in 3+ places | Extract shared function | | Deep nesting | > 3 levels of if/for/try | Early returns, extract helper | | Long parameter list | > 4 parameters | Introduce parameter object | | Feature envy | Method uses another class's data more than its own | Move method | | God class/module | One file does every