refactor-cleaner

refactor-cleaner is an agent for coding agents from hmj1026/dhpk. It costs 71 tokens per session (1,318 once invoked), scanned A, original, MIT.

A language-independent cleanup assistant for removing unused code, merging duplicated logic, splitting oversized files, and gathering scattered patterns together.

In plain words
What is it for?
Use it during refactoring, especially when removing dead code, deduplicating logic, splitting files over 800 lines, or cleaning up after a large feature.
Why use it?
It reduces maintenance work caused by code that is no longer used, repeated implementations, and files that have grown too large to manage easily.

Agent

Installs and runs on its own, but its text points at files inside its plugin — anything it tells you to read at a ${CLAUDE_PLUGIN_ROOT} path is only there once the plugin is installed. Installing the plugin gets both.

Part of the dhpk plugin — 19 commands, 36 agents shipped together

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.

agentmods
npx agentmods add agents/hmj1026/dhpk/refactor-cleaner
Clone the repo
git clone --depth 1 https://github.com/hmj1026/dhpk

Or install dhpk, the plugin that ships this one along with the rest of its 19 commands, 36 agents.

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

README.md
[![agentmods](https://agentmods.dev/badge/agents/hmj1026/dhpk/refactor-cleaner.svg)](https://agentmods.dev/agents/hmj1026/dhpk/refactor-cleaner)
Your own site
<a href="https://agentmods.dev/agents/hmj1026/dhpk/refactor-cleaner"><img src="https://agentmods.dev/badge/agents/hmj1026/dhpk/refactor-cleaner.svg" alt="Measured on agentmods" height="20"></a>
Per session 71 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,318 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00071 $0.01318
Opus 5 $0.00036 $0.00659
Sonnet 5 $0.00014 $0.00264
Haiku 4.5 $0.00007 $0.00132

Measured 3d ago against content hash dfe384cf1d37, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

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 3d 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/refactor-cleaner.md · 94 lines

How it starts

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

Refactor Cleaner

Remove dead code, merge dupes, split files >800 lines.

Detect usage with cx references --name X (preferred) or gitnexus_impact. Renames go through gitnexus_rename when available; without it, enumerate every call site with cx references first, then apply scoped Edits and re-verify — never blind find-and-replace. See ${CLAUDE_PLUGIN_ROOT}/rules/tool-routing.md.

When NOT

  • Post-edit quality gate → code-reviewer. This agent is not a reviewer.

Stack trap sheet (load on demand)

Detect the active stack, then load ONLY the matching trap sheet(s); ignore other stacks.

1-2. Loader: ${CLAUDE_PLUGIN_ROOT}/agent-traps/_common/trap-sheet-loader.md (<agent-name> = refactor-cleaner). 3. No sheet matches → apply the Project Rules below as the language-agnostic baseline.

Project Rules

Stack-specific traps (example shapes — adapt to your codebase):

  • Backend MVC / DDD frameworks — move duplicates through the project's layering (e.g. Controller → Service → Repository); don't introduce syntax newer than the project's pinned language version; watch for stale ORM relations, disabled lifecycle hooks, and obsolete module aliases in the framework config file. Replace string enum literals with typed constants per your project's magic-value rule.
  • Frontend / legacy JS bundle — if a single highly-coupled bundle owns most of the page, prefer local removals over bulk refactor; annotate removals with // Removed [date] - [reason]; never edit *.min.js directly (edit source and re-minify); route AJAX through the project's existing wrapper instead of bare fetch/$.ajax; attach globals to a single project-owned namespace, never window.

Stack-specific module overlays (e.g. modules/php-5.6/, modules/yii-1.1/) may provide more detailed checklists per framework — consult them if the matching module is enabled.

What counts as removable

Delete only with proof (a cx references / gitnexus_impact miss, not a guess):

Read the full file on GitHub · 94 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. 3d ago First seen · 94 lines · 71 tokens per session scan A dfe384cf1d37

Subscribe to this mod's changes

refactor-cleaner is an agent published in the GitHub repository hmj1026/dhpk (2 stars, last pushed 3d ago), licensed MIT. It adds 71 tokens to every session and 1,318 once invoked, about $0.0004 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-08-31.