ai-slop-cleaner
它能做什么
这项技能在不改变代码功能的前提下,整理杂乱的代码。适合拥有重复、过度抽象或遗留无用路径代码的开发者。
适用场景
- ✓当代码变得臃肿、重复,或充满不必要的包装层的时候。
- ✓当最近的一次更改留下了重复代码、无用代码或薄弱的边界的时候。
- ✓当你想清理代码,并需要测试来证明行为得以保留的时候。
技能链接
https://github.com/Yeachan-Heo/oh-my-codex/blob/main/plugins/oh-my-codex/skills/ai-slop-cleaner/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请整理我本周生成的代码。删除重复和无用的部分,但不要改变它的功能。”
每周 5 个新技能,1 分钟读完。
工作原理
它会先编写锁定当前行为的测试,然后制定整理计划。它会审查有风险的回退代码,优先修复价值最高的问题,并用证据检查结果。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
AI Slop Cleaner Task Card
Use this bounded helper for cleanup/refactor/deslop work, not as a competing top-level
workflow. Shared operating invariants live in templates/AGENTS.md; this card defines
scope, smell taxonomy, passes, and evidence.
When to use and inputs
Use when working code is bloated, noisy, repetitive, over-abstracted, or AI-generated; the user requests cleanup/refactor/deslop; or a follow-up left duplicate/dead code, weak boundaries, missing tests, fallback-like paths, or wrappers. Inputs are the requested feature/files and behavior to preserve. A file list scope is valid; keep the pass bounded to it. Limit the pass to the calling task's changed files unless broader cleanup was requested.
Before editing
- Lock behavior with regression tests first: identify behavior to preserve, run/add the narrowest targeted tests, and cover both primary and preserved compatibility/fail-safe fallback paths.
- Create a cleanup plan before code: list scope and smells, include fallback findings/classifications/escalation, and order safest/highest-signal fixes first.
- Inventory fallback-like code in scope: quick hacks, temporary workaround, temporary fallback, just bypass, just skip, fallback if it fails, swallowed errors, silent defaults, broad compatibility shims, and duplicate alternate execution paths.
- Classify each fallback: Masking fallback slop hides evidence, bypasses the contract, suppresses validation, swallows failures, silently defaults, or adds untested paths; Grounded compatibility/fail-safe fallback is narrow at an external/version/fail-safe boundary, documents rationale, preserves failure evidence, and tests primary plus fallback.
- Prefer root-cause repair, deletion, boundary repair, or explicit failure behavior. For broad/ambiguous/cross-layer/architectural findings, invoke
$ralplanfor consensus resolution; when already inside ralplan, ultragoal, team, or another OMX workflow, do not spawn a nested$ralplan—attach the finding to the active handoff.
Smell taxonomy and passes
Classify before changing:
- Fallback-like code: masking fallbacks, workaround branches, bypasses, swallowed errors, silent defaults, broad shims, alternate paths.
- Duplication: repeated logic, copy-paste branches, redundant helpers.
- Dead code: unused/unreachable code, stale flags, debug leftovers.
- Needless abstraction: pass-through wrappers, speculative indirection, single-use layers.
- Boundary violations: hidden coupling, leaky responsibilities, wrong-layer imports/side effects.
- Missing tests: behavior not locked or edge cases uncovered.
- UI/design slop: context-sensitive signals, not absolute bans; preserve intentional brand, design-system, accessibility, or product-context exceptions. Challenge Korean body text at 11-12px (generally 14px or larger); gratuitous box shadows; repetitive eyebrow + title + description + paragraph stacks and generic emoji badges; default AI blue/purple such as
#3B82F6; reflexive 3-column or 4-column grids; and extreme gradients unless justified by context.
Resolve the fallback-like code resolution gate first, then 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 and avoid unrelated refactors. Prefer deletion/existing utilities; no new abstractions or dependencies unless explicitly required.
Evidence/output contract
Report:
AI SLOP CLEANUP REPORT
Scope: [files/feature]
Behavior Lock: [targeted tests added/run]
Cleanup Plan: [bounded smells/order]
Fallback Findings: [finding -> masking fallback slop | grounded compatibility/fail-safe fallback -> escalation]
UI/Design Findings: [none/N/A or signal -> action/defer -> intentional rationale]
Passes Completed: [resolution gate; Passes 1-4]
Quality Gates: Regression tests, Lint, Typecheck, Tests, Static/security scan (PASS/FAIL/N/A)
Changed Files: [path -> simplification]
Remaining Risks: [none or deferred item]
Include changed files, simplifications, fallback classifications/escalation status, tests/diagnostics/build checks run, UI findings when relevant, and deferred risks. Keep writer/reviewer separation for cleanup plans and approvals.
Exit condition
Stop when the requested scope has behavior-lock evidence, each selected smell pass is complete or explicitly deferred with rationale, verifica
常见问题
它会改变代码的行为吗?
它力求保持行为不变,并在整理之前用测试锁定这些行为。
它会整理整个项目吗?
不会。除非你要求更大范围的整理,它只处理任务中的文件。
什么是回退路径?
它们是诸如静默默认值或吞掉错误之类的变通方法,技能会对其进行审查,因为它们可能掩盖真正的问题。
详情
热度
- GitHub 星标
- 34k
- 排名
- #8409
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …