AI Slop Cleaner Skill
Reduce AI-generated slop with a regression-tests-first, smell-by-smell cleanup workflow that preserves behavior and raises signal quality.
When to Use
Use this skill when:
- A code path works but feels bloated, noisy, repetitive, or over-abstracted
- A user asks to “cleanup”, “refactor”, or “deslop” AI-generated output
- Follow-up implementation left duplicate code, dead code, weak boundaries, missing tests, or unnecessary wrapper layers
- You need a disciplined cleanup workflow without broad rewrites
GPT-5.4 Guidance Alignment
- Keep outputs concise and evidence-dense unless risk or the user requests more detail.
- Treat newer user instructions as local workflow updates without discarding earlier non-conflicting constraints.
- Keep using inspection, tests, diagnostics, and verification until the cleanup is grounded.
- Proceed automatically through clear, reversible cleanup steps; ask only when a choice materially changes scope or behavior.
Scoped File Lists and Ralph Workflow
- This skill can accept a file list scope instead of a whole feature area.
- When the caller provides a changed-files list (for example, Ralph session-owned edits), keep the cleanup strictly bounded to those files.
- In the Ralph workflow, the mandatory deslop pass should run this skill on Ralph's changed files only, in standard mode unless the caller explicitly requests otherwise.
与 ddev-gate 的关系
ddev-clean 不再是 ddev-gate 的独立流水线阶段;清理项识别已并入 gate 的代码评审 subagent(只出清单,只读)。
- 清理执行由主 agent 在收到代码评审结论后按需进行:加载本 skill 直接执行,或派发受限清理 subagent。范围是代码评审给定的 changed-files 或更窄的文件列表。
- 只有在完成编码规范 / 质量 / 注释审查结论之后才执行清理,避免边审边改。
- 目标是在不改变文档已批准的架构、detail、数据流、接口和行为的前提下,删除 slop 并提升可维护性。
- 如果为锁定行为必须补测试,只允许纳入锁定既有行为所必需的最小测试文件,不得借此扩大实现范围。
- 清理产生任何代码修改后,必须补充验证证据;主 agent 必须基于最终代码重新并行派发一致性审查与代码评审做只读复审。
- 如果维护性问题真正需要架构或流程变更才能解决,停止并上报,不要借 cleanup 做重构。
Procedure
Lock behavior with regression tests first
- Identify the behavior that must not change
- Add or run targeted regression tests before editing cleanup candidates
- If behavior is currently untested, create the narrowest test coverage needed first
Create a cleanup plan before code
- List the specific smells to remove
- Bound the pass to the requested files/scope
- If a file list scope is provided, keep the pass restricted to that changed-files list
- Order fixes from safest/highest-signal to riskiest
- Do not start coding until the cleanup plan is explicit
Categorize issues before editing
- Duplication — repeated logic, copy-paste branches, redundant helpers
- Dead code — unused code, unreachable branches, stale flags, debug leftovers
- Needless abstraction — pass-through wrappers, speculative indirection, single-use helper layers
- Boundary violations — hidden coupling, leaky responsibilities, wrong-layer imports or side effects
- Missing tests — behavior not locked, weak regression coverage, gaps around edge cases
Execute passes one smell at a time
- Pass 1: Dead code deletion
- Pass 2: Duplicate removal
- Pass 3: Naming/error handling cleanup
- Pass 4: Test reinforcement
- Re-run targeted verification after each pass
- Avoid bundling unrelated refactors into the same edit set
Run quality gates
- Regression tests stay green
- Lint passes
- Typecheck passes
- Relevant unit/integration tests pass
- Static/security scan passes when available
- Diff stays minimal and scoped
- No new abstractions or dependencies unless explicitly required
Finish with an evidence-dense report
- Changed files
- Simplifications made
- Tests/diagnostics/build checks run
- Remaining risks
- Residual follow-ups or consciously deferred cleanup
Output Format
AI SLOP CLEANUP REPORT
======================
Scope: [files or feature area]
Behavior Lock: [targeted regression tests added/run]
Cleanup Plan: [bounded smells and order]
Passes Completed:
1. Pass 1: Dead code deletion - [concise fix]
2. Pass 2: Duplicate removal - [concise fix]
3. Pass 3: Naming/error handling cleanup - [concise fix]
4. Pass 4: Test reinforcement - [concise fix]
Quality Gates:
- Regression tests: PASS/FAIL
- Lint: PASS/FAIL
- Typecheck: PASS/FAIL
- Tests: PASS/FAIL
- Static/security scan: PASS/FAIL or N/A
Changed Files:
- [path] - [simplification]
Remaining Risks:
- [none or short deferred item]
Scenario Examples
Good: The user says continue after tests already lock behavior and the next smell pass is clear. Continue with the next bounded cleanup pass.
Good: The user narrows the scope to a specific file after planning. Keep the regression-tests-first workflow, but apply the new scope locally.
Bad: Start rewriting architecture before protecting behavior with tests.
Bad: Collapse multiple smell categories into one large refactor with no intermediate verification.
Gate 审查模式
当本 skill 被 ddev-gate 流程在代码评审返回后加载时,必须使用 reviewer-prompt.md 作为任务模板执行受限清理。该模板定义了清理输入、scope 约束、regression-tests-first 规则和输出格式。清理完成后,主 agent 会基于最终代码重新并行派发一致性审查与代码评审做只读复审。
进度记录
当本 skill 被 ddev-exec 或 ddev-gate 工作流调用时,清理完成后须将 diff 摘要写入项目根目录的 progress.md:
- 记录清理前后的变更文件数和行数(新增/删除)
- 记录各 Pass 通过的 Quality Gates 结果(PASS/FAIL)
- 如有 defer 的风险项,一并记录
- 写到最后一次执行日志后,追加时间戳
1---2name: ddev-clean3description: Run an anti-slop cleanup/refactor/deslop workflow4---56# AI Slop Cleaner Skill78Reduce AI-generated slop with a regression-tests-first, smell-by-smell cleanup workflow that preserves behavior and raises signal quality.910## When to Use1112Use this skill when:13- A code path works but feels bloated, noisy, repetitive, or over-abstracted14- A user asks to “cleanup”, “refactor”, or “deslop” AI-generated output15- Follow-up implementation left duplicate code, dead code, weak boundaries, missing tests, or unnecessary wrapper layers16- You need a disciplined cleanup workflow without broad rewrites1718## GPT-5.4 Guidance Alignment1920- Keep outputs concise and evidence-dense unless risk or the user requests more detail.21- Treat newer user instructions as local workflow updates without discarding earlier non-conflicting constraints.22- Keep using inspection, tests, diagnostics, and verification until the cleanup is grounded.23- Proceed automatically through clear, reversible cleanup steps; ask only when a choice materially changes scope or behavior.2425## Scoped File Lists and Ralph Workflow2627- This skill can accept a **file list scope** instead of a whole feature area.28- When the caller provides a changed-files list (for example, Ralph session-owned edits), keep the cleanup strictly bounded to those files.29- In the **Ralph workflow**, the mandatory deslop pass should run this skill on Ralph's changed files only, in standard mode unless the caller explicitly requests otherwise.3031## 与 ddev-gate 的关系3233- `ddev-clean` 不再是 ddev-gate 的独立流水线阶段;**清理项识别**已并入 gate 的代码评审 subagent(只出清单,只读)。34- **清理执行**由主 agent 在收到代码评审结论后按需进行:加载本 skill 直接执行,或派发受限清理 subagent。范围是代码评审给定的 changed-files 或更窄的文件列表。35- 只有在完成编码规范 / 质量 / 注释审查结论之后才执行清理,避免边审边改。36- 目标是在**不改变**文档已批准的架构、detail、数据流、接口和行为的前提下,删除 slop 并提升可维护性。37- 如果为锁定行为必须补测试,只允许纳入锁定既有行为所必需的最小测试文件,不得借此扩大实现范围。38- 清理产生任何代码修改后,必须补充验证证据;主 agent 必须基于最终代码重新并行派发一致性审查与代码评审做只读复审。39- 如果维护性问题真正需要架构或流程变更才能解决,停止并上报,不要借 cleanup 做重构。4041## Procedure42431. **Lock behavior with regression tests first**44 - Identify the behavior that must not change45 - Add or run targeted regression tests before editing cleanup candidates46 - If behavior is currently untested, create the narrowest test coverage needed first47482. **Create a cleanup plan before code**49 - List the specific smells to remove50 - Bound the pass to the requested files/scope51 - If a file list scope is provided, keep the pass restricted to that changed-files list52 - Order fixes from safest/highest-signal to riskiest53 - Do not start coding until the cleanup plan is explicit54553. **Categorize issues before editing**56 - **Duplication** — repeated logic, copy-paste branches, redundant helpers57 - **Dead code** — unused code, unreachable branches, stale flags, debug leftovers58 - **Needless abstraction** — pass-through wrappers, speculative indirection, single-use helper layers59 - **Boundary violations** — hidden coupling, leaky responsibilities, wrong-layer imports or side effects60 - **Missing tests** — behavior not locked, weak regression coverage, gaps around edge cases61624. **Execute passes one smell at a time**63 - **Pass 1: Dead code deletion**64 - **Pass 2: Duplicate removal**65 - **Pass 3: Naming/error handling cleanup**66 - **Pass 4: Test reinforcement**67 - Re-run targeted verification after each pass68 - Avoid bundling unrelated refactors into the same edit set69705. **Run quality gates**71 - Regression tests stay green72 - Lint passes73 - Typecheck passes74 - Relevant unit/integration tests pass75 - Static/security scan passes when available76 - Diff stays minimal and scoped77 - No new abstractions or dependencies unless explicitly required78796. **Finish with an evidence-dense report**80 - Changed files81 - Simplifications made82 - Tests/diagnostics/build checks run83 - Remaining risks84 - Residual follow-ups or consciously deferred cleanup8586## Output Format8788```text89AI SLOP CLEANUP REPORT90======================9192Scope: [files or feature area]93Behavior Lock: [targeted regression tests added/run]94Cleanup Plan: [bounded smells and order]9596Passes Completed:971. Pass 1: Dead code deletion - [concise fix]982. Pass 2: Duplicate removal - [concise fix]993. Pass 3: Naming/error handling cleanup - [concise fix]1004. Pass 4: Test reinforcement - [concise fix]101102Quality Gates:103- Regression tests: PASS/FAIL104- Lint: PASS/FAIL105- Typecheck: PASS/FAIL106- Tests: PASS/FAIL107- Static/security scan: PASS/FAIL or N/A108109Changed Files:110- [path] - [simplification]111112Remaining Risks:113- [none or short deferred item]114```115116## Scenario Examples117118**Good:** The user says `continue` after tests already lock behavior and the next smell pass is clear. Continue with the next bounded cleanup pass.119120**Good:** The user narrows the scope to a specific file after planning. Keep the regression-tests-first workflow, but apply the new scope locally.121122**Bad:** Start rewriting architecture before protecting behavior with tests.123124**Bad:** Collapse multiple smell categories into one large refactor with no intermediate verification.125126## Gate 审查模式127128当本 skill 被 ddev-gate 流程在代码评审返回后加载时,必须使用 `reviewer-prompt.md` 作为任务模板执行受限清理。该模板定义了清理输入、scope 约束、regression-tests-first 规则和输出格式。清理完成后,主 agent 会基于最终代码重新并行派发一致性审查与代码评审做只读复审。129130## 进度记录131132当本 skill 被 ddev-exec 或 ddev-gate 工作流调用时,清理完成后须将 diff 摘要写入项目根目录的 `progress.md`:133134- 记录清理前后的变更文件数和行数(新增/删除)135- 记录各 Pass 通过的 Quality Gates 结果(PASS/FAIL)136- 如有 defer 的风险项,一并记录137- 写到最后一次执行日志后,追加时间戳