Skip to main content
New aislop v0.9.4: four new Python rules from the SlopCodeBench paper, plus a CLI star prompt and GitHub Discussions. Read more →
ai-slop/narrative-comment auto-fixable

Narrative comment.

A multi-line comment block that walks through what the function does in prose. The signature already says it; the prose is decorative.

Bad — what an agent ships
// This function takes a user ID and a list of orders,
// filters the orders to only those belonging to the user,
// then sums the total amount across them and returns it.
function sumUserOrders(userId: string, orders: Order[]): number {
  return orders
    .filter(o => o.userId === userId)
    .reduce((sum, o) => sum + o.amount, 0)
}
Good — what aislop hands back
function sumUserOrders(userId: string, orders: Order[]): number {
  return orders
    .filter(o => o.userId === userId)
    .reduce((sum, o) => sum + o.amount, 0)
}

Agents are trained to "explain" code. They pad function bodies with explanatory preambles even when the signature, parameter names, and operator chain already tell the same story.

How this rule is justified.

Rule id

ai-slop/narrative-comment

Enforcing engine

ai-slop

Detector strategy

Deterministic comment-block parse: flags consecutive comment lines that paraphrase the immediately following declaration.

Legitimate code that is NOT flagged

WHY comments, license headers, doc comments documenting public API contracts, and comments stating a non-obvious constraint are not flagged.

Evidence

Verbosity signals derive from SlopCodeBench, which measured comment padding in long-horizon coding tasks, and recurred across the first public scan batch.