stack-merge

A procedure for moving a complete stack of related Graphite pull requests into the main branch with one fast-forward update. A pull-request stack is a chain of dependent changes, and a fast-forward keeps their commits in a straight line.

In plain words
What is it for?
Bulk-merging a stack through a chosen pull request, updating main, and closing the included pull requests explicitly.
Why use it?
It lands many dependent changes at once without waiting for Graphite’s merge queue or creating merge commits, subject to administrator access and the stated checks.

Skill for Claude CodeCodex

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 skills/rivet-dev/actors/stack-merge
Any agent
npx skills add rivet-dev/actors --skill stack-merge
Clone the repo
git clone --depth 1 https://github.com/rivet-dev/actors

Made for: Claude Code, Codex.

Per session 157 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,214 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.00157 $0.02214
Opus 5 $0.00078 $0.01107
Sonnet 5 $0.00031 $0.00443
Haiku 4.5 $0.00016 $0.00221

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

Security

Grade A, and why

stack-merge 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.

The scan reads SKILL.md. This mod also ships 4 executable files (scripts/detect_ralph.sh, scripts/exec_merge.sh, scripts/list_merge_path.sh, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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/skills/stack-merge/SKILL.md · 138 lines

How it starts

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

Stack Merge

Land an entire Graphite downstack into main in one admin-bypass fast-forward push, then close every in-scope PR explicitly. No per-PR CI gates, no merge commits on main, no gh pr merge per PR. PRs end up in Closed state (not MERGED) unless their base was already main, but their commits are in main's history.

This skill replaces Graphite's merge queue — use when you want the outcome Graphite's queue produces (linear history, all PRs merged) but without waiting for the queue. Requires admin bypass on main branch protection.

When NOT to use

  • User wants normal single-PR merge → use gh pr merge.
  • User isn't a repo admin → push will reject (tell them to use Graphite's queue).
  • Stack tip has failing CI and user cares → queue would refuse; pause here too.

Preconditions (verify at start; bail early)

  1. Admin/bypass on main: gh api repos/rivet-dev/rivet/branches/main/protection — check user is in bypass_pull_request_allowances.users[] or has repo admin. If not, stop.
  2. Graphite initialized: gt ls succeeds.
  3. Clean working tree: git status --short empty. In-flight rebase/merge state must be resolved first.
  4. Worktree sanity: git worktree list — prune any prunable entries with git worktree prune. Stale worktrees break rebases with "already checked out at" errors. See references/gotchas.md.

The flow (8 phases)

Each phase has a validation gate or confirmation gate. Writes happen only after the user explicitly approves the final commands.

Phase 1 — Scope

Input: target branch name from user.

  • Enumerate the merge path: walk gh pr view <branch> --json baseRefName from target down to main. Produces the ordered list of all PRs that will be closed in Phase 8.
  • Do not infer parents from gt ls visual order — use each PR's baseRefName. See gotchas.md.
  • Script: scripts/list_merge_path.sh <target-branch>.

Phase 2 — Sync

  • gt sync --no-interactive. Pulls latest main, cleans up merged upstream branches.
  • Read output for any (needs restack) markers in the merge path.

Read the full file on GitHub · 138 lines

Files

What ships with it

6 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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 · 138 lines · 157 tokens per session scan A f0c3b6cbad81

Subscribe to this mod's changes

stack-merge is a skill published in the GitHub repository rivet-dev/actors (6,096 stars, last pushed 4d ago), licensed Apache-2.0. It adds 157 tokens to every session and 2,214 once invoked, about $0.0008 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-30.