# W Refactor

> Refactor selected code while preserving behavior, then verify.

- Skill: `blockmatic/w-refactor` (Agent Skill)
- Install (CLI): `npx get-skill add blockmatic/w-refactor`
- Raw SKILL.md: https://api.skillmd.com/api/skills/blockmatic/w-refactor/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Productivity
- Author: blockmatic (https://skillmd.com/u/blockmatic)
- Updated: 2026-11-11
- Page: https://skillmd.com/skills/blockmatic/w-refactor

---


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.

