← Back to Library|SkillsRefactor Assistant
Install this skill: copy and save to ~/.claude/skills/refactor-assistant/SKILL.md

Refactor Assistant

Identifies code smells, duplicated logic, overly complex functions, and suggests targeted refactors without changing behavior.

5 min|Intermediate
BuildDeep WorkDeveloper
SKILL.md~/.claude/skills/refactor-assistant/
---
name: refactor-assistant
description: |
  Identifies and fixes code smells, duplication, and complexity without changing behavior.
  IMPORTANT: Activate this skill whenever the user asks to "refactor",
  "clean up this code", "simplify this", or "reduce complexity".
  This skill MUST be used for all refactoring requests.
---

# Refactor Assistant

Finds code smells, duplicated logic, and overly complex functions, then suggests targeted refactors that improve readability and maintainability without changing external behavior.

**Trigger:**

Say any of these to activate this skill:
- "refactor this"
- "clean up this code"
- "simplify this function"
- "Use skill: refactor assistant"

**How It Works:**

1. Read the target file(s) and identify code smells: long functions, deep nesting, duplicated blocks, unclear naming
2. Check for patterns that can be simplified: repeated conditionals, manual loops that could be map/filter, nested callbacks
3. Identify duplicated logic across files that could be extracted into a shared utility
4. Propose each refactor individually with before/after comparison
5. Apply approved refactors one at a time
6. Run tests after each change to verify behavior is preserved
7. If no tests exist, warn the user before making changes

**Guidelines:**

- Never change external behavior (inputs, outputs, side effects must remain the same)
- Refactor one thing at a time, not everything at once
- Do not introduce new abstractions unless the duplication is in 3+ places
- Prefer readability over cleverness (a clear 5-line function beats a clever 1-liner)
- Always run tests after each refactor to catch regressions

**Works With:**

- Best with: Claude Code CLI (can run tests between refactors)
- Also works: Cursor, Windsurf
- Expects: A codebase with tests for confidence in behavior preservation

**Output Format:**

- List of identified code smells with severity
- Before/after for each proposed refactor
- Test results confirming no behavior change

Finds code smells, duplicated logic, and overly complex functions, then suggests targeted refactors that improve readability and maintainability without changing external behavior.

Say any of these to activate this skill: - "refactor this" - "clean up this code" - "simplify this function" - "Use skill: refactor assistant"

1. Read the target file(s) and identify code smells: long functions, deep nesting, duplicated blocks, unclear naming 2. Check for patterns that can be simplified: repeated conditionals, manual loops that could be map/filter, nested callbacks 3. Identify duplicated logic across files that could be extracted into a shared utility 4. Propose each refactor individually with before/after comparison 5. Apply approved refactors one at a time 6. Run tests after each change to verify behavior is preserved 7. If no tests exist, warn the user before making changes

  • Never change external behavior (inputs, outputs, side effects must remain the same)
  • Refactor one thing at a time, not everything at once
  • Do not introduce new abstractions unless the duplication is in 3+ places
  • Prefer readability over cleverness (a clear 5-line function beats a clever 1-liner)
  • Always run tests after each refactor to catch regressions
  • Best with: Claude Code CLI (can run tests between refactors)
  • Also works: Cursor, Windsurf
  • Expects: A codebase with tests for confidence in behavior preservation
  • List of identified code smells with severity
  • Before/after for each proposed refactor
  • Test results confirming no behavior change
Refactor Assistant | Library | Modern Vibe Coding