git-stack

command module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

git-stack

Graphite like commands for GitHub native stacked PR's.

It's a CLI for stacked branches, installed as git-stack so git picks it up as git stack <cmd>. It mirrors the gt workflow (create, modify, restack, submit, sync, up/down/top/bottom, checkout) but sits on top of GitHub's official gh stack extension rather than a third party service, i.e. the metadata lives in your repo and the PRs are plain GitHub PRs. The same binary also runs as a stdio MCP server so coding agents can drive the stack the same way you do.

The design, what we learnt about gh stack and the reasoning behind the decisions are in docs/architecture.md, if you want to know why things are the way they are.

Install

go install github.com/DomBlack/git-stack@latest
git stack install          # git aliases, shell completion, agent MCP registration
Prerequisites
  • git 2.40+
  • gh (the GitHub CLI) logged in via gh auth login, plus the extension; gh extension install github/gh-stack
  • Claude Code (claude) on your PATH if you want the --ai flags (optional)

Commands

If you know gt you already know most of this; the table is the mapping.

Graphite git-stack Notes
gt create [name] git stack create [name] (git c) -a -u -p -m --ai
gt modify git stack modify (git m) amend (or -c for a new commit), then restack everything above
gt restack git stack restack (git rs) --upstack --downstack --continue --abort
gt up/down/top/bottom git stack up/down/top/bottom (git u/d/t/b) down from the bottom branch takes you to trunk
gt checkout git stack checkout (git co) interactive tree picker
gt log git stack or git stack log every stack as a tree, trunk at the bottom, with PR state
gt submit / gt ss git stack submit (git ss) -d -p --no-edit --dry-run --ai
gt sync git stack sync (git sync) every stack, checked out or not, across worktrees; merged branches deleted (stack.sync.prune)
(none) git stack install aliases, completion, agent MCP registration
(none) git stack completion <shell> bash, zsh, fish
(none) git stack mcp stdio MCP server
(none) git stack version --json for scripts
(none) git stack update --check --force; plain HTTPS, no login needed

Day to day

With the aliases installed a typical stack looks like this;

git co main                 # start from trunk
# ...hack on the first change...
git create -a --ai          # stage everything, Claude names the branch and writes the commit
# ...hack on the next change, which depends on the first...
git create -a --ai          # second branch, stacked on the first
git ss                      # push the whole stack; new PRs are drafts (or it asks)

Review comes back on the first PR;

git down                    # back to the first branch
# ...fix it up...
git modify -a               # amend, and the branch above is restacked for you
git ss                      # push both again

Once the bottom PR merges;

git sync                    # fetch, move trunk, restack what's left, delete the merged branch
git stack                   # where am I? every stack as a tree with its PRs
git co                      # the picker, to jump somewhere else

--ai is optional everywhere; git create -a -m "message" or plain git create name works just as well. git ss --ai -p drafts the PR titles and bodies for you and opens them ready for review rather than as drafts. If you always want the drafting, set git config --global stack.ai.auto true and drop the flag; --no-ai turns it off for one run.

Where am I?

git stack on its own (or git stack log) shows every stack the way gt log does; trunk at the bottom, newest branch at the top, ● on the branch you're on, and under each branch its PR (clickable in terminals that support it), how old it is and whether it needs a restack. Two stacks on the same trunk sit side by side and join above it.

● billing-webhook-retries
│  #418 open · 2h ago
│
○ billing-webhook-schema
│  #412 open · 1d ago
│
│ ○ fix-login-timeout
│ │  #399 draft · needs restack · 3d ago
├─┘
■ main  20m ago

The rest of the output follows the same rules (one headline with a spinner while something runs, ✔ ✖ ⚠ result lines, plain ok:/note:/error: when piped); that's all written down in docs/style.md.

git stack install

One command sets everything up. --dry-run prints every change before it happens, and --uninstall removes exactly what was installed and nothing else (we record what we touched in git config --global stack.managed*, so we never guess).

  • Aliases (--aliases, on by default): git create|modify|restack|submit|sync|up|down|top|bottom and the short ones git c|m|rs|ss|u|d|t|b|co, written with git config --global. Anything that clashes with a git builtin or an installed command is skipped, and an alias you already have is only replaced if you pass --force or say yes when asked.
  • Completion (--completion, --shell bash|zsh|fish): the cobra completion script plus the hooks that make git stack <TAB> and the aliases complete. See docs/completion.md.
  • Agents (--agents): registers git stack mcp with Claude Code (claude mcp add -s user) and Codex (codex mcp add) using the absolute path of the binary. If a CLI isn't installed it's skipped. See docs/mcp.md.
  • Skill (--skill, asked interactively if you don't pass it): a Claude Code skill at ~/.claude/skills/git-stack/SKILL.md describing the stacked workflow.

Configuration

Everything is plain git config, so set it globally or per repo as you like.

git config key Default Meaning
stack.branchPrefix (none) prefix for generated branch names, e.g. dom/
stack.ai.command claude the Claude Code binary used for --ai
stack.ai.model haiku model alias passed to --model
stack.ai.extraPrompt (none) house style instructions appended to the prompts
stack.ai.timeout 60s timeout per AI call
stack.ai.auto false true makes create and submit behave as if --ai was passed; --no-ai still wins
stack.cacheTTL 5m how long pull request state is cached for
stack.submit.default ask draft, publish or ask for new PRs
stack.sync.prune always what sync does with branches whose PRs merged; ask on a terminal, or never

Differences from Graphite

It's worth being upfront about this; gh stack is linear and only lets you add branches at the top, so a handful of gt behaviours aren't possible yet: create --insert, restack --only, submit --update-only, sync --all and modify --into. Each one prints a single line saying why rather than silently doing something else.

submit also always submits the whole stack (gt submits downstack by default). Pass --stack to acknowledge that's what you want.

One thing we actively correct; gh stack treats a PR that is queued for merge like a merged one and bases the next PR on main, so a new PR shows the whole stack's diff. submit moves such a base back onto the real parent and tells you.

Updating

git stack update fetches the latest GitHub release over plain HTTPS (no gh login needed), checks the archive against the release's checksums.txt and swaps the binary in place. --check just tells you whether there's something newer.

If you built from source, git stack version says dev along with the commit, and update leaves you alone unless you pass --force; i.e. we assume you built it that way on purpose.

Releasing

Tag and push, that's it;

git tag v0.1.0
git push origin v0.1.0

The release workflow runs goreleaser, which builds linux and darwin on amd64 and arm64, stamps the version in, and publishes the archives plus checksums.txt to a GitHub release. git stack update and go install github.com/DomBlack/git-stack@latest both pick it up.

Development

There's no task runner on purpose; this is the whole check:

go build ./... && go vet ./... && golangci-lint run && go test ./...

The rules for contributors (human or agent) are in AGENTS.md, the architecture notes are in docs/architecture.md, and how the CLI should look and talk is in docs/style.md.

License

MIT, see LICENSE.

Documentation

Overview

Command git-stack is a Graphite-style stacked-branch CLI. Installed on PATH, git exposes it as `git stack <cmd>`.

Directories

Path Synopsis
Package cmd wires the cobra command tree.
Package cmd wires the cobra command tree.
pkg
agents
Package agents registers the git-stack MCP server with coding-agent CLIs.
Package agents registers the git-stack MCP server with coding-agent CLIs.
ai
Package ai is the port for drafting commit messages, branch names and pull-request text.
Package ai is the port for drafting commit messages, branch names and pull-request text.
ai/claudecode
Package claudecode implements ai.Drafter with the local Claude Code CLI in headless mode (`claude -p`).
Package claudecode implements ai.Drafter with the local Claude Code CLI in headless mode (`claude -p`).
app
Package app holds the use cases.
Package app holds the use cases.
backend/ghstack
Package ghstack implements the stack ports on top of GitHub's gh-stack extension.
Package ghstack implements the stack ports on top of GitHub's gh-stack extension.
cache
Package cache stores small JSON documents per repository under <git-common-dir>/git-stack/ so that commands (and completion) can render instantly from the last known state.
Package cache stores small JSON documents per repository under <git-common-dir>/git-stack/ so that commands (and completion) can render instantly from the last known state.
config
Package config reads git-stack settings from `git config stack.*`.
Package config reads git-stack settings from `git config stack.*`.
exec
Package exec runs subprocesses.
Package exec runs subprocesses.
exec/exectest
Package exectest provides a scripted exec.Runner for unit tests.
Package exectest provides a scripted exec.Runner for unit tests.
forge
Package forge is the port for pull-request operations.
Package forge is the port for pull-request operations.
forge/github
Package github implements forge.Forge with the gh CLI.
Package github implements forge.Forge with the gh CLI.
git
Package git is a typed wrapper around the git command line.
Package git is a typed wrapper around the git command line.
git/gittest
Package gittest creates isolated temporary repositories for tests.
Package gittest creates isolated temporary repositories for tests.
gitconfig
Package gitconfig installs and removes the git aliases that make `git create`, `git co` and friends run git-stack.
Package gitconfig installs and removes the git aliases that make `git create`, `git co` and friends run git-stack.
install
Package install sets up git aliases, shell completion (with git integration), agent MCP registration and the optional Claude Code skill, and removes exactly what it installed.
Package install sets up git aliases, shell completion (with git integration), agent MCP registration and the optional Claude Code skill, and removes exactly what it installed.
mcp
Package mcp exposes the stack use cases as MCP tools over stdio so coding agents can drive git-stack.
Package mcp exposes the stack use cases as MCP tools over stdio so coding agents can drive git-stack.
shell
Package shell composes the completion scripts git-stack installs: cobra's generated script for the git-stack binary plus the hooks that make `git stack <TAB>` and git aliases such as `git co <TAB>` complete through the same engine.
Package shell composes the completion scripts git-stack installs: cobra's generated script for the git-stack binary plus the hooks that make `git stack <TAB>` and git aliases such as `git co <TAB>` complete through the same engine.
stack
Package stack is the domain model: stacks of branches rooted at a trunk, pure navigation over them, and the ports a backend must implement.
Package stack is the domain model: stacks of branches rooted at a trunk, pure navigation over them, and the ports a backend must implement.
stack/stacktest
Package stacktest provides an in-memory stack backend for tests.
Package stacktest provides an in-memory stack backend for tests.
ui
Package ui holds every terminal UI component: lipgloss styles, the reusable stack tree renderer and the bubbletea checkout picker.
Package ui holds every terminal UI component: lipgloss styles, the reusable stack tree renderer and the bubbletea checkout picker.
update
Package update replaces the running git-stack binary with the latest GitHub release.
Package update replaces the running git-stack binary with the latest GitHub release.
version
Package version works out which git-stack this binary is.
Package version works out which git-stack this binary is.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL