Sub topic 13
Using AI as a Second Reviewer, with Limits
This chapter assumes you can read a Git diff, run unit tests, and have used an AI coding assistant. It also assumes you have read the earlier chapters on failure modes, tests as evidence, and static analysis.
A second AI pass can find problems you missed. It cannot prove the code is correct. Treat it as a cheap extra reader whose claims you must check.
What a second pass is good for
A reviewer model reads the diff with fresh context. It has not seen the reasoning that produced the code, so it is less likely to repeat the same blind spot. It is useful for:
- Listing edge cases you did not think of, such as empty input,
None, or very large values. - Pointing at suspicious lines, such as string-built SQL or a swallowed exception.
- Comparing the code to the requirement and noting what is missing.
- Suggesting test cases to write.
It is weak at anything that needs execution. It cannot reliably tell you the code runs, passes the tests, or that an imported package exists in your environment.
Why it is not proof
The reviewer shares the author's weaknesses. Both can invent APIs, and both can approve plausible code. If the same model wrote and reviewed the change, it may repeat the same mistake. A review that says "looks good" is not evidence. A failing test, a type error, or a linter warning is.
The reviewer can also produce false alarms. It may flag correct code or cite a problem that does not exist. Every finding needs a check against the real code.
A workflow that keeps you in control
- Run your own review first, using the checklist from the previous chapter.
- Give the second reviewer the requirement and the diff, not only the code.
- Ask for specific output: concrete failure inputs, not general praise.
- Verify each finding by running code or reading the source.
- Turn confirmed findings into tests.
git diff main...HEAD > change.diffThen use a prompt such as:
Requirement: average() must return the mean of a list of numbers.
Review the attached diff. List inputs that would make it fail or
behave unexpectedly. For each, give the input and the expected
outcome. Do not say the code is correct.The last line matters. Asking for failures pushes the reviewer to search instead of approve.
Verify the findings
Suppose the reviewer says average([]) raises an error. Do not take its word for it. Run it.
def average(values):
return sum(values) / len(values)
try:
average([])
except ZeroDivisionError as error:
print("confirmed:", error)The output is confirmed: division by zero. The finding is now evidence, and you can write a test for it. If you cannot reproduce a claim, treat it as unconfirmed and do not act on it.
Limits to keep in mind
| Limit | What to do |
|---|---|
| Reviewer misses real bugs | Keep your own review and the tests as the main gate |
| Reviewer invents problems | Reproduce each finding before acting |
| Same model has the same blind spots | Use a different model or a fresh session when you can |
| Diff has secrets or private code | Check what your tool sends to the model before you paste it |
Exercise
An AI reviewer says "This function looks correct and handles all cases." Why is this not enough to accept the change, and what would you do next?
Show answer
The statement is an opinion, not evidence. The reviewer cannot run the code and may share the author's blind spots. Next, do your own review, ask the reviewer for specific failing inputs, run those inputs, and add tests for any confirmed problems before deciding.
Exercise
The reviewer claims a function fails on negative numbers, but you cannot reproduce it. How should you treat the claim?
Show answer
Treat it as unconfirmed. Try a few more inputs and read the code path. If you still cannot reproduce it, drop the finding or note it as unverified, and do not change the code on its basis.