
Refactor
Finds where refactoring pays off from git churn and bug history, then applies it safely
Refactor is an open-source agent skill for developer tools. It is available on Claude Code.
- Scripts
- None
- Platforms
- Claude Code
- GitHub stars
- 9
- Last commit
- License
- MIT
- Listing updated
Similar skills
About Refactor
Refactor works in two modes. A survey pass ranks candidate areas of the codebase using evidence such as frequently edited complex files, a recurring bug log and planned upcoming work, then gives each candidate a verdict of refactor, prep, leave or watch. Leaving code alone is the default, and design patterns must be justified by a concrete problem in the codebase rather than by general best practice. Results are saved as a brief and tracked in a debt register so later surveys start from what has changed.
Execution mode takes one approved target and changes it in small named moves, such as extracting a function or renaming across call sites. The skill checks for a passing test suite before starting, writes characterization tests when an area has none, and reverts any step that turns the suite red rather than patching forward. Bugs found along the way are logged for separate fixing so the diff keeps its behavior intact.
The skill expects a git repository and a runnable test suite, and it uses git history to measure churn. It can also read an optional bug log and planning notes kept in the project's output folder.
When your agent uses it
Evidence-driven refactoring — where does structural improvement actually pay off, then make that change without changing behavior. Survey mode diagnoses by evidence, not aesthetics — git churn × complexity hotspots, the recurring-bug log, upcoming work — and verdicts each candidate REFACTOR/PREP/LEAVE/WATCH, where LEAVE is the default and "the textbook recommends it" is never a reason. Execute mode takes one approved candidate in small behavior-preserving moves, suite green after each. Keeps a debt register in out/refactor/tracker.md so repeat surveys open with what changed. Use for "clean up this module", "improve the architecture", "pay down tech debt" — e.g. "/refactor", "/refactor <target>". For new behavior use feature; for something broken use bugfix.
From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.
What it can access
From a static check of its 2 files (10 KB) on GitHub on 4 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.
Check another skill before you install it.
Install
This skill ships in the coding-loop plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):
/plugin marketplace add duthaho/skillhub
/plugin install coding-loop@skillhubOr copy only this skill to ~/.claude/skills/refactor:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/duthaho/skillhub.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/refactor &&
cp -R "$tmp/.claude/skills/refactor" ~/.claude/skills/refactor &&
rm -rf "$tmp"For one project only, put the folder in .claude/skills/refactor inside it instead.
Copy the skill folder to ~/.agents/skills/refactor to use it in every repository:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/duthaho/skillhub.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/refactor &&
cp -R "$tmp/.claude/skills/refactor" ~/.agents/skills/refactor &&
rm -rf "$tmp"For one repository only, put the folder in .agents/skills/refactor inside it instead.
Copy the skill folder to ~/.cursor/skills/refactor to use it in every project:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/duthaho/skillhub.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/refactor &&
cp -R "$tmp/.claude/skills/refactor" ~/.cursor/skills/refactor &&
rm -rf "$tmp"For one project only, put the folder in .cursor/skills/refactor inside it instead.
Run in a terminal (add --scope workspace to install it for the current workspace only):
gemini skills install https://github.com/duthaho/skillhub.git --path .claude/skills/refactorOr copy the folder to ~/.gemini/skills/refactor yourself.
For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/refactor:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/duthaho/skillhub.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/refactor &&
cp -R "$tmp/.claude/skills/refactor" ~/.copilot/skills/refactor &&
rm -rf "$tmp"For one project only, put the folder in .github/skills/refactor inside it instead.
Get the folder:
git clone --depth 1 https://github.com/duthaho/skillhub.gitThen copy skillhub/.claude/skills/refactor into your agent's skills folder as refactor. Agents that support SKILL.md read one folder per skill.
What it does
- Evidence-based candidate survey
- Ranks code areas by git churn combined with complexity to find where structural work will actually pay off.
- Verdict per candidate
- Labels each candidate as refactor, prep, leave or watch, with leave as the default outcome.
- Pattern justification gate
- Requires any proposed design pattern to address a named problem with a file location and evidence.
- Small behavior-preserving moves
- Applies refactors as named steps, running the test suite and checkpoint committing after each.
- Characterization tests first
- Pins current behavior with tests around untested code before restructuring it.
- Persistent debt register
- Keeps a tracker of verdicts so repeat surveys show what has changed since the last one.
Good for
- Find the modules in this repo where cleanup would actually reduce future work
- Refactor a specific module without changing its behavior
- Pay down technical debt in a frequently edited file
- Prepare a messy area so an upcoming feature is easier to add
- Plan a large rename across the codebase in safe stages
Refactor FAQ
What does the skill need to run?
It needs a test suite the agent can run to confirm behavior is preserved, and git history for the churn analysis.
Does Refactor change code when I run the survey?
No. The survey only produces a brief and updates the tracker. Code changes happen only in execute mode on a target you choose.
What happens if a refactoring step breaks a test?
The step is reverted and rethought or split into smaller moves instead of being patched until the tests pass.
Does it fix bugs it finds during a refactor?
No. Bugs are logged for a separate fix so the refactor keeps existing behavior.
How do I install Refactor in Claude Code?
Copy the skill folder from GitHub to ~/.claude/skills/refactor to use it in all your projects, or to .claude/skills/refactor in one project. Or install the coding-loop plugin, which includes it: /plugin marketplace add duthaho/skillhub, then /plugin install coding-loop@skillhub.
Does Refactor run scripts?
No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.
Which AI agents can use Refactor?
Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.
What are the best alternatives to Refactor?
The closest alternatives to Refactor are Refactoring guide, Refactor, Refactor, Refactor seams and Improve architecture.
Where this comes from
- Description: from the skill's own SKILL.md.
More from duthaho/skillhub

Lists parked items from your other skills that are now due for a re-check
- Open source
- 9 GitHub stars
- Productivity

Maps peer projects and their user demand to decide which features to adopt
- Open source
- 9 GitHub stars
- Developer tools

Audits your agent setup against past sessions and proposes one-line harness fixes
- Open source
- 9 GitHub stars
- Developer tools

Builds scored, evidence-backed technology decision briefs comparing options for a context
- Open source
- 9 GitHub stars
- Developer tools

Generates grounded architecture docs and mermaid diagrams for a codebase or feature
- Open source
- 9 GitHub stars
- Documentation review

Reproduce, root-cause, fix test-first and verify a bug before shipping the change
- Open source
- 9 GitHub stars
- Developer tools





