Use when code should be restructured without changing behaviour - extract, merge, rename, deduplicate, move, migrate callers, deepen a module. States the gain up front, pins behaviour at a seam the change won't move, and merges only if the pins stay green and the gain shows; otherwise reverts.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Vrefactor?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/vocsong-vrefactor)
---
name: vrefactor
description: Use when code should be restructured without changing behaviour - extract, merge, rename, deduplicate, move, migrate callers, deepen a module. States the gain up front, pins behaviour at a seam the change won't move, and merges only if the pins stay green and the gain shows; otherwise reverts.
---
# vrefactor — change structure, not behaviour
Read `../vcore/SKILL.md` first and follow it.
## 1. State the gain
Before touching code, write the concrete improvement in terms the diff can show: fewer layers, a
deleted API, one owner instead of several copies, simpler call sites, less code, a contract suite
that now covers every implementation. "Cleaner" is not a gain.
## 2. Pin behaviour
Write characterization tests ("pins") so any behaviour change fails loudly. Typecheck and lint are
not pins.
- **Pin at a seam the refactor doesn't move** — the public entry points callers use, not internals
you are about to reshape. Check each pin with two imagined edits: break the behaviour → the pin
must fail; change only the internals → the pin must keep passing.
- Run the pins green on the unchanged code first.
- **Pins are frozen during the refactor.** If one goes red, the refactor changed behaviour — fix the
code, not the pin. Any edit to a pin is flagged by review's gate-integrity check.
## 3. Shape the work
- **Contained** — one PR. A separate first commit that only deletes dead code makes the reshape
easier to review.
- **Wide** (many callers or modules) — expand → migrate → contract: add the new shape beside the
old, move callers in batches sized by blast radius, then delete the old shape. Each batch is a
slice: spec them with `../vspec/SKILL.md` and `../vslice/SKILL.md` (with the spec sign-off gate)
and build them like `vfeature`'s large path. If batches can't each stay green on the base, use a
shared integration branch and a final integrate-and-verify slice.
## 4. Change
- Keep behaviour identical. Resist adjacent fixes; note them for the report.
- **Renames:** sweep strings, docs, config, IPC channel names, log messages and test names, not just
identifiers.
- Larger reshapes: an **equivalence check** — run old and new on the same inputs and diff outputs.
UI refactors: compare screenshots before and after (image diff).
## 5. Check the bar
- All pins and the layers the feature map requires stay green.
- The gain from step 1 is visible in the diff. If it isn't, **revert** rather than ship a sideways
move, and say so in the report.
## 6. Finish
`../vverify/SKILL.md` → `../vreview/SKILL.md` → `../vmerge/SKILL.md`. The PR states the gain and
shows it (lines, layers, copies or APIs before and after).