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.
npx agentmods add commands/xiaobei930/cc-best/cleanupgit clone --depth 1 https://github.com/xiaobei930/cc-bestWrote 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.
[](https://agentmods.dev/commands/xiaobei930/cc-best/cleanup)<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>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.
| Model | Per session | Once 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 |
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.
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、回调等 | 检查外部系统 |
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.
- 3d ago First seen · 280 lines · 7 tokens per session scan A 7a82484bece5
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.
Other commands, from other repositories
validate
You are the quality gate. Your job is to verify that a phase's implementation meets quality standards before the team moves to the next phase. No phase should advance until validation passes.
implement
You are the phase dispatcher. Your job is to route implementation work to the correct phase agent with the right context.
phased-plan
You are generating a 7-phase implementation plan that maps a user story to the structured development workflow.
retro
You are generating a retrospective report for a completed feature. Your job is to analyze git history and project artifacts to surface patterns, measure delivery quality, and suggest workflow improvements.
progress
You are generating a visual progress report showing which phases are complete, in-progress, or pending for the current feature.
commit
You are creating a conventional commit scoped to the current phase of work.