gh-stack: Instructions file for GitHub Copilot

.github/copilot-instructions.md

gh-stack copilot-instructions.md is an instructions file for GitHub Copilot from github/gh-stack. It costs 1,063 tokens per session, scanned A, original, MIT.

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

Written for GitHub Copilot: a Copilot instructions file. Also seen: mentions AGENTS.md.

This is github/gh-stack's own configuration. It tells GitHub Copilot 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 →

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is go run ./scripts/test -workers 4 # full race-enabled suite in isolated processes.

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

Made for: GitHub Copilot.

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 copilot-instructions.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/github/gh-stack/copilot-instructions/github.svg)](https://agentmods.dev/instructions/github/gh-stack/copilot-instructions)
Your own site
<a href="https://agentmods.dev/instructions/github/gh-stack/copilot-instructions"><img src="https://agentmods.dev/badge/instructions/github/gh-stack/copilot-instructions/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 copilot-instructions.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/github/gh-stack/copilot-instructions"><img src="https://agentmods.dev/badge/instructions/github/gh-stack/copilot-instructions.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 1,063 This file is loaded in full into every session.
When invoked 1,063 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.01063 $0.01063
Opus 5.5 $0.00425 $0.00425
Sonnet 5.5 $0.00213 $0.00213
Haiku 4.5 $0.00106 $0.00106

Measured 10d ago against content hash 529daf0fde8c, 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 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 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.

.github/copilot-instructions.md · 49 lines

How it starts

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

Repository operations require Git 2.36+.

Build and validate

go mod download                  # install deps
go build -o gh-stack .           # build
go vet ./...                     # static analysis. Always run before tests.
go run ./scripts/test -workers 4 # full race-enabled suite in isolated processes

Run vet before tests. See CONTRIBUTING.md for canonical/targeted commands and runner details. Do not add t.Parallel to tests that change Git mocks, cwd, or environment variables.

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 wrapping git CLI. MockOps for tests. Use ForWorktree(path) for scoped execution, CommonDir() for shared storage, and GitDir() for native per-worktree state. Never use production os.Chdir or SetOps to switch context.
  • 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/: Shared catalog (<common-dir>/gh-stack, JSON), conservative legacy migration, atomic saves, and short catalog locks.
  • internal/worktree/: Origin/owner identities, cleanliness preflight, scoped operations, and touched-ref recovery.
  • internal/theme/: GitHub-branded palette (single source of all hex colors), plain-output colorizers, and CanvasOutput, which paints GitHub's canvas behind full-screen TUIs.
  • internal/tui/: bubbletea views (stackview, modifyview).

Read the full file on GitHub · 49 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 · +2 lines · +83 tokens per session 529daf0fde8c
  2. 14d ago Changed · +2 lines · +54 tokens per session 19fee3723a36
  3. 1mo ago Changed · +8 lines · +297 tokens per session 0f569c4036dd
  4. 2mo ago 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,749 stars, last pushed 3d ago), licensed MIT. It adds 1,063 tokens to every session, about $0.0043 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 copilot-instructions.md compared with instructions from other repositories

gh-stack copilot-instructions.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
gh-stack copilot-instructions.mdgithub/gh-stackInstructions file1.7k3d agoMITA1,063GitHub Copilot
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