New Tool Radar

AI Agents & Automation

How to Build a Code-Review Agent That Checks Pull Requests

Build a code-review agent that checks pull requests against a written checklist, so every review covers the same ground.

Schematic illustration with three step boxes: write the review checklist, run it on each pull request, and post findings as comments.

A code-review agent is useful when its checks are written down: the same checklist on every pull request, the same severity labels, and the same rule about what blocks a merge. Without a checklist, the agent reviews a different thing each time, and the team cannot tell whether a clean review means clean code or a lazy agent.

Before you start

A repository the agent can read, pull requests to review, and a written review checklist.

Write the review checklist

Write the checks the agent must run: tests pass, no secrets committed, no new dependencies without a reason, error handling on every new call, and the change matches the pull request description.

Give each check a severity: block means the pull request cannot merge, warn means it should be fixed, note means it is a suggestion.

Run the checklist on each pull request

On each pull request, run the agent over the diff only, not the whole repository: the review is about what changed. Record which checks passed, which warned, and which blocked.

Run the tests as part of the review when you can: a review that does not run the tests cannot know whether the change breaks them.

Post the findings as comments on the code

Post each finding as a comment on the exact line it concerns, with the check name, the severity, and the suggested fix. A finding without a line number is hard to act on.

Never let the agent merge a pull request itself: the review is advice, and a human decides whether to merge.

Practice check: fictional Maple Corner pull request, 4 files changed, 120 lines

The table below is fictional practice material, worked out by hand from the stated checklist. It is the expected result for the practice review, not a run of any agent.

Check Result Severity Verdict
Tests pass Pass Block if fail Pass
No secrets committed Pass Block if fail Pass
Error handling on new call Missing Block Fail – blocks merge
New dependency justified Yes Warn Pass
Matches description Yes Warn Pass

Four of five checks pass, but the missing error handling on a new call blocks the merge. The finding is posted on the exact line, with the fix suggested.

Expected result. UNTESTED: the checks in the practice table are worked out by hand, not measured by running an agent. Write your own review checklist with severities, run it on a real pull request, and post each finding on the exact line it concerns.

Limits

  • The agent reviews; a human merges. Never let the review agent merge a pull request itself.
  • Review the diff, not the whole repository: the review is about what changed.

Sources

See all