/dev-skills:refactor [target to refactor]from dev-skills
Plans and executes behavior-preserving refactoring with a written plan and standing contract. Use for restructuring, extracting, splitting code, or paying down tech debt.
Ships in dev-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Structure changes; behavior does not. This skill has two parts, because a plan alone enforces nothing.
Part 1 is the plan. You write it before you delete or move anything, and the owner approves it.
Part 2 is the standing contract. Rules R1, R2, and R3 bind you for the whole run.
A behavior change is supposed to break tests. This skill treats a broken test as evidence of a mistake, so it gives the wrong answer for feature work. Use ordinary TDD instead.
If the work mixes both, split it. Land the structural half first, under this skill. Then make the behavior change as its own commit. That split is R4, and Part 1 sequences it for you.
This text is in your context right now, and it stays there. So the triage gate below applies at the moment a test actually goes red, not only while you plan. Read R2 again at that moment. Do not act from memory of it.
The full rules live in references/refactoring-discipline.md in this plugin. That file is the source of truth. This skill carries what you need, because you may not be able to read that file from another plugin root.
Produce a written, reviewable plan. Do not delete, move, or rename anything until the owner approves it.
State what you restructure, and state the spec that defines its contract. The spec is one of these:
## Direction and ## Acceptance criteria sections, for a type:tech-debt issue;If the code has no tests, you cannot refactor it. You can only change it and hope. Write characterization tests first. Pin what the code does now, including behavior that looks wrong. Assert the observed output, not the intended output. These tests detect change; they do not judge correctness. That is R6, and it settles R2's hardest cases in advance.
If you cannot identify the spec, stop. Report it to the owner as a spec gap.
R4: a structural change and a behavioral change never share a commit. Make the change easy, then make the easy change, in two commits. A commit that moves code and alters behavior cannot be bisected or reviewed. Land the structural move green first.
R5: to remove an API that callers depend on, use parallel change. Do not edit it in place.
The old path's tests die at contract time. Never repair them to pass against the new API. That deletion is the point of the step, and it gets its own commit citing the spec line.
Write the sequence as an ordered list of commits. Mark each one structural or behavioral.
For each test, give three things:
A test you cannot classify in advance is a spec gap. Raise it in the plan. The owner decides spec gaps.
Write each dependency in this form: "X cannot move until Y is done." These become the leaves you commit from later.
Give the plan to the owner. Wait for approval. Do not begin execution until you have it.
That is what the word means. So a failing test has exactly two explanations:
"Edit the test until it goes green" is not a third explanation. It is how a refactor silently becomes a behavior change that nobody reviewed.
Default to explanation 1. Prove explanation 2 from the spec before you act on it.
Never open a failing test file to "fix it." Classify it first, from the spec. Do not classify it from the test body. The test body tells you what the old code did; only the spec tells you what the contract is.
There are three outcomes, and no others.
| Classification | Action |
|---|---|
| Asserts required behavior | The code is wrong. Fix the code. |
| Asserts behavior the spec deliberately removed | Delete the test. Cite the spec line in the commit message. |
| Asserts an implementation detail of a structure that no longer exists | Delete the test. Name the removed structure. |
Never repair a test whose subject was removed. Only delete it. A rewrite re-creates the old design's shape in the test suite, and it blocks the refactor you were asked to do.
If you cannot classify a failing test from the spec, stop and report it. An unclassifiable failure is a spec gap, and the owner decides spec gaps.
When an attempt breaks something you did not expect:
The revert is the whole method. An attempt held open while you patch what it broke grows a change nobody can review and nobody can abandon.
Here is the signal that you are grinding: you are editing files you did not plan to touch, to support a change you have not committed. When you see it, revert.
Some changes look structural but alter the public contract. Each language has its own set. Load your language's style guide and check its hazards before you plan. Every language agent supplies its own list.
Rust is the worked example:
#[cfg(test)] helper that pins an internal shape you just removed;Treat each hazard as a test you expect to die, and list it in the plan.
Editing the same test file more than twice in one unit of work is a signal, not a crime. It means the classification was probably wrong, or the step was too big.
Treat the third edit as a prompt to re-read R2 and re-classify. It is not a licence to keep going.
If your instructions name a refactor circuit breaker mode, obey that mode. If they say nothing about one, nothing halts you. Re-classify and continue. Do not invent a stop the owner did not ask for, and do not revert anything on your own initiative.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
6 skills in this plugin
/complexity-reductionMeasure cognitive complexity and duplicate code with PMD (Java) or rust-code-analysis-cli (Rust), then reduce both by pure-move extraction, re-measuring after every step. Runs over a subsystem or over a PR diff. Use this when the user asks to simplify, refactor, clean up, or reduce the complexity of a subsystem, asks "how complex is X", asks to find duplicate code, asks to make code "beautiful", or asks for a complexity check on a diff or PR. It measures before it edits and re-measures after; it never accepts an unmeasured claim that a change helped. It reports only, unless the user passes `--refactor`. It is not `/simplify`, which reads the current diff and has no metric.
/ide-explainRender an IDE-style single-page HTML view that explains anything the owner needs to see whole — a code diff, a GitHub issue plus everything linked to it, project docs, or any mix — as a file tree on the left, a code/diff/doc editor top-right, and an explanation pane bottom-right. Deterministic by default (no model tokens spent on markup); a hand-authored manifest mode exists for taught narratives. Self-contained output, no server, no CDN. Standalone — works in any repo, no other plugin required. Use whenever the owner wants one visual, walkable view instead of raw diff output or hopping between GitHub tabs — including looking at a plain backlog issue before any worktree or diff exists./prose-reviewGrade the prose in a patch against prose-style.md and report the findings; apply them with --fix. Covers code comments and javadoc by default, and commit messages, the PR description, or release notes when asked. Use this skill when the user asks to review, audit, grade, clean up, fix, tidy, or restyle comments, javadoc, commit messages, a PR description, or release notes, says "the comments need work", "check the prose on this branch", "do a comment pass", or asks for prose-style.md to be applied to anything. It reports by default and edits only with --fix. It never reviews code correctness; /code-review does that.
/tech-debtAudit the codebase for structural improvement opportunities — SOLID/composability, code duplication, and unnecessary layering — using a parallel team of review agents. Ranks the 10 most impactful findings, excludes anything already in the open backlog, and walks the owner through them one at a time with full context; the owner decides per item whether to file it as a GitHub issue. Not tied to any issue; owner-invoked, never automatic./walkthroughRender a diagram-first, ordered-step HTML presentation that teaches how something works — or presents a technical-debt review, an areas-for-improvement pass, a set of recommendations, or a performance analysis. You investigate the code and author every word; a deterministic renderer turns your manifest into one self-contained page (vertical scroll by default, one button away from slide-by-slide). Self-contained output, no server, no CDN. Standalone — works in any repo, no other plugin required. Use when the owner needs to be walked through something in order, one idea at a time, rather than handed a diff or a reference page to navigate themselves.npx claudepluginhub rustyrazorblade/skills --plugin dev-skillsOther plugins' skills for the same job