agentleFS
GitHubKnown publishergithub/gh-stack/.github/copilot-instructions.md

gh-stack

Copilot instructions1.6k starsChanged 59 days agoMITView on GitHub

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+. No Makefile, no code generation, no external linter config. Standard Go toolchain only. For full architecture details, see AGENTS.md in the repository root.

Trending

Less talk lately.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 3 mentionsAug 2026: 22 mentionsSep 2026: 16 mentionsOct 2026: 5 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the github/gh-stack repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about github/gh-stack

The biggest 5 of 46 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 46

Talked about on GitHub, Bluesky and Hacker News (46 times).

On GitHub · 41

36 more on GitHub

On Hacker News · 1

The file

We split this copilot-instructions.md into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    No Makefile, no code generation, no external linter config.

    line 16
  2. Very specific:

    Check errors with var exitErr *ExitError.

    line 31
  3. Very specific:

    Use config.NewTestConfig() for test configs with captured I/O.

    line 33
  4. Very specific:

    Use stackStateDir(cfg) for application state and beginStackMutation before mutation snapshots.

    line 38

≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

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 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 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/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.
  • Use stackStateDir(cfg) for application state and beginStackMutation before mutation snapshots; defer cleanup. The clone-wide operation lock is separate from short catalog saves.
  • Recovery must match stack identity, execute in the recorded worktree, and retain journals on partial failures. Native Git markers stay per-worktree.
  • Finish paused operations before switching preview stages or versions. Reject origin-only and unknown rebase execution modes before routing recovery; use the matching layer3 build in the recorded origin for origin-only journals.
  • Mutation locks coordinate gh-stack only, not Git commands/editors. Keep affected worktrees quiescent during rewrites. Pass the snapshot SHA (or prior Context.Touched SHA) to Context.Start before ref mutations; never claim an external commit as this operation's work during continuation.
  • Distributed modify preflights action/cascade targets and executes in recorded owners; only the origin may switch for unoccupied branches. Preserve dropped/folded source worktrees and refs. Before native continuation, preflight other worktrees, not remaining branches in the intentionally busy pending worktree.

For full architecture details, see AGENTS.md in the repository root.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.