iCode Workbench · Guide · Review
How to review AI-generated code
A green run is not an approval. The agent exited zero, the task is marked complete, and the diff looks plausible. None of that proves the change is correct. Review is the step that turns generated code into accepted work — and it needs a different rhythm from reviewing code a person wrote.
This guide is a practical review workflow: what to read before the diff, how to inspect it in the checkout, what to test, where the risk hides, and how to make a decision that is separate from process exit.
This guide is currently available in English only.
Why AI-generated code needs a different review
Human code review assumes the author had a model of the system. Agent output is different: it can be locally plausible and globally wrong. It can hallucinate an import, weaken a test to make it pass, change a file outside the task, or copy a pattern from the wrong part of the codebase.
The volume is different too. An agent can produce a reviewable diff in minutes, and a fleet can produce several at once. If you review every line at the same depth, the queue wins. The review has to be risk-first: find the changes that can hurt, then spend your attention there.
The goal is not to distrust the agent. It is to make the review a real decision, not a ceremony after a green run.
Before you read the diff
Read the task first. You cannot judge the diff without knowing what it was supposed to do. Check:
- The goal. One sentence. If it is vague, the diff will be too.
- The owned paths. The files the agent was allowed to change. Drift outside them is a finding, not a detail.
- The done-when command. The verification the agent was supposed to run. You will run it again.
- The baseline. The commit or worktree state the task started from. Review against that, not against your memory of main.
- The agent's summary — with suspicion. The summary says what the agent intended. The diff says what it did. When they disagree, the diff wins.
If the task did not have these fields, the review starts with a question: what was the agent asked to do? That is cheaper to fix before you read a 40-file diff.
Read the diff in the checkout
Review where the agent worked. Open the checkout, not a chat transcript and not a summary. You want the real diff, the surrounding code, and the ability to run the tests in the same tree.
A sequence that works:
- Start with the file list. Look for files outside the owned paths, deleted tests, dependency changes, and generated files. These are the highest-signal lines in the diff.
- Read the diff by risk, not by file order. Auth, data, shared interfaces, and migrations first. Formatting and docs last.
- Open the surrounding code. A diff can be correct in isolation and wrong in context. Read the callers of the changed function and the tests that cover it.
- Check what was removed. Deleted assertions, skipped tests, removed error handling, and narrowed types are common ways a diff looks smaller than the behavior change.
- Leave line notes. A note attached to the line is easier to act on than a paragraph in chat.
If the diff is too large to review, that is a finding: the task was too broad. Split it and re-run, rather than skimming.
Run the tests yourself
A passing test in the agent's shell is evidence. A passing test in your shell is proof. Run the done-when command in the checkout, then run the broader suite if the change touches shared code.
- For a bug fix, confirm the test fails before the fix and passes after. If it passes both ways, the test is not covering the bug.
- Look for skipped or weakened tests. A test that was deleted, skipped, or changed to assert less is a change to the safety net, not just the code.
- Run the combined result after each merge. Two branches can pass alone and fail together.
If the suite is flaky, say so in the review. A green run you do not trust is worse than a red run you do.
Where the risk hides
- Auth and permissions. A missing check, a widened role, a token that lives too long. Read these diffs line by line.
- Data and migrations. Forward-only changes, missing rollback, locks on large tables, backfills that assume an empty database.
- Shared interfaces. Route tables, exported types, API schemas, dependency manifests. A small change here can break every caller.
- Error handling. A new catch that swallows the error, a retry without a bound, a fallback that hides a failure.
- Concurrency. Shared state, locks, queues, idempotency. These bugs pass tests and fail in production.
- Dependencies. A new package, a version bump, a lockfile change. Check why it was added, not just that it installs.
- Generated files. Lockfiles, snapshots, and build output should be regenerated, not hand-edited.
- Style drift. A different pattern from the surrounding code is not always wrong, but it is a question. Ask why.
Write feedback the agent can act on
A review comment should be specific enough to produce a change without another round of questions. “This looks wrong” is not actionable. “This catch swallows the timeout; rethrow it so the retry sees it” is.
A useful comment includes:
- The location. A file and line, or a line note attached to the diff.
- The problem. What will go wrong, not just what you dislike.
- The expected change. A direction, not a full rewrite.
- The evidence. The failing test, the command output, or the caller that breaks.
Batch the comments and send them in one pass. A stream of small corrections across five messages is harder for the agent to apply and harder for you to track.
Make the review decision
The decision is separate from process exit. There are three outcomes:
- Accept. The diff matches the task, the tests pass, and the risk areas are covered. Record the decision and merge.
- Reject. The change is wrong, out of scope, or not worth fixing. Keep the branch and the history; a rejection is information.
- Revise. The direction is right but the diff needs another pass. Send the line notes back to the agent, then review the new diff.
Do not auto-merge a green task. The review decision is the human judgment the workbench exists to protect. If you accept everything, the gate is decorative.
For the “why” behind this model, read the review gate. For the queue side, read how to queue coding agent tasks.
A diff that looks fine
The task: “Fix token refresh when the API returns 401.” The agent changes src/auth/refresh.ts, adds a retry, edits src/routes.ts, and changes tests/auth/refresh.test.ts. The suite is green.
A line-by-line read of the main file might miss the problems. A risk-first read finds them in the file list:
- Out-of-scope change.
src/routes.tswas not in the owned paths. The agent may have “fixed” a route while it was there. That is a separate task and a separate review. - Weakened test. The test file was edited. If an assertion was removed or a case was skipped, the green run is not evidence that the bug is fixed.
- Unbounded retry. A retry on 401 can loop forever if the refresh token is also expired. The diff needs a bound and a failure path.
- Missing case. There is no test for an expired refresh token, which is the case that matters most.
The decision is “revise,” not “accept.” The line notes should name the out-of-scope file, the skipped test, the retry bound, and the missing case. The next diff is smaller and the review is faster.
When the diff is too large
A large diff is a process finding, not a review challenge. If the change touches dozens of files or hundreds of lines, the task was too broad. Skimming it produces a review that looks thorough and catches nothing.
Split the task by behavior or by owned path, re-run the agent, and review the smaller diffs. If the change is genuinely one atomic migration, review it in stages: schema, backfill, callers, rollback.
The same rule applies to a diff you do not understand. “I will read it later” is how unreviewed code reaches main. Ask the agent to explain the change, then verify the explanation against the diff.
Checklist
- Does the diff match the task, or did the agent drift?
- Are there files outside the owned paths? Why?
- Were any tests deleted, skipped, or weakened?
- Did the verification command fail before the fix and pass after?
- Are auth, data, shared interfaces, and dependencies covered?
- Does the combined result pass after the merge?
- Is the review decision recorded separately from process exit?
For a printable version, use the agent diff review checklist.