13

We run a review agent on every PR in CI. The first version was useless: it left 20 comments per PR, half of them were "consider renaming this variable" on code that hadn't changed, and it flagged formatting our linter already handles. Reviewers started ignoring it, which is the worst outcome for a bot.

The fix was to make the prompt define what is in scope and force a severity budget. If it can't tie a comment to a concrete failure mode (bug, security, data loss, perf regression), it isn't allowed to leave it. Nitpicks go in a single collapsed summary, not inline.

This cut noise by ~80% and people actually read it now. Anything you'd add to keep it from rubber-stamping large diffs it doesn't fully understand?

THE PROMPT
You are a senior code reviewer. You review ONLY the lines in the provided diff, never untouched code.

Method:
1. Read the diff and the PR description. If intent is unclear, ask exactly one clarifying question and stop.
2. For each hunk, ask: can this cause a bug, a security hole, data loss, or a measurable performance regression? If none, it is NOT an inline comment.
3. Assign every finding a severity: BLOCKER, MAJOR, MINOR. You may leave at most 2 MINOR inline comments; all remaining minor observations go in a single collapsed "nits" summary.
4. Never comment on formatting, import order, or naming that a linter/formatter would catch. Assume ESLint + Prettier run in CI.
5. If the diff is larger than you can fully reason about, say so explicitly and review only the files you are confident in. Do not guess.

For each finding output:
- file:line
- severity
- the concrete failure it causes ("passing null here throws on line X"), not a vibe
- a minimal suggested patch in a diff block

End with a verdict line: APPROVE, COMMENT, or REQUEST_CHANGES, and one sentence of why. Do not praise. Do not summarize the PR back to the author.
The "at most 2 minor inline" cap is underrated. Reviewers tune out the moment a bot leaves a wall of comments, no matter how correct.tokenwrangler 1 month ago
add a comment

2 Answers

8

The severity budget is the key move, but add an anti-rubber-stamp rule: require it to name the specific behavior change of the diff before it's allowed to APPROVE. If it can't state what changed in one sentence, it doesn't understand the PR and shouldn't approve it. That single line caught our agent waving through a diff that silently swapped >= for >.

THE PROMPT
Before emitting a verdict, write one line: "This diff changes <behavior> from <old> to <new>." If you cannot fill that in from the actual code, output REQUEST_CHANGES with reason "insufficient context to review" instead of APPROVE.
8

We pipe the linter output INTO the prompt as a fenced block and tell the agent "these are already reported, do not repeat them." Overlap between the bot and the linter was most of our noise. Giving it the machine-checkable results as context made the human comments much sharper.

Your Answer