This playbook helps you ask Gemini to review a tightly scoped diff and turn its response into candidate findings that can be located and verified. The result is not approval to merge, but a set of findings that a person must verify one by one. It cannot replace human review, repository checks, or continuous integration (CI).
If you import a code folder into Gemini Apps, first confirm that the model actually received the requirements, diff, and tests. The official help documentation warns that details may be missed in a large body of source material. Google also reminds users that they are responsible for the results of using generated code. Do not skip the source code, tests, or CI just because the response sounds confident.
In plain English: A diff is evidence, not a verdict
Section titled “In plain English: A diff is evidence, not a verdict”An effective review separates three layers: facts directly visible in the materials, risks inferred from those facts, and results that can be confirmed only by running the code. For example, “the requirement says >=, but the new code uses >” is a fact; “the new condition will filter out a boundary input” is a static inference; “the full test suite has failed” can be confirmed only after actually running it. If the materials do not include callers, describe the user impact as “unknown; inspect callers.”
Minimal example
Section titled “Minimal example”Weak prompt:
Review this change and find every issue.Improved prompt:
Review only correctness and regressions. For each finding, output“Location | Issue | Evidence | Severity | Recommendation.”In the Evidence column, separate “Fact” from “Inference.” Label any conclusion thatcannot be confirmed from the requirements, diff, or tests as “Needs testing.”List dismissed concerns separately. Do not report style preferences or count the sameroot cause more than once.Complete example: Review a restock-list refactor
Section titled “Complete example: Review a restock-list refactor”Starting materials
Section titled “Starting materials”This is a complete synthetic example:
restock-review/├── package.json├── requirements.md├── review.diff├── src/│ └── select-restock-items.js└── test/ └── select-restock-items.test.js{ "type": "module", "scripts": { "test": "node --test" }}The known environment is Node 24 with ECMAScript modules, and the test command is node --test.
The restock list selects items that can be transferred to a store. `minimumStock` is the transfer threshold, not the out-of-stock threshold.
- Include items where `stock >= minimumStock` in the restock list, preserving their input order.- The output `sku` must match the input exactly, with no case normalization.- Call `loadUnitPrice(sku)` once for each selected item. Price lookup errors must propagate to the caller.- `unitPrice: 0` is a valid price and must not cause the item to be dropped.The implementation before the change is:
export function selectRestockItems(items, minimumStock, loadUnitPrice) { const selected = [];
for (const item of items) { if (item.stock < minimumStock) continue;
selected.push({ sku: item.sku, unitPrice: loadUnitPrice(item.sku), }); }
return selected;}The existing test covers only the happy path: all-uppercase SKUs, stock above the threshold, nonzero prices, and no errors:
import test from 'node:test';import assert from 'node:assert/strict';import { selectRestockItems } from '../src/select-restock-items.js';
test('selects stocked items in input order', () => { const prices = new Map([ ['PAPER-2', 12], ['INK-7', 28], ]); const items = [ { sku: 'PAPER-2', stock: 8 }, { sku: 'INK-7', stock: 6 }, ];
assert.deepEqual( selectRestockItems(items, 5, (sku) => prices.get(sku)), [ { sku: 'PAPER-2', unitPrice: 12 }, { sku: 'INK-7', unitPrice: 28 }, ], );});Here is the review.diff under review:
diff --git a/src/select-restock-items.js b/src/select-restock-items.js--- a/src/select-restock-items.js+++ b/src/select-restock-items.js@@ -1,14 +1,15 @@ export function selectRestockItems(items, minimumStock, loadUnitPrice) {- const selected = [];-- for (const item of items) {- if (item.stock < minimumStock) continue;-- selected.push({- sku: item.sku,- unitPrice: loadUnitPrice(item.sku),- });- }-- return selected;+ return items+ .filter((item) => item.stock > minimumStock)+ .map((item) => {+ try {+ return {+ sku: item.sku.toUpperCase(),+ unitPrice: loadUnitPrice(item.sku),+ };+ } catch {+ return null;+ }+ })+ .filter(Boolean); }Allowed scope
Section titled “Allowed scope”- Gemini reviews only
requirements.md, the implementation before the change,review.diff, and the existing test. It does not modify files or run commands. - Report only correctness issues, error-handling problems, and regressions against the requirements. Do not present naming or formatting preferences as defects.
- During verification, you may add
test/review-cases.test.json an isolated branch or in a temporary directory, but the review task itself does not modify product code. - Do not speculate about callers, production data, the deployment environment, or business losses when the supplied materials provide no evidence about them.
Full prompt
Section titled “Full prompt”Review the synthetic JavaScript change below. Start with review findings. Do not modifyfiles, run commands, or claim that you have run tests.
[Goal]Find correctness issues that violate requirements.md or change existing observable behavior.Do not report pure formatting issues or personal style preferences.
[Materials]- requirements.md: the source of truth for expected behavior;- the implementation of src/select-restock-items.js before the change: evidence of previous behavior;- review.diff: the current change;- test/select-restock-items.test.js: the existing coverage.
[Process]1. First, list the materials you actually received. If anything is missing or truncated, stop rather than speculate;2. Compare the requirements, deleted lines, and added lines item by item. Check the happy path, boundary inputs, error paths, and zero values;3. Use this fixed format for every candidate: Location | Issue | Evidence | Severity | Recommendation;4. In the Evidence column, separate “Fact” from “Inference.” Facts may come only from the supplied materials. Write “Needs testing” for anything that can be confirmed only by running the code; do not present it as something that already happened;5. Use High / Medium / Low severity and explain the directly observable impact. If the materials are insufficient, write “Unknown; inspect callers” for user impact;6. Keep recommendations minimal. Provide a reproducible input or a suggested test without adding an opportunistic refactor;7. List “Dismissed concerns” separately and explain why they are not issues. Do not count the same root cause more than once;8. Finally, list the tests I need to run myself and the items that still require human judgment.
[Constraints]- Do not invent callers, production impact, files, or test results;- Do not automatically assume the old code is correct or the new approach is a problem;- Report each root cause only once;- Review findings cannot replace human review or CI.Expected output
Section titled “Expected output”The review should find these three real issues:
| Location | Issue | Evidence | Severity | Recommendation |
|---|---|---|---|---|
.filter((item) => item.stock > minimumStock) |
Excludes items whose stock is exactly the minimum | Fact: The requirement says stock >= minimumStock, while the new condition uses >. An input with stock: 5 and minimumStock: 5 does not satisfy the new condition. Inference: User impact is unknown; check whether callers pass boundary values. |
Medium | Restore >= and add an equality-boundary test. |
The new try / catch, return null, and final filter |
Swallows price lookup errors | Fact: The requirement says errors must propagate. The old implementation did not catch them, while the new implementation converts them to null and then removes them. Inference: User impact is unknown; check whether callers depend on error propagation. |
High | Remove the catch or rethrow the error, and add assert.throws. |
sku: item.sku.toUpperCase() |
Changes sku despite the requirement to preserve it exactly |
Fact: The requirement says to preserve the value exactly. Mixed-case input is rewritten. Inference: User impact is unknown; check whether callers associate records using the original sku. |
Medium | Return item.sku and add a mixed-case test. |
It should also list this plausible-looking but harmless concern separately:
| Location | Issue | Evidence | Severity | Recommendation |
|---|---|---|---|---|
.filter(Boolean) |
Dismissed false positive: it will not drop a successful item because unitPrice: 0 |
Fact: The filter receives the entire object. An object containing the number 0 is still truthy. Removing null is part of the preceding swallowed-error problem and must not be counted as a separate defect. Inference: None; run the zero-price case to confirm. |
Not an issue | Do not change the code in response to this false positive. Add a zero-price verification case. |
This result separates static evidence from potential impact and does not report the same catch root cause twice.
Verification: Turn each review finding into a test
Section titled “Verification: Turn each review finding into a test”First apply review.diff on an isolated branch or in a temporary directory, then add the following verification file:
import test from 'node:test';import assert from 'node:assert/strict';import { selectRestockItems } from '../src/select-restock-items.js';
test('includes stock exactly at the minimum', () => { const items = [{ sku: 'PAPER-5', stock: 5 }];
assert.deepEqual(selectRestockItems(items, 5, () => 16), [ { sku: 'PAPER-5', unitPrice: 16 }, ]);});
test('propagates price lookup errors', () => { const items = [{ sku: 'INK-404', stock: 7 }];
assert.throws( () => selectRestockItems(items, 5, () => { throw new Error('price unavailable'); }), /price unavailable/, );});
test('preserves the original SKU spelling', () => { const items = [{ sku: 'Paper-Mix', stock: 7 }];
assert.deepEqual(selectRestockItems(items, 5, () => 19), [ { sku: 'Paper-Mix', unitPrice: 19 }, ]);});
test('keeps an item whose unit price is zero', () => { const items = [{ sku: 'SAMPLE-0', stock: 7 }];
assert.deepEqual(selectRestockItems(items, 5, () => 0), [ { sku: 'SAMPLE-0', unitPrice: 0 }, ]);});Run the existing test first:
node --test test/select-restock-items.test.jsIts minimum expected result is tests 1, pass 1, and fail 0. This shows that the happy-path coverage is insufficient; it does not show that the diff has no problems.
Then run all tests:
node --testThis is an expected failure. The minimum expected result for the flawed diff is tests 5, pass 2, and fail 3:
- The equality-boundary case fails, with an actual value of
[]. - The error-propagation case fails because the expected exception is missing.
- The original-
skucase fails, with an actual value of'PAPER-MIX'and an expected value of'Paper-Mix'. - The zero-price case passes, ruling out the false positive that “
.filter(Boolean)dropsunitPrice: 0.” - The original happy-path test passes.
This expected-failure command should exit with code 1. To check that each recommendation matches its root cause, change > back to >= in a temporary directory, remove the try / catch that swallows errors, and change the output back to sku: item.sku. Even if you keep .filter(Boolean), running node --test again should produce tests 5, pass 5, and fail 0. Do not delete or weaken tests to manufacture a green result.
The requirements and diff are enough to prove the three static conflicts, but you must run checks or inspect the repository yourself to answer the following questions:
- Whether the failures reproduce in the Node version and dependency environment specified by the project.
- Whether the targeted tests, full test suite, type checks,
lint, and CI all pass after the fix. - How the real callers handle price lookup errors and whether the severity should change.
- Whether other repository modules depend on case conversion or boundary behavior.
- Whether the diff contains files or generated artifacts not shown in the current materials.
The exercise repository was not run as part of preparing this page. Its source-checked status means only that the product facts were verified, not that this code was run-tested in your environment.
Verification checklist
Section titled “Verification checklist”- You received the requirements, implementation before the change, complete diff, and relevant tests without filling in missing materials through speculation.
- Every finding identifies a specific location and includes the issue, factual evidence, an inference, severity, and a minimal recommendation.
- The three real issues cover the equality boundary, error propagation, and exact preservation of
sku, without counting any root cause twice. - The zero-price concern about
.filter(Boolean)has been dismissed using object truthiness and a targeted test case. - The existing happy-path test and
test/review-cases.test.jshave both actually been run. - Every failure is caused by the expected conflict with the requirements, not by an environment error misclassified as a code regression.
- The full test suite and CI have been run after the fix, or every unrun check and its reason have been recorded explicitly.
- A person with the necessary context still makes the final merge decision; Gemini’s findings are not treated as approval.
Recovery and safety boundaries
Section titled “Recovery and safety boundaries”- The diff or requirements are truncated: Stop drawing conclusions. After supplying the missing materials, ask the model to list the files and excerpts it received again.
- The response cites a caller that does not exist: Remove any impact description that cannot be located, keep only the static facts, and have a person search for the real call sites.
- A zero price is falsely reported as a defect: Check whether the filter receives an object or a number, and verify it with a minimal test. Do not accept a claim just because it is phrased confidently.
- There are many findings but no evidence: Require each one to cite an added or deleted line, a requirement, and a reproducible input. Move pure style feedback out of the blocking findings.
- Test results differ from expectations: First confirm that you applied the same diff, ran the same test file, and used the same Node version before reassessing the review’s conclusions.
- Severity cannot be determined: Mark user impact as an inference. Inspect callers, logs, and the release scope, then have a person adjust the severity.
- The recommendation expands into a large rewrite: Limit the fix to one root cause and its corresponding test. Open a separate task for refactoring.
- The materials involve secrets, customer data, or an undisclosed vulnerability: Do not upload them through an inappropriate interface. Follow your organization’s access controls and security response process.
- The recommendation includes destructive commands: Do not perform deletions, resets, force pushes, or production changes. First constrain the target and obtain authorization.
Gemini can bring an additional perspective to a review, but the merge decision remains a human responsibility. Next: if boundary tests are missing, read Add tests for an existing function; once the issue is confirmed, continue to Locate and fix a bug; for a general method of checking answers, read Verify the answer.