trash-truck

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

trash-truck

trash-truck

Finds and removes code slop without changing behavior. Opens small, reviewable PRs. Inspired by the real cost of AI-generated entropy: teams that skip cleanup spend 20% of their week on slop.
可在不改变代码行为的前提下查找并移除冗余代码。会创建小型、便于评审的PR。灵感来源于AI生成代码带来的冗余成本:跳过代码清理的团队每周会有20%的时间耗费在冗余代码上。

Invocation

调用方式

/trash-truck [org/repo]
/trash-truck [org/repo] focus:dead-code
/trash-truck [org/repo] focus:duplicates
/trash-truck [org/repo] focus:drift
/trash-truck [org/repo] focus:misplaced
/trash-truck [org/repo] focus:committed-by-error
/trash-truck [org/repo] focus:unused-functions
/trash-truck [org/repo]
/trash-truck [org/repo] focus:dead-code
/trash-truck [org/repo] focus:duplicates
/trash-truck [org/repo] focus:drift
/trash-truck [org/repo] focus:misplaced
/trash-truck [org/repo] focus:committed-by-error
/trash-truck [org/repo] focus:unused-functions

Targets

检查目标

CategoryWhat to look for
dead-codeUnused exports, orphaned imports, debug
console.log
/
print
, commented-out code blocks
duplicatesSame concept implemented multiple ways across the codebase
inconsistentSame operation done differently in different modules (error handling, fetch patterns, config access)
driftDeviations from golden principles documented in
CLAUDE.md
,
docs/
, or established skill files
misplacedFiles in wrong directories — test files outside test dirs, configs buried in source trees
committed-by-errorFiles that shouldn't be in version control —
.env
,
.DS_Store
, swap files, compiled bytecode, IDE configs, database files
unused-functionsFunctions/methods defined but never called or referenced anywhere in the codebase (Python via
ast
, JS/TS via export/import analysis)
类别检查内容
dead-code未使用的导出、孤立的导入、调试用的
console.log
/
print
、被注释掉的代码块
duplicates代码库中同一功能被多次实现
inconsistent不同模块中同一操作的实现方式不一致(错误处理、请求模式、配置访问)
drift偏离
CLAUDE.md
docs/
或已确立的skill文件中记录的规范准则
misplaced文件存放目录错误——测试文件不在测试目录中、配置文件被埋在源码目录里
committed-by-error不应纳入版本控制的文件——
.env
.DS_Store
、交换文件、编译后的字节码、IDE配置文件、数据库文件
unused-functions已定义但在代码库中从未被调用或引用的函数/方法(Python通过
ast
检测,JS/TS通过导出/导入分析检测)

How It Works

工作原理

  1. Clone or enter the target repo
  2. Run pre-scan for cheap static analysis before spending tokens on LLM review
  3. Review pre-scan results — filter false positives, group into cleanup units
  4. Open each PR with a focused, reviewable diff
  1. 克隆或进入目标代码库
  2. 运行预扫描:在使用LLM评审消耗token之前,先进行低成本的静态分析
  3. 评审预扫描结果——过滤误报,将结果分组为清理单元
  4. 为每个清理单元创建一个聚焦、便于评审的PR

Pre-scan (Step 2)

预扫描(步骤2)

Run the pre-scan yourself, in the foreground. Invoke
pre-scan.sh
directly with the Bash tool and wait for its JSON output inline. Do not dispatch a worker, background the scan (
&
/
nohup
), or hand it off and "wait for a notification" — it is a fast, bounded local scan (seconds). In a headless/operator runner there is no background-completion wake-up, so backgrounding deadlocks the session and the mission fails with no outcome marker. This is hands-on work: do it yourself, do not delegate it.
The
pre-scan.sh
script in this skill's directory uses
rg
+ Python
ast
to find candidates cheaply before Claude reviews them. This cuts token cost by 5-10x compared to having Claude grep the entire codebase.
bash
undefined
请在前台自行运行预扫描。 使用Bash工具直接调用
pre-scan.sh
,等待其输出JSON结果。不要分配工作线程、后台运行扫描(
&
/
nohup
)或转交任务后“等待通知”——这是一个快速、有限的本地扫描(仅需数秒)。在无头/操作员运行环境中,没有后台完成唤醒机制,后台运行会导致会话死锁,任务将无结果失败。这是需要手动操作的工作:请自行完成,不要委托他人。
本skill目录中的
pre-scan.sh
脚本使用
rg
+ Python
ast
在Claude评审前低成本查找候选冗余代码。与让Claude搜索整个代码库相比,这可将token成本降低5-10倍。
bash
undefined

Run from the repo root — outputs structured JSON

从代码库根目录运行——输出结构化JSON

SKILL_DIR="$(dirname "$(readlink -f "$0")")" # or wherever the skill was synced bash "$SKILL_DIR/pre-scan.sh" [focus] [repo-root]
SKILL_DIR="$(dirname "$(readlink -f "$0")")" # 或skill同步到的其他位置 bash "$SKILL_DIR/pre-scan.sh" [focus] [repo-root]

Examples:

示例:

bash pre-scan.sh all /path/to/repo # everything except unused-functions bash pre-scan.sh dead-code /path/to/repo # just debug stmts + commented code bash pre-scan.sh unused-functions /path/to/repo # deeper analysis, slower

The script outputs JSON with findings grouped by category. Each finding has `file`, `kind`, and usually `line` and `detail`. Use this output to guide which files to read and what to clean up — don't re-scan what the script already found.

**What pre-scan does NOT do:** It finds candidates, not confirmed slop. Claude still needs to verify each finding (is the "unused" function actually called via reflection? is the "debug" print actually a user-facing log?). The script is intentionally aggressive — false positives are filtered by Claude, not suppressed at scan time.
bash pre-scan.sh all /path/to/repo # 扫描除未使用函数外的所有内容 bash pre-scan.sh dead-code /path/to/repo # 仅扫描调试语句和注释代码 bash pre-scan.sh unused-functions /path/to/repo # 深度分析,速度较慢

该脚本输出按类别分组的JSON格式结果。每个结果包含`file`、`kind`,通常还包含`line`和`detail`。请使用此输出指导要读取的文件和清理内容——不要重新扫描脚本已发现的内容。

**预扫描不做什么:** 它仅查找候选冗余代码,而非确认的冗余代码。Claude仍需验证每个发现(例如“未使用”的函数是否通过反射被调用?“调试”打印是否实际是面向用户的日志?)。脚本的检测逻辑故意设置得较为严格——误报由Claude过滤,而非在扫描阶段抑制。

PR Rules

PR规则

  • One PR per logical cleanup — keep diffs small and reviewable
  • Title format:
    chore: [what was cleaned] in [file/module]
  • No behavior changes — if a change could alter runtime behavior, skip it and open an issue instead
  • CTO reviews process (was the right pattern followed?), not the code itself
  • 每个逻辑清理单元对应一个PR——保持差异内容小且便于评审
  • 标题格式:
    chore: [清理内容] in [文件/模块]
  • 不改变代码行为——如果修改可能改变运行时行为,请跳过并创建issue
  • CTO评审流程(是否遵循了正确的模式),而非代码本身

What NOT to Do

禁止操作

  • Do not refactor logic — only remove or consolidate dead/duplicate patterns
  • Do not open a single giant PR — small diffs or nothing
  • Do not touch tests unless the test itself is dead or duplicated
  • 不要重构逻辑——仅移除或合并死代码/重复代码模式
  • 不要创建单个大型PR——要么创建小型差异PR,要么不做
  • 不要修改测试,除非测试本身是死代码或重复代码