h.jk

TIGHT comments

Continuing with the careful choice of initialisms... I've noticed (and still noticing) that models can get quite occupied with littering the codebase with comments. The models definitely need a clear purpose of what to include, hence the TIGHT comments.

Term When it fails Why failing is bad
Thematic Comments that say how, not why... Everyone can read code, not everyone knows why it had to be written.
Intentional Flourishes, the decorative kind. Future comment churn.
Grounded References to code in another file, right down to the line... Comments get outdated the moment referenced code changes.
Helpful Calls an own function that already has a docstring, quotes the docstring. Redundant.
Thoughtful Single-use variable getting its comment how it's made. Having to over-explain code are usually hints it can be better written.

Generally, I feel the scenarios where models dump code are when they are tasked to:

The documentation I tasked my agent-model to prepare had the following passage (with light edits):

Keep comments that explain why — non-obvious rationale, trade-offs, constraints. Drop comments that explain how, and never narrate what the code literally does: the code already shows it, and behavior-prose is redundant now and wrong later.

Docstrings by visibility — private/internal helpers (module-local, leading-underscore) usually need none; a public function that needs one gets a single line, not an essay.

No temporal or pointer references — no line numbers into other files, no issue/ticket/MR/PR numbers, no "ported from X" / "same as the old Y" provenance. Those decay the moment the target moves, renames, or closes, and aren't even locally checkable; they belong on the issue/ticket, not in the comment and not in the commit message. Point at a thing by its name, not its position: a line number is a coordinate into a file that moves, the name survives every rename and rebase and is greppable. That holds wherever the reference is written — a code comment, a review-thread note, a work-item description — and a coordinate is at its worst when the wrong line still reads plausibly, because the reader follows it and gets no signal. Never assert a negative about usage either — "resolved first, not read", "no caller passes this"; a test that fails when the claim stops being true is the carrier for it, not a comment.

A "why" comment on a single call argument doesn't qualify — cut it. If the argument's rationale matters, it belongs on the callee's own definition, not repeated at every call site.

If the name plus return type/annotation already make the behavior obvious, skip the comment.

Weigh comment lines against code lines — both are LoC. A 1-line comment on 1 line of code is the default anti-pattern; make the code stand alone. A 10-line block earns a few comment lines, not thirty — if it needs thirty, abstract the code further. When two similarly-named things need a comment just to tell them apart, rename one instead.

Exception: a genuinely empty-bodied function (a true no-op) keeps its one-line docstring — without it, the empty body reads as an unfinished stub, a worse misread than the ratio violation.

We'll explore documentation density tiers next week!

AI disclaimer: The concepts' bullet points (contents, not the terms) and that passage (minus light edits).

#tight-comments