Shattered Vales Studio Inc.

Reviewing AI-Generated Code

AI agents can produce a complete, tidy-looking pull request in minutes. That speed shifts the hard work to the reviewer. AI code fails in different ways from human code: it's rarely sloppy, but it can be confidently, plausibly wrong. This guide builds on Conducting Effective Code Reviews with what to check specifically when a machine wrote the code.

Step 1: Hold It to the Same Bar, with More Skepticism

Step 2: Check the Scope First

Before reading any code, compare the list of changed files with the issue. Agents eagerly "improve" things they pass on the way, and an unrelated change buried in a big diff is easy to miss.

gh pr diff 123 --name-only       # every changed file
gh pr view 123                    # the description and linked issue

Ask for out-of-scope changes to be removed, not just justified. They can become their own issues.

Step 3: Know the AI Failure Modes

Failure modeWhat it looks like
Invented APIsCalls to methods, parameters, or config options that don't exist, or that existed in an older version of the library.
Plausible but wrong logicCode that reads naturally but has an off-by-one error, inverted condition, wrong time zone, or wrong rounding.
Tests that don't testAssertions that can't fail, tests that mock the very thing under test, or expected values copied from the code's own output.
Making the checks pass instead of the code workWeakened or deleted assertions, skipped tests, broadened catch blocks, disabled lint rules, or special cases for test inputs.
Swallowed errorstry/catch that logs and carries on, or default values that hide failures.
Reinventing existing codeA new helper that duplicates a utility already in the codebase, because the agent didn't find it.
Missing contextCode correct in isolation that breaks a project invariant: no tenant filter, wrong layer, ignores the architecture document.
Misleading commentsComments or PR descriptions that claim something the code doesn't do.

Step 4: Prove the Tests Actually Test

A test only has value if it fails when the code is wrong. The quickest check: put the old version of the code back while keeping the new tests, and run them. If they still pass, they aren't testing the change.

gh pr checkout 123
git restore --source=origin/Dev -- src/Inventory/ItemSorter.cs   # old implementation, new tests
dotnet test --filter "FullyQualifiedName~ItemSorterTests"          # these should now FAIL
git restore -- src/Inventory/ItemSorter.cs                          # put the PR's version back

Also read the test names and assertions against the issue's acceptance criteria. Each criterion should have a test that would catch it being broken, including the edge cases the issue lists.

Step 5: Verify Every New Dependency

AI tools sometimes suggest packages that don't exist, are abandoned, or have names close to a popular package. Attackers publish malicious packages under exactly those names. For every new or upgraded dependency in the diff, including lockfile changes:

  1. Find the package on its official registry (NuGet, npm, the Unity registry) and confirm it's the real, well-known one: publisher, download count, source repository.
  2. Check it's actively maintained and its license is compatible with the project.
  3. Ask whether it's needed at all. A dependency for ten lines of code is rarely worth it.

Step 6: Feed Problems Back to the Agent

Leave review comments exactly as you would for a person: specific, with the reason and the expected fix. Then decide how to proceed:

Reviewer checklist for AI-generated pull requests:

- [ ] Changed files match the issue's scope; no unrelated edits
- [ ] Every API and method used exists in our versions of the libraries
- [ ] Logic checked against the acceptance criteria, including edge cases
- [ ] Tests fail when the change is reverted
- [ ] No weakened tests, skipped checks, or broadened catch blocks
- [ ] Errors are handled, not swallowed
- [ ] Reuses existing utilities; no duplicate helpers
- [ ] Project invariants respected (tenant scoping, layers, ARCHITECTURE.md)
- [ ] New dependencies verified as real, maintained, and needed
- [ ] Comments and PR description match what the code actually does