DEV Community

Sandscale
Sandscale

Posted on Originally published at sandscale.dev

A checklist for reviewing a pull request an AI agent wrote

Reviewing a pull request from a colleague, you lean on context: you know how they work, what they were asked to do, and where they usually cut corners. A PR from a coding agent has none of that. It is often tidy, confidently described, and correct-looking at a glance, which is exactly why it needs a different kind of attention.

This is the checklist we use. It is ordered by where problems tend to hide, not by file order.

Before reading the code

1. Re-read the task. Write down, in one sentence, what the PR should do. Agents drift: asked to fix a failing test, they sometimes change the test. Asked to add a feature, they sometimes refactor three modules on the way. Your one sentence is the yardstick for the rest of the review.

2. Read the diff stats. Which files changed, and how many lines? A bug fix that touches 30 files, or a change to a lockfile in a PR that should not need new dependencies, tells you where to look before you read a line.

3. Distrust the description. The PR description is generated by the same process that wrote the code. Treat it as a claim to verify, not a summary to trust. "All tests pass" means nothing until CI says so.

The lines that deserve the most suspicion

4. Dependency changes. Any new entry in package.json, requirements.txt, go.mod, Cargo.toml or similar. Check that the package exists, is the one you think it is, and is not a near-miss of a popular name. Read the lockfile diff for unexpected transitive additions. Models sometimes recommend packages that do not exist, and attackers register those names; see our post on what can go wrong when agents install packages.

5. Tests that changed alongside the code. If a test and the code it tests both changed, read the test change first. Was an assertion weakened, a case deleted, an expected value updated to match new output, or a test marked as skipped? "Fixing" a failure by changing the expectation is one of the most common agent shortcuts.

6. Error handling. Look for new try/catch or except blocks that swallow errors, broad exception types, and fallbacks that return a default value on failure. These make tests pass and hide real problems.

7. Configuration, CI and build files. Changes to CI workflows, Dockerfiles, build scripts, linters and their config. An agent that disables a lint rule or a CI step to get green has removed a check, not passed it. A CI workflow change can also grant new permissions or expose secrets to new steps.

8. Anything touching auth, permissions or secrets. New environment variables, credential handling, permission checks, CORS settings, token scopes. Read these line by line, whatever their size.

9. Code that talks to the outside. New network calls, URLs, webhooks or telemetry. Ask why each one is there and where the data goes. A hardcoded URL to a host you do not recognize is a stop-and-ask moment.

10. Shell and SQL built from strings. Any command line or query assembled with string formatting or concatenation. Agents reach for the quick version; make sure inputs are passed as arguments or parameters, not pasted into the string.

Correctness checks that agents trip on

11. Invented APIs. Calls to functions, options or flags that look plausible but do not exist in the version you use. Type checks and compilers catch many of these. Dynamic languages and config files often do not, so check unfamiliar options against the library's docs for your version.

12. Edge cases in the happy path. Agents tend to handle the example from the task well. Ask about empty input, very large input, concurrent calls, time zones and Unicode.

13. Dead and duplicate code. Helper functions that already exist elsewhere in the codebase, or new code that nothing calls. Both are signs the agent did not find the existing pattern.

14. Comments that do not match the code. A comment describing what the code was supposed to do, left over from an earlier attempt, misleads the next reader.

Before you approve

15. Run it, but not on your laptop. Check out the branch and run the tests yourself, or confirm CI did. Do it somewhere disposable: the PR's code, its tests and its install scripts are all code you have not fully read yet. Our post on running untrusted PR code in sandboxes shows one way to do that.

16. Try to break the change. Spend five minutes on the one input most likely to fail. If you found nothing in the whole review, this is where something usually turns up.

17. Check the size of the blast radius. If this change is wrong, what breaks, and how would you find out? If the answer is "silently, in production, weeks from now", ask for a test that would catch it.

18. Decide with a reason. Approve, request changes, or close. If you close, say why in a line the next agent run or the next person can use.

Make the checklist cheaper over time

A checklist that lives in someone's head gets skipped on a busy day. Some items automate well:

  • Fail CI when a lockfile changes without a matching manifest change, or flag new dependencies for a named reviewer.
  • Use code owners for CI config, auth code and dependency files, so those changes always reach the right person.
  • Lint for swallowed exceptions and skipped tests.
  • Run every agent PR's code in an isolated environment by default, so "run it" never means "run it on a laptop".

The rest needs a person who knows what the PR was meant to do. That is the part of review an agent cannot do for itself.

Originally published on the Sandscale blog.

Top comments (1)

Collapse
 
userxnom profile image
Abdullah Naseer •

Item 5 is the one I have seen bite people most — a test and the code it tests changing together, with an assertion quietly weakened. Do you have a quick way to spot that in the diff, short of reading both files line by line? I have started looking at test changes first, as you suggest, but a loosened assertion can still look like a reasonable update at a glance. Curious whether you diff the expected values separately or rely on CI coverage to catch it.