stack

A command for managing stacked pull requests with GitHub's gh stack extension. Stacked pull requests are a series of dependent pull requests, where each one builds on the previous change.

In plain words
What is it for?
Use it to view a stack, initialize or add branches, submit pull requests, synchronize branches, rebase them, and merge the stack after checks pass.
Why use it?
It organizes dependent changes and helps keep their branches and pull-request status synchronized. It also stops when rebasing produces conflicts instead of resolving them silently.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/cbmono/ai-setup/stack
Clone the repo
git clone --depth 1 https://github.com/cbmono/ai-setup

Made for: Claude Code.

Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 764 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00764
Opus 5 $0.00000 $0.00382
Sonnet 5 $0.00000 $0.00153
Haiku 4.5 $0.00000 $0.00076

Measured yesterday against content hash 2402eee81e31, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

stack scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/stack.md · 29 lines

How it starts

The opening of the file, as written. The whole thing — 29 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Manage a stacked-PR workflow using GitHub's gh stack extension.

Usage

  • /stack — no args → dispatch the stack-navigator agent for a summary + recommended next action
  • /stack <action> [args] — run the specific action below

Actions

Each maps to a real gh stack subcommand (run gh stack --help to see the full surface).

  • view (alias: status) — gh stack view, then summarize: current branch, position in stack, PR numbers and CI state. If not in a stack, say so and suggest init.
  • init <branch>gh stack init <branch>. Confirm the stack root was created.
  • add <branch>gh stack add <branch>. Remind the user to commit before the next submit.
  • submitgh stack view first (show what will be pushed), then gh stack submit. Report PR URLs.
  • syncgh stack sync (fetch + rebase + push + sync PR state). On rebase conflict, stop and hand back to the user with a clear summary. Do not resolve conflicts silently.
  • rebasegh stack rebase. Same conflict rule as sync.
  • merge — confirm the bottom PR is green, then gh stack merge. After it merges, run gh stack sync so the rest rebases onto the new base. If the stack is now empty (or only the base branch remains), list any files in .claude/plans/ and ask the user which (if any) to delete — the merged stack may have produced one. Where possible, highlight the likely candidate by matching plan filenames against Jira keys / branch names from the merged commits.
  • up [n] / down [n] / top / bottom — navigate via gh stack up/down/top/bottom. Confirm the new branch.
  • unstack — confirm with the user before running gh stack unstack — it removes the stack locally and on GitHub.

Guardrails

  • Never pass --force-style flags that aren't already the default. gh stack push already builds an explicit per-branch --force-with-lease refspec, so there is nothing to add.
  • gh stack push is not atomic — a multi-branch push can partially succeed. It pushes without --atomic (upstream cmd/push.go; recent gh stack push --help states it outright: "a branch may update even if another branch is rejected"). So when a push comes back non-zero, don't report it as "the push failed": say that some branches may already be updated on the remote, name the ones the output shows as pushed and the one that was rejected, and rerun only after the rejection is resolved — a blind rerun re-pushes what already landed and buries which lease actually failed. Don't generalise from gh stack sync, which does push atomically (--force-with-lease --atomic).
  • If gh isn't authenticated (gh auth status non-zero), tell the user to run gh auth login and stop.
  • If the extension isn't installed (gh extension list doesn't include github/gh-stack), tell the user to run gh extension install github/gh-stack and stop.
  • For submit / sync, always show the stack view first so the user sees what's about to happen.

Read the full file on GitHub · 29 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 29 lines · 0 tokens per session scan A 2402eee81e31

Subscribe to this mod's changes

stack is a command published in the GitHub repository cbmono/ai-setup (2 stars, last pushed 8d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 764 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.