[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6ADDNYXKXTK783Q96FCRBS9":3,"skill-same:01M6ADDNYXKXTK783Q96FCRBS9":70},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":24,"linkOnly":25,"markdownContent":26,"markdownBody":27,"frontMatter":28,"refName":32,"commitSha":33,"skillDirectory":34,"forksCount":35,"repositoryHtmlUrl":36,"repositoryHomepageUrl":37,"ownerHtmlUrl":38,"ownerBlogUrl":39,"ownerDescription":40,"updatedAt":41,"install":42,"resources":55},"01M6ADDNYXKXTK783Q96FCRBS9","gh-stack",null,"Manages stacked PRs and splits multi-part work into reviewable branches with gh-stack. Use for stack creation, viewing, edits, push, submit, sync, rebase, merge, or checkout; when asked to split or isolate work for review; whenever a user mentions a stack, branch layers, dependent PRs, or gh stack; or when a stack is checked out.","github\u002Fgh-stack","github","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F9919?v=4","01M6AC83DS133TPXFSP1DHNCC6","GitHub","01M6ADDKVVJHNKSADGV8RR3P5D",1769,"MIT","https:\u002F\u002Fgithub.com\u002Fgithub\u002Fgh-stack\u002Fblob\u002Fmain\u002Fskills\u002Fgh-stack\u002FSKILL.md",[],[19,20,9,21,22,23],"gh stack","review","merge","sync","push","2026-11-10 10:12:30",false,"---\nname: gh-stack\ndescription: >\n  Manages stacked PRs and splits multi-part work into reviewable branches with gh-stack.\n  Use for stack creation, viewing, edits, push, submit, sync, rebase, merge, or checkout;\n  when asked to split or isolate work for review; whenever a user mentions a stack,\n  branch layers, dependent PRs, or gh stack; or when a stack is checked out.\nmetadata:\n  author: github\n  version: \"0.2.0\"\n---\n\n# gh-stack\n\n`gh stack` is a [GitHub CLI](https:\u002F\u002Fcli.github.com\u002F) extension for stacked branches and pull\nrequests. A stack is an ordered chain of branches rooted on a trunk, where each branch has one PR\nbased on the branch below it, so a reviewer sees only that layer's diff.\n\n`gh stack` prints a stack trunk-first, left to right:\n\n```\n(main) \u003C- auth \u003C- api \u003C- frontend\n```\n\nLeft is the **bottom**, right is the **top**. `auth` is based on `main` and merges first;\n`frontend` merges last. `up` moves toward the top, away from trunk; `down` moves toward it.\nFoundational work belongs at the bottom, code that depends on it above. For how to choose the\nlayers, read `references\u002Fstack-design.md`.\n\n## Setup\n\nRequires Git 2.36+ and an authenticated GitHub CLI.\n\n```bash\ngh extension install github\u002Fgh-stack\ngit config rerere.enabled true         # remember conflict resolutions\ngit config remote.pushDefault origin   # required if the repo has more than one remote\n```\n\n## Non-interactive use\n\n`gh stack` branches on whether **stdout is a TTY**. Piped, most commands error cleanly or print\nstatic text; under a PTY the same commands open a prompt or a full-screen TUI and block forever.\nAgent harnesses differ, so always pass the flags below instead of relying on that detection.\n\n**Multiple remotes:** never run `push`, `submit`, `sync`, `rebase`, or `link` without\n`--remote \u003Cname>` unless `remote.pushDefault` is configured. `checkout` and `trunk` have no\n`--remote` flag and require the config.\n\n| Always run | Never run bare | Why |\n|---|---|---|\n| `gh stack view --json` | `gh stack view` | opens a TUI under a PTY |\n| `gh stack submit --auto` | `gh stack submit` | prompts for a title per new PR |\n| `gh stack merge \u003Ctarget> --yes` | `gh pr merge` | `gh pr merge` cannot merge a stack |\n| `gh stack init \u003Cbranch>...` | `gh stack init` | prompts for branch names |\n| `gh stack add \u003Cbranch>` | `gh stack add` | prompts for a name, and fails even when piped |\n| `gh stack checkout \u003Ctarget>` | `gh stack checkout` | opens a selection menu |\n| `gh stack up` \u002F `down` \u002F `top` \u002F `bottom` | `gh stack switch` | `switch` is menu-only |\n| — | `gh stack modify` | TUI-only, no non-interactive path |\n\n- `view --short` is safe in both modes, but it is formatted for humans. Use `--json` to parse.\n- **`checkout \u003Cpr>` when a different local stack already covers those branches** cannot be forced.\n  Run `gh stack unstack --local` first (this keeps the stack on GitHub), then retry.\n- **Worktrees:** local stacks share one common-directory catalog. Use `--print-path` with\n  navigation or explicit-target `checkout` to locate a foreign-owned branch without stealing its\n  checkout. Unoccupied targets are checked out here first. Check the exit status before changing\n  directories; parse only successful path-mode stdout, never status messages.\n\n## Branch placement\n\n- **Starting multi-part work:** create the stack before writing files. Do not implement every\n  concern on trunk and split it later. Put one dependent concern in each layer, bottom to top.\n- **Editing an existing stack:** check out the layer that owns the change before editing. Never\n  commit a lower layer's concern on the current top branch. Run `gh stack view --json`; if\n  ownership is unclear, inspect `git log --all -- \u003Cpath>`. Then check out the owner, edit, commit,\n  rebase upstack, and return to top.\n\n```bash\ngh stack down                   # or: gh stack checkout api\ngit add ... && git commit -m \"Add get-user endpoint\"\ngh stack rebase --upstack       # replay every branch above onto the change\ngh stack top                    # return to where you were\ngh stack push\n```\n\n## Core loop\n\n```bash\ngh stack init auth              # create the stack and check out its branch\ngit add ... && git commit -m \"Add auth middleware\"\ngh stack add api                # next layer, branched from the current one\ngit add ... && git commit -m \"Add API routes\"\ngh stack submit --auto          # push every branch and open draft PRs\ngh stack view --json            # confirm\n```\n\nAdd `--open` to `submit` to create PRs ready for review instead of drafts. Branch names are\nverbatim — `gh stack add refactor\u002Ffoo` creates `refactor\u002Ffoo`.\n\n## Staying in sync\n\n```bash\ngh stack sync                   # fetch, reconcile with GitHub, rebase, push, refresh PR state\ngh stack sync --prune           # also delete local branches for merged PRs\n```\n\nPruning never happens without `--prune` when non-interactive. If the local and remote stacks have\ndiverged, `sync` prints both chains, makes no changes, and exits 0 with `Sync aborted` — see\n`references\u002Ftroubleshooting.md`.\n\n## Merging\n\nScope the merge with an argument:\n\n```bash\ngh stack merge 42 --yes          # PR #42 plus every unmerged PR below it\ngh stack merge 7 --yes           # every unmerged PR in stack #7\ngh stack merge 42 --yes --squash # or --merge, --rebase, --merge-method \u003Cmethod>\n```\n\nPass a PR number to merge that PR and every unmerged PR below it, or a stack number to merge every\nunmerged PR in that stack. The operation is all-or-nothing: if any PR in that set cannot merge,\nnone do.\n\nWithout a method flag the last-used method is reused. If the base branch uses a merge queue, the\nstack is queued instead and the queue picks the method, ignoring any flag you passed with a\nwarning; queued PRs may land in separate groups.\n\n## Reading state\n\n`gh stack view --json` writes JSON to **stdout**. Status messages go to **stderr** — do not parse\nthem, branch on exit codes instead.\n\n```\ntrunk           string\ncurrentBranch   string\nbranches[]      name, head, base, isCurrent, isMerged, isQueued, needsRebase\nbranches[].pr   number, url, state (\"OPEN\" | \"MERGED\" | \"QUEUED\"); absent when no PR exists\n```\n\n`base` is the saved SHA of the parent branch that this branch was last known to contain. It may be\nolder than the parent's current tip. `needsRebase` is true when the current parent tip is no longer\nan ancestor of the branch.\n\n## Exit codes\n\n| Code | Meaning | Recovery |\n|---|---|---|\n| 0 | Success | — |\n| 1 | Generic error | Read stderr |\n| 2 | Not in a stack | `gh stack init`, or `gh stack checkout \u003Ctarget>` |\n| 3 | Rebase conflict | Follow the Exit 3 recovery below |\n| 4 | GitHub API failure | Check `gh auth status`, retry |\n| 5 | Invalid arguments | Fix the invocation; see `\u003Ccommand> --help` |\n| 6 | Disambiguation required | Branch is in several stacks; check out a non-shared branch |\n| 7 | Rebase already in progress | `gh stack rebase --continue` or `--abort` |\n| 8 | Stack file locked | Another `gh stack` process is writing; retry after ~5s |\n| 9 | Stacked PRs unavailable | Not enabled on the repository; tell the user |\n| 10 | Modify recovery required | `gh stack modify --abort` |\n\n**Exit 3 recovery:**\n\n- After `gh stack rebase`: resolve the files, run `git add`, then\n  `gh stack rebase --continue`; use `gh stack rebase --abort` to restore the stack.\n- After `gh stack sync`: the stack has already been restored. Run `gh stack rebase` to recreate the\n  conflict, then resolve and continue as above.\n\n## Constraints\n\n- Stacks are strictly linear: one parent, at most one child. Use separate stacks for parallel work.\n- `rebase` and `sync` automatically update affected clean worktrees; they never auto-stash or\n  create\u002Fremove worktrees. Mutations serialize across the clone, and paused operations require\n  recovery in their recorded owners.\n- `modify` supports distributed stack branches, but its editor remains TUI-only. Actions run in\n  affected clean owners; unoccupied branches use the origin. Drop\u002Ffold source branches and\n  worktrees are preserved. Recovery flags may run from any worktree and use recorded native\n  operation owners; never resolve\u002Fstage in the caller's tree unless the diagnostic names it.\n- There is no non-interactive reorder or removal. Errors may suggest `gh stack modify`, but it is\n  TUI-only — restructure with `unstack` then `init` instead.\n- PR titles and bodies are auto-generated. Use `gh pr edit` afterwards to change them.\n\n## More detail\n\n`gh stack \u003Ccommand> --help` is authoritative for flags and arguments. Note that\n`gh stack help \u003Ccommand>` does **not** work — it prints the top-level help.\n\nOpen the reference whose trigger matches the task; no need to preload all three.\n\n- `references\u002Fstack-design.md` — read before creating a stack, when deciding how many layers to\n  use, what belongs in each one, or whether work belongs in a new stack.\n- `references\u002Fcommands.md` — read when a command fails unexpectedly or you need its preconditions,\n  side effects, atomicity, or ordering guarantees.\n- `references\u002Ftroubleshooting.md` — read on a rebase conflict, after a squash-merge, on local and\n  remote divergence, when restructuring a stack, or when driving stacks from another tool.\n","# gh-stack\n\n`gh stack` is a [GitHub CLI](https:\u002F\u002Fcli.github.com\u002F) extension for stacked branches and pull\nrequests. A stack is an ordered chain of branches rooted on a trunk, where each branch has one PR\nbased on the branch below it, so a reviewer sees only that layer's diff.\n\n`gh stack` prints a stack trunk-first, left to right:\n\n```\n(main) \u003C- auth \u003C- api \u003C- frontend\n```\n\nLeft is the **bottom**, right is the **top**. `auth` is based on `main` and merges first;\n`frontend` merges last. `up` moves toward the top, away from trunk; `down` moves toward it.\nFoundational work belongs at the bottom, code that depends on it above. For how to choose the\nlayers, read `references\u002Fstack-design.md`.\n\n## Setup\n\nRequires Git 2.36+ and an authenticated GitHub CLI.\n\n```bash\ngh extension install github\u002Fgh-stack\ngit config rerere.enabled true         # remember conflict resolutions\ngit config remote.pushDefault origin   # required if the repo has more than one remote\n```\n\n## Non-interactive use\n\n`gh stack` branches on whether **stdout is a TTY**. Piped, most commands error cleanly or print\nstatic text; under a PTY the same commands open a prompt or a full-screen TUI and block forever.\nAgent harnesses differ, so always pass the flags below instead of relying on that detection.\n\n**Multiple remotes:** never run `push`, `submit`, `sync`, `rebase`, or `link` without\n`--remote \u003Cname>` unless `remote.pushDefault` is configured. `checkout` and `trunk` have no\n`--remote` flag and require the config.\n\n| Always run | Never run bare | Why |\n|---|---|---|\n| `gh stack view --json` | `gh stack view` | opens a TUI under a PTY |\n| `gh stack submit --auto` | `gh stack submit` | prompts for a title per new PR |\n| `gh stack merge \u003Ctarget> --yes` | `gh pr merge` | `gh pr merge` cannot merge a stack |\n| `gh stack init \u003Cbranch>...` | `gh stack init` | prompts for branch names |\n| `gh stack add \u003Cbranch>` | `gh stack add` | prompts for a name, and fails even when piped |\n| `gh stack checkout \u003Ctarget>` | `gh stack checkout` | opens a selection menu |\n| `gh stack up` \u002F `down` \u002F `top` \u002F `bottom` | `gh stack switch` | `switch` is menu-only |\n| — | `gh stack modify` | TUI-only, no non-interactive path |\n\n- `view --short` is safe in both modes, but it is formatted for humans. Use `--json` to parse.\n- **`checkout \u003Cpr>` when a different local stack already covers those branches** cannot be forced.\n  Run `gh stack unstack --local` first (this keeps the stack on GitHub), then retry.\n- **Worktrees:** local stacks share one common-directory catalog. Use `--print-path` with\n  navigation or explicit-target `checkout` to locate a foreign-owned branch without stealing its\n  checkout. Unoccupied targets are checked out here first. Check the exit status before changing\n  directories; parse only successful path-mode stdout, never status messages.\n\n## Branch placement\n\n- **Starting multi-part work:** create the stack before writing files. Do not implement every\n  concern on trunk and split it later. Put one dependent concern in each layer, bottom to top.\n- **Editing an existing stack:** check out the layer that owns the change before editing. Never\n  commit a lower layer's concern on the current top branch. Run `gh stack view --json`; if\n  ownership is unclear, inspect `git log --all -- \u003Cpath>`. Then check out the owner, edit, commit,\n  rebase upstack, and return to top.\n\n```bash\ngh stack down                   # or: gh stack checkout api\ngit add ... && git commit -m \"Add get-user endpoint\"\ngh stack rebase --upstack       # replay every branch above onto the change\ngh stack top                    # return to where you were\ngh stack push\n```\n\n## Core loop\n\n```bash\ngh stack init auth              # create the stack and check out its branch\ngit add ... && git commit -m \"Add auth middleware\"\ngh stack add api                # next layer, branched from the current one\ngit add ... && git commit -m \"Add API routes\"\ngh stack submit --auto          # push every branch and open draft PRs\ngh stack view --json            # confirm\n```\n\nAdd `--open` to `submit` to create PRs ready for review instead of drafts. Branch names are\nverbatim — `gh stack add refactor\u002Ffoo` creates `refactor\u002Ffoo`.\n\n## Staying in sync\n\n```bash\ngh stack sync                   # fetch, reconcile with GitHub, rebase, push, refresh PR state\ngh stack sync --prune           # also delete local branches for merged PRs\n```\n\nPruning never happens without `--prune` when non-interactive. If the local and remote stacks have\ndiverged, `sync` prints both chains, makes no changes, and exits 0 with `Sync aborted` — see\n`references\u002Ftroubleshooting.md`.\n\n## Merging\n\nScope the merge with an argument:\n\n```bash\ngh stack merge 42 --yes          # PR #42 plus every unmerged PR below it\ngh stack merge 7 --yes           # every unmerged PR in stack #7\ngh stack merge 42 --yes --squash # or --merge, --rebase, --merge-method \u003Cmethod>\n```\n\nPass a PR number to merge that PR and every unmerged PR below it, or a stack number to merge every\nunmerged PR in that stack. The operation is all-or-nothing: if any PR in that set cannot merge,\nnone do.\n\nWithout a method flag the last-used method is reused. If the base branch uses a merge queue, the\nstack is queued instead and the queue picks the method, ignoring any flag you passed with a\nwarning; queued PRs may land in separate groups.\n\n## Reading state\n\n`gh stack view --json` writes JSON to **stdout**. Status messages go to **stderr** — do not parse\nthem, branch on exit codes instead.\n\n```\ntrunk           string\ncurrentBranch   string\nbranches[]      name, head, base, isCurrent, isMerged, isQueued, needsRebase\nbranches[].pr   number, url, state (\"OPEN\" | \"MERGED\" | \"QUEUED\"); absent when no PR exists\n```\n\n`base` is the saved SHA of the parent branch that this branch was last known to contain. It may be\nolder than the parent's current tip. `needsRebase` is true when the current parent tip is no longer\nan ancestor of the branch.\n\n## Exit codes\n\n| Code | Meaning | Recovery |\n|---|---|---|\n| 0 | Success | — |\n| 1 | Generic error | Read stderr |\n| 2 | Not in a stack | `gh stack init`, or `gh stack checkout \u003Ctarget>` |\n| 3 | Rebase conflict | Follow the Exit 3 recovery below |\n| 4 | GitHub API failure | Check `gh auth status`, retry |\n| 5 | Invalid arguments | Fix the invocation; see `\u003Ccommand> --help` |\n| 6 | Disambiguation required | Branch is in several stacks; check out a non-shared branch |\n| 7 | Rebase already in progress | `gh stack rebase --continue` or `--abort` |\n| 8 | Stack file locked | Another `gh stack` process is writing; retry after ~5s |\n| 9 | Stacked PRs unavailable | Not enabled on the repository; tell the user |\n| 10 | Modify recovery required | `gh stack modify --abort` |\n\n**Exit 3 recovery:**\n\n- After `gh stack rebase`: resolve the files, run `git add`, then\n  `gh stack rebase --continue`; use `gh stack rebase --abort` to restore the stack.\n- After `gh stack sync`: the stack has already been restored. Run `gh stack rebase` to recreate the\n  conflict, then resolve and continue as above.\n\n## Constraints\n\n- Stacks are strictly linear: one parent, at most one child. Use separate stacks for parallel work.\n- `rebase` and `sync` automatically update affected clean worktrees; they never auto-stash or\n  create\u002Fremove worktrees. Mutations serialize across the clone, and paused operations require\n  recovery in their recorded owners.\n- `modify` supports distributed stack branches, but its editor remains TUI-only. Actions run in\n  affected clean owners; unoccupied branches use the origin. Drop\u002Ffold source branches and\n  worktrees are preserved. Recovery flags may run from any worktree and use recorded native\n  operation owners; never resolve\u002Fstage in the caller's tree unless the diagnostic names it.\n- There is no non-interactive reorder or removal. Errors may suggest `gh stack modify`, but it is\n  TUI-only — restructure with `unstack` then `init` instead.\n- PR titles and bodies are auto-generated. Use `gh pr edit` afterwards to change them.\n\n## More detail\n\n`gh stack \u003Ccommand> --help` is authoritative for flags and arguments. Note that\n`gh stack help \u003Ccommand>` does **not** work — it prints the top-level help.\n\nOpen the reference whose trigger matches the task; no need to preload all three.\n\n- `references\u002Fstack-design.md` — read before creating a stack, when deciding how many layers to\n  use, what belongs in each one, or whether work belongs in a new stack.\n- `references\u002Fcommands.md` — read when a command fails unexpectedly or you need its preconditions,\n  side effects, atomicity, or ordering guarantees.\n- `references\u002Ftroubleshooting.md` — read on a rebase conflict, after a squash-merge, on local and\n  remote divergence, when restructuring a stack, or when driving stacks from another tool.\n",{"name":5,"metadata":29,"description":31},{"author":9,"version":30},"0.2.0","Manages stacked PRs and splits multi-part work into reviewable branches with gh-stack. Use for stack creation, viewing, edits, push, submit, sync, rebase, merge, or checkout; when asked to split or isolate work for review; whenever a user mentions a stack, branch layers, dependent PRs, or gh stack; or when a stack is checked out.\n","main","2a49e6751238633db504655d8a8eba3e433e827d","skills\u002Fgh-stack",103,"https:\u002F\u002Fgithub.com\u002Fgithub\u002Fgh-stack","https:\u002F\u002Fgh.io\u002Fstacks","https:\u002F\u002Fgithub.com\u002Fgithub","https:\u002F\u002Fgithub.com\u002Fabout","How people build software.","2026-11-14 22:19:04",{"source":8,"skillName":5,"commands":43,"prompt":53,"zipAvailable":54},[44,47,50],{"tool":45,"command":46},"npx","npx skills add github\u002Fgh-stack --skill gh-stack",{"tool":48,"command":49},"bunx","bunx skills add github\u002Fgh-stack --skill gh-stack",{"tool":51,"command":52},"pnpm","pnpm dlx skills add github\u002Fgh-stack --skill gh-stack","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fgithub\u002Fgh-stack\u002Fblob\u002Fmain\u002Fskills\u002Fgh-stack\u002FSKILL.md",true,[56,62,66],{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"references\u002Fcommands.md","REFERENCE","参考文档",11145,"https:\u002F\u002Fgithub.com\u002Fgithub\u002Fgh-stack\u002Fblob\u002Fmain\u002Fskills\u002Fgh-stack\u002Freferences\u002Fcommands.md",{"path":63,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":64,"sourceHtmlUrl":65},"references\u002Fstack-design.md",4209,"https:\u002F\u002Fgithub.com\u002Fgithub\u002Fgh-stack\u002Fblob\u002Fmain\u002Fskills\u002Fgh-stack\u002Freferences\u002Fstack-design.md",{"path":67,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":68,"sourceHtmlUrl":69},"references\u002Ftroubleshooting.md",9109,"https:\u002F\u002Fgithub.com\u002Fgithub\u002Fgh-stack\u002Fblob\u002Fmain\u002Fskills\u002Fgh-stack\u002Freferences\u002Ftroubleshooting.md",[]]