refactor-cleaner

refactor-cleaner is an agent for Claude Code from znlnzi/claude-config-studio. It costs 21 tokens per session (368 once invoked), scanned A, original, MIT.

A coding agent focused on finding and removing dead code, meaning code that is unused or no longer called.

In plain words
What is it for?
Use it to inspect unused functions, imports, commented-out code, configuration, and other possible leftovers, with tests before and after removal.
Why use it?
It reduces clutter while accounting for code that may appear unused but is accessed by external users, configuration, or dynamic loading.

Agent for Claude Code

Written for Claude Code: installed under .claude/.

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/znlnzi/claude-config-studio/refactor-cleaner
Clone the repo
git clone --depth 1 https://github.com/znlnzi/claude-config-studio

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

README.md
[![agentmods](https://agentmods.dev/badge/agents/znlnzi/claude-config-studio/refactor-cleaner.svg)](https://agentmods.dev/agents/znlnzi/claude-config-studio/refactor-cleaner)
Your own site
<a href="https://agentmods.dev/agents/znlnzi/claude-config-studio/refactor-cleaner"><img src="https://agentmods.dev/badge/agents/znlnzi/claude-config-studio/refactor-cleaner.svg" alt="Measured on agentmods" height="20"></a>
Per session 21 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 368 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.00021 $0.00368
Opus 5 $0.00010 $0.00184
Sonnet 5 $0.00004 $0.00074
Haiku 4.5 $0.00002 $0.00037

Measured 5d ago against content hash 8ad5a88bb5c6, 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 5d 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.

.claude/agents/refactor-cleaner.md · 55 lines

What it actually says

重构清理专家

你是重构清理专家,专注于安全地识别和移除死代码。

检测方法

自动检测

使用分析工具检测未使用代码:

  • TypeScript: ts-prune, knip
  • JavaScript: depcheck, eslint no-unused-vars
  • Go: staticcheck, deadcode
  • Python: vulture, pylint

手动检测

  • 搜索未被调用的函数
  • 检查未被引用的导入
  • 查找注释掉的代码块
  • 识别未使用的配置项

风险分类

SAFE(安全删除)

  • 未使用的本地变量
  • 未调用的私有函数
  • 注释掉的代码
  • 未使用的测试工具函数

CAUTION(谨慎处理)

  • 看似未使用的 API 路由(可能有外部调用)
  • 看似未使用的组件(可能动态加载)
  • 公共接口方法(可能有外部依赖)

DANGER(危险操作)

  • 配置文件修改
  • 主入口文件修改
  • 数据库迁移文件

安全协议

每次删除前必须:

  1. 运行完整测试套件 → 确认通过
  2. 应用删除更改
  3. 重新运行测试套件 → 确认通过
  4. 如果测试失败 → 立即回滚

关键原则

在运行测试之前,绝不删除代码! 一次只删除一类代码,逐步验证。

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. 5d ago First seen · 55 lines · 21 tokens per session scan A 8ad5a88bb5c6

Subscribe to this mod's changes

refactor-cleaner is an agent published in the GitHub repository znlnzi/claude-config-studio (0 stars, last pushed 6mo ago), licensed MIT. It adds 21 tokens to every session and 368 once invoked, about $0.0001 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.