# Gh stack

> Gh stack is an open-source agent skill for developer tools. Guides an agent through creating, editing, syncing and merging stacked GitHub pull. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/richardgill/nix/tree/main/built/ai-agents/ampcode/skills/gh-stack
- **Repository:** https://github.com/richardgill/nix
- **GitHub stars:** 39
- **License:** MIT
- **Skill name:** gh-stack
- **Collection:** https://github.com/richardgill/nix
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-03

## About

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.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/richardgill/nix/tree/HEAD/built/ai-agents/ampcode/skills/gh-stack)
- [License: MIT](https://github.com/richardgill/nix/tree/HEAD/built/ai-agents/ampcode/skills/gh-stack)

## Features

- **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

## Install

### Claude Code

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

```sh
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.

### Codex

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

```sh
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.

### Cursor

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

```sh
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.

### Gemini CLI

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

```sh
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.

### VS Code

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

```sh
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.

### Other agents

Get the folder:

```sh
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.

## 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.

## Alternatives

- [GitHub workflow](https://ai-powered.com/skills/github-workflow): GitHub workflow is an open-source agent skill for developer tools.
- [Gh CLI](https://ai-powered.com/skills/gh-cli): Gh CLI is an open-source agent skill for developer tools.
- [Git and release ops edho ferdian](https://ai-powered.com/skills/git-and-release-ops-edho-ferdian): Git and release ops edho ferdian is an open-source agent skill for developer tools.
- [Make PR easy to review](https://ai-powered.com/skills/make-pr-easy-to-review): Make PR easy to review is an open-source agent skill for developer tools.
- [GitHub triage](https://ai-powered.com/skills/github-triage): GitHub triage is an open-source agent skill for developer tools.
- [Code review](https://ai-powered.com/skills/code-review-flutter): Code review is an open-source agent skill for developer tools.
- [GitHub issues](https://ai-powered.com/skills/github-issues): GitHub issues is an open-source agent skill for developer tools.
- [Code pull request](https://ai-powered.com/skills/code-pull-request): Code pull request is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/gh-stack
