deslop
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRemove AI Slop & Simplify
移除AI冗余代码(AI Slop)并简化代码
Slop is code heavier than it needs to be: comments stating the obvious,
defensive checks the codebase does not use, single-use abstractions, type escape
hatches, ceremony, cleverness that obscures intent. This skill finds every
instance in a diff and removes it without changing behavior.
AI Slop指的是冗余臃肿的代码:包括赘述的注释、代码库中从未用到的防御性检查、仅使用一次的抽象、类型逃逸漏洞、繁琐的仪式化代码、以及掩盖代码意图的炫技式写法。本技能会在代码差异中找出所有此类问题,并在不改变代码功能的前提下将其移除。
Flags
参数说明
| Flag | Effect |
|---|---|
| Diff staged changes ( |
| Diff unstaged changes ( |
| Diff since merge base: |
Mutually exclusive; use the first detected. needs a branch name. If
missing, stop: .
--base--base requires a branch name (e.g., --base main)| 参数 | 作用 |
|---|---|
| 对比已暂存的变更( |
| 对比未暂存的变更( |
| 对比与指定分支合并基准后的变更: |
以上参数互斥,将优先使用第一个检测到的参数。需要指定分支名称,若未提供则会终止操作,并提示:。
--base--base requires a branch name (e.g., --base main)Step 1: Diff the changes
步骤1:生成代码差异
- or default:
--stagedgit diff --cached | cat - :
--unstagedgit diff | cat - :
--base <branch>git diff <branch>...HEAD | cat
If empty, stop: "No changes found to deslop."
- 使用或默认选项:
--stagedgit diff --cached | cat - 使用:
--unstagedgit diff | cat - 使用:
--base <branch>git diff <branch>...HEAD | cat
若差异为空,则终止操作:"未找到可进行Deslop处理的变更。"
Step 2: Read the files
步骤2:读取文件内容
Read the full content of every file in the diff, plus adjacent files that reveal
existing patterns: comment style, error-handling philosophy, type-safety level,
abstraction level, validation/defensiveness, and project-standard imports,
naming, and formatting. Slop is defined relative to these local norms.
读取差异中所有文件的完整内容,以及能体现项目现有规范的相邻文件:包括注释风格、错误处理理念、类型安全级别、抽象程度、验证/防御性代码,以及项目标准的导入方式、命名规则和格式规范。AI冗余代码的判定是基于这些本地规范的。
Step 3: Classify every change against all 8 slop categories
步骤3:对照8大类冗余代码对所有变更进行分类
Check every changed line in every file against the 8 categories in
. Do not stop at the first hit. The step is done only when every
file in the diff has been checked against every category.
./REFERENCE.md对照中的8大类冗余代码,检查每个文件中的每一行变更。不要在发现第一个问题后就停止,只有当差异中的所有文件都完成所有类别的检查后,本步骤才算完成。
./REFERENCE.mdStep 4: Compile the instance list
步骤4:整理问题清单
Record each instance: file path, line number(s), category (1-8), the issue, and
why it violates local norms. If none found, stop: "No AI slop or simplification
opportunities detected. The changes look clean."
记录每个问题实例:文件路径、行号、所属类别(1-8)、具体问题,以及为何违反本地规范。若未发现任何问题,则终止操作:"未检测到AI冗余代码或可简化的空间,当前变更看起来很简洁。"
Step 5: Filter against the guardrails
步骤5:对照防护规则筛选问题
Drop any instance whose removal would violate the maintainability guardrails in
. Keep only clear wins.
./REFERENCE.md移除任何移除后会违反中可维护性防护规则的问题实例,仅保留明确可优化的内容。
./REFERENCE.mdStep 6: Remove the slop
步骤6:移除冗余代码
Edit the source files to strip every kept instance. Make the smallest change
that preserves exact functionality, logic, timing, side effects, and public
APIs unchanged. Introduce no new complexity while removing.
编辑源文件,移除所有保留的问题实例。确保修改后的代码在功能、逻辑、执行时机、副作用和公开API上与原代码完全一致。移除冗余的过程中不得引入新的复杂度。
Step 7: Re-stage
步骤7:重新暂存变更
bash
git add <modified-files>bash
git add <modified-files>Step 8: Report
步骤8:生成报告
In 2-4 sentences: which categories were addressed, how many files changed, why
the code is cleaner, and any trade-off considered.
用2-4句话说明:处理了哪些类别的问题、修改了多少个文件、代码变得更简洁的原因,以及考虑过的任何取舍。