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

Good fit Use it for code cleanup and refactoring with tools such as knip, depcheck, and ts-prune, followed by reference checks, builds, and tests.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/sangrokjung/claude-forge/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/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/github.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/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 refactor-cleaner

Your own site · 80×15
<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="Reviewed on agentmods" width="80" 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. 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.00109 $0.00690
Opus 5.5 $0.00044 $0.00276
Sonnet 5.5 $0.00022 $0.00138
Haiku 4.5 $0.00011 $0.00069

Measured 1mo ago against content hash 9a84a05fa873, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 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/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. 1mo 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 (863 stars, last pushed 1mo ago), licensed MIT. It adds 109 tokens to every session and 690 once invoked, about $0.0004 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-30.

Related

Other agents, from other repositories

go-observability-reviewer

Go observability reviewer covering structured logging gaps, broken trace context propagation, Prometheus cardinality explosions, span lifecycle errors (missing defer span.End(), unrecorded errors), and sensitive fields in logs. Use when Go code changes import go.uber.org/zap, log/slog, go.opentelemetry.io…

johnqtcg/awesome-skills · 119 tokens

go-error-reviewer

Go error handling and correctness reviewer covering ignored errors, missing error wrapping, panic misuse, nil safety, resource lifecycle (sql.Rows, resp.Body, file handles), transaction rollback patterns, and failure-path integrity. Use when Go code changes contain error returns, panic calls, sql.Rows, tx.Begin, HTTP…

johnqtcg/awesome-skills · 97 tokens

go-logic-reviewer

Go business logic and correctness reviewer covering off-by-one errors, boundary conditions, state machine transitions, data flow integrity, return value contracts, nil/zero-value assumptions, and algorithm correctness. Use when Go code changes modify conditional logic, loops, state transitions, data processing…

johnqtcg/awesome-skills · 81 tokens

go-test-reviewer

Go test quality reviewer covering table-driven test patterns, t.Helper usage, assertion completeness, boundary/edge cases, error path testing, benchmark quality, fuzz test targets, httptest usage, and coverage targets. Use when Go code changes include test.go files, test helpers, testdata directories, testing.B…

johnqtcg/awesome-skills · 89 tokens

go-concurrency-reviewer

Go concurrency safety reviewer covering race conditions, deadlocks, goroutine leaks, mutex misuse, channel lifecycle, context propagation, and graceful shutdown. Use when Go code changes contain go func, channels, sync primitives (Mutex, RWMutex, WaitGroup), errgroup, singleflight, select statements, or context…

johnqtcg/awesome-skills · 85 tokens

go-quality-reviewer

Go code quality and style reviewer covering function length, nesting depth, naming conventions, mutable globals, interface design, receiver consistency, modern Go idioms (slog, generics, typed atomics), and golangci-lint integration. Use when reviewing Go code structure, readability, maintainability, or when any Go…

johnqtcg/awesome-skills · 85 tokens