nw-refactor

nw-refactor is a skill for Claude Code from nWave-ai/nWave. It costs 34 tokens per session (675 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 34 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 675 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.00034 $0.00675
Opus 5.5 $0.00014 $0.00270
Sonnet 5.5 $0.00007 $0.00135
Haiku 4.5 $0.00003 $0.00068

Measured 17d ago against content hash 568c57927d5f, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 17d 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 · 34 lines

How it starts

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

Post-green refactor

Preconditions

  1. Start only when the required check is green on the current commit. Refactor only the code your slice changed; never the oracle, its supports or feature records.
  2. Declared paradigm picks the smell catalogue: functional, object-oriented; procedural uses long function, duplication, unclear names, mixed decision and effect.

Procedure

  1. Work smallest level first: L1 readability (rename, constants, dead code), L2 complexity (extract, simplify conditionals), L3 responsibilities, L4 abstractions, L5 patterns, L6 SOLID. Start a level only when lower levels are clean in the changed code.
  2. Inside a managed delivery slice, the default is one behaviour-preserving move per commit, and the same check you ran on the parent is green on each commit. A standalone /nw-refactor request follows the command's own batch-then-verify execution model (plan L1-L6, apply as one batch, run the suite once; nWave/tasks/nw/refactor.md).
  3. Edit no test and no expected value; declared laws and expected values stay unchanged. A test that must change means the move altered behaviour: revert the move. A test that encodes an implementation detail: report it to its owner, do not edit it.
  4. If red after a move, fix or revert the production code only.
  5. Multi-class moves: list the dependency steps, do the leaf first, commit each green.
  6. A structural move made before new behaviour leaves oracle content untouched. Probe once: re-inject a break at the moved code, confirm a test fails, then restore.

Per changed unit apply, then record what was applied or why none was needed

  1. Object-oriented domain and application classes (not adapters, DTOs, read models, config): apply the Object Calisthenics rules by their rule numbers in nw-code-design-oo, strictly; a deliberate break is recorded with its smell, benefit and cost. Functional and procedural code skip this rule and use the paradigm smell classes.
  2. Apply the nw-code-design-oo rules on data-owner decisions and on sequence-only grouping to each changed unit.
  3. Each agreed literal (limit, label, name) lives in one place that every use reads.
  4. Judge in order: tests demonstrate behaviour; no semantic duplication; clarity; fewest elements. Remove a type only if the first three still hold; keep an element whose removal raises the whole-path burden.
  5. Do not add a framework or abstraction for a single caller.

Read the full file on GitHub · 34 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. 17d ago Changed · -70 lines · -4 tokens per session 568c57927d5f
  2. 24d ago Changed · +3 lines e61c4f2f4f8b
  3. 27d ago Changed · -3 lines de8bfa51f190
  4. 2mo 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 (636 stars, last pushed 11d ago), licensed MIT. It adds 34 tokens to every session and 675 once invoked, about $0.0001 per session on Opus 5.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.

Related

nw-refactor compared with skills from other repositories

nw-refactor next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
nw-refactornWave-ai/nWaveSkill63611d agoMITA34Claude Code
java-testing-junit-mockitomakifbaysal/tasktrooperSkill123todayApache-2.0A46Claude Code, Codex
test-writingandreaswasita/copilot-agents-dojoSkill562mo agoMITA11Claude Code, Codex
principle-test-behavior-not-implementationmichael-denyer/pstack-claudeSkill5.0ktodayMITA50Claude Code, Codex
temporal-python-testingwshobson/agentsSkill43k6d agoMITA45Claude Code
test-automationa5c-ai/babysitterSkill1.9k29d agoMITA0Claude Code, Codex
JUnit 5 TestingPramodDutta/qaskillsSkill25227d agoMITA36Claude Code, Codex