Agent skill · software engineering · aiskillstore
refactoring
Systematic refactoring with small-step discipline. Use when user says 'refactor', 'clean up', 'restructure', 'extract', 'rename', 'simplify', or mentions code smells. Enforces one change → test → commit cycle. For structural improvements, NOT style/formatting (use /lint). NOT for adding features or fixing bugs.
Why this skill is useful
Provides a structured approach to systematic refactoring with specific patterns and tests that the AI wouldn't reliably generate on its own.
What it needs
About 4k tokens when loaded. Last updated 2026-08-07. 405 stars on the source repository.
What this skill does
Refactoring Improve code structure without changing behavior. One small step at a time. Iron Law: ONE REFACTORING → TEST → COMMIT. Never batch changes. When to Use Answer IN ORDER. Stop at first match: 1. User says "refactor", "clean up", "restructure"? → Use this skill 2. User asks to "extract", "rename", "simplify"? → Use this skill 3. Code smell identified? → Use this skill 4. User wants to add feature or fix bug? → Skip (use tdd-enforcer) 5. User wants formatting/style fixes? → Skip (use /lint) Code smells (common triggers): Duplicated code (same logic in multiple places) Long function (>30 lines, doing too much) Magic numbers/strings (unexplained literals) Deep nesting (>3 levels of indentation) Dead code (unused functions, unreachable branches) Poor naming (unclear what something does) --- Phase 1: ASSESS Is this actually refactoring? User Intent Action ------------------- ----------------------------------------------- "Make this cleaner" ✓ Refactoring "Add validation" ✗ New behavior → tdd-enforcer "Fix this bug" ✗ Bug fix → tdd-enforcer or systematic-debugger "Format this code" ✗ Style → /lint If not refactoring: Explain and suggest correct approach. --- Phase 2: PROTECT Does the code have tests? Coverage Action ---------------- --------------------------------------------- Well-tested Skip to Phase 3 Partial coverage Add characterization tests for untested parts No tests Add characterization tests first Characterization Tests Capture current behavior before refactoring: Purpose: Safety net, not specification. Test what the code DOES, not what it SHOULD do. --- Phase 3: REFACTOR Iron Law: ONE refactoring at a time. Run tests after EVERY change. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills aiskillstore/refactoring