gh-stack

gh-stack is a skill for Claude Code, Codex from knitli/toolshed. It costs 65 tokens per session (10,581 once invoked), scanned A, a copy of gh-stack, MIT.

A GitHub CLI extension for managing stacked branches and pull requests. A stack is a chain of dependent branches where each pull request builds on the one below it.

In plain words
What is it for?
Use it to create, push, rebase, synchronize, inspect, and navigate stacks of dependent GitHub pull requests.
Why use it?
It helps split a large change into smaller pull requests while keeping their dependencies organized. It also supports updating and navigating the branch chain.

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

Made for: Claude Code, Codex.

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 gh-stack

README.md
[![agentmods](https://agentmods.dev/badge/skills/knitli/toolshed/gh-stack.svg)](https://agentmods.dev/skills/knitli/toolshed/gh-stack)
Your own site
<a href="https://agentmods.dev/skills/knitli/toolshed/gh-stack"><img src="https://agentmods.dev/badge/skills/knitli/toolshed/gh-stack.svg" alt="Measured on agentmods" height="20"></a>
Per session 65 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 10,581 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 100% copy Near-identical to another mod 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.00065 $0.10581
Opus 5 $0.00032 $0.05291
Sonnet 5 $0.00013 $0.02116
Haiku 4.5 $0.00006 $0.01058

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

Security

Grade A, and why

gh-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 today.

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.

Origin

This is a copy

100% identical to gh-stack — 18 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.agents/skills/gh-stack/SKILL.md · 892 lines

How it starts

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

gh-stack

gh stack is a GitHub CLI extension for managing stacked branches and pull requests. A stack is an ordered list of branches where each branch builds on the one below it, rooted on a trunk branch (typically the repo's default branch). Each branch maps to one PR whose base is the branch below it, so reviewers see only the diff for that layer.

main (trunk)
 └── auth-layer     → PR #1 (base: main)            - bottom (closest to trunk)
  └── api-endpoints → PR #2 (base: auth-layer)
   └── frontend     → PR #3 (base: api-endpoints)   - top (furthest from trunk)

The bottom of the stack is the branch closest to the trunk, and the top is the branch furthest from the trunk. Each branch inherits from the one below it. Navigation commands (up, down, top, bottom) follow this model: up moves away from trunk, down moves toward it.

When to use this skill

Use this skill when the user wants to:

  • Break a large change into a chain of small, reviewable PRs
  • Create, rebase, push, or sync a stack of dependent branches
  • Navigate between layers of a branch stack
  • View the status of stacked PRs
  • Tear down and rebuild a stack to remove, reorder, or rename branches

Prerequisites

The GitHub CLI (gh) v2.0+ must be installed and authenticated. Install the extension with:

gh extension install github/gh-stack

Before using gh stack, configure git to prevent interactive prompts:

git config rerere.enabled true           # remember conflict resolutions (skips prompt on init)
git config remote.pushDefault origin     # if multiple remotes exist (skips remote picker)

Agent rules

All gh stack commands must be run non-interactively. Every command invocation must include the flags and positional arguments needed to avoid prompts, TUIs, and interactive menus. If a command would prompt for input, it will hang indefinitely.

  1. Always supply branch names as positional arguments to init, add, and checkout. Running these commands without arguments triggers interactive prompts. Branch names are used exactly as given — a name is never prefixed or transformed, so gh stack add refactor/foo creates a branch named refactor/foo.
  2. Always use --auto with gh stack submit to auto-generate PR titles. Without --auto, submit prompts for a title for each new PR.
  3. Always use --json with gh stack view. Without --json, the command launches an interactive TUI that cannot be operated by agents. There is no other appropriate flag — always pass --json.
  4. Handle multiple remotes. If more than one remote is configured, pre-configure git config remote.pushDefault origin, or pass --remote <name> to the commands that accept it: push, submit, sync, rebase, and link. checkout, modify, and trunk resolve a remote but have no --remote flag — they rely on remote.pushDefault. With multiple remotes and no configured default, these commands exit with an error in non-interactive mode.
  5. Avoid branches shared across multiple stacks. If a branch belongs to multiple stacks, commands exit with code 6. Check out a non-shared branch first.
  6. Plan your stack layers by dependency order before writing code. Foundational changes (models, APIs, shared utilities) go in lower branches; dependent changes (UI, consumers) go in higher branches. Think through the dependency chain before running gh stack init.
  7. Use standard git add and git commit for staging and committing. This gives you full control over which changes go into each branch. The -Am shortcut is available but should not be the default approach—stacked PRs are most effective when each branch contains a deliberate, logical set of changes.
  8. Navigate down the stack when you need to change a lower layer. If you're working on a frontend branch and realize you need API changes, don't hack around it at the current layer. Navigate to the appropriate branch (gh stack down, gh stack checkout, or gh stack bottom), make and commit the changes there, run gh stack rebase --upstack, then navigate back up to continue.
  9. Use gh stack link for external tool workflows. When branches are managed by an external tool (jj, Sapling, etc.), use gh stack link branch-a branch-b. link does not rely on local tracking state and is intended for API-driven PR and stack management. Provide at least two branches/PRs to create or update a stack, or a stack number followed by the new branches/PRs to append them to the top of an existing stack (e.g. gh stack link 7 branch-c).
  10. Use gh stack merge --yes to merge stacked PRs. gh pr merge does not work with stacked PRs. In a non-interactive terminal gh stack merge runs without prompting and merges the entire stack (bottom to top) atomically; pass --yes to be explicit. Scope the merge by passing a pull request number (gh stack merge 42 --yes merges everything up to and including PR #42) or a stack number (gh stack merge 7 --yes, which needs no local checkout). Choose the method with --squash, --rebase, --merge, or --merge-method <method>; without one, the last-used method is used. The merge is all-or-nothing — if any PR can't be merged, none are, and the failure reason is reported. Only basic pull request state is checked before merging (open and not a draft); bypassing merge requirements is not supported for stacks. If the base branch uses a merge queue, the stack is added to the queue instead of merging directly: the queue chooses the merge method (any method you pass is ignored with a warning), and the pull requests are added to the queue together but merge as the queue processes them, so they may land in separate groups rather than all at once.

Read the full file on GitHub · 892 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. today First seen · 892 lines · 65 tokens per session scan A d02c3b73baac

Subscribe to this mod's changes

gh-stack is a skill published in the GitHub repository knitli/toolshed (1 stars, last pushed yesterday), licensed MIT. It adds 65 tokens to every session and 10,581 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. It is 100% identical to gh-stack, differing in 18 lines, and is treated as a copy.

Related

Other skills, from other repositories

motherduck-build-cfa-app

Design a MotherDuck-backed customer-facing analytics app. Use for embedded analytics, multi-tenant SaaS reporting, or product analytics for external users -- whenever the decision depends on per-customer isolation, backend routing, service-account boundaries, read scaling, or Hypertenancy-style patterns.

motherduckdb/agent-skills · 63 tokens

motherduck-build-data-pipeline

Design an end-to-end MotherDuck data pipeline. Use for ETL/ELT workflows -- choosing raw, staging, and analytics boundaries, bulk ingestion paths, transformation sequencing, dlt/dbt integration, publication targets, or whether DuckLake is actually required.

motherduckdb/agent-skills · 59 tokens

motherduck-create-dive

Create, edit, manage, share, or embed MotherDuck Dives — live React + SQL dashboards, charts, and data apps saved in the workspace. Use for any dashboard, chart, KPI display, or data visualization over MotherDuck data, and for Dive authoring mechanics such as getdiveguide, useSQLQuery, local preview, version history…

motherduckdb/agent-skills · 95 tokens

motherduck-create-flight

Create, schedule, run, and debug MotherDuck Flights — Python jobs that run on MotherDuck compute. Use whenever someone wants to create a flight, schedule a Python script or recurring job on MotherDuck, set up scheduled ingestion from Postgres, dlt sources, S3, BigQuery, Snowflake, or APIs, refresh aggregates or…

motherduckdb/agent-skills · 106 tokens

motherduck-migrate-to-motherduck

Plan a migration onto MotherDuck. Use when moving from Snowflake, BigQuery, Redshift, PostgreSQL, dbt-heavy stacks, or lakehouse tooling and the key decisions are target pattern, cutover slices, source-vs-target validation, rollback, and native-versus-DuckLake posture.

motherduckdb/agent-skills · 70 tokens

motherduck-build-dashboard

Build a live MotherDuck dashboard as a Dive. Use when composing one shareable KPI, trend, and breakdown story over existing MotherDuck data, especially when the result should stay a saved workspace artifact rather than a full application.

motherduckdb/agent-skills · 50 tokens