
Stack Mode
Run PR review or fix flows once across an entire stacked-diff chain in base-to-tip order instead of repeating commands per PR.
Install
npx skills add https://github.com/athola/claude-night-market --skill stack-modeWhat is this skill?
- Resolves stack membership via Step 1 before any per-PR workflow runs
- Requires `--stack` flag and optional `--base` override (default master)
- Iterates the calling command in base-to-tip order across all stack PRs
- Keeps per-PR outputs unchanged and emits one consolidated summary on the stack root
- Depends on sanctum stack-create, stack-push, stack-rebase and leyline git-platform
Adoption & trust: 1 installs on skills.sh; 304 GitHub stars; trending (+100% hot-view momentum).
Recommended Skills
Triagemattpocock/skills
Caveman Commitjuliusbrussee/caveman
Using Git Worktreesobra/superpowers
Finishing A Development Branchobra/superpowers
Git Commitgithub/awesome-copilot
Git Guardrails Claude Codemattpocock/skills
Journey fit
Primary fit
Stack mode wraps review and fix commands at ship time when multiple dependent PRs target the same base branch. Canonical shelf is code review and PR iteration—the skill loops `/pr-review --stack` and `/fix-pr --stack` without changing per-PR outputs.
SKILL.md
READMESKILL.md - Stack Mode
# Stack Mode Shared contract for commands that need to operate across a whole stack of dependent PRs in one invocation. Used by `/pr-review --stack` and `/fix-pr --stack`. The goal is one simple thing: when a PR is part of a stack targeting a common base branch, loop the command's normal workflow across every PR in the stack in base-to-tip order and emit one consolidated summary on the stack root. ## When to Use Load this skill when a command accepts a `--stack` flag (or auto-detects stack membership) and needs to iterate its normal workflow across multiple PRs. Do NOT load this skill for single-PR workflows. The per-PR workflow stays unchanged; stack mode wraps it. ## Contract A calling command MUST: 1. Accept a `--stack` boolean flag AND a `--base <branch>` override (default: `master`). 2. Call Step 1 below to resolve stack membership BEFORE running its main workflow. 3. Run its main workflow per PR in the resolved order. 4. Emit per-PR outputs unchanged (thread replies, issue links, etc.). 5. Emit ONE stack-level summary comment on the root PR using the format in Step 4. 6. Respect per-PR Gate rules (every PR still needs its own thread resolution and issue tracking). A calling command MAY: - Auto-detect stack membership and prompt the user rather than requiring `--stack` explicitly. - Short-circuit iteration when a per-PR failure leaves downstream PRs with stale context. ## Required Progress Tracking The caller creates `TodoWrite` items: 1. `stack-mode:membership-resolved` 2. `stack-mode:iteration-complete` 3. `stack-mode:root-summary-posted` ## Step 1: Resolve Stack Membership (`membership-resolved`) Given a starting PR number `$PR_NUM` and optional base `$BASE` (default: `master`), try three strategies in order and stop at the first that yields a stack of size >= 2. ### Strategy A: Branch-name convention (cheapest) ```bash START_HEAD=$(gh pr view "$PR_NUM" \ --json headRefName -q .headRefName) # stack/<feature-name>/<slice-name> if [[ "$START_HEAD" =~ ^stack/([^/]+)/.+$ ]]; then FEATURE="${BASH_REMATCH[1]}" PREFIX="stack/${FEATURE}/" # All local branches with the same prefix STACK_BRANCHES=$(git branch --list "${PREFIX}*" \ | sed 's/^[* ]*//' | sort) # Map branches -> PR numbers (skip branches with no PR) STACK_PRS=() for branch in $STACK_BRANCHES; do pr=$(gh pr list --head "$branch" \ --json number --jq '.[0].number') [ -n "$pr" ] && STACK_PRS+=("$pr") done echo "strategy=A prs=${STACK_PRS[*]}" fi ``` ### Strategy B: Stack summary comment (most reliable) `stack-push` posts a `## Stack` markdown table on the root PR with columns `# | Branch | PR`. Parse it: ```bash # Find the root PR of the stack containing $PR_NUM # The current PR may be the root, or may link to it via # a "Part of stack `stack/<feature>`" phrase in its body BODY=$(gh pr view "$PR_NUM" --json body -q .body) # Look for a "## Stack" table in THIS PR's comments TABLE=$(gh pr view "$PR_NUM" --json comments \ --jq '.comments[] | select(.body | contains("## Stack")) | .body' | head -1) # If not on this PR, look for the root PR reference if [ -z "$TABLE" ]; then ROOT_REF=$(echo "$BODY" \ | grep -oE 'stack/[^ `]+' | head -1) # ... resolve ROOT_REF -> root PR number and re-fetch fi # Parse the table: extract all `#<num>` from the PR column STACK_PRS=($(echo "$TABLE" \ | grep -oE '#[0-9]+' | tr -d '#' | sort -un)) echo "strategy=B prs=${STACK_PRS[*]}" ``` ### Strategy C: Base-chain wa