Reviewing AI-Generated Pull Requests: A Commented Checklist for Human Reviewers

Close-up photo of a closed padlock

Reviewing an AI-generated pull request needs three checks a human-written one usually doesn’t: whether every dependency it added actually exists and is the real package, whether claims in the PR description about what was tested are actually true, and whether a suspiciously confident comment or docstring is describing behavior the code doesn’t actually have. None of these show up as a diff problem — the code can look completely reasonable and still fail all three, which is what makes them easy for a reviewer moving quickly to miss entirely.

Close-up photo of a closed padlock
Image: ImagePerson, CC BY-SA 4.0, via Wikimedia Commons

Check 1: Does every new dependency actually exist?

AI coding tools sometimes recommend a package name that sounds plausible but doesn’t exist — a pattern researchers call “slopsquatting,” where an attacker pre-registers the hallucinated name on a real package registry before anyone else can, so the next person who copies the suggestion installs the attacker’s code instead of a 404. This isn’t a theoretical risk: a 2025 USENIX Security study (Spracklen et al., “We Have a Package for You!”) tested 16 code-generating models across 2.23 million code samples and found 19.7% contained at least one hallucinated package name, with commercial models averaging 5.2% and open-source models averaging 21.7% — a gap worth knowing if your team mixes a commercial assistant for most work with an open-source model for cost-sensitive tasks. Worse, 43% of hallucinated names reappeared consistently when the same prompt was run ten times — meaning a hallucination isn’t always a one-off fluke you’d catch by chance on a second look. The same study broke the hallucinated names down by type: 51% were pure fabrications with no real analog, 38% conflated two real package names into one that doesn’t exist, and 13% were typo-like variants of a real name — the last category being the hardest for a quick visual check to catch, since it looks almost identical to the legitimate package it’s standing in for.

  • Every new import or dependency line gets checked against the real registry (npm, PyPI, crates.io, etc.), confirming it resolves to an actual package, not just that the install command runs without error.
  • A newly added dependency’s publish date and maintainer history get a second look if it was registered recently or has very few downloads — a common signature of a squatted package rather than an established one.
  • Lockfiles are committed and diffed, not just the manifest file, so a change to a transitive dependency doesn’t slip through unreviewed.

Check 2: Does the PR description claim something the diff doesn’t support?

A model asked to summarize its own change will sometimes describe testing it didn’t run, or state a behavior the code doesn’t actually implement — the same overconfident-but-wrong pattern covered in reducing AI hallucinations with better prompts, applied to the PR description itself rather than to application output. A description that says “added tests for the empty-input case” is a claim to verify against the actual diff, not a fact to take at face value just because it reads fluently and the author is usually right about this kind of thing.

  • Every testing claim in the description has a matching test in the diff. If the description says a case is covered, find the actual assertion, don’t take the sentence as the evidence.
  • The description’s summary of the change matches its actual scope. A model that was asked to fix one bug sometimes refactors adjacent code along the way; a reviewer scanning only the summary can miss that the real diff is bigger than described — our guide on writing commit messages and PR descriptions the model can actually use covers prompting for a description that matches scope in the first place, which makes this check faster but doesn’t replace it.

Check 3: Do comments and docstrings describe real behavior?

A generated docstring can describe what a function is supposed to do, written confidently, while the actual implementation does something subtly different — a mismatch that’s easy to miss because the comment reads as documentation rather than as a claim requiring verification. This is a close cousin of the pattern in our flaky test suite debugging case study: a plausible-sounding explanation and a correct one aren’t the same thing, and the gap between them doesn’t announce itself.

  • Spot-check at least one nontrivial docstring or comment against its actual function body, rather than assuming the two always agree.
  • Edge cases the comment claims are handled get a specific test or a manual trace, not just a visual confirmation that an if statement exists somewhere nearby.

The checklist in full

  • Every new dependency resolves to a real, correctly-named package on the actual registry — not assumed from the import statement alone.
  • Recently-published or low-download dependencies get a manual look at maintainer and registration history.
  • Lockfile changes are reviewed, not just the manifest.
  • Every testing claim in the PR description has a corresponding test in the diff.
  • The description’s stated scope matches the diff’s actual scope.
  • At least one nontrivial docstring or comment is checked against its function’s real behavior.
  • Edge cases claimed as “handled” have an actual test or trace, not just a visible conditional.
  • CI passing is treated as one signal among several, not as a substitute for the checks above — a green pipeline confirms the code runs, not that it’s correct, secure, or does what the description says.

Walking the checklist through one PR

Take an illustrative example: an AI assistant opens a PR that adds retry logic to a flaky API call, importing a small helper package for exponential backoff, and describing itself as “tested against the timeout and connection-reset cases.”

Check 1 means confirming the backoff package’s name resolves on the actual registry the project uses, not just that npm install or pip install completed without an error locally — a squatted package installs successfully too, which is exactly what makes it dangerous. Check 2 means opening the test file the PR touched and confirming there are assertions for both the timeout case and the connection-reset case specifically, not a single generic retry test that happens to touch similar code. If only the timeout case has a real test, the description overstates coverage, regardless of how confidently it was written. Check 3 means reading the new retry function’s docstring against its actual backoff calculation — a common AI-generated mismatch is a comment describing exponential backoff while the code actually implements a fixed delay, because the function was adapted from a template without updating the comment to match.

None of these three checks would show up by reading the diff top to bottom at normal reading speed. Each one requires deliberately cross-referencing a specific claim — a package name, a tested case, a described behavior — against an independent source of truth: the registry, the actual test file, the actual implementation.

Common mistakes

  • Rubber-stamping because the diff looks clean. Clean formatting and a plausible structure are not correctness signals — a hallucinated package name looks exactly like a real import line.
  • Reviewing the description instead of the diff. A fluent, well-organized PR description is easier to trust than it should be; it’s a summary written by the same system that wrote the code, not an independent check on it.
  • Treating this checklist as additional work instead of a replacement for assumptions you were already making implicitly. Most human-written PRs get an informal version of these same checks from a reviewer who already knows the codebase; the difference with AI-generated code is that the usual shortcuts (trusting a familiar contributor’s judgment, assuming they’d have mentioned it if something was untested) don’t transfer.

FAQ

Does this checklist apply differently to a PR an AI drafted versus one an AI coding assistant helped a human write interactively?

The dependency and comment checks apply the same way regardless of how much human interaction shaped the final diff, since a hallucinated package name or a stale docstring can survive an interactive session just as easily as a fully autonomous one. The description-accuracy check matters somewhat less when a human wrote the final PR description themselves in their own words, since that removes one layer of unverified AI-generated claims — though it’s still worth confirming the human description accurately reflects what ended up in the diff after iteration.

Should a tool automate the dependency-verification check instead of a human doing it manually?

Where possible, yes — a CI step that checks every new dependency against the real registry and flags recently-registered packages scales much better than a human remembering to do it on every PR. The research note behind the slopsquatting statistics above specifically recommends this kind of automated allowlisting and registration-date flagging. Automating the check doesn’t remove the need for a human to review the result, since a legitimate new dependency will still trigger the same automated flag as a malicious one and someone has to tell them apart, usually by checking the same registration-date and maintainer signals a human reviewer would check manually.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top