# Review Graphite Stack Chomper

> Reviews all open non-draft PRs in a Graphite stack in parallel. Use when the user provides a PR number or URL and wants the entire stack reviewed. Runs review-pr-chomper on each branch and auto-posts GitHub comments and Linear updates without user confirmation. Supports --include-drafts to review draft PRs as well (e.g. for self-review).

- Skill: `n1ddeh/review-graphite-stack-chomper` (Agent Skill)
- Install (CLI): `npx skillmds@latest add n1ddeh/review-graphite-stack-chomper`
- Raw SKILL.md: https://api.skillmd.com/api/skills/n1ddeh/review-graphite-stack-chomper/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: n1ddeh (https://skillmd.com/u/n1ddeh)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/n1ddeh/review-graphite-stack-chomper

---


# Review Stack

Reviews all open non-draft PRs in a Graphite stack in parallel using the review-pr-chomper process.

## Phase 1: Parse Input

The user will provide a PR URL or number. Extract the owner, repo, and PR number:

- If input matches `https://github.com/{owner}/{repo}/pull/{number}`, extract all three
- If input is a bare number (e.g. `2568`), detect the current repo from git remote:
  ```bash
  git remote get-url origin  # parse owner/repo from SSH or HTTPS URL
  ```
  Use the parsed `owner` and `repo` with `number={input}`
- If no input is given, use the current branch to find the PR:
  ```bash
  gh pr view --json number,headRefName,baseRefName,isDraft
  ```

Also detect if the user wants to include draft PRs. Set `INCLUDE_DRAFTS=true` if any of the following are present:
- `--include-drafts` flag
- phrases like "including drafts", "self review", "review drafts too", "all PRs", or similar intent

Store: `OWNER`, `REPO`, `PR_NUMBER`, `INCLUDE_DRAFTS` for use in subsequent phases.

## Phase 2: Discover Stack

**Step 1 — Detect the local repo path:**

Search in this order:
1. Current directory (if it matches the repo name)
2. Glob `~/Documents/projects/**/{repo}`
3. Glob `~/{repo}`

If not found, report and abort: `Error: Local clone of {owner}/{repo} not found. Clone it first.`

Store as `LOCAL_REPO_PATH`.

**Step 2 — Fetch all open PRs for the repo:**
```bash
gh pr list --repo {OWNER}/{REPO} --state open \
  --json number,headRefName,baseRefName,title,isDraft \
  --limit 100
```

Store the result as `ALL_OPEN_PRS`.

**Step 3 — Resolve the anchor PR's branches:**
```bash
gh pr view {PR_NUMBER} --repo {OWNER}/{REPO} \
  --json number,headRefName,baseRefName,title,isDraft
```

Store as `ANCHOR_PR`.

**Step 4 — Traverse the stack via base-branch chain:**

Build the full ordered stack by walking both directions from the anchor PR using `ALL_OPEN_PRS`:

**Downstack (toward trunk):** Find the PR in `ALL_OPEN_PRS` whose `headRefName` = anchor's `baseRefName`. Then repeat for that PR's `baseRefName`. Stop when no matching PR is found (i.e. `baseRefName` is a trunk branch: `develop`, `main`, `master`, or matches `release/*`).

**Upstack (away from trunk):** Find PRs in `ALL_OPEN_PRS` whose `baseRefName` = anchor's `headRefName`. Repeat for each found PR's `headRefName`. If a branch has multiple upstack PRs (diverged stack), include all.

**Step 5 — Sort from trunk upward:**

Order the collected PRs from closest-to-trunk at [1] up to the tip at the end. The anchor PR may be anywhere in this list.

**Step 6 — Display the stack:**

Show the full stack before proceeding. Mark drafts based on `INCLUDE_DRAFTS`:
```
Stack discovered for PR #{PR_NUMBER}:
  [1] #{number} {branch} — open
  [2] #{number} {branch} — open
  [3] #{number} {branch} — draft (reviewing)     ← if INCLUDE_DRAFTS=true
  [3] #{number} {branch} — draft, skipping        ← if INCLUDE_DRAFTS=false
```

Proceed automatically (do not wait for user confirmation).

## Phase 3: Dispatch Parallel Agents

Use the Task tool to launch one `general-purpose` agent per PR to review **simultaneously in a single message** (all Task tool calls in the same response). Do not wait for one agent to finish before starting the next.

Which PRs to dispatch:
- If `INCLUDE_DRAFTS=false` (default): dispatch only non-draft open PRs
- If `INCLUDE_DRAFTS=true`: dispatch all open PRs in the stack, including drafts

Each agent receives the following prompt. Fill in the bracketed values for each PR:

---

**Agent prompt template:**

```
You are reviewing PR #{PR_NUMBER} ({PR_TITLE}) on branch {HEAD_REF} in the {OWNER}/{REPO} repo.

Your job is to run a full code review using the review-pr-chomper skill and automatically post all findings without asking for user confirmation.

IMPORTANT: Do NOT ask the user to confirm anything. Automatically post all GitHub comments and all Linear comments. Do not pause for approval.

## Setup: Create a worktree

```bash
cd {LOCAL_REPO_PATH}
# Ensure .worktrees is gitignored
grep -q '.worktrees' .gitignore || echo '.worktrees/' >> .gitignore
git fetch origin {HEAD_REF}
git worktree add .worktrees/review-stack-{PR_NUMBER} origin/{HEAD_REF}
cd .worktrees/review-stack-{PR_NUMBER}
```

## Run the review-pr-chomper process

Read the full skill from `~/.claude/skills/review-pr-chomper/SKILL.md` and follow every step exactly as written, with these modifications:

1. **Step 4 (PR comments):** Run `~/.claude/skills/review-pr-chomper/scripts/pr-comments.sh` from within the worktree directory.
2. **GitHub Comments — SKIP the confirmation prompt.** After generating the suggested GitHub comments, post them immediately using:
   ```bash
   gh api repos/{OWNER}/{REPO}/pulls/{PR_NUMBER}/reviews \
     --method POST \
     --field body='' \
     --field event='COMMENT' \
     --field 'comments[][path]={file}' \
     --field 'comments[][line]={line}' \
     --field 'comments[][body]={comment_body}'
   ```
   Post all comments as a single batch review. Do not ask the user.
3. **Linear Ticket Gap — SKIP the confirmation prompt.** If a significant gap is found, post the comment on the Linear ticket immediately using the Linear MCP `create_comment` tool. Do not ask the user.
4. **Existing PR comment replies — SKIP the confirmation prompt.** For any Questionable or Noise PR comments where you would normally offer to post a reply, post it automatically using:
   ```bash
   gh api repos/{OWNER}/{REPO}/pulls/comments/{COMMENT_DATABASE_ID}/replies \
     --method POST \
     --field body='{reply_body}'
   ```

## Cleanup

After the review is complete, remove the worktree:
```bash
cd {LOCAL_REPO_PATH}
git worktree remove .worktrees/review-stack-{PR_NUMBER} --force
```

## Return a structured summary

When done, return ONLY this structured summary (no other text):

```
PR #{PR_NUMBER} — {PR_TITLE}
Branch: {HEAD_REF}
Linear: {ISSUE_ID or "none"}

Issues:
  🔴 Bugs: {count}
  🟡 Warnings: {count}
  🔵 Suggestions: {count}

GitHub comments posted: {count}
Linear comment posted: {yes/no — reason if yes}
PR comment replies posted: {count}

Top findings:
- {severity} {file}:{line} — {one-line description}
- {severity} {file}:{line} — {one-line description}
(list up to 5 most important)

Skeptic dropped: {count} suggestions filtered
```
```

---

## Phase 4: Present Aggregated Summary

After all agents return, compile their structured summaries into a single report:

```markdown
## Stack Review — PR #{ANCHOR_PR_NUMBER}

Stack ({total_reviewed} reviewed, {total_skipped} skipped):
  [1] #{number} {title}
  [2] #{number} {title}
  [3] #{number} {title} — (draft, skipped)     ← INCLUDE_DRAFTS=false
  [3] #{number} {title} — (draft)               ← INCLUDE_DRAFTS=true

---

### #{number} {title}
🔴 {bugs}  🟡 {warnings}  🔵 {suggestions}
GitHub comments: {count} posted
Linear: {issue_id} — {gap comment posted / no gap found}

Top findings:
- {finding}
- {finding}

### #{number} {title}
✅ No issues found
GitHub comments: {count} posted
Linear: No gap found

---

Total: {total_bugs} bugs, {total_warnings} warnings, {total_suggestions} suggestions across {total_reviewed} PRs
{total_github_comments} GitHub comments posted | {total_linear_comments} Linear comments posted
```

If any agent failed (e.g. worktree error, branch not found), report it clearly:
```
### #{number} {title} — ERROR
Failed to create worktree: {error message}
```

