Skip to content

Menu

Playbooks

Have an agent review a change

Use read-only controls for an agent review of a small diff, require a file and line for every finding, and verify each one yourself.

min read
14
Level
Intermediate
Last verified

This playbook applies to Antigravity CLI or App. It helps developers who already know how to read a diff delegate the first pass over a small code change to an agent. You will produce candidate findings with file and line references, a human verification record for each finding, and a final judgment made by a person. An agent review is not approval and cannot replace repository rules, tests, continuous integration (CI), or a reviewer with the necessary context.

This is an independent, unofficial project with no affiliation with Google. Its examples and output are fictional.

In plain English: Read-only prevents side effects, not bad findings

Section titled “In plain English: Read-only prevents side effects, not bad findings”

A regular chat returns text. An agent may also read a repository, edit files, or run commands; see Your first agent task: Use execution modes and permissions as guardrails for the entry-point behavior. A review should inspect an existing change, so make the session read-only first. Read-only controls reduce side effects, but not false positives, missed defects, or incorrect severity.

The general review method is covered in Have Gemini review a change: separate facts, inferences, and claims that still need testing; report one finding per root cause; and verify every finding yourself. This page adds the modes, permissions, stopping points, and recovery steps needed when an agent performs the first pass.

Pages elsewhere in this guidebook do not name any App preset “read-only review.” This playbook composes existing controls instead: choose plan in CLI, choose Request Review in App, and deny write_file(*) and command(*) for the review. plan starts with read-only search and inspection tools; Request Review pauses for every terminal command; explicit deny rules take precedence under Deny > Ask > Allow. If mode names, presets, rule syntax, or interface locations differ from what you see, follow the official page. See Your first agent task: Use execution modes and permissions as guardrails and Permissions and sandbox: what presets, rules, and the sandbox each control for the verified guidance elsewhere in this guidebook.

Entry point Execution setting Permission setting What to check first
CLI Switch to plan Deny write_file(*) and command(*) The status bar shows the intended mode, and the rules are in a scope this session reads
App Select Request Review Deny write_file(*) and command(*) The current project has not overridden the preset with a broader one, and the rules block writes and commands

This setup deliberately prevents the agent from running tests. It proposes verification steps; you run them in your own terminal.

Weak prompt:

Check this PR for problems. Fix anything you find and run the tests.

This combines review, modification, and execution without specifying an evidence format. The agent may change the object under review and finish with only an “all fixed” summary.

Improved prompt:

Review this diff read-only. Do not modify files or run commands.
Report only correctness and regression issues. Every finding must include “file:new-file-line,”
quote the relevant code, and separate direct facts, inferred impact, and claims that need testing.
Do not report a candidate without a reliable location and supporting evidence.
Finish with checks I should run myself, and do not describe the review as approval.

Complete example: Review a small demo-notes PR

Section titled “Complete example: Review a small demo-notes PR”

demo-notes is a fictional JavaScript project. The PR attempts to replace two filters with a single counting scheme. The requirements have only three rules:

1. Count only lines beginning with "- [ ] " as open.
2. Count only lines beginning with "- [x] " as done. Ignore uppercase [X] and markers in prose.
3. Do not count headings, blank lines, or ordinary prose in either category.

The existing test covers only the happy path with one open and one done item:

test/summarize.test.js
import test from 'node:test';
import assert from 'node:assert/strict';
import { summarize } from '../src/summarize.js';
test('counts open and done tasks', () => {
const lines = ['- [ ] draft', '- [x] publish'];
assert.deepEqual(summarize(lines), { open: 1, done: 1 });
});

Here is the complete review.diff under review:

diff --git a/src/summarize.js b/src/summarize.js
--- a/src/summarize.js
+++ b/src/summarize.js
@@ -1,5 +1,5 @@
export function summarize(lines) {
- const open = lines.filter((line) => line.startsWith('- [ ] ')).length;
- const done = lines.filter((line) => line.startsWith('- [x] ')).length;
+ const done = lines.filter((line) => line.toLowerCase().includes('[x]')).length;
+ const open = lines.length - done;
return { open, done };
}

Line references use the new file in this diff: the two added statements are src/summarize.js:2 and src/summarize.js:3. If the PR changes later, regenerate the diff instead of reusing stale line numbers.

Step 1: Pin down the review target and boundaries

Section titled “Step 1: Pin down the review target and boundaries”

Record the review object before asking the agent to explore:

  • Object: the complete review.diff above.
  • Behavioral authority: the three requirements.
  • Existing coverage: test/summarize.test.js.
  • Allowed operations: read those materials and return text.
  • Prohibited operations: write files, run commands, use the network, commit, or push.
  • Review scope: correctness, requirement regressions, and test gaps; exclude naming, formatting, and personal style preferences.

Stop and supply missing materials instead of guessing. For the general reason a review should include requirements, prior behavior, the complete diff, and relevant tests, see Have Gemini review a change.

In CLI, confirm that the current mode is plan. In App, confirm that the project uses Request Review. Then verify that the write_file(*) and command(*) deny rules are effective. Do not assume what the default should be: default modes, available presets, and interfaces can vary with the version, account, or sandbox conditions. Follow the official page for current behavior; the comparison elsewhere in this guidebook is in Permissions and sandbox: what presets, rules, and the sandbox each control.

The acceptance condition is not the agent saying “I will remain read-only.” You must see the expected settings. Prohibitions in the prompt define the task boundary; permission rules define the execution boundary. Use both.

Perform a read-only review of this fictional PR. Do not modify or create files, run commands,
or use the network. If any material is missing or truncated, list what is missing and stop.
[Review object]
- requirements: the three requirements below;
- review.diff: the complete diff;
- test/summarize.test.js: the complete existing test.
[Scope]
Review only correctness, requirement regressions, and test gaps. Ignore formatting, naming,
and personal style preferences. Do not speculate about callers, production data, or business loss
that is not present in the materials.
[Output format]
First list the materials you actually received. Then use this fixed schema for every candidate:
ID | file:new-file-line | code excerpt | issue | direct fact | inferred impact | suggested human check.
Requirements:
1. Bind every finding to a file and new-file line in review.diff.
2. Direct facts may come only from the requirements, diff, or test. Label anything requiring execution as “Needs testing.”
3. Report each root cause once. Do not report a candidate that lacks a location or evidence.
4. List “Dismissed concerns” separately so that non-issues do not become blockers.
5. Finish with the smallest tests I should run myself. Do not claim they were run.
6. End with: “These are candidate findings awaiting human verification, not approval or rejection of the PR.”
[Materials]
Paste the complete requirements, review.diff, and test/summarize.test.js here.

Step 4: Check the shape of the agent’s output first

Section titled “Step 4: Check the shape of the agent’s output first”

The following is fictional expected output, not the result of an agent run performed for this page:

ID Location Code excerpt Candidate issue Direct fact Inferred impact Suggested human check
R1 src/summarize.js:2 line.toLowerCase().includes('[x]') The done-item predicate expands from an exact prefix to a case-insensitive match anywhere in the line The requirement accepts only a lowercase - [x] prefix; the added code lowercases the line and uses includes('[x]') Uppercase or embedded markers may be counted as done even though the requirements exclude them Use ['note [X] later'] and confirm that it must not count as done
R2 src/summarize.js:3 const open = lines.length - done; Every line not counted as done is counted as open The new code subtracts done from all input lines; the requirement excludes headings, blank lines, and prose Headings, blank lines, and prose may inflate the open count Use ['# Notes', '', 'plain text'] and expect { open: 0, done: 0 }

Check the form before debating severity: every item needs a file and line, an excerpt from an added line, and a fact traceable to supplied material. Execution-dependent claims must remain labeled “Needs testing.”

Apply the same four questions to every finding:

  1. Is the location current? Open the current diff and confirm that the path, line, and excerpt belong to the same version.
  2. Is the fact true? Compare the code and requirement word for word. Do not accept “this is usually expected.”
  3. Does a minimal counterexample distinguish old and new behavior? R1 uses an uppercase marker embedded in prose; R2 uses a heading, blank line, and ordinary text.
  4. Does it require execution? You can confirm a direct static conflict first. Actual failures in the project environment, full regressions, and CI status require your own run.

A verification record might look like this:

ID Human status Verification basis Next action
R1 Confirmed src/summarize.js:2 directly conflicts with requirement 2 Add uppercase and embedded-marker cases before deciding the fix
R2 Confirmed src/summarize.js:3 classifies every non-done line as open, contradicting requirement 3 Add heading, blank-line, and prose cases

If you add the R1 and R2 cases to test/summarize.test.js, run:

终端窗口
node --test test/summarize.test.js

Expect the original happy-path case to pass and the R1 and R2 cases to fail before the implementation is fixed. If you use a temporary test file instead, run node --test <TEMP_TEST_FILE>. Then run the project’s full checks. This page did not run these commands, so do not record an expectation as an observed result.

Even if both findings are confirmed, the agent has shown only that the PR needs the confirmed issues addressed. It has no authority to approve, reject, or merge. Your final record should distinguish at least:

  • Confirmed issues: supported by requirements, the diff, or results you ran yourself.
  • Dismissed findings: unsupported, duplicated, or disproved by a minimal case.
  • Context needed: dependent on callers, platform constraints, or repository policy.
  • Checks not run: outstanding tests, type checks, lint, or CI.

Weak approach 1: Use auto or Turbo to review and fix everything

Section titled “Weak approach 1: Use auto or Turbo to review and fix everything”

auto automatically accepts workspace edits, while Turbo turns off the sandbox and runs commands directly. Both conflict with a read-only review. Rewrite the workflow: use plan in CLI, Request Review in App, and deny writes and commands. Finish the review, then open a separate, tightly scoped fix task. See Before enabling auto or Turbo: risks, acceptable cases, and reversal for the gates those settings remove and the recovery process.

Weak approach 2: Accept the agent’s summary

Section titled “Weak approach 2: Accept the agent’s summary”

The summary is the agent’s account, not diff evidence. Rewrite the workflow: compare the file list with the allowed scope, read every hunk, rerun the checks yourself, and use Git as an independent comparison. App’s Review pane, CLI’s /diff, and per-turn review are covered in Review agent changes before you accept them.

  • I personally confirmed the CLI or App mode, preset, and permission rules.
  • write_file(*) and command(*) are denied, and the agent did not modify files or run commands.
  • The review uses one version of the requirements, complete diff, and relevant tests rather than mixing commits.
  • Every finding contains file:line, a code excerpt, and a direct fact traceable to supplied material.
  • Inferred impact and claims needing tests are not presented as observed results.
  • The same root cause is not counted twice, and dismissed concerns are recorded separately.
  • I opened the diff and verified every candidate, with a minimal check for each confirmed item.
  • I actually ran tests, type checks, lint, and CI, or recorded every check not run.
  • A person with the necessary context made the final decision; the agent review was not treated as approval.
  • The agent requests a write or command: Deny it and stop the current turn. Check the mode, project override, and deny rules. A promise in the prompt does not prove that permissions are effective; verify the controls before restarting.
  • The working tree changed: First preserve git status --short and git diff as evidence. Use git restore <file> only for files you know this task changed. Avoid a broad command that could overwrite unrelated uncommitted work.
  • You suspect a command ran: Guidance elsewhere in this guidebook notes that the official pages do not provide a single unified log of executed commands. CLI can expand tool-call details in the conversation, while App can show tool calls in the conversation; cross-check either record against Git and system state. See Before enabling auto or Turbo: risks, acceptable cases, and reversal.
  • Line numbers no longer match: The diff probably changed. Save the current commit or PR version, regenerate the complete diff, and ask the agent to locate the findings again. Do not manually slide old findings onto new lines.
  • The agent says tests passed: Commands were prohibited, so the claim lacks execution evidence. Rewrite it as a suggested check, run it yourself, and record the exact command, output, and exit status.
  • There are many weak findings: Narrow the review to one file or behavior and require every candidate to cite an added or deleted line. Move style feedback out of blocking findings.
  • A fix is needed: End the review task. Preserve the verification record and open a separate minimal fix task instead of quietly broadening permissions in the same read-only session.
  • The material is sensitive: Do not place real secrets, customer data, private conversations, or undisclosed vulnerabilities in an inappropriate entry point. Use YOUR_API_KEY for any example key.

Next: For a more complete finding schema and test-based verification, read Have Gemini review a change. To inspect files an agent has already changed, read Review agent changes before you accept them. After confirming a defect, continue to Locate and fix a bug.