takes-cleaner

takes-cleaner is a command for Claude Code from an8079/take-skills. It costs 49 tokens per session (1,323 once invoked), scanned A, original, MIT.

A command that removes unnecessary complexity from AI-generated code while preserving its existing behaviour.

In plain words
What is it for?
Use it to clean a specific file or current changes, remove dead and repeated code, simplify abstractions, fix boundary problems, and strengthen regression tests.
Why use it?
Generated code can contain duplicate logic, unused code, needless wrapper layers, unclear names, or weak tests. A focused cleanup process helps reduce those problems and checks that the code still works.

Command for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the claude-dev-assistant plugin — 21 skills, 39 commands shipped together

Good fit Use it to clean a specific file or current changes, remove dead and repeated code, simplify abstractions, fix boundary problems, and strengthen regression tests.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/an8079/take-skills/takes-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/an8079/take-skills

Made for: Claude Code.

Or install claude-dev-assistant, the plugin that ships this one along with the rest of its 21 skills, 39 commands.

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

README.md
[![agentmods](https://agentmods.dev/badge/commands/an8079/take-skills/takes-cleaner/github.svg)](https://agentmods.dev/commands/an8079/take-skills/takes-cleaner)
Your own site
<a href="https://agentmods.dev/commands/an8079/take-skills/takes-cleaner"><img src="https://agentmods.dev/badge/commands/an8079/take-skills/takes-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 takes-cleaner

Your own site · 80×15
<a href="https://agentmods.dev/commands/an8079/take-skills/takes-cleaner"><img src="https://agentmods.dev/badge/commands/an8079/take-skills/takes-cleaner.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 49 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,323 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.00049 $0.01323
Opus 5 $0.00024 $0.00661
Sonnet 5 $0.00010 $0.00265
Haiku 4.5 $0.00005 $0.00132

Measured 10d ago against content hash fbf54a88004c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

takes-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 10d 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/takes-cleaner.md · 162 lines

How it starts

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

🧹 /takes-cleaner — AI 垃圾代码清理

清理 AI 生成的臃肿代码,删除重复、死代码、无用抽象,保留原有行为。

何时使用

场景 示例
代码感觉臃肿 太多包装层、重复辅助函数
重复逻辑 复制粘贴的分支、冗余代码
过度抽象 投机性间接层、单用辅助层
死代码 未使用的导出、调试残留、无reachable 分支
边界违规 隐藏耦合、职责错位、跨层导入

何时不用

场景 原因
主要任务是新功能构建 应该用 /code
想要 broad redesign 范围太大
通用重构 没有 anti-slop 意图

清理规则

优先级(从高到低)

  1. 死代码删除 — 最安全,先删
  2. 重复代码移除 — 提取公共逻辑
  3. 命名和错误处理清理 — 提高可读性
  4. 测试加固 — 补充缺失的测试

分类处理

类型 特征 处理方式
Duplication 重复逻辑、复制粘贴分支 提取公共函数
Dead code 未使用代码、不可达分支 直接删除
Needless abstraction 包装层、单用辅助层 展开内联
Boundary violations 隐藏耦合、跨层导入 重构职责
Missing tests 行为未锁定、回归覆盖弱 补充测试

工作流程

Step 1: 保护现有行为
   - 识别必须保持不变的部分
   - 添加或运行最窄的回归测试
   - 如无法先测试,记录验证计划

Step 2: 制定清理计划
   - 绑定到目标文件或功能区
   - 列出具体的代码味道
   - 从最安全删除到风险更高的合并

Step 3: 逐个味道清理
   - Pass 1: 死代码删除
   - Pass 2: 重复移除
   - Pass 3: 命名和错误处理
   - Pass 4: 测试加固
   - 每次后运行验证

Step 4: 质量门禁
   - 回归测试保持绿色
   - 运行 lint、typecheck
   - 失败则回退或修复

Step 5: 输出报告
   - 变更文件列表
   - 简化内容
   - 行为锁定/验证结果
   - 剩余风险

触发方式

/takes-cleaner                    # 清理当前改动
/takes-cleaner <文件>             # 清理指定文件
/takes-cleaner src/auth           # 清理指定目录
/takes-cleaner --review           # 仅审查模式(不修改)

示例

Good 用法

/takes-cleaner src/auth
→ 删除 auth 模块中的死代码、重复逻辑

/takes-cleaner src/utils.ts src/api.ts
→ 清理指定文件的包装层

/takes-cleaner --review
→ 仅审查模式,输出清理计划但不修改

Bad 用法

/takes-cleaner 重构 auth 支持 SSO
→ 范围过大,是新功能不是清理

/takes-cleaner 清理格式
→ 应该用 lint/format 工具

审查模式 (--review)

审查模式不修改文件,只输出清理计划:

  1. 不从编辑文件开始
  2. 审查清理计划、变更文件、回归覆盖
  3. 检查:
    • 死代码或未使用导出残留
    • 应被整合的重复逻辑
    • 仍模糊边界的无用包装层
    • 保留行为缺失测试或回归覆盖弱
    • 看起来改变了行为但没有意图的清理
  4. 输出审查意见和需要的跟进
  5. 将需要的更改交给单独的 writer pass

报告模板

# 🧹 清理报告 — [文件/模块]

## 变更文件
| 文件 | 变更类型 | 说明 |
|------|----------|------|
| src/auth.ts | 删除 | 移除未使用的 validateToken 函数 |

## 简化内容
- 删除 3 个死函数
- 合并 2 个重复辅助函数
- 展开 1 个无用包装层

## 行为锁定
- ✅ 单元测试通过: 42 passed
- ✅ 集成测试通过: 12 passed
- ✅ ESLint: 0 errors
- ✅ TypeScript: 0 errors

## 剩余风险
- [ ] 建议补充 token 刷新的集成测试

## 验证
运行 `npm test` 全部通过 ✅

Read the full file on GitHub · 162 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. 10d ago First seen · 162 lines · 49 tokens per session scan A fbf54a88004c

Subscribe to this mod's changes

takes-cleaner is a command published in the GitHub repository an8079/take-skills (4 stars, last pushed 5mo ago), licensed MIT. It adds 49 tokens to every session and 1,323 once invoked, about $0.0002 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.