Skip to content

Code Refactoring Assistant

Guides safe, test-backed, step-by-step refactoring of existing code using Martin Fowler's methods

Stars
46,401
Licence
MIT
Files
4 files

What it does

When you ask the agent to clean up, restructure, or reduce technical debt in code, this skill makes it follow a staged process: first understand the code and check for tests, then list code smells (such as long functions or duplicated logic), propose a written plan of named refactorings with rollback steps, and make small changes one at a time. It asks you to approve each stage and runs the tests after every change so behaviour stays the same.

Great for

  • Developers who have legacy code with long functions, duplication or unclear structure and want a careful, reviewable cleanup
  • Teams that want refactoring done in small, committed steps with user checkpoints rather than one large rewrite

Skip it if

  • Code with no tests and no appetite for risk: the skill itself says not to refactor without tests unless you explicitly accept the risk
  • Urgent production incidents: the skill advises against refactoring during an outage

Try asking

  • “Refactor the processOrder function in src/orders.js, it is about 150 lines and I want it split up safely”
  • “Find code smells in this Python module and propose a prioritized refactoring plan before changing anything”
  • “Remove dead code and rename unclear variables in the billing folder, one commit per change”
Step-by-step guide: how to use Code Refactoring AssistantInstall, first run, examples, tips and FAQs

Install in 3 steps

  1. 1

    Download the skill

    The ZIP contains the 4 original files, the MIT licence and an attribution note.

    refactor.zip
  2. 2

    Add it to your agent

    Claude Code (all projects)

    mkdir -p ~/.claude/skills && unzip refactor.zip -d ~/.claude/skills/

    Claude Code / Agent SDK (this project only)

    mkdir -p .claude/skills && unzip refactor.zip -d .claude/skills/

    Claude apps (web/desktop): Settings → Capabilities → Skills → Upload skill, and choose the ZIP.

  3. 3

    Ask for the task

    No special command needed — the agent reads the skill's description and loads it when your request matches. Try one of the prompts above.

Get better results

  • Ask the agent to confirm test coverage first, and give it the test command for your project so it can run tests after each step
  • Review the proposed plan and approve one stage (quick wins, then structural, then architectural) at a time rather than the whole plan
  • Check each commit yourself; the agent's behaviour-preserved claim depends on your tests and manual checks

What's inside

  • references/code-smells.md
  • references/refactoring-catalog.md
  • SKILL.md
  • templates/refactoring-plan.md

Redistributed unmodified from luongnv89/claude-howto under the MIT licence. The assessment was drafted with AI from the skill's files on 2026-10-29. Skills can instruct your agent to run code — read SKILL.md and any scripts before installing.