|
1 | 1 | --- |
2 | 2 | name: stack-cli |
3 | | -description: Use for the `stack` GitHub stacked-PR CLI. Covers safe init, track, create, status, restack, submit, sync, move, and queue workflows with preview-first, repairable operations on ordinary branches and PRs. |
| 3 | +description: Use for the `stack` GitHub CLI for stacked PRs and landing orchestration. Covers graph setup, stacked-PR workflows, landing branches, verification, superseded PR handling, closeout, and queue handoff for the real merge target. |
4 | 4 | --- |
5 | 5 |
|
6 | 6 | # stack CLI |
7 | 7 |
|
8 | | -Use this skill when helping someone operate the `stack` CLI safely. |
| 8 | +Use this skill to operate `stack` safely: make the graph explicit, then choose how it lands. |
| 9 | + |
| 10 | +## Decide the path first |
| 11 | + |
| 12 | +There are two supported paths: |
| 13 | + |
| 14 | +- standard stacked PR flow: each tracked branch lands as its own PR |
| 15 | +- landing workflow: one composed landing branch and landing PR become the real merge target |
| 16 | + |
| 17 | +If you are starting from existing PRs, first make the graph explicit, then continue with one of those two paths. |
9 | 18 |
|
10 | 19 | ## Operating rules |
11 | 20 |
|
12 | | -- Prefer `stack status` first when the repo state is unclear. |
| 21 | +- Prefer `stack status` first when repo state is unclear. |
13 | 22 | - Treat stack metadata as the source of truth; use `sync` to refresh GitHub-backed state. |
14 | | -- Keep write flows previewable and repairable. If a command can be checked before mutation, do that. |
15 | | -- Use `git` and `gh` for the repository and PR operations around `stack`. |
16 | | -- When a command offers confirmation or `--yes`, assume the safer preview path unless the user explicitly wants unattended execution. |
17 | | -- Stop on ambiguity. Do not guess parentage, merge bases, or repair actions when the CLI surfaces a manual-review case. |
18 | | - |
19 | | -## Core flow map |
20 | | - |
21 | | -- `init`: initialize repo-level stack metadata. |
22 | | -- `create <branch>`: create a new tracked branch on top of the current branch. |
23 | | -- `track <branch> --parent <parent>`: adopt an existing branch into the stack graph. |
24 | | -- `status`: inspect stack health, hierarchy, and cached PR state. |
25 | | -- `restack [branch] | --all`: preview and rebase tracked branches onto their configured parents. |
26 | | -- `continue`: resume an interrupted restack after conflicts are resolved. |
27 | | -- `abort`: abandon an interrupted restack and restore the original branch when possible. |
28 | | -- `submit [branch] | --all`: fetch, optionally restack, preview the push plan, then push and create or update one normal PR per branch. |
29 | | -- `sync [--apply]`: refresh cached PR metadata and report or apply only clean repairs. |
30 | | -- `move <branch> --parent <parent>`: change a branch parent, preview the rewrite, and restack affected descendants. |
31 | | -- `queue <branch>`: hand one healthy bottom-of-stack PR to GitHub auto-merge or merge queue. |
32 | | - |
33 | | -## Safe usage patterns |
34 | | - |
35 | | -- Start with `stack status` or `stack status --json` to understand the graph and current drift. |
36 | | -- Use `stack init` once per repo before tracking branches. |
37 | | -- Use `stack create` for new stack branches and `stack track` for existing ones; always make the parent explicit. |
38 | | -- Prefer `stack submit` before `stack queue`; queue handoff expects a fresh push, matching PR base, and matching head commit. |
39 | | -- Use `stack sync` after merges or PR changes to reconcile local metadata with GitHub. |
40 | | -- Use `stack sync --apply` only for clean repairs. If the tool marks a case as ambiguous or manual review, keep it manual. |
| 23 | +- Preview before mutating when possible. |
| 24 | +- Stop on ambiguity. Do not guess parentage, merge bases, repair actions, or the real merge target when the CLI surfaces a manual-review case. |
| 25 | +- Prefer preview over `--yes` unless the user wants unattended execution. |
| 26 | +- Use ordinary `git` and `gh` around `stack`; do not invent a parallel hosted workflow. |
| 27 | + |
| 28 | +## Core command map |
| 29 | + |
| 30 | +- Setup |
| 31 | +- `init`: initialize repo metadata |
| 32 | +- `create <branch>`: create a tracked branch |
| 33 | +- `track <branch> --parent <parent>`: adopt an existing local branch |
| 34 | +- `adopt pr <number> --parent <parent>`: adopt an existing PR head |
| 35 | +- Health and repair |
| 36 | +- `status`: graph, PR, verification, and landing health |
| 37 | +- `sync [--apply]`: refresh PR state and apply clean repairs |
| 38 | +- `restack [branch] | --all`: rebase tracked branches onto parents |
| 39 | +- `continue`: resume an interrupted restack |
| 40 | +- `abort`: abandon an interrupted restack |
| 41 | +- `move <branch> --parent <parent>`: change a branch parent |
| 42 | +- Standard PR flow |
| 43 | +- `submit [branch] | --all`: push tracked branches and create or update PRs |
| 44 | +- Landing workflow |
| 45 | +- `compose <name>`: create a landing branch |
| 46 | +- `verify add <branch>`: attach verification evidence |
| 47 | +- `verify list <branch>`: inspect verification records |
| 48 | +- `supersede --landing <branch> --prs ...`: mark original PRs as superseded |
| 49 | +- `closeout <landing-branch> [--apply]`: plan or apply post-merge closure work |
| 50 | +- Queue handoff |
| 51 | +- `queue <branch>`: hand off the real merge target |
| 52 | + |
| 53 | +## Standard stacked-PR workflow |
| 54 | + |
| 55 | +Typical flow: |
| 56 | + |
| 57 | +1. `stack init --trunk main --remote origin` |
| 58 | +2. `stack create feature/base` |
| 59 | +3. `stack create feature/child` |
| 60 | +4. `stack status` |
| 61 | +5. `stack restack` when a parent moved |
| 62 | +6. `stack submit --all` |
| 63 | +7. `stack queue feature/base` |
| 64 | +8. `stack sync` after merges |
| 65 | + |
| 66 | +## Existing PR pile setup |
| 67 | + |
| 68 | +Typical flow: |
| 69 | + |
| 70 | +1. `stack init --trunk main --remote origin` |
| 71 | +2. `stack adopt pr 353 --parent main` |
| 72 | +3. `stack adopt pr 354 --parent pr/353` |
| 73 | +4. `stack status` |
| 74 | +5. `stack sync` |
| 75 | +6. `stack move`, `stack restack`, and `stack submit` until the graph matches intent |
| 76 | + |
| 77 | +Do not ask `stack` to infer the dependency graph. The operator still chooses the parent chain. |
| 78 | + |
| 79 | +Once the graph is explicit, continue with Standard stacked-PR workflow or Landing workflow. |
| 80 | + |
| 81 | +## Landing workflow |
| 82 | + |
| 83 | +Typical flow: |
| 84 | + |
| 85 | +1. make the graph explicit with the setup flow above |
| 86 | +2. `stack compose discovery-core --from pr/353 --to pr/364 --ticket LNHACK-66 --ticket LNHACK-74 --open-pr` |
| 87 | +3. `stack verify add stack/discovery-core --type sim --run-id run-123 --passed` |
| 88 | +4. `stack supersede --landing stack/discovery-core --prs 353,354,363,364 --close-after-merge` |
| 89 | +5. `stack queue stack/discovery-core` |
| 90 | +6. `stack closeout stack/discovery-core` |
| 91 | +7. `stack closeout stack/discovery-core --apply` after the landing PR merges |
| 92 | + |
| 93 | +Important operator rules: |
| 94 | + |
| 95 | +- use explicit `--ticket` flags during compose; closeout no longer guesses tickets from branch names |
| 96 | +- keep verification on the landing branch, not only in chat or in a PR body |
| 97 | + |
| 98 | +## Before queue |
| 99 | + |
| 100 | +- Queue only the real merge target: the bottom tracked PR in standard flow, or the landing PR in landing workflow. |
| 101 | +- Prefer `submit` before `queue`. |
| 102 | +- If queue reports stale remote or stale PR head state, rerun `submit`. |
| 103 | +- If verification exists, queue requires the latest verification to pass and still match the current head. |
41 | 104 |
|
42 | 105 | ## Repair loop |
43 | 106 |
|
44 | | -When state drifts: |
| 107 | +1. inspect with `stack status` |
| 108 | +2. refresh with `stack sync` |
| 109 | +3. apply only clean repairs if they are obvious and supported |
| 110 | +4. restack, resubmit, or recompose only after the graph is consistent again |
| 111 | + |
| 112 | +If a restack stops mid-flight: |
| 113 | + |
| 114 | +- use `stack continue` from the same worktree after resolving conflicts |
| 115 | +- use `stack abort` if you need to clear the operation journal and recover instead |
| 116 | + |
| 117 | +## Queue and GitHub guardrails |
45 | 118 |
|
46 | | -1. Inspect with `stack status`. |
47 | | -2. Refresh with `stack sync`. |
48 | | -3. Apply only clean repairs if they are obvious and supported. |
49 | | -4. Restack or resubmit only after the graph is consistent again. |
| 119 | +- `queue` is for a healthy trunk-bound PR or recorded landing PR, not for any arbitrary branch in the graph |
| 120 | +- when a landing batch exists, original source PRs are traceability-only; if queue redirects you to the landing PR, trust that |
| 121 | +- if a PR is closed, merged, draft, or on the wrong base, repair that before queue handoff |
50 | 122 |
|
51 | | -If a restack stops mid-flight, use `stack continue` from the same worktree after resolving conflicts. Use `stack abort` if you need to clear the operation journal and recover instead. |
| 123 | +## Repo-specific sandbox note |
52 | 124 |
|
53 | | -## Queue and submit guardrails |
| 125 | +On machines with multiple `gh` accounts, pin `GH_TOKEN`; do not rely on the active account: |
54 | 126 |
|
55 | | -- `submit` may push branch tips, create PRs, edit PR bases, and refresh PR metadata. Preview first. |
56 | | -- `queue` is only for a tracked branch that already targets trunk, has a PR, has a pushed remote branch, and has a current head that matches local state. |
57 | | -- For queue handoff, prefer the default merge strategy unless the user asked for `squash` or `rebase`. |
58 | | -- If the CLI reports stale remote state, re-run `submit` before `queue`. |
59 | | -- If a PR is closed, merged, draft, or on the wrong base, repair that state before handing it to queue. |
| 127 | +```bash |
| 128 | +gh auth switch -u roodboi |
| 129 | +TOKEN="$(gh auth token)" |
| 130 | +GH_TOKEN="$TOKEN" scripts/sandbox/seed-fixtures.sh |
| 131 | +``` |
60 | 132 |
|
61 | 133 | ## What to avoid |
62 | 134 |
|
63 | 135 | - Do not bypass stack metadata with direct remote mutations unless the user explicitly wants a manual repair step. |
64 | 136 | - Do not override the CLI’s manual-review cases with guesses. |
65 | | -- Do not present `stack tui` as an edit surface; it is read-only. |
| 137 | +- Do not treat `stack tui` as an edit surface; it is read-only. |
0 commit comments