gh-stack AGENTS.md

Project instructions for gh-stack, a GitHub CLI extension that manages related branches and pull requests as a stack. A stacked set of branches lets developers split one larger change into smaller dependent reviews.

In plain words
What is it for?
Building the Go project, running static checks and tests, installing it as a gh extension, and understanding its command structure.
Why use it?
It explains how to build, test, validate, and install the extension, reducing uncertainty when working on the project. It also documents where commands and shared code live.

Instructions file for CodexOpenCode

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 instructions/github/gh-stack/agents-md
Clone the repo
git clone --depth 1 https://github.com/github/gh-stack

Made for: Codex, OpenCode.

Per session 1,925 This file is loaded in full into every session.
When invoked 1,925 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found 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.01925 $0.01925
Opus 5 $0.00962 $0.00962
Sonnet 5 $0.00385 $0.00385
Haiku 4.5 $0.00193 $0.00193

Measured yesterday against content hash 94c2e7ac9e52, 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 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 yesterday.

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.

AGENTS.md · 138 lines

How it starts

The opening of the file, as written. The whole thing — 138 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.

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 test -race -count=1 ./...     # all tests with race detection

Always run go vet before go test. CI runs both on every push/PR across ubuntu, windows, and macOS (test.yml).

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 (52 methods)
    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/                     # stack file (.git/gh-stack) management, JSON schema, 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
  pr/                        # PR template discovery
  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)

Read the full file on GitHub · 138 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. yesterday First seen · 138 lines · 1,925 tokens per session scan A 94c2e7ac9e52

Subscribe to this mod's changes

gh-stack AGENTS.md is an instructions file published in the GitHub repository github/gh-stack (1,405 stars, last pushed 4d ago), licensed MIT. It adds 1,925 tokens to every session, about $0.0096 per session on Opus 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.