← Tous les articles

Using AI to review a pull request: what it catches and what it misses

A coding assistant can spot slips in a pull request before a human reviewer does, as long as you give it the right context and check every finding.

Using AI to review a pull request: what it catches and what it misses

Key points

  • AI review works as a first pass, never as the final sign-off.
  • Give it the goal of the PR and a specific checklist, not just the diff.
  • Demand file, line and a triggering scenario for each finding, then verify them one by one.

In small teams, code review is often the bottleneck: the only other developer is busy and the pull request sits for two days. Clients keep asking whether an AI assistant can take that job. We’ve been using one on our own projects for a while, alongside human review. Here’s how we go about it, and above all what not to expect.

Start with a readable diff

A 3,000-line diff that’s half lockfile gets a shallow review. Strip out everything generated first:

# The branch diff, minus generated files
git diff main...HEAD -- . ':(exclude)package-lock.json' ':(exclude)composer.lock' 
  ':(exclude)*.min.js' ':(exclude)build/*' > pr.diff

# Files touched, to give the diff some context
git diff --stat main...HEAD

If the PR is still huge, that tells you something: split it. Any review, human or not, is far better on 200 coherent lines. And before pasting a diff into an external tool, check it holds no API keys, passwords or customer data.

Give context and a specific brief

A diff alone doesn’t say what the code is meant to do. A vague “review this code” mostly yields style nitpicks and generic advice. We use a template along these lines:

Context: WordPress plugin, PHP 8.1, WordPress Coding Standards.
Goal of this PR: let customers cancel an appointment up to 24 hours beforehand.

Review this diff and report only:
1. security issues (nonce checks, capabilities, escaping, SQL);
2. unhandled edge cases (null values, time zones, double submits);
3. code that contradicts the goal above.

For each finding: file and line, the problem, a scenario that triggers it.
No style comments. If you're unsure, say so.

<paste diff here>

Asking for a concrete scenario per finding makes a real difference: a finding you can’t illustrate is usually wrong, and the model admits doubt more readily when you explicitly invite it to.

What it’s good at

On our projects, the useful findings tend to be:

  • unescaped output, or SQL built by string concatenation;
  • a missing nonce or capability check in a new handler;
  • an unhandled null, or a loop that never considers the empty array;
  • an error message or condition that contradicts the stated goal.

Those are exactly the slips a tired reviewer waves through at the end of the day. Fixing them first leaves the human review free to focus on design and behaviour.

What it misses, or makes up

The assistant only sees what you show it. It doesn’t know the function you changed is called from three other places, that the table holds millions of rows in production, or that the client has an unusual business rule. It will also, now and then, confidently flag a problem that isn’t there, or refer to a WordPress function that doesn’t exist under that name.

Our rule: every finding is checked in the code before it’s fixed, and the AI never approves a PR. Merging stays the call of a developer who knows the project.

FAQ

Can we automate this on GitHub?

Yes, several tools post findings straight onto the PR. Start by hand to tune your brief: automating a poorly tuned prompt just multiplies the noise.

Is it enough for a solo developer?

It beats nothing and it does catch real mistakes. For sensitive code such as payments, permissions or personal data, an outside human review is still worth it.

Working solo or in a small team and want a second pair of eyes on your code? We run code reviews and security audits for WordPress and PHP projects.

Partager LinkedIn Facebook X WhatsApp
</>

webtestudio

Agence web : sites WordPress sur mesure, thèmes premium et logiciels SaaS.

Parler de votre projet →