Sub topic 8
Reviewing AI-assisted pull requests
This chapter assumes you know the pull request workflow, have reviewed code in a team, and have used an AI coding assistant. It builds on the idea that the author owns the change. Review is where that rule gets tested.
Why review needs adjusting
AI-assisted code often looks polished. It is well formatted, consistently named, and commented. That surface quality can lower a reviewer's guard. The code may still call a function that does not exist, handle only the happy path, or reuse a pattern that is unsafe in your context.
The goal is not a different review process. It is the same standard, applied with attention to the failure modes AI tends to produce.
What to look for
- Plausible but wrong logic. Check edge cases: empty input, null values, off-by-one boundaries, time zones.
- Invented APIs. Confirm that imported packages, methods, and flags exist in the versions you use.
- Security gaps. Look for missing input validation, string-built queries, weak authorization checks, and hard-coded secrets.
- Unneeded code. Assistants tend to add helpers, options, and abstractions nobody asked for. Ask for them to be removed.
- Weak tests. Tests that only repeat the implementation, or assert nothing meaningful, give false confidence.
- Style drift. The change should match your codebase's conventions, not the assistant's defaults.
Shared responsibilities
Reviewers and authors each have a part. The author must read and understand every line before requesting review. The reviewer checks the change against the same standard as any other PR.
| Role | Responsibility |
|---|---|
| Author | Understands every line, ran the tests, filled in the PR template |
| Reviewer | Checks logic, security, tests, and fit with the codebase |
| Code owner | Approves changes in sensitive paths |
| CI | Runs the same tests on every PR |
Route sensitive paths to owners
A CODEOWNERS file requests review from named teams whenever a PR touches certain paths. This applies whether a person or a tool wrote the code.
# .github/CODEOWNERS
/auth/ @example-org/security-team
/payments/ @example-org/payments-team
/.github/ @example-org/platform-team
/docs/policies/ @example-org/engineering-leadsFor the rule to be enforced, enable "Require review from Code Owners" in branch protection. Without it, owner review is only a suggestion.
Use the PR template as a review aid
The template tells the reviewer what the author claims to have done. A reviewer can then check those claims.
## How I verified it
- [ ] I read and understand every line in this PR
- [ ] I ran the tests locally
- [ ] New or changed behavior has testsA review flow
Common errors
- Reviewing only the diff's style. Clean formatting says nothing about correctness. Read for behavior.
- Accepting "the AI wrote it" as an explanation. If the author cannot explain a line, the PR is not ready.
- Reviewing very large generated PRs in one pass. Ask the author to split them. Large diffs hide problems.
- Treating passing CI as approval. Tests show only what they cover.
Exercise
A teammate opens a 900-line PR that an assistant mostly generated. CI passes and the code is neatly formatted. Name two reasons you should still review it carefully, and one action you could take as the reviewer.
Show answer
Passing CI only shows that the existing tests pass, and neat formatting says nothing about correct logic, invented APIs, or security gaps. Generated code can also include unneeded abstractions or weak tests. As reviewer, you could ask the author to split the PR into smaller changes, or ask them to explain specific non-obvious lines before you continue.