Agent skill · software engineering · erichowens

refactoring-surgeon

Expert code refactoring specialist for improving code quality without changing behavior. Activate on: refactor, code smell, technical debt, legacy code, cleanup, simplify, extract method,

Why this skill is useful

Provides specific refactoring techniques and patterns that improve code quality without altering behavior, which the AI may not generate independently.

What it needs

About 3k tokens when loaded. Last updated 2026-07-14. 180 stars on the source repository.

What this skill does

Refactoring Surgeon Expert code refactoring specialist focused on improving code quality without changing behavior. Quick Start 1. Ensure tests exist - Never refactor without a safety net 2. Identify the smell - Name the specific code smell you're addressing 3. Make small changes - One refactoring at a time, commit frequently 4. Run tests after each change - Behavior must remain identical 5. Don't add features - Refactoring ≠ enhancement 6. Document significant changes - Explain the "why" for future maintainers Core Capabilities Category Techniques ---------- ------------ Extraction Extract Method, Extract Class, Extract Interface Movement Move Method, Move Field, Inline Method Simplification Replace Conditional with Polymorphism, Decompose Conditional Organization Introduce Parameter Object, Replace Magic Numbers Legacy Migration Strangler Fig, Branch by Abstraction, Parallel Change Code Smells Reference Bloaters OO Abusers Change Preventers Reference Examples Complete refactoring examples in ./references/: File Pattern Use Case ------ --------- ---------- extract-method.ts Extract Method Long methods → focused functions replace-conditional-polymorphism.ts Replace Conditional switch/if → polymorphic classes introduce-parameter-object.ts Parameter Object Long params → structured objects strangler-fig-pattern.ts Strangler Fig Legacy code → gradual migration Anti-Patterns (10 Critical Mistakes) 1. Big Bang Refactoring Symptom: Rewriting entire modules in one massive change Fix: Strangler fig pattern, small incremental changes with tests 2. Refactoring Without Tests Symptom: Changing structure without test coverage Fix: Write characterization tests first, add coverage for affected areas 3. Premature Abstraction Symptom: Creating generic frameworks "for future flexibility" Fix: Wait for three concrete examples before abstracting (Rule of Three) 4. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills erichowens/refactoring-surgeon

View the source on GitHub

Browse the @skills marketplace