Fix Claude diff temp file handling

This commit is contained in:
Garry Tan
2026-04-25 08:44:01 -07:00
parent efcd10ac8c
commit 864342726c
3 changed files with 9 additions and 5 deletions
+6 -5
View File
@@ -151,8 +151,9 @@ Review the current branch diff with nested Claude in tool-less mode.
```bash
_REPO_ROOT=$(git rev-parse --show-toplevel) || { echo "ERROR: not in a git repo" >&2; exit 1; }
cd "$_REPO_ROOT"
DIFF_FILE=$(mktemp /tmp/gstack-claude-diff-XXXXXX.patch)
git fetch origin <base> --quiet 2>/dev/null || true
git diff "origin/<base>" > /tmp/gstack-claude-diff-$$.patch 2>/dev/null || git diff "<base>" > /tmp/gstack-claude-diff-$$.patch
git diff "origin/<base>" > "$DIFF_FILE" 2>/dev/null || git diff "<base>" > "$DIFF_FILE"
```
If the diff file is empty, stop and say:
@@ -171,7 +172,7 @@ Additional user instructions, if any:
DIFF:
EOF
cat /tmp/gstack-claude-diff-$$.patch >> "$PROMPT_FILE"
cat "$DIFF_FILE" >> "$PROMPT_FILE"
```
3. Run Claude:
@@ -192,7 +193,7 @@ CLAUDE SAYS (code review):
5. Cleanup:
```bash
rm -f /tmp/gstack-claude-diff-$$.patch "$PROMPT_FILE" "$RESP_FILE" "$ERR_FILE"
rm -f "$DIFF_FILE" "$PROMPT_FILE" "$RESP_FILE" "$ERR_FILE"
```
---
@@ -217,7 +218,7 @@ Focus area, if any:
DIFF:
EOF
cat /tmp/gstack-claude-diff-$$.patch >> "$PROMPT_FILE"
cat "$DIFF_FILE" >> "$PROMPT_FILE"
```
3. Run Claude:
@@ -238,7 +239,7 @@ CLAUDE SAYS (adversarial challenge):
5. Cleanup:
```bash
rm -f /tmp/gstack-claude-diff-$$.patch "$PROMPT_FILE" "$RESP_FILE" "$ERR_FILE"
rm -f "$DIFF_FILE" "$PROMPT_FILE" "$RESP_FILE" "$ERR_FILE"
```
---