restack

restack is a command for coding agents from muhimu/claude-plan-lifecycle. It costs 53 tokens per session (3,101 once invoked), scanned A, original, MIT.

A command for updating a stacked pull-request chain after lower pull requests are squash-merged into the default branch.

In plain words
What is it for?
Discovering the stack from GitHub, cascading rebases through its branches, verifying the final branch, force-with-lease pushing, and retargeting the next pull request.
Why use it?
It carries the remaining branches forward onto the updated base and checks the result before publishing rewritten history.

Command

Part of the plan-lifecycle plugin — 3 skills, 5 commands shipped together

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/muhimu/claude-plan-lifecycle/restack
Clone the repo
git clone --depth 1 https://github.com/muhimu/claude-plan-lifecycle

Or install plan-lifecycle, the plugin that ships this one along with the rest of its 3 skills, 5 commands.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for restack

README.md
[![agentmods](https://agentmods.dev/badge/commands/muhimu/claude-plan-lifecycle/restack.svg)](https://agentmods.dev/commands/muhimu/claude-plan-lifecycle/restack)
Your own site
<a href="https://agentmods.dev/commands/muhimu/claude-plan-lifecycle/restack"><img src="https://agentmods.dev/badge/commands/muhimu/claude-plan-lifecycle/restack.svg" alt="Measured on agentmods" height="20"></a>
Per session 53 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,101 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.00053 $0.03101
Opus 5 $0.00026 $0.01550
Sonnet 5 $0.00011 $0.00620
Haiku 4.5 $0.00005 $0.00310

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

Security

Grade A, and why

restack 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 4d 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.

commands/restack.md · 218 lines

How it starts

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

Restack

Run after one or more bottom PRs of a stack (created by /execute-plan stacked mode) squash-merged to the default branch. Rebases every surviving branch onto the new default-branch head (cascade), verifies the tip, and — after a single confirmation — force-with-lease pushes the rebased branches and retargets the new bottom PR to the default branch.

This command runs in the worktree holding the stack. It refuses to run in the main checkout.

Step 1 — Pre-flight checks

Run each check in order. On any failure, stop: print the message and end the turn.

  1. Inside a git worktree? git rev-parse --is-inside-work-tree — if not, stop: "Not inside a git working tree."
  2. Worktree, not main checkout? git rev-parse --git-dir — if the output is .git (or an absolute path ending in /.git), stop: "This command refuses to run in the main checkout. Run it in the stack's worktree."
  3. Not on the default branch? Resolve it once — DEFAULT_BRANCH="$(git symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null | sed 's|^origin/||')", falling back to gh repo view --json defaultBranchRef -q .defaultBranchRef.name; every later mention of $DEFAULT_BRANCH means this value. Then git rev-parse --abbrev-ref HEAD — if it equals $DEFAULT_BRANCH (or main/master), stop: "Worktree is on a protected branch. Check out a stack branch first."
  4. Clean tree (tracked files). git status --porcelain — ignore ?? (untracked) lines: when local/ is symlinked into the worktree, ?? local is always present (the symlink isn't matched by the local/ gitignore entry) and untracked files don't participate in a rebase. If any NON-?? line exists, stop: "Worktree has uncommitted changes to tracked files. Commit or stash them first — restacking with a dirty tree is not supported."
  5. Fetch. git fetch origin --prune (prune so branches GitHub auto-deleted after merge disappear from remote-tracking refs).

Read the full file on GitHub · 218 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. 4d ago First seen · 218 lines · 53 tokens per session scan A 8f21d2153e3f

Subscribe to this mod's changes

restack is a command published in the GitHub repository muhimu/claude-plan-lifecycle (2 stars, last pushed 3d ago), licensed MIT. It adds 53 tokens to every session and 3,101 once invoked, about $0.0003 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.