ai-slop-cleaner
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese<Purpose>
Use this skill to systematically clean AI-generated code slop without changing intended behavior. It focuses on simplifying existing code by deleting dead code, collapsing duplicates, removing needless abstractions, tightening boundaries, and reinforcing tests before and after cleanup.
</Purpose>
<Use_When>
- The user explicitly says "deslop", "anti-slop", or "AI slop"
- The request is to clean up or refactor code that feels bloated, repetitive, or overly abstract
- The user wants a reviewer-only anti-slop pass via after cleanup work is drafted
--review - The user calls out duplicate code, dead code, wrapper layers, boundary violations, or weak regression coverage
- The goal is simplification, deletion, and cleanup rather than adding new features </Use_When>
<Do_Not_Use_When>
- The task is primarily a new feature build -- use or direct implementation instead
autopilot - The user wants a broad architecture redesign rather than an incremental cleanup pass
- The request is a generic refactor with no cleanup/simplification intent
- Behavior is unclear and there are no tests or concrete anchors -- clarify scope first </Do_Not_Use_When>
<Why_This_Exists>
AI-generated code often works while still adding avoidable complexity: duplicate helpers, dead branches, wrapper layers, inconsistent naming, boundary leaks, and missing tests. This skill enforces a disciplined cleanup workflow so simplification happens deliberately instead of as vague "refactoring" that might expand scope.
</Why_This_Exists>
<Review_Mode>
<Purpose>
使用本技能可以在不改变预期行为的前提下,系统性清理AI生成的劣质冗余代码。它专注于简化现有代码,具体方式包括删除死代码、合并重复内容、移除不必要的抽象、收紧边界,以及在清理前后加固测试。
</Purpose>
<Use_When>
- 用户明确提到「deslop」、「anti-slop」或「AI slop」
- 需求是清理或重构看起来臃肿、重复或者过度抽象的代码
- 用户希望在清理工作草稿完成后,通过参数运行仅评审的去冗余检查
--review - 用户指出存在重复代码、死代码、包装层、边界违规或者薄弱的回归测试覆盖
- 目标是简化、删除和清理,而非添加新功能 </Use_When>
<Do_Not_Use_When>
- 任务核心是新功能开发——请使用或直接实现功能
autopilot - 用户想要进行大范围的架构重新设计,而非增量式的清理
- 需求是通用重构,没有清理/简化的明确意图
- 代码行为不明确,且没有测试或者具体的锚点可参考——请先明确范围 </Do_Not_Use_When>
<Why_This_Exists>
AI生成的代码通常可以正常运行,但往往会引入可避免的复杂度:重复的辅助函数、死分支、包装层、命名不一致、边界泄漏、测试缺失。本技能提供了一套规范的清理工作流,让简化工作可以有序开展,而非变成可能扩大范围的模糊「重构」。
</Why_This_Exists>
<Review_Mode>
Review Mode (--review
)
--review评审模式 (--review
)
--review--review- Writer pass: make the cleanup changes with behavior locked by tests.
- Reviewer pass (): inspect the result for duplication, dead code, boundary violations, missing tests, and unnecessary abstractions.
--review - The same pass must not both write and self-approve without a separate review step.
In review mode:
- Do not make edits first.
- Inspect the cleanup plan, changed files, and regression coverage.
- Check specifically for:
- leftover dead code or unused exports
- duplicate logic that was not consolidated
- needless wrappers or abstractions that still blur boundaries
- missing tests or weak verification for preserved behavior
- risky cleanup that changed behavior without explicit intent
- Produce a reviewer verdict with required follow-ups.
- If changes are needed, hand them back to a separate writer/executor pass instead of fixing and approving in one pass.
This mode exists to preserve writer/reviewer separation: the authoring pass changes code, the reviewer pass evaluates whether the cleanup actually reduced slop safely.
</Review_Mode>
<Execution_Policy>
- Preserve behavior unless the user explicitly asks for behavior changes
- Lock behavior with regression tests first whenever practical
- Write a cleanup plan before editing code
- Prefer deletion over addition
- Reuse existing utilities and patterns before introducing anything new
- Avoid new dependencies unless the user explicitly requests them
- Keep diffs small, reversible, and smell-focused
- Keep writer/reviewer separation: author in one pass, review in another
- Verify with lint/typecheck/tests/static analysis relevant to the touched area </Execution_Policy>
-
Create a cleanup plan
- Do not start coding immediately
- List the targeted smells and the files likely involved
- Sequence cleanup passes from lowest-risk deletion to higher-risk consolidation
-
Categorize the slop
- Duplicate code
- Dead or unused code
- Needless abstraction / wrapper layers
- Boundary violations / misplaced responsibilities
- Missing or weak tests
-
Execute one smell-focused pass at a time
- Pass 1: Dead code deletion -- remove unused branches, helpers, exports, and stale comments
- Pass 2: Duplicate removal -- consolidate repeated logic into existing patterns where possible
- Pass 3: Naming and error-handling cleanup -- tighten naming, trim noisy plumbing, normalize obvious inconsistencies
- Pass 4: Test reinforcement -- fill any regression gaps revealed by the cleanup
-
Run quality gates
- Run the relevant lint, typecheck, unit/integration tests, and any static or security checks already present for the touched area
- If a gate fails, fix the underlying issue or revert the risky cleanup instead of forcing it through
-
Optionalpass
--review- Run a distinct reviewer pass that checks duplication, dead code, boundary violations, test coverage, and needless abstractions
- If the reviewer finds issues, address them in a follow-up cleanup pass before closing the task
-
Report outcome
- Changed files
- Simplifications made
- Behavior locked by tests
- Remaining risks or slop intentionally left for a later pass </Steps>
<Final_Report>
Always end with:
- Changed files
- Simplifications
- Verification run
- Remaining risks </Final_Report>
--review- 编写阶段:在测试锁定代码行为的前提下进行清理改动
- 评审阶段 ():检查结果是否存在重复、死代码、边界违规、测试缺失以及不必要的抽象
--review - 不得在同一个环节中同时完成代码编写和自我审批,必须有独立的评审步骤
在评审模式下:
- 不要一开始就编辑代码
- 检查清理计划、改动的文件以及回归测试覆盖情况
- 重点检查以下内容:
- 残留的死代码或者未使用的导出内容
- 没有被合并的重复逻辑
- 仍然会模糊边界的不必要包装或抽象
- 针对保留行为的测试缺失或者验证不足
- 没有明确意图就改动行为的高风险清理操作
- 给出评审结论以及要求的后续处理项
- 如果需要改动,将其交回独立的编写/执行环节处理,不要在同一个环节中同时修复和审批
该模式的存在是为了保持编写者/评审者的职责分离:编写环节改动代码,评审环节评估清理工作是否真正安全地减少了冗余代码。
</Review_Mode>
<Execution_Policy>
- 除非用户明确要求改动行为,否则始终保留原有行为
- 只要可行,优先通过回归测试锁定代码行为
- 编辑代码前先编写清理计划
- 优先选择删除而非新增内容
- 引入新内容前优先复用现有工具和模式
- 避免引入新依赖,除非用户明确要求
- 保持diff小巧、可回滚,且聚焦于代码异味处理
- 保持编写者/评审者分离:一个环节负责编写,另一个环节负责评审
- 针对改动的区域,运行相关的lint、类型检查、测试、静态分析工具进行验证 </Execution_Policy>
-
创建清理计划
- 不要立刻开始编写代码
- 列出目标代码异味以及可能涉及的文件
- 按风险从低到高排序清理环节:先做删除操作,再做风险更高的合并操作
-
冗余代码分类
- 重复代码
- 死代码或未使用代码
- 不必要的抽象/包装层
- 边界违规/职责错位
- 测试缺失或薄弱
-
每次执行一个聚焦于特定代码异味的清理环节
- 环节1:死代码删除——移除未使用的分支、辅助函数、导出内容以及过时注释
- 环节2:重复代码移除——尽可能将重复逻辑合并到现有模式中
- 环节3:命名和错误处理清理——规范命名、删减冗余的管道代码、统一明显的不一致问题
- 环节4:测试加固——补充清理过程中发现的回归测试缺口
-
运行质量门禁检查
- 针对改动区域,运行已有的相关lint、类型检查、单元/集成测试,以及任何静态或安全检查
- 如果门禁检查不通过,修复底层问题或者回滚高风险的清理操作,不要强行通过
-
可选的评审环节
--review- 运行独立的评审环节,检查重复代码、死代码、边界违规、测试覆盖以及不必要的抽象
- 如果评审发现问题,在关闭任务前通过后续清理环节解决这些问题
-
上报结果
- 改动的文件
- 完成的简化操作
- 通过测试锁定的代码行为
- 剩余风险或者有意留到后续环节处理的冗余代码 </Steps>
<Final_Report>
始终在末尾附上以下内容:
- 改动的文件
- 简化操作
- 运行的验证检查
- 剩余风险 </Final_Report>