agentleFS
timmo001timmo001/skills/gh-stack/SKILL.md

gh-stack

Skill1 starsChanged 20 days agoApache-2.0View on GitHub

Manage stacked branches and pull requests with GitHub's `gh stack` extension. Use when work involves stacked PRs, dependent branches, stack creation, navigation, submission, synchronisation, rebasing, restructuring, linking, or merging.

We split this skill into the rules it gives an agent

25 rules. 0 are common, 7 are distinctive, and 18 are very specific to this project.

  • 0

    Common

    Most of the 40 edited versions we read keep these.

  • 7

    Distinctive

    This author's own choices. Worth a look.

  • 18

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    Use GitHub's official gh stack extension for linear stacks of dependent branches and pull requests.

    line 10
  2. Very specific:

    Do not commit through gh stack add -m, -A, or -u, and never run raw git commit.

    line 20
  3. Very specific:

    Treat push, submit, sync, and branch arguments passed to link as push operations.

    line 23
  4. Very specific:

    Treat rebase, modify, unstack, and rebuilding local tracking as history or stack-structure rewrites.

    line 29
  5. Very specific:

    Run merge only after explicit merge authorisation for the named stack or PR range.

    line 32
  6. Very specific:

    Never use plain force push.

    line 36
  7. Distinctive:

    Avoid commands that open prompts or TUIs:

    line 41
  8. Very specific:

    Use gh stack view --json, never bare view or view --short.

    line 43
  9. Very specific:

    Treat view as best-effort PR-state refresh as well as inspection.

    line 44
  10. Very specific:

    Do not run interactive modify.

    line 47
  11. Very specific:

    If multiple remotes exist, pass --remote <name> where supported.

    line 49
  12. Very specific:

    When authorised to commit, use dot git commit on the exact paths.

    line 104
  13. Distinctive:

    Add the next branch from the current top:

    line 105
  14. Distinctive:

    When the user separately authorises pushing and the generated PR metadata, submit non-interactively, then verify:

    line 111
  15. Very specific:

    Do not use --open unless the user asks to mark them ready for review.

    line 120
  16. Very specific:

    Commit only through the authorised dot git commit workflow.

    line 133
  17. Distinctive:

    Use it only with explicit push and rewrite authorisation.

    line 147
  18. Very specific:

    After a squash merge, sync can replay remaining branches onto the updated trunk.

    line 149
  19. Very specific:

    Follow git-context for conflict resolution.

    line 161
  20. Distinctive:

    If local and remote stack composition diverge, stop and present the actual local/remote chains.

    line 164
  21. Very specific:

    If a modification conflicts, resolve and stage the files in the worktree named by the conflict.

    line 180
  22. Distinctive:

    When a stack must be reordered, inserted into, renamed, folded, or have a layer removed:

    line 187
  23. Very specific:

    Use gh stack unstack (or --local when preserving GitHub grouping).

    line 192
  24. Very specific:

    Verify branch order, heads, bases, and PR associations with gh stack view --json.

    line 201
  25. Distinctive:

    Before merging, verify every selected PR and every layer below it is open, non-draft, approved, current, and passing required checks.

    line 206

“Common” is measured: kept by at least 6 in 10 of the 40 edited versions of this file we could read. “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
SKILL.md

GitHub Stacks

Use GitHub's official gh stack extension for linear stacks of dependent branches and pull requests. Each branch builds on the branch below it, and each pull request targets that immediate parent so reviewers see one layer's diff.

Load git-context for branch and rebase operations. Load dot-git-commit only after the user explicitly requests a commit or push.

Safety And Authorisation

  • Inspect with gh stack view --json before and after every mutation.
  • Do not commit through gh stack add -m, -A, or -u, and never run raw git commit. Commit only after explicit authorisation through dot git commit, following the dot-git-commit skill.
  • Treat push, submit, sync, and branch arguments passed to link as push operations. Run them only when the user explicitly authorises that push.
  • submit and link can create pull requests and generate or change titles, descriptions, and base branches. Obtain explicit consent for those specific PR changes before running them; permission to create a PR alone does not authorise its description.
  • Treat rebase, modify, unstack, and rebuilding local tracking as history or stack-structure rewrites. Run them only when requested or when the user approves the explained recovery operation.
  • Run merge only after explicit merge authorisation for the named stack or PR range. Never infer merge permission from approval to push or submit.
  • Preserve unrelated worktree changes. Structural operations require a clean tree; do not stash, discard, or absorb user changes without permission.
  • Never use plain force push. Stack pushes use per-branch --force-with-lease; stop if a lease is rejected.

Agent-Safe Operation

Avoid commands that open prompts or TUIs:

  • Use gh stack view --json, never bare view or view --short.
  • Treat view as best-effort PR-state refresh as well as inspection.
  • Give branch names to init and add.
  • Give a stack number, PR number, PR URL, or branch to checkout.
  • Do not run interactive modify. Explain the intended structure and use the explicit non-interactive recovery path only after approval.
  • If multiple remotes exist, pass --remote <name> where supported. Do not change remote.pushDefault merely to avoid a prompt.

The extension must be installed and authenticated:

gh extension install github/gh-stack
gh stack --help

Installation is a separate system change and requires the user's request or approval. Verify command flags against live help because gh stack is in public preview.

Choose The Right Operation

IntentCommandImportant effect
Inspect local stackgh stack view --jsonRead-only
Start/adopt local trackinggh stack init --base <trunk> <branches...>Creates/adopts branches
Add a top layergh stack add <branch>Creates and checks out a branch
Navigategh stack up, down, top, bottom, trunkChanges checkout
Check out known stackgh stack checkout <target>Fetches remote stack when target is a stack/PR
Push tracked branchesgh stack push --remote <remote>Pushes active branches with leases
Create/update PR stackgh stack submit --auto --remote <remote>Pushes, creates/updates PRs and remote stack
Routine reconciliationgh stack sync --remote <remote>Fetches, may rebase, pushes, and updates remote stack
Cascade historygh stack rebase [--upstack|--downstack]Rewrites stack branch history
Link externally managed branches/PRsgh stack link ...Remote-only tracking; may push/create/retarget PRs
Restructuregh stack modifyInteractive; do not drive as an agent
Remove tracking/groupinggh stack unstack [--local]Removes local and optionally remote stack state
Mergegh stack merge <stack-or-pr> --yes <method>Merges an authorised prefix or stack

link does not establish local stack tracking. Use it for branches managed by another tool or when the user explicitly wants remote-only linking. Use init/submit for a locally managed stack.

For numeric checkout targets, resolution is stack number, then PR number, then branch name. Prefer an explicit PR URL or branch when a number could be ambiguous.

Build A Stack

  1. Plan one coherent story in dependency order before implementing it, and create the stack first when the work is already known to need layers. Foundational changes belong below their consumers; unrelated work belongs in another stack. Prefer <topic>/<concern> branch names unless repository conventions differ.
  2. Confirm the worktree and branch context, then initialise with explicit branch names:

    gh stack init --base <trunk> <bottom-branch> [higher-branches...]
  3. Implement and verify one independently reviewable layer at a time.
  4. When authorised to commit, use dot git commit on the exact paths.
  5. Add the next branch from the current top:

    gh stack add <next-branch>
  6. When the user separately authorises pushing and the generated PR metadata, submit non-interactively, then verify:

    gh stack submit --auto --remote <remote>
    gh stack view --json

New PRs created with --auto default to draft unless --open is supplied. Do not use --open unless the user asks to mark them ready for review. init also enables Git rerere for the repository. Do not make additional Git configuration changes without authorisation. If every PR in the submitted stack has already merged, submission creates a new stack for remaining branches.

Fix A Lower Layer

Make a correction on the branch that owns it, not as an upstack workaround:

  1. Navigate to the owning branch with down, bottom, or explicit checkout.
  2. Make and verify the correction.
  3. Commit only through the authorised dot git commit workflow.
  4. With approval to rewrite the upstack branches, run:

    gh stack rebase --upstack
  5. With separate push authorisation, run gh stack push, then verify with gh stack view --json.

Synchronise And Recover

gh stack sync performs fetch, reconciliation, possible cascading rebase, push, PR-state sync, and remote-stack sync. It is not a read-only status check. Use it only with explicit push and rewrite authorisation.

After a squash merge, sync can replay remaining branches onto the updated trunk. If it reports a conflict, it restores the branches and exits with code 3. Then use the explicit rebase workflow:

gh stack rebase
# resolve files and stage only the resolutions
gh stack rebase --continue
# or restore the pre-rebase state
gh stack rebase --abort

Follow git-context for conflict resolution. Do not use raw interactive rebase continuation or editor workarounds when the extension owns the operation.

If local and remote stack composition diverge, stop and present the actual local/remote chains. Do not automatically choose the remote, delete the remote stack, or unstack. Those choices can discard tracking decisions.

Worktrees And Distributed Modify

rebase and sync update affected clean worktrees. They do not auto-stash or create or remove worktrees. Paused operations use their recorded worktree owners for recovery.

modify remains TUI-only and must not be launched by an agent. It now supports stack branches checked out across worktrees. It checks affected worktree owners before applying changes; unrelated and read-only worktrees are left alone, and unoccupied branches use the initiating worktree. Dropped and folded source branches and their worktrees are preserved.

If a modification conflicts, resolve and stage the files in the worktree named by the conflict. gh stack modify --continue and --abort can be invoked from any linked worktree, but operate in the recorded owners. No worktree is automatically stashed, created, or removed.

Restructure Without The TUI

When a stack must be reordered, inserted into, renamed, folded, or have a layer removed:

  1. Show the current view --json state and the proposed final branch order.
  2. Obtain explicit approval for local/remote unstacking and history rewrites.
  3. Use gh stack unstack (or --local when preserving GitHub grouping).
  4. Recreate local tracking with explicit ordered branches:

    gh stack init --base <trunk> <bottom> <middle> <top>
  5. Rebase as needed, then obtain explicit push and PR-metadata consent before submit --auto.
  6. Verify branch order, heads, bases, and PR associations with gh stack view --json.

Merge

Before merging, verify every selected PR and every layer below it is open, non-draft, approved, current, and passing required checks. Then require an explicit stack number or PR endpoint and merge method:

gh stack merge <stack-number-or-pr-number> --yes --squash

Without a merge queue, the selected range is all-or-nothing. With a merge queue, the PRs are enqueued together but may land in separate groups, and the queue chooses the merge method.

Exit Codes

CodeMeaningResponse
2Not in a stackInspect context; initialise only when requested
3Rebase conflictResolve and rebase --continue, or abort
4GitHub API failureReport authentication/API failure; do not guess
5Invalid argumentsCheck live help
6Branch belongs to multiple stacksCheck out a non-shared branch explicitly
7Rebase already in progressContinue or abort the existing operation
8Stack lockedStop; another process owns the stack
9Stacked PRs unavailableReport repository/platform availability
10Interrupted modifyRun modify --abort only with recovery approval

Limitations

  • Stacks are linear and all branches must live in the same repository.
  • link is additive and does not remove existing PRs from a remote stack.
  • Branch arguments to link may be pushed automatically.
  • submit generates PR titles and descriptions; edit them only with separate, specific user consent.
  • push and submit are not atomic across every branch. Inspect partial success before retrying.
  • GitHub's server-side rebase can create unsigned commits. Use the local extension workflow when signed commits are required.

Download now (ZIP)

  • Other versions41 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 41

    1. vercel/next.js★ 143ksame name
    2. remotion-dev/remotion★ 70ksame name
    3. CherryHQ/cherry-studio★ 53ksame name
    4. Arize-ai/phoenix★ 12ksame name
    5. trycompai/crm★ 11ksame name
    6. CherryHQ/cherry-studio-app★ 4ksame name
    7. dotnet/macios★ 2.9ksame name
    8. dotnet/android★ 2.1ksame name
    9. github/gh-stack★ 1.7ksame name
    10. NVIDIA-NeMo/Gym★ 1.3ksame name

    31 more not listed

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • Used alongsideProjects with it also use gh-create-pr, gh-commit and 7 more.

    Other files people use alongside this one.

    Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
    • ant-designSkill

      gh-create-pr

      使用 GitHub CLI (gh) 推送当前分支并创建或更新 PR。在用户说「提 PR」「新建 PR」「用 gh 建 PR」「submit PR」「create pull request」时使用。

      Also in 4 projects that use this

    • kelvincushmanSkill

      gh-commit

      Create well-formatted commits with conventional commit format.

      Also in 3 projects that use this

    • bmsuisseSkill

      prek

      Set up code formatting and pre-commit hooks using prek (fast Rust-based alternative to pre-commit) with prek.toml config. Use whenever the user wants to configure prek, add formatters, set up pre-commit hooks, or enforce code style. Triggers on "set up prek", "add formatting", "configure formatters", "pre-commit setup", "add ruff", "set up biome", "configure sqlfmt". Works on new and existing projects. Always use when init-app-stack has just run.

      Also in 3 projects that use this

    • carapace-shSkill

      bun

      Use when working with the bun CLI — Bun's all-in-one JavaScript runtime and toolkit. Covers the CLI command reference (install, add, remove, run, build, test, x, create, init, pm, upgrade, link, unlink), bunfig.toml configuration, environment variables, the package manager and lockfile, the test runner, the bundler, the Bun runtime API (Bun.serve, Bun.file, Bun.spawn, Bun.write, hashing, transpiler), the Bun shell ($ template literal), module resolution and loaders, and globals. Triggers on: "bun", "bunx", "bun install", "bun add", "bun remove", "bun run", "bun build", "bun test", "bun x", "bun create", "bun init", "bun pm", "bun upgrade", "bun link", "bun unlink", "bunfig.toml", "bun.lock", "Bun.serve", "Bun.file", "Bun.write", "Bun.spawn", "Bun.hash", "Bun.password", "bun:test", "Bun.build", "Bun.Transpiler", "bun shell", "$ template", "import.meta", "JavaScriptCore", "Bun.serve", "HTMLRewriter", "Bun.SQL", "Bun.RedisClient", "Bun.Glob", "Bun.plugin", "bun:ffi".

      Also in 3 projects that use this

    • xfstudioSkill

      typescript-expert

      TypeScript and JavaScript expert with deep knowledge of type-level programming, performance optimization, monorepo management, migration strategies, and modern tooling. Use PROACTIVELY for any TypeScript/JavaScript issues including complex type gymnastics, build performance, debugging, and architectural decisions. If a specialized expert is a better fit, I will recommend switching and stop.

      Also in 3 projects that use this

    • xfstudioSkill

      typescript-advanced-types

      Master TypeScript's advanced type system including generics, conditional types, mapped types, template literals, and utility types for building type-safe applications. Use when implementing complex type logic, creating reusable type utilities, or ensuring compile-time type safety in TypeScript projects.

      Also in 4 projects that use this

  • In this repository50 other files it gives its agents.

Does it work?

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

Reviews can't be read right now.

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.