nw-refactor

nw-refactor is a skill for Claude Code from nWave-ai/nWave. It costs 38 tokens per session (1,185 once invoked), scanned A, original, MIT.

A command-driven method for systematically refactoring code through six levels, from readability and complexity to responsibilities, abstractions, design patterns, and SOLID principles. It applies the planned changes together and verifies them with the test suite afterward.

In plain words
What is it for?
Use it to plan and apply multi-level refactors, reduce code smells, reorganize complex code, and verify the result with tests.
Why use it?
It provides an ordered way to improve code structure while checking that the refactoring has not changed expected behavior.

Skill for Claude Code

Written for Claude Code: user-invocable in frontmatter.

Good fit Use it to plan and apply multi-level refactors, reduce code smells, reorganize complex code, and verify the result with tests.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/nwave-ai/nwave/nw-refactor
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add nWave-ai/nWave --skill nw-refactor
Clone the repo
git clone --depth 1 https://github.com/nWave-ai/nWave

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for nw-refactor

README.md
[![agentmods](https://agentmods.dev/badge/skills/nwave-ai/nwave/nw-refactor/github.svg)](https://agentmods.dev/skills/nwave-ai/nwave/nw-refactor)
Your own site
<a href="https://agentmods.dev/skills/nwave-ai/nwave/nw-refactor"><img src="https://agentmods.dev/badge/skills/nwave-ai/nwave/nw-refactor/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for nw-refactor

Your own site · 80×15
<a href="https://agentmods.dev/skills/nwave-ai/nwave/nw-refactor"><img src="https://agentmods.dev/badge/skills/nwave-ai/nwave/nw-refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 38 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,185 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00038 $0.01185
Opus 5 $0.00019 $0.00593
Sonnet 5 $0.00008 $0.00237
Haiku 4.5 $0.00004 $0.00119

Measured 7d ago against content hash d3ae7401c1fc, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

nw-refactor scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

nWave/skills/nw-refactor/SKILL.md · 104 lines

How it starts

The opening of the file, as written. The whole thing — 104 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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:

  1. 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.
  2. Edits applied as one coherent batch — apply all planned L1-L6 transformations in a single editing session. NO interleaved test runs between levels.
  3. Run the test suite exactly ONCE, at the very end, after all L1-L6 edits.
  4. 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.

Legacy incremental variant (opt-in only): the nw-progressive-refactoring skill documents the incremental L1→test→L2→test cycle. It is NOT the default — use it only when explicitly requested. Anchor: feedback_refactor_batch_when_test_suite_slow_2026_05_19 (the prior "only batch when suite slow" conditional is removed — batch is now unconditional).

Context Files Required

  • src/* - Production codebase
  • tests/* - Test codebase

Agent Invocation

@nw-software-crafter

Execute *refactor for {target-class-or-module}.

Context Files:

  • src/*
  • tests/*

Configuration:

  • level: 3 # Shorthand: --from=1 --to=3 (RPP range)
  • from: 1 # Start RPP level (default: 1)
  • to: 3 # End RPP level (default: same as level)
  • scope: module # file/module/project
  • method: extract # extract/inline/rename/move
  • mikado_planning: false # Use Mikado Method for complex refactorings

Read the full file on GitHub · 104 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 7d ago First seen · 104 lines · 38 tokens per session scan A d3ae7401c1fc

Subscribe to this mod's changes

nw-refactor is a skill published in the GitHub repository nWave-ai/nWave (610 stars, last pushed 4d ago), licensed MIT. It adds 38 tokens to every session and 1,185 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.