Skip to content

feat(code-review): flag unnecessary comments - #304

Merged
juanmichelini merged 1 commit into
mainfrom
openhands/code-review-flag-unnecessary-comments
Jun 5, 2026
Merged

juanmichelini merged 1 commit into
mainfrom
openhands/code-review-flag-unnecessary-comments

Conversation

@juanmichelini

Copy link
Copy Markdown
Collaborator

Why

Requested in this comment on OpenHands/software-agent-sdk#3498.

That issue calls out PRs where a 3-line code change ships with ~19 lines of narrative comments — restating the code, summarizing the diff, or describing non-local behavior. The reporter asked that the code-review skill explicitly suggest removing those comments when it reviews a PR.

Summary

In skills/code-review/SKILL.md, extend scenario 2. Complexity and "Good Taste" Assessment with an Unnecessary comments sub-checklist that tells the reviewer to flag and suggest removal of:

  • Comments that restate what the code already says.
  • Comments that narrate the diff / change history ("previously we did X, now we do Y") — that belongs in the PR description / commit message / git blame.
  • Comments that describe non-local behavior (other modules, callers, downstream effects) with no mechanism to stay in sync.
  • Block comments that paraphrase the PR description inline.

…and reserves comments for genuinely unintuitive things (invariants, workarounds, ordering/locking, deliberate trade-offs). Includes the "3-line change should not produce 19 lines of comments" callback from #3498.

Placed under scenario 2 (rather than a new scenario) to avoid renumbering the rest of the framework — it's a natural fit alongside the existing "Missing inline documentation for non-obvious logic" bullet, which it complements.

How to Test

Documentation-only change to a skill prompt. Verified by:

  • Re-reading skills/code-review/SKILL.md to confirm the new bullet is consistent in tone and indentation with the existing list under scenario 2.
  • No code paths exercised; nothing to run.

Related


This PR was created by an AI agent (OpenHands) on behalf of @juanmichelini in response to OpenHands/software-agent-sdk#3498 (comment).

@juanmichelini can click here to continue refining the PR

Add an explicit 'Unnecessary comments' check under the Complexity / Good Taste
scenario so the code-review skill suggests removing noisy or redundant
comments that restate the code, narrate the diff, or describe non-local
behavior. Reserve comments for genuinely unintuitive things.

Refs OpenHands/software-agent-sdk#3498.

Co-authored-by: openhands <openhands@all-hands.dev>
@juanmichelini
juanmichelini marked this pull request as ready for review June 5, 2026 16:04

all-hands-bot commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

✅ Review complete.

This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here.

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

🟢 Good taste — Elegant, simple solution.


Analysis

This PR adds a new review criterion to the code-review skill: flagging unnecessary comments. The change is minimal (6 lines of bullet points), well-targeted, and addresses a genuine problem in code reviews.

What's good:

  • Clear examples of what to flag (self-describing comments, diff summaries, non-local behavior descriptions, PR description paraphrases)
  • Clear guidance on when comments ARE appropriate (non-obvious invariants, workarounds, ordering requirements, deliberate trade-offs)
  • Aligns with the existing philosophy: "When in doubt, prefer restructuring or renaming over commenting"
  • Fits naturally as an extension of section 2 (Complexity and Good Taste Assessment)

No issues found.


[RISK ASSESSMENT]

  • [Overall PR] ⚠️ Risk Assessment: 🟢 LOW
    This is a documentation-only change to a skill prompt file. No code changes, no dependencies, no breaking changes.

VERDICT:
✅ Worth merging — Well-reasoned, targeted addition that improves the reviewer persona without any downside.

KEY INSIGHT:
The guidance correctly identifies that comments which drift out of sync with code (non-local behavior descriptions) are worse than no comments at all.


This review was generated by an AI agent (OpenHands) on behalf of the user through OpenHands Automation. View conversation

all-hands-bot commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

✅ Review complete.

This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here.

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

🟢 Good taste — Elegant, targeted addition.


Analysis

This PR adds a new review criterion to flag unnecessary comments — a genuine pain point in code reviews. The change is well-executed:

What works:

  • Clear, actionable examples: Self-describing comments, diff summaries, non-local behavior descriptions, and PR-description paraphrases are all concrete anti-patterns reviewers can spot.
  • Positive framing: "Reserve comments for genuinely unintuitive things" provides the complementary signal — not just what to remove, but when to keep.
  • Right placement: Fits naturally under section 2 (Complexity and Good Taste) alongside "Missing inline documentation for non-obvious logic" — together they cover when documentation helps vs. hurts.
  • Consistent tone: Matches the existing framework's voice and indentation.
  • Real-world reference: The "3-line change should not produce 19 lines of comments" callback makes it immediately relatable.

No issues found.


[RISK ASSESSMENT]

  • [Overall PR] ⚠️ Risk Assessment: 🟢 LOW
    Documentation-only change to a skill prompt. No code paths, no dependencies, no breaking changes. Directly addresses a reported problem in the SDK's review workflow.

VERDICT:
✅ Worth merging — Concise, well-grounded addition that improves the reviewer persona without downside.

KEY INSIGHT:
The guidance correctly identifies that comments describing non-local behavior (other modules, callers, downstream effects) with no mechanism to stay in sync are worse than no comments — they drift and mislead readers.


This review was generated by an AI agent (OpenHands) on behalf of the user through OpenHands Automation. View conversation

@juanmichelini
juanmichelini merged commit 171a997 into main Jun 5, 2026
4 checks passed
@juanmichelini
juanmichelini deleted the openhands/code-review-flag-unnecessary-comments branch June 5, 2026 16:26
@openhands-release-bot openhands-release-bot Bot added the released: 0.1.0 Shipped in v0.1.0 label Jun 5, 2026
@openhands-release-bot

Copy link
Copy Markdown
Contributor

🚀 Released in v0.1.0.

@openhands-release-bot

Copy link
Copy Markdown
Contributor

🚀 Released in v0.2.0.

@openhands-release-bot openhands-release-bot Bot added released: 0.2.0 Shipped in v0.2.0 released: 0.4.0 Shipped in v0.4.0 labels Jun 5, 2026
@openhands-release-bot

Copy link
Copy Markdown
Contributor

🚀 Released in v0.4.0.

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.

4 participants