stack-pr

A command for splitting one oversized branch into several linked pull requests. A branch is a line of development, and a pull request is a proposed code change for review; each smaller request contains one slice of the original work.

In plain words
What is it for?
Use it to break a large branch into chained pull requests, choose a base branch, set a maximum size, create draft requests, or target selected repositories in a multi-repository workspace.
Why use it?
Large pull requests are harder to review and merge safely. This command can split work by commits or, when commits are messy, ask an analyzer to suggest logical slices within a line-count budget.

Command

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/higoralves/orc/stack-pr
Clone the repo
git clone --depth 1 https://github.com/HigorAlves/orc
Per session 46 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,784 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.00046 $0.02784
Opus 5 $0.00023 $0.01392
Sonnet 5 $0.00009 $0.00557
Haiku 4.5 $0.00005 $0.00278

Measured 2d ago against content hash b83036eecb75, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

stack-pr 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 2d ago.

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.

orc/commands/stack-pr.md · 272 lines

How it starts

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

/orc:stack-pr

Convert a single big branch into a stack of smaller, chained PRs. Use this when the size gate fires on /orc:ship, or anytime you've ended up with a 600-LOC branch and want to break it down before review.

Arguments

  • --smart — dispatch the orc-stack-analyzer agent to propose logical slices from the diff (rather than the default commit-based slicing). Use when commits are messy (WIP, fixups, no Conventional Commits).
  • --base <branch> — target a non-default base (e.g. develop). Defaults to origin/HEAD.
  • --draft — open every PR in the stack as a draft.
  • --max-loc <N> — override the per-slice LOC budget (default: 300).
  • --repos a,b / --repo a / --all-repos / --this-repo — workspace-mode targeting. See orc:workspace-mode.

Workflow

Phase 0 — Detect context

!orc-workspace-detect --banner

Context is injected above (ORC_* vars are exported for any Bash you run — do not re-run detection). Per-slice budget resolution: orc-pr-size budget ${ARG_MAX_LOC:+--max-loc "$ARG_MAX_LOC"}; per-slice LOC: orc-pr-size loc --base <slice-base>.

In workspace mode, resolve targetRepos from flags or AskUserQuestion. The stack lives per repo; cross-repo stacking is intentionally out of scope.

Phase 1 — Detect tooling

if command -v gh-stack >/dev/null 2>&1; then
  STACK_TOOL="gh-stack"
elif gh stack --help >/dev/null 2>&1; then
  STACK_TOOL="gh-stack-ext"
else
  STACK_TOOL="none"
fi

If none, present AskUserQuestion:

  1. Install — run gh extension install github/gh-stack. Continue when complete.
  2. Use plain-gh fallback — chain via gh pr create --base <prev-branch> per layer. No extension needed.
  3. Cancel.

Never auto-install.

Phase 2 — Verify preconditions

Invoke orc:verification-before-completion (tests pass, lint clean). Then per repo:

git status --porcelain                              # must be empty
git rev-list --merges "$base"..HEAD                 # must be empty
n_commits=$(git rev-list --count "$base"..HEAD)     # must be ≥ 2
git rev-list "@{u}..HEAD" --count 2>/dev/null       # should be 0; warn if not

Read the full file on GitHub · 272 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. 2d ago First seen · 272 lines · 46 tokens per session scan A b83036eecb75

Subscribe to this mod's changes

stack-pr is a command published in the GitHub repository HigorAlves/orc (6 stars, last pushed 5d ago), licensed MIT. It adds 46 tokens to every session and 2,784 once invoked, about $0.0002 per session on Opus 5. 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.