Skip to content

Commit 945018b

Browse files
committed
chore: Script the parallel-review diff fetch into fetch-diff.sh
1 parent 9b656f0 commit 945018b

3 files changed

Lines changed: 57 additions & 23 deletions

File tree

.claude/scripts/fetch-diff.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
# fetch-diff.sh — Fetch all git diff sections for parallel-review.
3+
# Usage: bash <path>/fetch-diff.sh <base-branch> <output-file>
4+
#
5+
# Writes the following sections to <output-file>:
6+
# === Changed Files (<base>..HEAD) ===
7+
# === Commit Log (<base>..HEAD) ===
8+
# === Commit Diff (<base>..HEAD) ===
9+
# === Staged Changes ===
10+
# === Unstaged Changes ===
11+
12+
BASE="${1:?Error: base branch argument required}"
13+
OUT="${2:?Error: output file path argument required}"
14+
15+
{
16+
printf '=== Changed Files (%s..HEAD) ===\n' "${BASE}"
17+
git diff --name-status "${BASE}..HEAD"
18+
printf '\n'
19+
20+
printf '=== Commit Log (%s..HEAD) ===\n' "${BASE}"
21+
git log "${BASE}..HEAD" --oneline
22+
printf '\n'
23+
24+
printf '=== Commit Diff (%s..HEAD) ===\n' "${BASE}"
25+
git diff "${BASE}..HEAD"
26+
printf '\n'
27+
28+
printf '=== Staged Changes ===\n'
29+
git diff --cached
30+
printf '\n'
31+
32+
printf '=== Unstaged Changes ===\n'
33+
git diff
34+
printf '\n'
35+
} > "${OUT}"

.claude/settings.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@
2222
"Bash(gh pr checks:*)",
2323
"Bash(cmake:*)",
2424
"Bash(clang-format:*)",
25-
"Bash(cmake-format:*)"
25+
"Bash(cmake-format:*)",
26+
"Bash(.claude/scripts/fetch-diff.sh:*)",
27+
"Skill(parallel-review)",
28+
"Skill(review-resolve)",
29+
"Skill(review-respond)",
30+
"Skill(review-rounds)"
2631
],
2732
"deny": [
2833
"Read(.env.production)",

.claude/skills/parallel-review/SKILL.md

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: parallel-review
33
description: Launch parallel code review with multiple specialist reviewers
4-
allowed-tools: Agent, Read, Glob, Grep, Bash(grep:*), Bash(ls:*), Bash(find:*), Bash(git log:*), Bash(git diff:*), Bash(git show:*)
4+
allowed-tools: Agent, Read, Glob, Grep, Bash(.claude/scripts/fetch-diff.sh:*), Bash(grep:*), Bash(ls:*), Bash(find:*), Bash(git log:*), Bash(git diff:*), Bash(git show:*), Bash(rm:*)
55
---
66

77
# Parallel Code Review
@@ -64,27 +64,25 @@ If a base branch is not specified via `--base`, use `main` or `master` if either
6464
2. Read the target files or diff to grasp the scope.
6565
3. Produce a concise summary of the review content.
6666
4. Decide whether to add optional reviewers based on the scope. If the user has explicitly requested specific reviewers, include them.
67-
5. **Fetch diff information** — To avoid each reviewer redundantly running `git diff` themselves, the review leader fetches the diff once here and passes it to each reviewer:
68-
- Changed file list: `git diff --name-status {base}..HEAD`
69-
- Commit diff: `git diff {base}..HEAD`
70-
- Staged changes: `git diff --cached`
71-
- Unstaged changes: `git diff`
72-
- Branch-specific commit log: `git log {base}..HEAD --oneline`
73-
6. **Decide how to pass the diff to reviewers based on its size:**
74-
- **Less than 1,000 lines:** Embed directly in the prompt.
75-
- **1,000 lines or more:** Save to a temporary file and pass the **file path** to reviewers, who will read it via Read.
76-
- **Use the OS temporary directory as the save location** (avoid `.claude/` paths since they prompt for user confirmation).
77-
- Windows: `%TEMP%` / `$TEMP` (typically `C:\Users\{user}\AppData\Local\Temp`)
78-
- macOS / Linux: `$TMPDIR` or `/tmp`
79-
- Example filename: `parallel-review-diff-{timestamp}.txt`
67+
5. **Fetch diff information via script** — Run the provided script to collect all diff data atomically. This guarantees every section — including unstaged changes — is always written to the output file:
68+
- Generate an output file path: `/tmp/parallel-review-diff-{timestamp}.txt`
69+
- Run the script:
70+
```
71+
.claude/scripts/fetch-diff.sh {base} {output-file-path}
72+
```
73+
- The script writes the following sections in order:
74+
Changed Files / Commit Log / Commit Diff (`{base}..HEAD`) / Staged Changes / Unstaged Changes
75+
6. **Decide how to pass the diff to reviewers based on file size:**
76+
- **Less than 1,000 lines:** Read the file and embed its contents directly in the reviewer prompt.
77+
- **1,000 lines or more:** Pass the **file path** to reviewers, who will read it via Read.
8078
8179
## Step 2 — Launching Parallel Reviewers
8280
8381
Launch all selected reviewers **simultaneously** using the Agent tool. Each reviewer runs as a **read-only** sub-agent.
8482
8583
### Agent Prompt Template
8684
87-
Pass the following prompt to each reviewer agent (filling in `{name}`, `{perspective}`, `{targets}`, `{base}`, `{changed_files_list}`, `{diff_content_or_path}`, and `{commit_log_summary}`):
85+
Pass the following prompt to each reviewer agent (filling in `{name}`, `{perspective}`, `{targets}`, `{base}`, and `{diff_content_or_path}`):
8886
8987
```
9088
You are {name}. Conduct a code review from your specialist perspective.
@@ -94,15 +92,11 @@ You are {name}. Conduct a code review from your specialist perspective.
9492
Review target:
9593
- Scope: {targets}
9694
- Base branch: {base}
97-
- Changed files:
98-
{changed_files_list}
9995

100-
Diff (fetched by the review leader):
96+
Diff and context (pre-fetched by the review leader via script):
10197
{diff_content_or_path}
102-
(For under 1,000 lines, embed the diff body directly here. For 1,000+ lines, write `File path: {path}` and have the reviewer read it via Read.)
103-
104-
Branch-specific commits:
105-
{commit_log_summary}
98+
(Contains these sections: Changed Files / Commit Log / Commit Diff / Staged Changes / Unstaged Changes.
99+
For under 1,000 lines, the contents are embedded above. For 1,000+ lines, a file path is shown — read it via Read.)
106100

107101
Rules:
108102
- You are read-only. Do not edit or write any files under any circumstances.

0 commit comments

Comments
 (0)