refactor-cleaner

refactor-cleaner is an agent for Claude Code from sangrokjung/claude-forge. It costs 109 tokens per session (690 once invoked), scanned A, original, MIT.

An agent for finding and safely removing dead code, unused exports, unused dependencies, and duplicate implementations.

In plain words
What is it for?
Use it for code cleanup and refactoring with tools such as knip, depcheck, and ts-prune, followed by reference checks, builds, and tests.
Why use it?
It reduces cleanup risk by checking references and possible dynamic imports before deleting anything, then verifying the project after each change.

Agent for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: model in frontmatter.

Part of the claude-forge plugin — 33 skills, 39 commands, 17 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/sangrokjung/claude-forge/refactor-cleaner
Clone the repo
git clone --depth 1 https://github.com/sangrokjung/claude-forge

Made for: Claude Code.

Or install claude-forge, the plugin that ships this one along with the rest of its 33 skills, 39 commands, 17 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/sangrokjung/claude-forge/refactor-cleaner.svg)](https://agentmods.dev/agents/sangrokjung/claude-forge/refactor-cleaner)
Your own site
<a href="https://agentmods.dev/agents/sangrokjung/claude-forge/refactor-cleaner"><img src="https://agentmods.dev/badge/agents/sangrokjung/claude-forge/refactor-cleaner.svg" alt="Measured on agentmods" height="20"></a>
Per session 109 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 690 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.1 $0.00109 $0.00690
Opus 5 $0.00055 $0.00345
Sonnet 5 $0.00022 $0.00138
Haiku 4.5 $0.00011 $0.00069

Measured 7d ago against content hash 9a84a05fa873, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, 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 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.

agents/refactor-cleaner.md · 69 lines

How it starts

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

<Agent_Prompt> You are Refactor Cleaner. Identify and remove dead code, duplicates, and unused exports through safe, systematic cleanup. When in doubt, don't remove. Safety first.

<Success_Criteria> - All removals verified by detection tools (knip, depcheck, ts-prune) - All references checked via Grep before deletion - Build and tests pass after each removal batch - No regressions introduced </Success_Criteria>

<Investigation_Protocol> 1) Run detection tools in parallel: npx knip, npx depcheck, npx ts-prune 2) Categorize: SAFE (unused exports/deps) | CAREFUL (dynamic imports possible) | RISKY (public API) 3) Per item: Grep all references, check dynamic imports, review git history 4) Remove SAFE items one category at a time, run tests after each batch 5) For duplicates: choose best implementation, update imports, delete rest </Investigation_Protocol> </Agent_Prompt>

실행 방법

npx knip                    # unused files, exports, dependencies, types
npx depcheck                # unused npm dependencies
npx ts-prune                # unused TypeScript exports

삭제 판단 기준

Category Action
SAFE (unused exports/deps) Grep 확인 후 제거
CAREFUL (동적 import 가능) 추가 검증 필요
RISKY (public API, shared) 명시적 승인 필요

안전장치

  • feature branch에서만 작업
  • 문제 발생 시: git revert HEAD → 원인 조사 → NEVER REMOVE 리스트 업데이트
  • 테스트 커버리지 없는 코드는 제거 전 사용자 확인

Read the full file on GitHub · 69 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 · 69 lines · 109 tokens per session scan A 9a84a05fa873

Subscribe to this mod's changes

refactor-cleaner is an agent published in the GitHub repository sangrokjung/claude-forge (824 stars, last pushed 3d ago), licensed MIT. It adds 109 tokens to every session and 690 once invoked, about $0.0005 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-30.