cleanup

cleanup is a command for coding agents from xiaobei930/cc-best. It costs 7 tokens per session (1,954 once invoked), scanned A, original, MIT.

A cleanup command that finds code, files, and dependencies that appear to be unused, then removes only items confirmed to be unnecessary.

In plain words
What is it for?
Use it to inspect unused exports, files, dependencies, commented-out code, and duplicate utilities. It can classify deletion risk, verify references, record removals, and check the build and tests afterward.
Why use it?
It helps reduce clutter and maintenance work while accounting for risks such as dynamic imports, public interfaces, configuration references, and test-only code.

Command

Part of the cc-best plugin — 3 skills, 44 commands, 8 agents, 20 hooks 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 commands/xiaobei930/cc-best/cleanup
Clone the repo
git clone --depth 1 https://github.com/xiaobei930/cc-best

Or install cc-best, the plugin that ships this one along with the rest of its 3 skills, 44 commands, 8 agents, 20 hooks.

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 cleanup

README.md
[![agentmods](https://agentmods.dev/badge/commands/xiaobei930/cc-best/cleanup.svg)](https://agentmods.dev/commands/xiaobei930/cc-best/cleanup)
Your own site
<a href="https://agentmods.dev/commands/xiaobei930/cc-best/cleanup"><img src="https://agentmods.dev/badge/commands/xiaobei930/cc-best/cleanup.svg" alt="Measured on agentmods" height="20"></a>
Per session 7 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,954 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.00007 $0.01954
Opus 5 $0.00003 $0.00977
Sonnet 5 $0.00001 $0.00391
Haiku 4.5 $0.00001 $0.00195

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

Security

Grade A, and why

cleanup 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.

commands/cleanup.md · 280 lines

How it starts

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

/cleanup - 死代码清理

专注于识别和安全删除未使用的代码、依赖和文件。核心原则:安全删除,完整记录。

角色定位

  • 身份: 代码清理专家
  • 目标: 保持代码库精简,移除技术债务
  • 原则: 安全第一,充分验证,完整记录

核心理念

只删除确认无用的代码,不删任何存疑的内容

安全删除

✅ 工具确认未使用的导出 ✅ 无引用的文件 ✅ 未使用的依赖包 ✅ 注释掉的代码块 ✅ 重复的工具函数

保持警惕

⚠️ 动态导入的模块 ⚠️ 公共 API 的导出 ⚠️ 配置文件引用的代码 ⚠️ 测试专用的代码

工作流程

1. 分析阶段
   ├─ 运行 knip(未使用导出/文件/依赖)
   ├─ 运行 depcheck(未使用 npm 依赖)
   ├─ 手动搜索确认(grep 验证)
   └─ 收集所有待清理项

2. 风险评估
   ├─ 分类:SAFE / CAREFUL / RISKY
   ├─ 检查动态导入
   ├─ 检查公共 API
   └─ 确定删除顺序

3. 安全删除
   ├─ 从 SAFE 项开始
   ├─ 每批删除后验证构建
   ├─ 记录到 DELETION_LOG.md
   └─ 提交 git commit

4. 验证阶段
   ├─ 构建通过
   ├─ 测试通过
   └─ 无运行时错误

检测工具

knip - 全面检测

# 安装
npm install -D knip

# 运行(检测未使用的导出、文件、依赖)
npx knip

# 输出示例
# Unused files: src/old-util.ts
# Unused exports: src/utils.ts → unusedFunction
# Unused dependencies: lodash

depcheck - 依赖检测

# 安装
npm install -g depcheck

# 运行
depcheck

# 输出示例
# Unused dependencies:
# * lodash
# * moment

手动搜索验证

# 搜索函数引用
grep -r "functionName" src/

# 搜索文件引用
grep -r "fileName" src/

# 搜索包引用
grep -r "from 'package'" src/
grep -r "require('package')" src/

风险分类

SAFE(安全删除)

类型 特征 示例
未使用导出 knip 报告,grep 无引用 export function unused()
未使用依赖 depcheck 报告,代码中无引用 lodash 在 package.json 但从未 import
孤立文件 无任何 import/require src/old-feature.ts
注释代码 大段注释的代码块 // function oldCode() {...}

CAREFUL(谨慎处理)

类型 风险 检查方式
动态导入 import() 字符串拼接 搜索 import(require(
配置引用 配置文件中使用 检查 webpack/vite/next 配置
条件导出 环境变量控制 检查 process.env 条件

RISKY(高风险)

类型 风险 建议
公共 API 外部使用者依赖 不删除,或先废弃再删
共享组件 可能跨项目使用 确认所有使用方
第三方集成 Webhook、回调等 检查外部系统

Read the full file on GitHub · 280 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 · 280 lines · 7 tokens per session scan A 7a82484bece5

Subscribe to this mod's changes

cleanup is a command published in the GitHub repository xiaobei930/cc-best (50 stars, last pushed 2mo ago), licensed MIT. It adds 7 tokens to every session and 1,954 once invoked, about $0.0000 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.