w-refactor — Claude Code skill: refactoring and setup
The w-refactor Claude Code skill restructures selected code while preserving its behavior. It starts by recording a baseline with tests, type checks, or a manual scenario.
MIT 647 installs ★ 1 updated 2026-10-02
npx skills add blockmatic-icebox/basilic-skills --skill w-refactor -a claude-codeWhat w-refactor does
The skill works on selected files or a named code concern. First, it identifies what callers rely on and which checks can show that behavior remains intact. Then it suggests a small, focused diff: remove duplication, clarify names, or reduce nesting while reusing packages already in the repository.
Algorithm or data-structure changes require evidence from the repository’s profiler, tests, or traces. After editing, the skill runs the checks chosen at the start and calls for restoring behavior if they fail. It does not run the full pre-push suite. Commit, push, and pull request creation are outside its scope.
If behavior or commands change, documentation can be updated with /w-docs.
What it helps with
- remove duplication from selected files
- reduce deeply nested code
- rename code elements without changing behavior
- check a refactor with selected tests
Example prompts for the agent
- Run
w-refactoron these files and preserve their behavior. - Use
w-refactorto simplify the structure of this code section.
How to install w-refactor
1Skills CLI (Vercel)
npx skills add blockmatic-icebox/basilic-skills --skill w-refactor -a claude-code2Manually: put the files in place
~/.claude/skills/w-refactor/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/w-refactor/
1Skills CLI (Vercel)
npx skills add blockmatic-icebox/basilic-skills --skill w-refactor -a codex2Manually: put the files in place
.agents/skills/w-refactor/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add blockmatic-icebox/basilic-skills --skill w-refactor -a cursor2Manually: put the files in place
.cursor/skills/w-refactor/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install blockmatic-icebox/basilic-skills skills/workflow/w-refactor2Manually: put the files in place
.github/skills/w-refactor/SKILL.md1Skills CLI (Vercel)
npx skills add blockmatic-icebox/basilic-skills --skill w-refactor -a gemini-cli2Platform CLI
gemini skills install https://github.com/blockmatic-icebox/basilic-skills --path skills/workflow/w-refactorManually: put the files in place
.devin/skills/w-refactor/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add blockmatic-icebox/basilic-skills --skill w-refactor -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about w-refactor
How do I install w-refactor in Claude Code?
Run npx skills add blockmatic-icebox/basilic-skills --skill w-refactor -a claude-code. The skill file is at ~/.claude/skills/w-refactor/SKILL.md.
What does w-refactor do?
It helps restructure selected files or a named area of code, recording checks for behavior before edits. It does not authorize commits, pushes, or pull request creation.
What evidence does w-refactor require for algorithm changes?
Changes to algorithms or data structures need support from the repository’s profiler, tests, or traces.
Source text
SKILL.md · MIT
--- name: w-refactor description: Refactor selected code while preserving behavior, then verify. disable-model-invocation: true --- Use the selected files or a named concern. Capture current behavior with tests, types, or a manual scenario before editing. Refactor does not authorize commit, push, or PR. 1. Record a baseline: what callers depend on, which checks prove it, and what must not change. 2. Improve structure in the smallest useful diff: extract duplication, clarify names, reduce nesting. Reuse existing packages. Do not add comments that restate the code. 3. Change algorithms or data structures only with measured evidence from the repository's profiler, tests, or traces. 4. Run the affected checks from the baseline. Restore behavior if they fail. Never the full pre-push suite. 5. Docs: `/w-docs` if behavior or commands changed.
© blockmatic-icebox · MIT · blockmatic-icebox/basilic-skills