Have an agent review your pull request before a person does

Catch style nits, missing tests, and logic gaps before your teammate sees the PR, so human review focuses on design.

For anyone who opens pull requests · 8 steps · 7 min

How it works today.

You push a branch, open the pull request, and tag a reviewer. Two hours later they comment that you forgot to update the test fixture, left a debug log statement, and used a variable name that clashes with the module three files over. You fix all three in ninety seconds, push again, and wait for another review cycle.

The back-and-forth is worst when the PR is large or touches unfamiliar code. You know a second pair of eyes would have caught the obvious stuff before you hit 'create', but re-reading your own diff feels like looking at a blank wall—your brain skips what it just wrote.

Before you start.

All of it has to be true, or step one fails in a way that is annoying to debug.

  • A GitHub, GitLab, or Bitbucket account where you open pull requests.
  • API access to your repository host, usually a personal access token with read:repo and write:discussion scopes.
  • An agent platform account (Wordware, Dust, Relevance AI, or similar) that can call your repo API and accept a diff as input.
  • Write access to create or edit an agent workflow in that platform.
  • The agent must be able to read your repository's contribution guidelines, style guide, or linting config if you want it to enforce them.

The steps.

  1. Create a new agent workflow and connect your repository

    In your agent platform, start a new workflow and add your repository host as a data source. Paste your API token when prompted. Confirm the agent can list branches and read diffs by testing the connection against a recent closed PR. If your repo is private, check that the token scope includes private repositories.

  2. Configure the agent to fetch the PR diff and metadata on demand

    Set the workflow trigger to manual or API call—you will invoke it from a script or CI step, not on every commit. The agent should accept a PR number or URL as input, fetch the full diff, the PR description, and the list of changed files. Test this by passing a known PR number and confirming the agent returns the correct file list.

  3. Write the review prompt with your team's checklist

    Give the agent a prompt that mirrors what a human reviewer checks first: test coverage for new functions, whether the PR description matches the code changes, adherence to naming conventions, and any obvious logic errors. Include a link to your style guide or paste the relevant section. Tell the agent to output a markdown list of issues, each with the file name and line number.

    Paste this
    You are reviewing a pull request. Check: (1) every new function or method has a corresponding test, (2) variable and function names follow [your team's naming convention], (3) the PR description accurately describes the code changes, (4) no debug statements or commented-out code remain, (5) no obvious logic errors like off-by-one loops or unhandled null cases. For each issue, cite the file and line number. If everything looks good, say 'No issues found.' Do not approve or reject the PR.
  4. Add a step to check for missing documentation

    Extend the prompt or add a second agent step to scan for new public functions, API endpoints, or configuration flags that lack docstrings or README updates. If your project has a docs folder, the agent should check whether a new feature appears in the changelog draft. This catches the 'works fine but nobody knows it exists' problem.

    Paste this
    List any new public functions, classes, or API routes in this diff that do not have a docstring or equivalent inline documentation. Also check if [your docs folder or CHANGELOG file] mentions this change. If a new feature is added but not documented, flag it.
  5. Run the agent on a closed PR and compare its output to the actual review comments

    Pick a merged PR where a reviewer left several comments. Feed it to the agent and see if it flags the same issues. If the agent misses something your team cares about, add that rule to the prompt. If it flags things you ignore, tell it to skip those. Iterate until the agent's output matches the first-pass comments you wish you had written yourself.

  6. Integrate the agent into your pre-review routine

    Before you tag a human reviewer, run the agent manually or via a CLI script that calls the agent API with your PR number. Read the agent's output, fix the issues it found, and push the fixes as a new commit. Only then assign the PR to a person. If your CI system supports it, add the agent as a non-blocking check that posts results as a PR comment, but do not make it a required status—humans still merge.

  7. Set up a feedback file for false positives

    Create a shared document or a pinned issue where your team logs cases where the agent flagged something that was actually fine, or missed something important. Review this file monthly and update the agent prompt with the patterns that recur. If the agent complains about a style choice your team has since adopted, remove that rule. This keeps the agent in sync with how your standards evolve.

  8. Tune the agent's sensitivity to PR size

    Large PRs need different scrutiny than two-line fixes. Add logic or a separate prompt variant that checks architectural concerns when the diff exceeds a threshold—say, ten files or three hundred lines. For small PRs, focus the agent on formatting and test presence. If your platform supports conditional steps, branch the workflow based on the file count the agent fetched earlier.

    Paste this
    This PR changes more than ten files. In addition to the standard checks, verify: (1) the change is scoped to one logical feature or fix, (2) no unrelated refactoring is bundled in, (3) the commit history is clean or a squash plan is noted in the description. If the PR is too broad, suggest splitting it.

What you keep.

Automating the typing does not move the accountability. These stay with a person.

  • Deciding whether the PR solves the right problem or introduces acceptable trade-offs—agents read diffs, not product strategy.
  • Final approval and merge. The agent's review is a checklist pass, not a gate. A human confirms the code is correct and safe to ship.
  • Judging when to override the agent's feedback. If it flags something you intentionally did for a reason the agent cannot know, you explain that in a comment and move on.
  • Updating the agent prompt when your team's standards or architecture change. The agent does not learn from merged PRs unless you teach it.

Once it works.

The first run is the demo. These are where the time actually comes back.

Fire it from an event

Run the agent automatically when a PR moves from draft to ready-for-review, posting results as the first comment so you can fix issues before tagging a person.

Run it on a loop

After you push a fix in response to the agent's feedback, re-run the agent on the updated diff to confirm you addressed everything and did not introduce new issues.

Hand off to another agent

If the agent finds zero issues on three consecutive PRs from the same author, skip the agent step for that author's next small PR and route straight to human review, reducing latency for trusted contributors.

Scale it wider

Run the agent nightly against all open PRs older than two days that have no review comments yet, posting a summary in Slack so you know which PRs are waiting on trivial fixes versus real design questions.

The work this replaces.

These are the O*NET work activities this workflow covers, and the categories of tool that address them.

Addressed by vertical agents, eval and observability, tools and auth