Skip to content

🤖 Add a policy for writing code comments - #227

Merged
taras merged 2 commits into
mainfrom
policy/code-comments
Jul 31, 2026
Merged

🤖 Add a policy for writing code comments#227
taras merged 2 commits into
mainfrom
policy/code-comments

Conversation

@taras

@taras taras commented Jul 31, 2026

Copy link
Copy Markdown
Member

Stacked on #225 — both add a row to .policies/index.md, so basing this on main would guarantee a conflict. GitHub will retarget to main automatically once #225 merges.

Why

Every comment I wrote in #226 opened by narrating the code and only then got to the point. Reviewing them one at a time with @taras, the same thing happened five times: the prose describing what the comment should communicate was better than the comment itself.

That's a repeatable failure mode, not a one-off, and nothing in .policies/ currently covers it — documentation.md governs outward-facing docs (JSDoc, examples, changelogs), which are held to the opposite standard.

The rule

A comment must say something the code cannot. The test is four questions:

  1. What is happening around the comment?
  2. What does the comment say now?
  3. What should it communicate?
  4. Why do we need this comment at all?

The fourth removes most comments. If the honest answer is "so the reader understands the code", the code should be clearer instead.

Writing rules

  • Lead with the instruction, not the mechanism
  • State the consequence, especially when the failure is silent
  • Prefer why over when — version numbers rot unless tied to a live constraint in the same package
  • Verify before you assert
  • Don't overstate

Examples

Real before/after pairs from #226 and #224, not invented ones. Including the three kinds of comment the review concluded were worth keeping:

  • an ordering constraint (Don't hoist this above the spawns — teardown would hang waiting on closed)
  • a deliberate deviation from another policy (We can't use scoped here to prevent losing the halt on effection older than 4.1)
  • a reach into a private API (intentionally omitted from Effection's public Coroutine because it's considered a private API)

And the ones that were deleted: mechanism-without-instruction, when-instead-of-why, and restating async-teardown.md at the call site.

State: Strict

Violations must be fixed before merge, alongside Package.json Metadata and No Agent Marketing.

Also here

  • AGENTS.md gains a line under Coding Standards. Agents write the comments this policy is about and read that section, not .policies/.
  • documentation.md cross-references it, so the tension between the two is explicit rather than implied.

Open question

Whether the "Commenting to explain a confusing name → Rename it" row belongs here or in naming-consistency.md.

Docs only, no version bumps.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@taras, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 5 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7cbe4550-d006-4e71-9f4c-b20a55f23b25

📥 Commits

Reviewing files that changed from the base of the PR and between c63f18a and 7e4bb6c.

📒 Files selected for processing (4)
  • .policies/code-comments.md
  • .policies/documentation.md
  • .policies/index.md
  • AGENTS.md

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@taras
taras force-pushed the docs/async-teardown-policy branch from e18bf73 to dc9cd4d Compare July 31, 2026 18:31
@taras
taras force-pushed the policy/code-comments branch from cf185d1 to 36a8fd4 Compare July 31, 2026 18:31
taras added 2 commits July 31, 2026 14:46
Every comment in the async teardown migration opened by narrating the
code and only then reached its point. Reviewing them one at a time, the
prose describing what each comment *should* say was consistently better
than the comment itself — which is a repeatable failure, not a one-off.

The rule: a comment must say something the code cannot. The test is four
questions, and the fourth — why do we need this comment at all — is the
one that removes most of them.

Examples are the real before/after pairs from that review, including the
three kinds of comment worth keeping: an ordering constraint, a
deliberate deviation from another policy, and a reach into a private API.

Cross-referenced from documentation.md, which governs the outward-facing
docs held to the opposite standard.
Violations must be fixed before merge.
@taras
taras force-pushed the policy/code-comments branch from 36a8fd4 to 7e4bb6c Compare July 31, 2026 18:46
@taras
taras changed the base branch from docs/async-teardown-policy to main July 31, 2026 18:46
@pkg-pr-new

pkg-pr-new Bot commented Jul 31, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@effectionx/bdd@227
npm i https://pkg.pr.new/@effectionx/middleware@227

commit: 7e4bb6c

@taras
taras merged commit 02d93f9 into main Jul 31, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants