gh-stack: Instructions file for Codex

AGENTS.md

gh-stack AGENTS.md is an instructions file for Codex, OpenCode from github/gh-stack. It costs 3,032 tokens per session, scanned A, original, MIT.

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 ✓ vendor

Written for Codex and OpenCode: the file is AGENTS.md.

This is github/gh-stack's own configuration. It tells Codex and OpenCode how to work on gh-stack itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything gh-stack configures →

About the project

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.

github/gh-stack · 1,749 stars · on GitHub · gh.io

Reuse

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.

Copy the file
curl -O https://raw.githubusercontent.com/github/gh-stack/main/AGENTS.md
Clone the repo
git clone --depth 1 https://github.com/github/gh-stack

Made for: Codex, OpenCode.

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

agentmods badge for gh-stack AGENTS.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/github/gh-stack/agents-md/github.svg)](https://agentmods.dev/instructions/github/gh-stack/agents-md)
Your own site
<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.

agentmods 80×15 button for gh-stack AGENTS.md

Your own site · 80×15
<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>
Per session 3,032 This file is loaded in full into every session.
When invoked 3,032 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.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

Measured 10d ago against content hash fbeff52be896, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 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.

AGENTS.md · 153 lines

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)

Read the full file on GitHub · 153 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. 10d ago Changed · +3 lines · +311 tokens per session fbeff52be896
  2. 14d ago Changed · +35 tokens per session 13f384dd1464
  3. 1mo ago Changed · +12 lines · +761 tokens per session 5d1bc931850c
  4. 2mo ago 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,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.

Related

gh-stack AGENTS.md compared with instructions from other repositories

gh-stack AGENTS.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
gh-stack AGENTS.mdgithub/gh-stackInstructions file1.7k3d agoMITA3,032Codex, OpenCode
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143ktodayMITA7,461Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA5,516GitHub Copilot
langchain AGENTS.mdlangchain-ai/langchainInstructions file149ktodayMITA4,680Codex, OpenCode
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA3,093GitHub Copilot
deepseek-harness AGENTS.mddeepseek-ai/deepseek-harnessInstructions file274k2d agoMITA4,313Codex, OpenCode