gh-stack copilot-instructions.md

Repository instructions for developing and checking gh-stack, a Go command-line tool for managing stacked branches and pull requests.

In plain words
What is it for?
They are for building the tool, running static checks and race-detected tests, and following its GitHub and merge-queue conventions.
Why use it?
They give coding agents the project's required layout, interfaces, APIs, and validation commands.

Instructions file for GitHub Copilot

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

Made for: GitHub Copilot.

Per session 629 This file is loaded in full into every session.
When invoked 629 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.00629 $0.00629
Opus 5 $0.00315 $0.00315
Sonnet 5 $0.00126 $0.00126
Haiku 4.5 $0.00063 $0.00063

Measured yesterday against content hash 4c49e960762f, 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 copilot-instructions.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.

.github/copilot-instructions.md · 37 lines

How it starts

The opening of the file, as written. The whole thing — 37 lines — stays where its author put it; the contents beside it link to each section on GitHub.

gh-stack: Copilot Instructions

A Go CLI extension (gh stack) for managing stacked branches and pull requests. Uses Cobra for commands, bubbletea/lipgloss for TUI, and stretchr/testify for tests.

Build and validate

go mod download                  # install deps
go build -o gh-stack .           # build
go vet ./...                     # static analysis. Always run before tests.
go test -race -count=1 ./...     # tests with race detection

No Makefile, no code generation, no external linter config. Standard Go toolchain only.

Project layout

  • cmd/: One Cobra command per file. Each exports <Name>Cmd(cfg *config.Config) with logic in run<Name>().
  • internal/git/: Ops interface (52 methods) wrapping git CLI. MockOps for tests. Package-level functions delegate to swappable ops variable.
  • internal/github/: ClientOps interface (18 methods) for GitHub API. MockClient for tests. Stack operations use the public Stacks REST API (/repos/{owner}/{repo}/stacks); merges use the async merge API (/repos/{owner}/{repo}/pulls/{n}/merge-async) with an explicit merge_action (direct_merge or merge_queue) chosen from the base branch's merge-queue detection. merge_action is optional — omitting it (or sending default) lets the server auto-route (merge queue if one is configured, else direct merge) — but the CLI sends it explicitly so a wrong detection fails loudly instead of silently merging directly.
  • internal/config/: Config struct passed to all commands. Holds I/O, colors, and test hooks (SelectFn, ConfirmFn, InputFn, GitHubClientOverride).
  • internal/stack/: Stack file (.git/gh-stack, JSON) management with file locking.
  • internal/tui/: bubbletea views (stackview, modifyview).

Coding conventions

  • Return typed ExitError sentinels (codes 1-10 in cmd/utils.go) from RunE. Never call os.Exit() directly.
  • Check errors with var exitErr *ExitError; errors.As(err, &exitErr).
  • Table-driven tests with t.Run() subtests.
  • Use config.NewTestConfig() for test configs with captured I/O.
  • Mock git: restore := git.SetOps(&git.MockOps{...}); defer restore(). Always defer restore.
  • Mock GitHub: cfg.GitHubClientOverride = &github.MockClient{...}.
  • Mock prompts: set cfg.SelectFn, cfg.ConfirmFn, or cfg.InputFn.
  • Load stack files with stack.Load(dir) after writing to get correct checksums.

Read the full file on GitHub · 37 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 · 37 lines · 629 tokens per session scan A 4c49e960762f

Subscribe to this mod's changes

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