跳到正文
Skillpedia
通用编程70k · #3138

remove-ai-slops

它能做什么

这个工具可以删除你代码改动中由人工智能生成的“冗余”或不必要的代码。它会安全地进行操作,确保程序的功能保持不变。

适用场景

  • ✓当你要求“清理”更新内容或“删除不必要的代码”时。
  • ✓在使用 AI 生成代码后,想要进行审查时。
  • ✓为了确保 AI 生成的代码符合最佳实践时。

技能链接

https://github.com/code-yeongyu/oh-my-openagent/blob/dev/packages/shared-skills/skills/remove-ai-slops/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/code-yeongyu/oh-my-openagent/blob/dev/packages/shared-skills/skills/remove-ai-slops/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“清理我最近几次提交中 AI 生成的代码。”

每周 5 个新技能,1 分钟读完。

工作原理

该工具会先编写测试,确保代码能正常工作。然后,它会分析并删除被视为“冗余”的 AI 代码模式。最后,它会再次运行测试,确认没有出现问题。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Remove AI Slops Skill

Inputs

  • Default scope: branch diff vs merge-base main (no arguments needed)
  • Optional scope: explicit file list passed by the caller (e.g., a Ralph workflow's changed-files set)

What this skill does

Cleans AI-generated slop from a bounded set of changed files while strictly preserving behavior. Locks behavior with regression tests first, then runs a categorized multi-pass cleanup, then verifies with quality gates and a critical review. Reverts and direct-edits when verification fails.

The core safety invariant: behavior is locked by green tests before a single line is removed. A checklist alone is not safety; a passing regression test is.


Categories (what counts as slop)

The agent looks for these nine categories. The first three are stylistic, the next three are structural, the next two are about hidden cost, and the last is about behavior coverage.

Stylistic

  1. Obvious comments — comments restating code, trivial docstrings, section dividers, commented-out code, vague TODOs/Notes.

    • KEEP: comments explaining WHY (business logic, edge cases, workarounds), ticket links, regex/algorithm explanations.
    • KEEP: BDD markers (# given, # when, # then, # when/then).
  2. Over-defensive code — null checks for guaranteed values, try/except around code that cannot raise, isinstance checks for statically typed params, default values for required params, backward-compat shims, redundant validation duplicated at multiple layers, broad exception catching (except Exception/except BaseException in Python, empty catch {} or catch (e) { console.error(e) } without narrowing in TypeScript/JavaScript).

    • KEEP: validation at system boundaries (user input, external APIs), I/O error handling, nullable DB fields. Top-level boundary catch-all (CLI main(), HTTP handler) with explicit logging + re-raise is acceptable.
    • REFACTOR: except Exception → catch the specific exception you expect. Empty catch {} → add instanceof narrowing or re-throw. catch (e) { log(e) } → narrow with instanceof, handle known cases, re-throw unknown.
    • PROOF REQUIRED: before deleting any validation or error handling at a trust boundary, Phase 2 must include an adversarial regression (malformed or hostile input) that fails if the guard is removed. No adversarial test → the guard stays. Redundant defense to remove is a duplicate of a check that already runs inside the boundary; a guard with no proof of redundancy is load-bearing.
  3. Excessive complexity — deep nesting (>3 levels), nested ternaries, complex boolean expressions (combine 4+ predicates), long parameter lists (>5 args without a struct/dataclass/object), god functions (>50 lines doing many things), overly clever one-liners that sacrifice readability, if/elif/else chains for type/enum/literal discrimination (must be match/case + assert_never), object used as a type annotation (must be Protocol, TypeVar, or explicit union).

    • KEEP: established complexity patterns in this codebase, performance-critical hot paths that intentionally use a complex idiom. if/else for boolean conditions and range checks (not variant discrimination).
    • REFACTOR: nested if-chains → guard clauses / early returns. Complex ternaries → explicit if/else. isinstance/enum if/elif chains → match/case with assert_never on the wildcard. object annotations → Protocol (structural), TypeVar (generic), or union (known variants).

Structural

  1. Needless abstraction — pass-through wrappers, single-use helpers, speculative indirection ("we might need this later"), interfaces with one implementer where the interface adds no testability win, factory functions that just call a constructor.

    • KEEP: abstractions that provide a real seam (testability, multiple implementers, framework-required boundaries).
  2. Boundary violations — wrong-layer imports (UI importing DB driver), leaky responsibilities (handler doing business logic that belongs in a service), hidden coupling (module A reads module B's private state), side effects in pure-named functions.

    • KEEP: pragmatic short-circuits already established as a pattern in this codebase. Flag for human judgment if unsure.
  3. Dead code — unused imports, unused private functions/methods, unreachable branches, stale feature flags, debug leftovers (console.log, print(...), dbg!), removed-but-still-referenced code.

…

常见问题

什么是“AI slops”(AI 冗余代码)?

指的是 AI 有时会生成的一些不理想的代码模式,比如多余的注释、过度防御性的代码,或者不必要的复杂结构。

这个工具会把我的代码改坏吗?

不会。该工具设计得很安全,只有在测试确认程序的行为没有改变之后,才会删除代码。

它会删除有用的注释吗?

不会。它会保留解释“为什么这样做”的注释、工单链接,以及对复杂算法的说明。它只会删除仅仅重复代码内容的注释。

详情

作者的原始描述

Removes AI-generated code smells from branch changes or an explicit file list behind regression tests. Use when the user asks to clean up, deslop, or remove AI-slop patterns from recent changes.

repo: code-yeongyu/oh-my-openagent

热度

GitHub 星标
70k
排名
#3138
许可证
NOASSERTION
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能