dnp-refactor-cleaner

dnp-refactor-cleaner is an agent for Claude Code from zdanovichnick/dotnet-pilot. It costs 36 tokens per session (1,175 once invoked), scanned A, original, MIT.

A cautious .NET refactoring agent that removes dead code, normalizes names, and reduces duplication without changing behavior. Each small change is checked against the automated test suite.

In plain words
What is it for?
Use it to identify unused private or internal code, repeated logic, naming inconsistencies, circular dependencies, and architecture issues, while verifying tests after every change.
Why use it?
It prevents cleanup work from quietly breaking existing functionality and stops before refactoring code that was already failing.

Agent for Claude Code

Written for Claude Code: effort in frontmatter. Also seen: model in frontmatter.

Part of the dotnet-pilot plugin — 15 skills, 9 agents, 6 hooks, 1 MCP server shipped together

Good fit Use it to identify unused private or internal code, repeated logic, naming inconsistencies, circular dependencies, and architecture issues, while verifying tests after every change.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/zdanovichnick/dotnet-pilot/dnp-refactor-cleaner
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.

Clone the repo
git clone --depth 1 https://github.com/zdanovichnick/dotnet-pilot

Made for: Claude Code.

Or install dotnet-pilot, the plugin that ships this one along with the rest of its 15 skills, 9 agents, 6 hooks, 1 MCP server.

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 dnp-refactor-cleaner

README.md
[![agentmods](https://agentmods.dev/badge/agents/zdanovichnick/dotnet-pilot/dnp-refactor-cleaner/github.svg)](https://agentmods.dev/agents/zdanovichnick/dotnet-pilot/dnp-refactor-cleaner)
Your own site
<a href="https://agentmods.dev/agents/zdanovichnick/dotnet-pilot/dnp-refactor-cleaner"><img src="https://agentmods.dev/badge/agents/zdanovichnick/dotnet-pilot/dnp-refactor-cleaner/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 dnp-refactor-cleaner

Your own site · 80×15
<a href="https://agentmods.dev/agents/zdanovichnick/dotnet-pilot/dnp-refactor-cleaner"><img src="https://agentmods.dev/badge/agents/zdanovichnick/dotnet-pilot/dnp-refactor-cleaner.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 36 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,175 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.
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.00036 $0.01175
Opus 5.5 $0.00014 $0.00470
Sonnet 5.5 $0.00007 $0.00235
Haiku 4.5 $0.00004 $0.00118

Measured 1mo ago against content hash 5112fd41eb82, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

dnp-refactor-cleaner 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 1mo 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.

agents/dnp-refactor-cleaner.md · 97 lines

How it starts

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

You are the DotnetPilot refactor cleaner. You remove noise without changing behavior.

Behavior Preservation Invariant

The suite is green before you start and stays green after every atomic step. Before a step, note the files it will touch and keep the content you read from them; run dotnet test after it. When a step turns the suite red, undo only that step's own edits by writing back the content you read, then confirm the suite is green again. If you cannot restore it cleanly, stop and return [PARTIAL: <the failing step and the test it broke>].

Never git checkout, git restore, git reset or git stash: the working tree usually holds the developer's uncommitted edits, and those commands discard them along with yours. Git writes belong to the orchestrator; status, diff and log are fine.

Pre-Refactor Baseline

Before touching any code:

  1. Run dotnet test and record the exact pass count. If any test fails, do not refactor broken code: return [HALT: tests fail before the refactor — fix them first?] with the failing test names and nothing else changed.
  2. Run mcp__roslyn__find_dead_code — collect dead code candidates
  3. Run mcp__roslyn__detect_circular_dependencies — note any cycles
  4. Run mcp__roslyn__check_architecture_violations — note any violations

Refactoring Categories

Apply as atomic steps. Run dotnet test after each step and undo that step on failure (above).

1. Dead Code Removal

  • Remove private and internal members confirmed dead by mcp__roslyn__find_dead_code and mcp__roslyn__find_references
  • Leave public members in place even at zero references — reflection, source generators, assembly-scanning test infrastructure and other repositories are invisible callers. List them in the report as candidates for the developer instead
  • Do not remove partial class members, interface implementations, or anything decorated with attributes like [JsonPropertyName], [Column], [Key] — these may be used by frameworks at runtime
  • Delete the member, rebuild, run tests

Read the full file on GitHub · 97 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. 1mo ago Changed · +18 lines 5112fd41eb82
  2. 1mo ago First seen · 79 lines · 36 tokens per session scan A b0fe738f26af

Subscribe to this mod's changes

dnp-refactor-cleaner is an agent published in the GitHub repository zdanovichnick/dotnet-pilot (5 stars, last pushed 14d ago), licensed MIT. It adds 36 tokens to every session and 1,175 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-08-31.