nw-refactor
Installation
SKILL.md
NW-REFACTOR: Systematic Code Refactoring
Wave: CROSS_WAVE
Agent: Crafty (nw-software-crafter)
Command: *refactor
Overview
Applies the Refactoring Priority Premise (RPP) — 6-level hierarchy L1 Readability|L2 Complexity|L3 Responsibilities|L4 Abstractions|L5 Design Patterns|L6 SOLID++. For complex multi-class refactorings, agent applies Mikado Method internally.
Execution Model — Batch-Then-Verify (default, unconditional)
/nw-refactor runs batch-then-verify by default, regardless of test-suite speed:
- Cascade governs PLANNING ORDER only — analyze and plan lower levels before higher (L2 transformations build on L1, L3 on L2, etc.). The cascade is a planning discipline, not a test-gating sequence.
- Edits applied as one coherent batch — apply all planned L1-L6 transformations in a single editing session. NO interleaved test runs between levels.
- Run the test suite exactly ONCE, at the very end, after all L1-L6 edits.
- If RED after the batch: diagnose the breakage and fix the production code. Do NOT modify tests to make them pass. A test that must change to pass means either (a) the refactor altered observable behavior — revert that transformation — or (b) the test encoded an implementation detail rather than behavior — flag this to the user explicitly before touching it. Tests changing during a refactor is a signal, not a step.