Skip to content

Commit 04ba536

Browse files
detainclaude
andcommitted
fix(review-prompt): size-aware diff strategy for large changes
Instead of always running `git diff _base HEAD` (which floods the agent's context on big changes and degrades the review), the prompt now tells the agent to size the change first (git diff --name-only / --numstat / --shortstat) and pick a reading strategy: one pass when small, file-by-file (git diff _base HEAD -- <path>) when large, and section-by-section for a single very large file. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 32f5530 commit 04ba536

1 file changed

Lines changed: 41 additions & 7 deletions

File tree

scripts/prompts/review.txt

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,49 @@ The changes may come from a pull request, a pushed commit, or a range of commits
55

66
## What changed
77

8-
The changes under review have been committed as a snapshot on top of the code as
9-
it was before them. To see EXACTLY what changed, run:
8+
The changes under review are the commit range `_base`..`HEAD`: `_base` is the
9+
baseline (the code before the change) and `HEAD` is the baseline plus the changes
10+
under review. That range — and only that range — is your review scope. Read the
11+
surrounding code for context, but do not go hunting for unrelated problems
12+
elsewhere in the repository.
1013

11-
git diff _base HEAD
14+
Do NOT blindly run `git diff _base HEAD` on a large change — a huge diff floods
15+
your context and makes the review worse. SIZE IT UP FIRST, then pick a strategy:
1216

13-
`_base` is the baseline (the code before the change); `HEAD` is the baseline plus
14-
the changes under review. That diff — and only that diff — is your review scope.
15-
Read the surrounding code for context, but do not go looking for unrelated
16-
problems elsewhere in the repository.
17+
1. List the changed files (this is your scope):
18+
19+
git diff --name-only _base HEAD
20+
21+
2. Measure the size, per file and overall:
22+
23+
git diff --numstat _base HEAD # added <tab> deleted <tab> path, per file
24+
git diff --shortstat _base HEAD # one-line total: files, insertions, deletions
25+
26+
3. Read the diff according to size:
27+
28+
- SMALL overall (roughly < 600 changed lines across a handful of files): read
29+
it in one pass —
30+
31+
git diff _base HEAD
32+
33+
- LARGE (many files, or more than ~600 changed lines total): review ONE FILE
34+
AT A TIME so no single command floods your context. For each path from
35+
step 1 —
36+
37+
git diff _base HEAD -- <path>
38+
39+
Review that file fully before moving to the next. You may skim or
40+
deprioritize obviously low-risk bulk files (generated code, lockfiles,
41+
vendored dependencies, large fixtures/snapshots) and spend your attention on
42+
hand-written source.
43+
44+
- A SINGLE VERY LARGE file (roughly > 1500 changed lines): do not load its
45+
whole diff at once. Inspect it in sections — view the diff for a line range,
46+
or open the file around each changed hunk — and review the substantive
47+
changes rather than every mechanical line.
48+
49+
Whichever strategy you use, review every changed file in scope, and fix/report
50+
issues exactly as described below.
1751

1852
## How to fix
1953

0 commit comments

Comments
 (0)