gh-stack is a GitHub CLI extension for managing stacked branches and pull requests, where each small change builds on the branch below it. Developers use it to create, rebase, submit, and navigate reviewable PR chains, and the catalogue entries help coding agents operate the extension.
Borrowing it
Nothing to install: this file belongs to github/gh-stack. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/github/gh-stack/main/AGENTS.mdgit clone --depth 1 https://github.com/github/gh-stackWrote 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.
[](https://agentmods.dev/instructions/github/gh-stack/agents-md)<a href="https://agentmods.dev/instructions/github/gh-stack/agents-md"><img src="https://agentmods.dev/badge/instructions/github/gh-stack/agents-md/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/instructions/github/gh-stack/agents-md"><img src="https://agentmods.dev/badge/instructions/github/gh-stack/agents-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.03032 | $0.03032 |
| Opus 5.5 | $0.01213 | $0.01213 |
| Sonnet 5.5 | $0.00606 | $0.00606 |
| Haiku 4.5 | $0.00303 | $0.00303 |
Grade A, and why
gh-stack AGENTS.md 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 10d 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.
How it starts
The opening of the file, as written. The whole thing — 153 lines — stays where its author put it; the contents beside it link to each section on GitHub.
gh-stack: Agent Instructions
A GitHub CLI (gh) extension for managing stacked branches and pull requests. Written in Go, it automates creating branches, keeping them rebased, setting PR base branches, and navigating between stack layers.
Repository operations require Git 2.36 or later.
Build, test, and validate
go mod download # install dependencies
go build -o gh-stack . # build (produces ./gh-stack binary)
go vet ./... # static analysis. Run before tests.
go run ./scripts/test -workers 4 # full race-enabled suite in isolated processes
Always run go vet before tests. See CONTRIBUTING.md for the alternative canonical go test command, targeted tests, and timing artifacts. CI runs the full platform-applicable suite with race detection on Linux, macOS, and Windows, with a cross-shard completion gate.
There is no Makefile, linter config, or code generation step. The standard Go toolchain is all that's needed.
Install locally as a gh extension
go build -o gh-stack .
gh extension remove stack 2>/dev/null
gh extension install .
Project structure
main.go # entrypoint. Calls cmd.Execute().
cmd/ # Cobra commands (one file per command + tests)
root.go # registers all subcommands in four groups
utils.go # shared helpers, ExitError types, exit codes
internal/
git/ # git.Ops interface + defaultOps (exec-based)
gitops.go # Ops interface, including scoped worktree execution
mock_ops.go # MockOps. Each method has a corresponding *Fn field.
github/ # github.ClientOps interface + real Client
client_interface.go # ClientOps interface (18 methods)
mock_client.go # MockClient. Uses function-pointer fields for testing.
stack/ # common-directory catalog, JSON schema, migration, locking
schema.json # JSON Schema for the stack file format
config/ # Config struct (I/O, colors, test overrides)
testing.go # NewTestConfig(). Returns *Config + stdout/stderr pipes.
branch/ # branch naming (Slugify, DateSlug)
modify/ # interactive stack modification state machine
worktree/ # operation-owned worktree identities and ref recovery
pr/ # PR template discovery
theme/ # GitHub-branded color palette, colorizers, full-screen canvas painting
tui/ # bubbletea/bubbles/lipgloss terminal UI
stackview/ # interactive stack visualization
modifyview/ # interactive modify session UI
shared/ # shared TUI types
docs/ # Astro + Starlight documentation site
skills/ # AI agent skill definition (SKILL.md)
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.
- 10d ago Changed · +3 lines · +311 tokens per session fbeff52be896
- 14d ago Changed · +35 tokens per session 13f384dd1464
- 1mo ago Changed · +12 lines · +761 tokens per session 5d1bc931850c
- 2mo ago First seen · 138 lines · 1,925 tokens per session scan A 94c2e7ac9e52
gh-stack AGENTS.md is an instructions file published in the GitHub repository github/gh-stack (1,749 stars, last pushed 3d ago), licensed MIT. It adds 3,032 tokens to every session, about $0.0121 per session on Opus 5.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-30.
gh-stack AGENTS.md compared with instructions from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| gh-stack AGENTS.mdgithub/gh-stack | Instructions file | 1.7k | 3d ago | MIT | A | 3,032 | Codex, OpenCode |
| vscode buildNext.instructions.mdmicrosoft/vscode | Instructions file | 195k | today | MIT | A | 9,719 | GitHub Copilot |
| next.js AGENTS.mdvercel/next.js | Instructions file | 143k | today | MIT | A | 7,461 | Codex, OpenCode |
| vscode oss-third-party-notices.instructions.mdmicrosoft/vscode | Instructions file | 195k | today | MIT | A | 5,516 | GitHub Copilot |
| langchain AGENTS.mdlangchain-ai/langchain | Instructions file | 149k | today | MIT | A | 4,680 | Codex, OpenCode |
| vscode copilot-instructions.mdmicrosoft/vscode | Instructions file | 195k | today | MIT | A | 3,093 | GitHub Copilot |
| deepseek-harness AGENTS.mddeepseek-ai/deepseek-harness | Instructions file | 274k | 2d ago | MIT | A | 4,313 | Codex, OpenCode |