anti-ai-slop
After working on the code, ensure the branch contains only the minimal, idiomatic changes by removing AI-generated slop introduced on this branch.
DeevsDeevs · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add DeevsDeevs/agent-system --skill anti-ai-slop技能说明
name: anti-ai-slop description: "After working on the code, ensure the branch contains only the minimal, idiomatic changes by removing AI-generated slop introduced on this branch."
Intent
This skill reviews the diff against main and removes changes that are likely “AI slop”: unnecessary, non-idiomatic, or inconsistent additions that do not materially contribute to the intended feature/fix.
Guiding principle: keep the smallest change that accomplishes the goal, and match the local conventions of each touched file.
Scope and diff source
Operate only on changes introduced on this branch relative to main.
Determine the diff source in this order:
git diff --cached(if non-empty)git diff(if non-empty)git diff main..HEAD(fallback)
Ifmaindoes not exist locally, usegit diff master..HEAD.
Do not refactor unrelated code outside the displayed diff hunks.
Non-goals
- Do not redesign architecture, rename APIs, or move code unless required by the feature/fix in the diff.
- Do not remove meaningful domain comments that encode invariants, reasoning, constraints, or known pitfalls.
- Do not remove validation at genuine trust boundaries (I/O, parsing, network, user input, third-party callbacks).
- Do not change formatting rules; follow repository tooling and the file’s established style.
What counts as AI slop
A) Comment and documentation bloat
Remove comments/docstrings that merely narrate the code, restate names, or are inconsistent with the file’s comment density and tone.
Python (before):
def clamp(x: float, lo: float, hi: float) -> float:
# Ensure x is not less than lo and not greater than hi
if x < lo:
return lo
if x > hi:
return hi
return x
Python (after):
def clamp(x: float, lo: float, hi: float) -> float:
if x < lo:
return lo
if x > hi:
return hi
return x
B) Unnecessary defensive checks inside trusted codepaths
Remove checks that are redundant because upstream validation/types/invariants already guarantee inputs.
Rust (before):
pub fn normalize_tag(tag: &str) -> String {
if tag.is_empty() {
return String::new();
}
tag.trim().to_ascii_lowercase()
}
If the rest of the codebase treats empty tags as impossible here (validated earlier), keep only the essential logic:
Rust (after):
pub fn normalize_tag(tag: &str) -> String {
tag.trim().to_ascii_lowercase()
}
C) Try/catch / try blocks that add no value
Remove wrappers that only rethrow, add inconsistent logging, or hide errors without providing recovery.
C++ (before):
void SaveRow(Db& db, const Row& row) {
try {
db.Save(row);
} catch (const std::exception& e) {
std::cerr << "Error saving row: " << e.what() << std::endl;
throw;
}
}
If the repository does not use log-and-rethrow at this layer, prefer:
C++ (after):
void SaveRow(Db& db, const Row& row) {
db.Save(row);
}
D) Single-use variables and one-off helpers that should be inlined
Prefer inlining when it improves clarity and matches surrounding style.
Python (before):
clean = s.strip().lower()
return clean
Python (after):
return s.strip().lower()
Rust (before):
let key = format!("{}:{}", user.id, user.region);
cache.insert(key, value);
If key is not reused and inlining remains readable:
Rust (after):
cache.insert(format!("{}:{}", user.id, user.region), value);
E) Redundant checks/casts duplicated at caller and callee
If a caller guarantees an invariant, remove repeated checks in the callee unless the subsystem consistently enforces invariants at every boundary.
Python (before):
def handle(req: Request) -> Response:
user = parse_user(req) # guarantees user.id is present
return do_work(user)
def do_work(user: User) -> Response:
assert user.id is not None
return Response(user.id)
Python (after):
def do_work(user: User) -> Response:
return Response(user.id)
F) Style drift and inconsistency with the file
Remove or rewrite changes that introduce new patterns inconsistent with the file or repository norms, such as:
- Adding type annotations in a Python file that otherwise does not use them.
- Introducing novel error-handling idioms in Rust (e.g., custom
Resultwrappers) where the module uses simpleanyhow::Result(or vice versa). - Adding complex abstractions (factories/providers/managers) for small local logic.
G) Noisy logging and narration
Remove logs that restate the line of code, are inconsistent with the module’s logging level, or spam hot paths.
Rust (before):
log::info!("Starting normalization");
let out = normalize_tag(tag);
log::info!("Finished normalization");
out
Rust (after):
normalize_tag(tag)
(Keep logs that support production debugging when the module’s convention calls for them.)
H) Placeholder TODOs without a ticket/reference
Remove “TODO: handle edge cases” style notes that add no actionable guidance and are not aligned with repository practices.
I) Unicode hazards and emoji noise in code/comments
Remove suspicious or unnecessary Unicode in code and configs, including:
- non-breaking spaces (
U+00A0) - zero-width characters (
U+200B,U+200D) - “smart quotes” (
“ ” ‘ ’) in code/config - homoglyphs in identifiers
- emojis in code comments/docs unless the repository explicitly uses them
Python (before):
# ✅ Done! 🚀
name = "abc" # zero-width space
Python (after):
name = "abc"
(Do not “sanitize” legitimate localized/user-facing content unless it appears to be accidental.)
Trust boundaries: when defensive checks are appropriate
Defensive checks are generally appropriate at untrusted boundaries, such as:
- requ