remove-ai-slops
What it does
This tool removes 'fat' or unnecessary code generated by artificial intelligence in your code changes. It does so safely, ensuring the program continues to function as before.
When to use it
- βWhen you ask to 'clean up' or 'remove unnecessary code' from an update.
- βAfter using an AI to generate code and wanting to review it.
- βTo ensure AI-generated code follows best practices.
Skill link
https://github.com/code-yeongyu/oh-my-openagent/blob/dev/packages/shared-skills/skills/remove-ai-slops/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βClean up AI-generated code in my latest commits.β
5 new skills a week. 1 minute to read.
How it works
The tool first creates tests to ensure the code works. Then, it analyzes and removes code patterns considered 'fat' by AI. Finally, it re-checks with tests to make sure nothing broke.
Technical content (original SKILL.md)
Original text by the author, straight from 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
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).
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 BaseExceptionin Python, emptycatch {}orcatch (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. Emptycatch {}β addinstanceofnarrowing or re-throw.catch (e) { log(e) }β narrow withinstanceof, 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.
- KEEP: validation at system boundaries (user input, external APIs), I/O error handling, nullable DB fields. Top-level boundary catch-all (CLI
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/elsechains for type/enum/literal discrimination (must bematch/case+assert_never),objectused as a type annotation (must beProtocol,TypeVar, or explicit union).- KEEP: established complexity patterns in this codebase, performance-critical hot paths that intentionally use a complex idiom.
if/elsefor 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/casewithassert_neveron the wildcard.objectannotations βProtocol(structural),TypeVar(generic), or union (known variants).
- KEEP: established complexity patterns in this codebase, performance-critical hot paths that intentionally use a complex idiom.
Structural
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).
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.
Dead code β unused imports, unused private functions/methods, unreachable branches, stale feature flags, debug leftovers (
console.log,print(...),dbg!), removed-but-still-referenced code.
β¦
FAQ
What are 'AI slops'?
These are code patterns that AIs sometimes generate and which are not ideal, such as obvious comments, overly defensive code, or unnecessary complexity.
Can this break my code?
No, the tool is designed to be safe. It only removes code after confirming with tests that the program's behavior has not changed.
Does it remove useful comments?
No, it keeps comments that explain the 'why' of something, ticket links, or explanations of complex algorithms. It only removes comments that merely restate the code.
Details
Original description by the author
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.
Popularity
- GitHub stars
- 70k
- Ranking position
- #3138
- License
- NOASSERTION
- Updated
- 10/15/2026
Comments
- β¦
More skills from this repository
comment-checker
70kHelps your agent understand and respond to feedback from automatic comment checkers. Useful for processing results from automated code or content reviews.
lcx-contribute-bug-fix
70kHelps your agent contribute bug fixes for LazyCodex-related projects. It creates issues or pull requests to ensure code quality.
lcx-doctor
70kLets your agent check the health of LazyCodex and Codex CLI installations. It's useful when the system behaves oddly after updates or changes.
lcx-report-bug
70kHelps your agent report bugs in detail for LazyCodex projects. It creates issues with useful information for developers to fix the problem.
Similar skills
diffs
394kLets your agent produce a real, shareable diff of edits as a viewer link or image file, instead of a hand-written summary.
coding-agent
394kHelps your agent hand a larger coding job to Codex, Claude Code, or OpenCode as a background worker, then check on its progress.
gh-issues
394kHelps your agent find GitHub issues, pick the ones to work on, and open pull requests with fixes, including follow-up on review comments.