Skip to content
Skill

Gh stack

Guides an agent through creating, editing, syncing and merging stacked GitHub pull

Gh stack is an open-source agent skill for developer tools. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

Scripts
None
Platforms
Claude Code, Codex, Cursor
GitHub stars
39
Last commit
License
MIT
Listing updated

Similar skills

About Gh stack

This skill teaches an AI coding agent to work with the gh-stack GitHub CLI extension, which manages chains of dependent branches where each branch backs one pull request based on the layer below it. It covers creating a stack, adding layers, viewing its state as JSON, pushing and submitting draft PRs, and keeping the stack in sync with GitHub after reviews or upstream changes.

Beyond the commands themselves, the instructions set rules for non-interactive use, since gh-stack opens prompts or full-screen interfaces under a terminal. The agent is told which flags to always pass, how to place a change in the correct layer when editing an existing stack, how to rebase upstack, and how to read exit codes and recover from rebase conflicts. It also includes an optional workflow that keeps each layer in its own worktree and links the stack on GitHub without local tracking.

The skill expects the gh CLI with the gh-stack extension installed, a git repository with a GitHub remote, and a configured default remote when more than one exists. Additional reference files cover stack design, command preconditions and troubleshooting.

When your agent uses it

Manages stacked PRs and splits multi-part work into reviewable branches with gh-stack. Use for stack creation, viewing, edits, push, submit, sync, rebase, merge, or checkout; when asked to split or isolate work for review; whenever a user mentions a stack, branch layers, dependent PRs, or gh stack; or when a stack is checked out.

From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.

What it can access

From a static check of its 4 files (29 KB) on GitHub on 3 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.

Check another skill before you install it.

Install

Copy the skill folder to ~/.claude/skills/gh-stack to use it in all your projects:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/richardgill/nix.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/gh-stack &&
cp -R "$tmp/built/ai-agents/ampcode/skills/gh-stack" ~/.claude/skills/gh-stack &&
rm -rf "$tmp"

For one project only, put the folder in .claude/skills/gh-stack inside it instead.

Claude Code docs on skills

Copy the skill folder to ~/.agents/skills/gh-stack to use it in every repository:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/richardgill/nix.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/gh-stack &&
cp -R "$tmp/built/ai-agents/ampcode/skills/gh-stack" ~/.agents/skills/gh-stack &&
rm -rf "$tmp"

For one repository only, put the folder in .agents/skills/gh-stack inside it instead.

Codex docs on skills

Copy the skill folder to ~/.cursor/skills/gh-stack to use it in every project:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/richardgill/nix.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/gh-stack &&
cp -R "$tmp/built/ai-agents/ampcode/skills/gh-stack" ~/.cursor/skills/gh-stack &&
rm -rf "$tmp"

For one project only, put the folder in .cursor/skills/gh-stack inside it instead.

Cursor docs on skills

Run in a terminal (add --scope workspace to install it for the current workspace only):

gemini skills install https://github.com/richardgill/nix.git --path built/ai-agents/ampcode/skills/gh-stack

Or copy the folder to ~/.gemini/skills/gh-stack yourself.

Gemini CLI docs on skills

For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/gh-stack:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/richardgill/nix.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/gh-stack &&
cp -R "$tmp/built/ai-agents/ampcode/skills/gh-stack" ~/.copilot/skills/gh-stack &&
rm -rf "$tmp"

For one project only, put the folder in .github/skills/gh-stack inside it instead.

VS Code docs on skills

Get the folder:

git clone --depth 1 https://github.com/richardgill/nix.git

Then copy nix/built/ai-agents/ampcode/skills/gh-stack into your agent's skills folder as gh-stack. Agents that support SKILL.md read one folder per skill.

The SKILL.md format

What it does

Stack creation and layering
Creates a stack of branches rooted on trunk and adds dependent layers in order from bottom to top.
Non-interactive command rules
Lists which gh-stack flags to pass so commands run without prompts or terminal menus.
Submit and sync
Pushes every branch, opens draft or ready PRs, and reconciles the stack with GitHub state.
Editing lower layers
Checks out the layer that owns a change, commits there, and rebases the branches above it.
Merge scoping
Merges a PR together with the unmerged PRs below it, or an entire stack, all-or-nothing.
Conflict and exit code recovery
Explains each exit code and how to resolve rebase conflicts during or after a sync.

Good for

  • Split a large feature into a chain of reviewable pull requests
  • Add a new layer on top of an existing stack and open PRs for it
  • Rebase upstack branches after changing a lower layer
  • Sync a stack after a lower PR was reviewed or merged
  • Merge the bottom part of a stack up to a chosen pull request

Gh stack FAQ

What does the skill need to run?

It needs the gh-stack GitHub CLI extension, installed with gh extension install github/gh-stack, and a git repository. It also recommends enabling git rerere and setting remote.pushDefault when the repo has several remotes.

Does Gh stack work with any AI client?

It is a plain SKILL.md folder in the shared agent skills format, with no client-specific hooks or plugin, so it is listed for all supported clients.

Can gh-stack reorder or remove layers non-interactively?

No. The skill notes there is no non-interactive reorder or removal, so restructuring means unstacking and running init again.

What happens when a rebase conflicts?

The skill describes recovery steps: resolve the files, git add them and run gh stack rebase --continue, or use --abort to restore the stack. After a sync it explains how to recreate the conflict first.

How do I install Gh stack in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/gh-stack to use it in all your projects, or to .claude/skills/gh-stack in one project.

Does Gh stack run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

Which AI agents can use Gh stack?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

What are the best alternatives to Gh stack?

The closest alternatives to Gh stack are GitHub workflow, Gh CLI, Git and release ops edho ferdian, Make PR easy to review and GitHub triage.

Where this comes from

  • Description: from the skill's own SKILL.md.

More from richardgill/nix

  1. Updates NixOS flake.lock to newest input commits without changing the release

    • Open source
    • 39 GitHub stars
    • Developer tools
  2. Guides an agent through upgrading a NixOS flake to a new stable release

    • Open source
    • 39 GitHub stars
    • Developer tools
  3. Proposes short, durable additions to AGENTS.md and CLAUDE.md files after a lesson is

    • Open source
    • 39 GitHub stars
    • Developer tools
  4. Lets your agent drive a browser: open pages, read elements, fill forms and capture results

    • Open source
    • 39 GitHub stars
    • Browser automation
  5. Builds a JSON-driven guided code tour and opens it in your running Neovim

    • Open source
    • 39 GitHub stars
    • Developer tools
  6. Shows all uncommitted git changes, staged, unstaged and untracked, in one view

    • Open source
    • 39 GitHub stars
    • Developer tools