State once what a comment keeps, scoped to prose #30

Merged
lilleman merged 2 commits from comment-rules into main 2026-09-25 07:53:51 +02:00
3 changed files with 7 additions and 8 deletions
+1
View File
@@ -16,3 +16,4 @@
- `settings.json`, the agents and the status line name no machine-specific path; the status line shows reset times in the host's time zone.
- `README.md`'s first line says what the repo holds, `principles/README.md` names the reviewer agents as the principles' audience, and every decision title in `docs/decisions.md` names its subject.
- `larv-review` states its re-entry rules once: a fix made in a later pass re-enters the passes it fires, and a re-entered loop takes a fresh round cap.
- `CLAUDE.md`'s comment rules say once what a comment keeps: one line for what the code cannot show, with doc comments a tool consumes outside them.
+6 -7
View File
@@ -108,22 +108,21 @@ How work proceeds in any repo, unless that repo's `AGENTS.md` says otherwise.
**Link, don't inline — and keep the link bare.** A mechanism identical across call sites or repos is documented once in the canonical source and pointed at with a one-line bare link; N copies drift, whether they are comments or READMEs. Don't summarize what's behind the link or restate the identifier's own name.
**A pointer is not a definition.** A definition the reader needs to follow the code — what a unit counts, what a term means, what invariant a cache rests on — sits at the code in one line. A pointer to it (`see AGENTS.md §11`) is the one comment form that cannot be checked against the code beside it, so it rots invisibly. A pointer carrying rationale — a rejected alternative, the premise behind a standing choice — is correct and stays.
**A pointer is not a definition.** A definition the reader needs to follow the code — what a unit counts, what a term means, what invariant a cache rests on — sits at the code. A pointer to it (`see AGENTS.md §11`) is the one comment form that cannot be checked against the code beside it, so it rots invisibly. A pointer carrying rationale — a rejected alternative, the premise behind a standing choice — is correct and stays.
### Comments
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.
**One line is the default; a paragraph is rare and has to be argued for.** A second line is a signal to stop and ask where this really belongs — nearly always the commit message or the ticket. Consecutive comment lines are the specific defect this rule exists to stop: they are how a file reaches 40% prose. A placement argument is not a length argument. A paragraph occasionally IS right — a genuinely subtle invariant a reader must hold before touching the code below, which stays with the code it guards. What earns it is an invariant, never a rationale.
**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.
**A plausible "why" is not enough on its own.** Multi-line background explaining what a thing is for, or how we got here, piles up into walls a few lines of code cannot justify. Keep a comment only where it stops a real mistake or records an external constraint the code can't show, and then as ONE terse line. When unsure, delete. GOOD: `# Pinned to 7.x: hurl 8's jsonpath change breaks the nth-filter asserts.`
**No file preambles, and no rationale for how code is arranged.** A file gets no header comment saying what it holds, why it exists, or why it sits where it does — the file name and the declarations are the index. Nor may a comment explain why two things share a file, why a check lives beside what it judges, or why an order was chosen: that choice has no effect on the running program and belongs in the commit that made it, or in the decision record. Structured doc comments a tool consumes (docstrings, godoc, JSDoc types) are not the target; prose narration is.
**Density is a review signal.** Set the tooling-consumed doc comments aside, then count: prose comment lines much past ~10% of a file's remaining 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.
**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.
### README
-1
View File
@@ -4,7 +4,6 @@
Ordered by how many seats of the 2026-09-24 scoring panel (`docs/decisions.md`) named the place; each is one chunk.
- Make `CLAUDE.md`'s comment rules say an invariant earns a line only where the code cannot show it, state the one-line rule once, and scope the docstring exemption to what a tool consumes; today a reviewer finds two sentences saying keep and one saying delete.
- Open `CLAUDE.md` → "Comments and documentation", "Negation and history", with its scope, comments and docs beside code, and cut its two restatements of the section bar; today a reviewer cites it against a `CHANGELOG.md` line, which the next paragraph governs.
- Give the comprehension floor in `larv-review` its own heading and move its six-project calibration sentence to `docs/decisions.md`; today it sits under §2 "Trigger".
- Cut what `review-protocol.md` → "Documenting decisions" restates from `CLAUDE.md`: the decision kinds, the create-or-fix line and the record-nothing default.