@@ -40,15 +40,20 @@ Use `read_agent` with `wait: true` to wait for each background agent.
4040## Step 1: Get the Diff and Build Inventory
4141
4242``` bash
43+ # Find the merge-base with main (handles: upstream remote, origin remote,
44+ # local main branch, or falls back to gh pr diff for cloud agent environments).
4345BASE=$( git merge-base upstream/main HEAD 2> /dev/null \
44- || git merge-base origin/main HEAD 2> /dev/null)
46+ || git merge-base origin/main HEAD 2> /dev/null \
47+ || git merge-base main HEAD 2> /dev/null)
4548if [ -z " $BASE " ]; then
46- echo " ERROR: Cannot find upstream/main or origin/main."
47- exit 1
49+ echo " No merge-base found. Falling back to gh pr diff."
50+ gh pr diff --name-only
51+ gh pr diff -- ' *.rs' ' *.toml' ' examples/' | head -2000
52+ else
53+ echo " Reviewing changes since: $BASE "
54+ git diff " $BASE " ..HEAD --stat
55+ git diff " $BASE " ..HEAD -- ' *.rs' ' *.toml' ' examples/' | head -2000
4856fi
49- echo " Reviewing changes since: $BASE "
50- git diff " $BASE " ..HEAD --stat
51- git diff " $BASE " ..HEAD -- ' *.rs' ' *.toml' ' examples/' | head -2000
5257```
5358
5459If the diff is empty, stop and report: "No changes found to review."
@@ -106,7 +111,9 @@ Use `model: "gpt-5.4"` in the task tool call (provides model diversity).
106111> Get the diff:
107112> ```
108113> BASE=$(git merge-base upstream/main HEAD 2>/dev/null \
109- > || git merge-base origin/main HEAD 2>/dev/null)
114+ > || git merge-base origin/main HEAD 2>/dev/null \
115+ > || git merge-base main HEAD 2>/dev/null)
116+ > # If BASE is empty, use: gh pr diff -- '*.rs' '*.toml' 'examples/'
110117> git diff "$BASE"..HEAD -- '*.rs' '*.toml' 'examples/'
111118> ```
112119>
@@ -161,7 +168,9 @@ Use `model: "claude-opus-4.6"` in the task tool call.
161168> Get the diff AND read full source files for context:
162169> ```
163170> BASE=$(git merge-base upstream/main HEAD 2>/dev/null \
164- > || git merge-base origin/main HEAD 2>/dev/null)
171+ > || git merge-base origin/main HEAD 2>/dev/null \
172+ > || git merge-base main HEAD 2>/dev/null)
173+ > # If BASE is empty, use: gh pr diff -- '*.rs' '*.toml' 'examples/'
165174> git diff "$BASE"..HEAD -- '*.rs' '*.toml' 'examples/'
166175> ```
167176> Then use `view` to read the full source files that were changed.
@@ -219,7 +228,9 @@ Use the default model (no `model` parameter).
219228> Get the diff:
220229> ```
221230> BASE=$(git merge-base upstream/main HEAD 2>/dev/null \
222- > || git merge-base origin/main HEAD 2>/dev/null)
231+ > || git merge-base origin/main HEAD 2>/dev/null \
232+ > || git merge-base main HEAD 2>/dev/null)
233+ > # If BASE is empty, use: gh pr diff -- '*.rs' '*.toml' 'examples/'
223234> git diff "$BASE"..HEAD -- '*.rs' '*.toml' 'examples/'
224235> ```
225236> Use `view` to read surrounding context.
@@ -439,7 +450,9 @@ Launch **1 general-purpose agent in background mode**.
439450> Get the diff:
440451> ```
441452> BASE=$(git merge-base upstream/main HEAD 2>/dev/null \
442- > || git merge-base origin/main HEAD 2>/dev/null)
453+ > || git merge-base origin/main HEAD 2>/dev/null \
454+ > || git merge-base main HEAD 2>/dev/null)
455+ > # If BASE is empty, use: gh pr diff -- '*.rs' '*.toml' 'examples/'
443456> git diff "$BASE"..HEAD -- '*.rs' '*.toml' 'examples/'
444457> ```
445458> Use `view` to read full source files.
0 commit comments