---
description: "Map Phase 4 triage findings to branch diff lines. Read-only post-hoc command, used after review to answer 'which finding lines up with which code change'. Use when a review finding has to be traced to the exact lines that caused it."
description-tr: "Faz 4 triyaj bulgularını branch diff satırlarına eşler. Review sonrası kullanılan salt-okunur komut: hangi bulgu hangi kod değişikliğine denk geliyor sorusunu cevaplar."
argument-hint: "[#task-id | --triage <path> | --state <path>] [--branch <name>] [--base <name>]"
---

# multi-agent diff-explain  -  Phase 4 Triage to Diff Bridge

Maps the Phase 4 triage output (`accepted` / `deferred` / `rejected`) onto the branch's `git diff`. Every finding lands inline with the matching file / line hunk.

**This command has no side effects.** It runs `git diff` and prints markdown.

## When to use it

- Between Phase 4 and Phase 5/6: answers "5 findings  -  which one belongs to which file?"
- Phase 7 reporting: a "review summary with code context" block to embed in the Wiki / Confluence output.
- Post-hoc audit: for a closed PR, a "what did review flag, and how did the code change" diff.

## Steps

1. **Resolve input**  -  figure out the triage source from `$ARGUMENTS`:
   - `#N` or `JIRA-N`: pull the triage from the task's state file
   - `--triage <path>`: triage-output.json directly
   - `--state <path>`: agent-state.json (with embedded triage)
   - None: use the active task

2. **Pick the diff source**:
   - `--branch <name>`: target branch (default: HEAD)
   - `--base <name>`: comparison base (default: origin/main → main)
   - `--diff <path>`: precomputed diff (skips the git call; for CI / sandboxes)

3. **Run the script** and show the output directly to the user:
   ```bash
   node "$HOME/.claude/scripts/diff-explain.mjs" \
     --triage "<resolved-path>" \
     --branch "<branch>" \
     --base "<base>"
   ```

4. **Annotate the output** (optional):
   - Whether every blocking finding actually got touched (Phase 3 fix-coverage check)
   - Whether every deferred finding is on the Phase 7 follow-up list

## Output template

```markdown
# Phase 4 Triage Diff Bridge

## Summary
- Accepted: 3 (🚫 1 blocking · ⚠️ 1 important · 💡 1 suggestion)
- Deferred: 1 · Rejected: 0
- Approved: ❌ no

## src/api/checkout.ts

### ✅ 🚫 BLOCKING  -  line 102 (opus)
> Race condition: order total computed twice without lock
**Fix:** Compute total once inside the existing transaction block
```diff
@@ -98,5 +98,7 @@ ...
   const total = sum(items);
+  const total2 = sum(items);  // duplicate
   await chargeCard(total);
```
```

Icons:
- Bucket: ✅ accepted · ⏭️ deferred · ❌ rejected
- Severity: 🚫 blocking · ⚠️ important · 💡 suggestion
