CertPrep
Domain 8 · Lesson 8.2 · 7 min read

Verification and AI Code Review

Exam skillVerification and AI Code Review Operations

Analyzing verification operations in delivery pipelines where generation outpaces review, including AI code review introduced in shadow mode, calibration against human review before merge gating, and human oversight design.

When agents write code faster than people can review it, give agents feedback loops that verify their own work, protect the checks from the agent, introduce AI code review in shadow mode and calibrate it against human review before it gates merges, and keep a human approver.

What you need to know

When generation outpaces review, the reviewer becomes the bottleneck, and the temptation is to trust summaries, skip review for small changes or let automated review approve. Verification operations keep quality while throughput grows: the agent checks its own work before anyone sees it, the checks cannot be weakened by the agent, AI review earns authority through calibration, and a human stays accountable.

Feedback loops for the agent

Give every session a way to verify its own work before reporting done:

  • one command for tests and one for the build, each exiting non-zero on failure, listed in CLAUDE.md with examples of healthy output;
  • a quantifiable target ("all tests in test_status.py pass");
  • for UI work, a browser or screenshot tool and a mock to compare against;
  • for bug fixes, write the failing test first, confirm it fails for the expected reason, commit it, and only then ask for the fix.

Protect the check

An agent fixing code must not be able to weaken the check on that code. A fix that edits a failing test's expected value to match buggy output "passes". Prevent it with a hook that blocks edits to test files during fix tasks, or reject any fix that touches the test in review. An instruction in CLAUDE.md is advisory.

Make tests a gate, not a promise: a Stop hook runs the suite and refuses to end the turn on failure (exit 2 feeds the failure back so the agent fixes it), and a PostToolUse hook lints and type-checks after edits.

Verify in proportion to supervision

How the run happenedVerification
Watched closely in a short sessionA quick read of the diff
Unattended, overnight or in CIStart from the diff, not the summary; check the JSON result and exit status; tests enforced by hook; a fresh reviewer (a separate session with no memory of writing the code) for anything that matters

A tidy summary can hide a change to a file nobody expected the agent to touch. Small changes can still break critical paths.

AI code review: from shadow to gate

StageWhat happensMoves on when
ShadowAI review runs on every pull request; findings are compared with human reviewsPrecision and recall are measured
AdvisoryFindings posted for authors and reviewersEngineers act on them; noise is low
GateSeverity counts feed a merge rule the team buildsPrecision on blocking-level findings is acceptable, and recall on serious defects is known

Two measures decide gating: precision of the findings that would block (share confirmed real by humans) and recall on serious defects (share of human-found serious issues it also found). Comment volume, speed and unverified opinions do not.

A managed AI review service posts ranked findings; it does not approve, block or push fixes. Teams keep branch protection and code-owner approval, and can build a merge gate on its findings once they trust them.

Keeping review useful

If many findings are style comments, engineers stop reading all of them, including real bugs. Tune the review policy: reserve high severity for defects that would break behavior, leak data or breach policy; cap low-priority comments; exclude generated files and what CI already enforces. When review flags the same mistake twice, add the correction to CLAUDE.md so the next pull request avoids it.

Human oversight and separation of duties

The agent that wrote the code cannot approve it. Branch protection requires a human code owner, and no agent identity can approve or merge its own pull requests. Engineers who directed the agent are its authors in effect and should not self-approve. Tests and AI review inform the approval; they do not replace it.

In the exam

Verification items describe a pipeline where agents produce lots of code, and a quality problem or a proposal to automate review. Pick the control that verifies before humans look, protects the check, calibrates AI review before giving it authority, or keeps a human approver distinct from the author. Distractors trust summaries, make AI review required on day one, let it approve, skip review for small diffs, or rely on CLAUDE.md rules.

Check your understanding

Question 1

A team wants AI review to block merges eventually but fears false positives. What rollout fits?

Show answer

Answer: C. Calibration against human review comes before gating authority.

Question 2

An agent made a failing test pass by editing its expected value. What prevents this?

Show answer

Answer: D. The check on the code must be out of the agent's reach; a rule in CLAUDE.md can be ignored.

Question 3

Which two measures should decide whether AI review can gate merges?

Show answer

Answer: B. Gating depends on how often blocking findings are right and how many serious defects it catches.

Apply it: Calibrate Riverbend's AI code review

Exercise · about 25 minCase: Riverbend Software

Riverbend's managed AI review runs on 60 repositories but is not a required check. Engineers mark 46% of its findings "not useful", mostly style comments. Agent-authored pull requests have a first-pass CI success rate of 64%. The VP wants AI review to block merges within a quarter.

  1. Design the shadow-mode study and what it measures.
  2. Tune the review policy to fix the noise.
  3. Improve agents' first-pass success before code reaches review.
  4. State the conditions for gating, and what stays human.
Check your work
Show model answer

1. Shadow study. For six weeks, compare AI findings with human review on 400 pull requests across 10 representative repositories. A tech lead labels each AI finding as confirmed or not, and each human-found serious defect as caught or missed by the AI. Report precision by severity and recall on serious defects, by repository type.

2. Policy. Update REVIEW.md: severity "Important" only for defects that break behavior, leak data or breach policy; style findings are nits, capped at five per review and summarized; generated paths and anything CI enforces are excluded. Mistakes flagged twice go into CLAUDE.md.

3. First-pass success. Each repository's CLAUDE.md lists one test command and one build command with healthy output; a Stop hook runs the tests before an agent can finish; bug-fix tasks start from a committed failing test with test-file edits blocked by a hook.

4. Gating. AI review blocks only on "Important" findings, and only in repository types where shadow precision on those findings is at least the agreed level (for example 85%) and recall on serious defects is known. A human code owner still approves every pull request, and no agent can approve or merge its own.

Key termsCLAUDE.mdHuman in the loop (HITL)Verification

Sources