antislop-code
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseantislop-code
antislop-code
Anti Slop: Rules for AI Coding Agents. Code Comments skill
Part of the antislop system. Read together with(the core). This skill filters comments that read as generically AI (decorative, restating the obvious, stiff, loud) while preserving the comments that carry real information. It references core rules by number and never duplicates or renumbers them. Load it when the task writes or edits code comments.antislop.md
Anti Slop:AI编码Agent的代码注释规则技能
属于antislop系统的一部分。请与核心文档一同阅读。本技能会过滤那些看起来是通用AI生成的注释(装饰性、复述显而易见的内容、生硬、夸张),同时保留承载真实信息的注释。它通过编号引用核心规则,绝不重复或重新编号这些规则。当任务涉及编写或编辑代码注释时加载本技能。antislop.md
How to use this skill
如何使用本技能
- Load together with whenever the task touches code comments. The core holds the mechanism (the purpose test, the three tiers, the Delivery Gate); this skill holds comment-specific depth.
antislop.md - Every entry has the same shape: Tell (the pattern), Why (why it reads as slop), Fix (what to do instead), with the governing core rule cited as R-XX.
- Scope guardrail: this skill only modifies comments. Never modify executable code, identifiers, imports, formatting, indentation, whitespace, control flow, or logic. When in doubt, leave the code untouched.
- The Delivery Gate in the core remains the gate. The "Code Comment Checklist" at the end of this file is the comment-specific supplement to run alongside it.
- 每当任务涉及代码注释时,与一同加载。核心文档包含机制(用途测试、三个层级、交付闸门);本技能包含注释相关的详细规则。
antislop.md - 每个条目都遵循相同的结构:识别(模式)、原因(为何属于冗余内容)、修正(替代方案),并引用对应的核心规则编号R-XX。
- 范围约束:本技能仅修改注释。绝不修改可执行代码、标识符、导入语句、格式、缩进、空白字符、控制流或逻辑。如有疑问,保持代码原样。
- 核心文档中的交付闸门仍然是最终准则。本文档末尾的“代码注释检查清单”是与之配合使用的注释专项补充内容。
Comments That Add Nothing
无价值的注释
Decorative Separators
装饰性分隔符
- Tell: banner comments built from repeated characters, ALL CAPS labels, or box drawing around a section name: around
// =======================,Authentication, or a// -------- WORKFLOW --------header./* ---- ROUTES ---- */ - Why: the decoration is the message. A label wrapped in or
=signals "AI made this" without adding information, and ALL CAPS reads as shouting.- - Fix: replace with a single plain line, or remove entirely if the label adds nothing (R-31).
- 识别:由重复字符、全大写标签或围绕章节名称的框线组成的横幅注释:比如包裹
// =======================、Authentication,或者// -------- WORKFLOW --------标题。/* ---- ROUTES ---- */ - 原因:装饰本身就是全部信息。用或
=包裹的标签只会传递“这是AI生成的”信号,没有添加任何实际信息,全大写的写法还显得像在大喊大叫。- - 修正:替换为单一的普通行,若标签本身无意义则直接移除(R-31)。
Restating the Obvious
复述显而易见的内容
- Tell: a comment that repeats what the next line or declaration already shows, like above
// Initialize the variable,let count = 0above// User class,class User {}above// Validate user, orfunction validateUser().const userAge = 25; // User age is 25 - Why: it doubles the reading load without adding anything. The code already says it; the comment just repeats it.
- Fix: remove and leave the line of code alone.
- 识别:重复下一行或声明内容的注释,比如上方的
let count = 0、// Initialize the variable上方的class User {}、// User class上方的function validateUser(),或者// Validate user。const userAge = 25; // User age is 25 - 原因:增加了阅读负担却没有任何价值。代码本身已经表达了这些信息,注释只是重复而已。
- 修正:移除注释,保留代码行不变。
Workflow Narration
工作流叙述
- Tell: comments that narrate the flow step by step, like ,
// Step 1: Validate input,// Step 2: Process request, or// Step 3: Return response,// First...,// Next....// Finally... - Why: the control flow is visible in the code itself. Numbering it reads as a checklist, not an explanation.
- Fix: remove. If the flow is genuinely hard to follow, that is a structure problem, not a missing comment problem.
- 识别:逐步骤叙述流程的注释,比如、
// Step 1: Validate input、// Step 2: Process request,或者// Step 3: Return response、// First...、// Next...。// Finally... - 原因:控制流在代码中清晰可见。编号的写法更像检查清单,而非解释说明。
- 修正:移除。如果流程确实难以理解,那是结构问题,而非缺少注释的问题。
Empty Labels
空标签
- Tell: generic labels with no information behind them: ,
// Main logic,// Core logic,// Business logic,// Helper function,// Entry point, or// Error handling/// Note: This is important.// Important: Please read. - Why: the label names a category, not a fact. "Main logic" tells the reader nothing they could not infer from the code.
- Fix: remove unless the label carries specific information. "Note: retries happen only on 5xx" earns its place; "Note: this is important" does not.
- 识别:无实际信息的通用标签:、
// Main logic、// Core logic、// Business logic、// Helper function、// Entry point,或者// Error handling/// Note: This is important.。// Important: Please read. - 原因:标签仅命名了类别,而非事实。“Main logic”并没有告诉读者任何他们无法从代码中推断出的信息。
- 修正:移除,除非标签包含特定信息。比如“Note: retries happen only on 5xx”是有价值的;而“Note: this is important”则没有。
Vague Placeholders
模糊的占位符
- Tell: comments that promise future work without saying what: ,
// TODO: Improve this,// Future improvements,// Additional optimization can be added here.// Add more validation - Why: a vague TODO is noise. It names a feeling (this could be better) instead of a task (what, and why).
- Fix: remove. Keep a TODO only when it names a specific task with enough context to act on.
- 识别:承诺未来工作但未说明具体内容的注释:、
// TODO: Improve this、// Future improvements、// Additional optimization can be added here。// Add more validation - 原因:模糊的TODO只是噪音。它表达的是一种感觉(这个可以更好),而非具体任务(做什么,为什么)。
- 修正:移除。只有当TODO明确命名了带有足够上下文的具体任务时才保留。
Signature Echo
签名重复
- Tell: documentation that only restates the signature, like a JSDoc block that repeats and
@param price The price.for a function whose name and parameters already say all of it.@returns Total price. - Why: docs that echo the signature add length, not understanding. The reader learns nothing new.
- Fix: simplify or remove the echo. Keep documentation that explains business rules, edge cases, assumptions, algorithms, limitations, side effects, API behavior, or security implications. Never strip real documentation.
- 识别:仅复述函数签名的文档,比如JSDoc块中重复和
@param price The price.,而函数名称和参数本身已经包含了所有信息。@returns Total price. - 原因:重复签名的文档只会增加长度,不会提升理解。读者无法学到任何新内容。
- 修正:简化或移除重复内容。保留那些解释业务规则、边缘情况、假设、算法、限制、副作用、API行为或安全影响的文档。绝不要删除真正有价值的文档。
Decorative Emoji
装饰性表情符号
- Tell: emoji used as decoration in comments, like or
// ✅ Validation.// 🚀 Performance - Why: emoji is visual noise in code, and the specific set (✅, 🚀, 🔒) is the AI default vocabulary.
- Fix: replace with plain English, or remove if the label adds nothing.
- 识别:在注释中用作装饰的表情符号,比如或
// ✅ Validation。// 🚀 Performance - 原因:表情符号在代码中是视觉噪音,而且特定的符号集(✅、🚀、🔒)是AI的默认词汇。
- 修正:替换为普通英文,若标签无意义则直接移除。
End Markers
结束标记
- Tell: comments that only mark the end of a block, like ,
} // end if, or# End of function.// End processOrder - Why: the closing brace already ends the block. The marker exists out of habit, not need.
- Fix: remove. In the rare case an end marker genuinely helps a long file, keep it only where it prevents confusion, not as a habit.
- 识别:仅标记代码块结束的注释,比如、
} // end if或# End of function。// End processOrder - 原因:闭合括号已经标记了块的结束。这种标记只是出于习惯,而非必要。
- 修正:移除。在极少数情况下,结束标记确实能帮助长文件的阅读,仅在能避免混淆的地方保留,不要养成习惯。
How It Should Read
正确的注释方式
Line-by-Line Narration
逐行叙述
- Tell: a comment on every trivial statement, narrating each line as it is written: , then
// Initialize count, then// Loop items, then// Get item, then// Increment.// Return result - Why: when every line is commented, none of the comments matter. The reader has to check each one to find the one that carries meaning.
- Fix: write one concise comment per logical block instead of one per line. If the block needs no comment, write none.
- 识别:每个琐碎语句都有注释,逐行叙述代码:,然后
// Initialize count,接着// Loop items,再// Get item,最后// Increment。// Return result - 原因:如果每一行都有注释,那么所有注释都失去了意义。读者必须检查每个注释才能找到有价值的内容。
- 修正:为每个逻辑块编写一条简洁的注释,而非逐行添加。如果块不需要注释,就不写。
Stiff or Loud Wording
生硬或夸张的措辞
- Tell: comments that sound formal, long, or shout: "This function is responsible for validating whether the supplied credentials are valid before continuing with the authentication process", or in caps.
// MAIN LOGIC - Why: formal and loud wording reads as generated, not as an engineer leaving a note for the next person.
- Fix: write short, sentence-case lines in a natural developer voice: Good comments explain why, not what, and they stay short.
// Validate credentials before issuing a token.
- 识别:措辞正式、冗长或夸张的注释:“This function is responsible for validating whether the supplied credentials are valid before continuing with the authentication process”,或者全大写的。
// MAIN LOGIC - 原因:正式和夸张的措辞看起来像是生成的,而非工程师留给下一位开发者的提示。
- 修正:用自然的开发者语气编写简短、句首大写的句子:好的注释解释原因,而非内容,并且保持简短。
// Validate credentials before issuing a token.
Not a Ban (preserve these)
并非禁止(保留以下注释)
Never remove comments that explain:
- business logic and intent
- architectural decisions
- security considerations
- performance trade-offs
- concurrency behavior
- protocol details
- API contracts
- workarounds
- edge cases and assumptions
- licensing and legal notices
Example that must stay:
js
// Stripe may retry webhook deliveries for up to three days.
// Ignore duplicate events using the event ID.A comment earns its place when it explains something the code does not already show: the reason, the constraint, the non-obvious behavior.
绝不要移除解释以下内容的注释:
- 业务逻辑与意图
- 架构决策
- 安全考量
- 性能权衡
- 并发行为
- 协议细节
- API契约
- 临时解决方案
- 边缘情况与假设
- 许可与法律声明
必须保留的示例:
js
// Stripe may retry webhook deliveries for up to three days.
// Ignore duplicate events using the event ID.当注释解释了代码未体现的内容时,它才有存在的价值:比如原因、约束、非显而易见的行为。
Code Comment Checklist
代码注释检查清单
Run these alongside the core Delivery Gate when the task touches comments. All answers must be yes:
- Does every comment add information the code does not already show? (R-31)
- Do the comments avoid decorative separators, ALL CAPS banners, and box-drawn headers?
- Do the comments avoid restating the obvious line, declaration, or signature?
- Do the comments avoid step-by-step workflow narration?
- Do the comments avoid empty labels and vague TODOs that name no task?
- Do the comments avoid decorative emoji and end markers?
- Is the comment density one per logical block, not one per line?
- Do the remaining comments read short, natural, and in sentence case?
- Is the scope guardrail held: only comments changed, the code untouched?
当任务涉及注释时,与核心交付闸门一同运行以下检查。所有答案必须为是:
- 每个注释是否都添加了代码未体现的信息?(R-31)
- 注释是否避免了装饰性分隔符、全大写横幅和框线标题?
- 注释是否避免了复述显而易见的代码行、声明或签名?
- 注释是否避免了逐步骤的工作流叙述?
- 注释是否避免了空标签和未指定任务的模糊TODO?
- 注释是否避免了装饰性表情符号和结束标记?
- 注释密度是否为每个逻辑块一条,而非逐行一条?
- 剩余的注释是否简短、自然且采用句首大写格式?
- 是否遵守了范围约束:仅修改注释,代码保持原样?