Get the FREE Ultimate OpenClaw Setup Guide →

review-graphite-stack-chomper

npx machina-cli add skill n1ddeh/fantastic-skills/review-graphite-stack-chomper --openclaw
Files (1)
SKILL.md
7.7 KB

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:
    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:
    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:

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:

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:
    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:
    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:

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}

Source

git clone https://github.com/n1ddeh/fantastic-skills/blob/main/review-graphite-stack-chomper/SKILL.mdView on GitHub

Overview

This skill reviews all open non-draft PRs in a Graphite stack in parallel, starting from a provided PR URL or number. It runs review-pr-chomper on every branch and auto-posts GitHub comments and Linear updates without user confirmation. It can include drafts with --include-drafts for self-review.

How This Skill Works

Phase 1 parses the input to extract OWNER, REPO, PR_NUMBER and whether to INCLUDE_DRAFTS. Phase 2 discovers the local repo path, fetches all open PRs for the repo, resolves the anchor PR, and traverses the stack up and down to build a trunk to tip order. Phase 3 launches one general purpose review agent per PR in parallel via the Task tool, delivering reviews and updates in GitHub and Linear without waiting for individual results.

When to Use It

  • You have a PR URL or number and want the entire Graphite stack reviewed in parallel.
  • You want to include draft PRs in the stack review for self review.
  • You need automated GitHub comments and Linear updates without manual prompts.
  • You want to see and verify the full trunk to tip stack before dispatching reviews.
  • You are coordinating reviews across multiple branches in a Graphite stack and want parallel execution.

Quick Start

  1. Step 1: Provide a PR URL or number to start the stack review
  2. Step 2: Add --include-drafts if you want to review draft PRs as well
  3. Step 3: Let the tool discover the stack, display it, and dispatch parallel review agents automatically

Best Practices

  • Confirm the anchor PR matches the intended stack before enabling parallel reviews.
  • Decide if drafts should be included and set INCLUDE_DRAFTS accordingly.
  • Ensure you have access to fetch PR data and post comments on GitHub and Linear.
  • Review the displayed stack order before dispatching agents.
  • Monitor the resulting GitHub comments and Linear updates for visibility.

Example Use Cases

  • Review a PR stack by URL and include drafts for self review.
  • Review a stack by PR number after cloning the repo locally.
  • Enable include drafts to perform a full self review across the stack.
  • The system prints the trunk to tip stack and posts automatic updates to GitHub and Linear.
  • Launches parallel review agents so all PRs are reviewed in a single batch.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers