Cite the section bar from the one-line rule instead of restating its list

This commit is contained in:
2026-09-25 07:53:38 +02:00
parent cbf57e237b
commit 0b5619079b
+3 -3
View File
@@ -112,15 +112,15 @@ How work proceeds in any repo, unless that repo's `AGENTS.md` says otherwise.
### Comments
These rules govern prose; doc comments a tool consumes — docstrings, godoc, JSDoc types — are outside them.
The rules below govern prose comments; doc comments a tool consumes — docstrings, godoc, JSDoc types — are outside them.
Default to NO comment. Delete one that is any of:
1. A **restatement** of the adjacent code. BANNED: `// Sanitized + bounded to 1000 chars` above `mb_substr(json_encode(LogSanitizer::body($x)), 0, 1000)`.
2. A **cross-cutting convention** used elsewhere (sanitization, the 1000-char Loki cap, "log so the source is recoverable"). Project-wide facts live in ONE doc, never repeated at call sites.
3. A **justification of self-evident code** (a log line is self-evidently for observing its value).
4. A **file preamble or arrangement rationale**: what a file holds, why it exists, why two things share it, why a check sits beside what it judges, why an order was chosen. The file name and the declarations are the index; a choice with no effect on the running program belongs in the commit that made it, or in the decision record.
4. A **file preamble or arrangement rationale**: what a file holds, why it exists, why two things share it, why a check sits beside what it judges, why an order was chosen. The file name and the declarations are the index; a choice with no effect on the running program belongs in the commit that made it.
**What stays is one terse line: a footgun, an external constraint, or an invariant, and only where the code cannot show it.** GOOD: `# Pinned to 7.x: hurl 8's jsonpath change breaks the nth-filter asserts.` Background on what a thing is for, however plausible, is deleted. A second line is a signal to stop and ask where the text belongs — nearly always the commit message or the ticket; consecutive comment lines are how a file reaches 40% prose. A paragraph is earned by an invariant a reader must hold before touching the code below, never by a rationale, and it stays with the code it guards. When unsure, delete.
**What stays is one terse line, and only where the code cannot show it.** GOOD: `# Pinned to 7.x: hurl 8's jsonpath change breaks the nth-filter asserts.` A second line belongs in the commit message or the ticket. The one exception is a paragraph for an invariant a reader must hold before touching the code below; it stays with the code it guards.
**Density is a review signal.** Prose comment lines much past ~10% of a file's non-blank lines mean something is wrong — narrating comments, or code that fails to carry its own meaning. A defect to investigate, not a style preference.