← ClaudeAtlas

refactorlisted

Surgical code refactoring to improve maintainability without changing behavior. Invoke when user says "refactor this", "clean up this code", "extract functions", "this is messy", "improve maintainability", "fix code smells", "simplify this", "this function is too long", or when you see god functions, nested conditionals, duplicate logic, magic numbers, unclear naming, or dead code. Always run a discovery pass first — catalog smells before touching anything. Gradual evolution, not revolution.
LucasSantana-Dev/sharekit-profile · ★ 1 · Code & Development · score 70
Install: claude install-skill LucasSantana-Dev/sharekit-profile
# Refactor Improve code structure and readability without changing external behavior. Behavior is sacred; structure is up for negotiation. ## Core Principle **Discover before you fix.** It's tempting to jump straight into the most obvious problem, but surveying the whole file first gives a better picture of what's worth fixing and in what order. It also surfaces smell dependencies (fixing X may make Y irrelevant). Never start editing until you've cataloged. ## Phase 0 — Discover Read the target file(s). Note language. Scan for every smell present. **Language detection:** Adapt patterns and tool suggestions to the actual language: | Language | Smell finders | Refactor tools | |---|---|---| | TS / JS | ESLint, ts-prune, unimported | ts-morph, jscodeshift, ast-grep | | Python | pylint, ruff, vulture | rope, pyupgrade, ruff --fix | | Go | staticcheck, golangci-lint | gorename, gopls | | Rust | clippy | cargo fix | **Also read 2–3 similar files in the project** before proposing changes. Refactoring should feel native to the codebase — matching its naming conventions, its error-handling style, its test structure. A brilliant refactor that looks foreign is still a bad refactor. **Catalog your findings:** ``` Smells found in auth.ts: [HIGH] Nested conditionals — handleAuth() has 8 levels of nesting; every error path buried inside [HIGH] Long method — 120 lines doing token parse, DB lookup, audit log, and response all in one [MED] Magic numbers — status === 2 and st