@qvac/harness 0.2.5 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/.claude/skills/asana/SKILL.md +86 -0
  2. package/.claude/skills/gh-stack/SKILL.md +181 -0
  3. package/.claude/skills/gh-stack/references/commands.md +177 -0
  4. package/.claude/skills/gh-stack/references/stack-design.md +97 -0
  5. package/.claude/skills/gh-stack/references/troubleshooting.md +159 -0
  6. package/.claude/skills/js-house-style/SKILL.md +671 -0
  7. package/.claude/skills/kvcache/SKILL.md +171 -0
  8. package/.claude/skills/pr-create/SKILL.md +180 -0
  9. package/.claude/skills/pr-review/SKILL.md +217 -0
  10. package/CLAUDE.md +39 -0
  11. package/README.md +26 -4
  12. package/dist/harness.bundle +8 -60
  13. package/dist/prebuilds-manifest.json +0 -8
  14. package/dist-lib/index.d.ts +4 -1
  15. package/dist-lib/index.js +23 -7
  16. package/dist-lib/lib/docx/index.d.ts +5 -0
  17. package/dist-lib/lib/docx/index.js +49 -0
  18. package/dist-lib/lib/models/model-pool.d.ts +1 -1
  19. package/dist-lib/lib/models/model-pool.js +3 -2
  20. package/dist-lib/lib/spawn.d.ts +1 -0
  21. package/dist-lib/lib/tools/exec/adapters/python/pyodide.js +2 -0
  22. package/dist-lib/lib/tools/exec/adapters/python/wheels.js +2 -1
  23. package/dist-lib/lib/tools/exec/adapters/python/worker/client.js +1 -1
  24. package/dist-lib/schema/generate.d.ts +6 -2
  25. package/dist-lib/schema/generate.js +10 -5
  26. package/docs/decisions/2026-05-29-kvcache-tool-turns.md +75 -0
  27. package/docs/decisions/2026-06-02-kvcache-tool-turns-reenabled.md +127 -0
  28. package/docs/decisions/2026-06-23-android-cpu-llm-defaults.md +126 -0
  29. package/docs/decisions/2026-07-29-assistant-owned-storage-layout.md +88 -0
  30. package/docs/decisions/2026-08-04-sidecar-orphan-reaping.md +79 -0
  31. package/docs/decisions/2026-08-11-pyodide-worker-thread.md +68 -0
  32. package/docs/decisions/2026-08-17-harness-hook-pipeline.md +84 -0
  33. package/docs/decisions/2026-08-17-harness-outbound-egress-guard.md +176 -0
  34. package/docs/decisions/2026-08-20-chat-prompt-prefix-is-stable.md +95 -0
  35. package/docs/decisions/2026-08-20-kvcache-static-placement.md +109 -0
  36. package/docs/decisions/2026-08-21-vendored-python-wheels.md +85 -0
  37. package/docs/decisions/2026-08-26-exec-is-not-gated-by-skills.md +64 -0
  38. package/docs/decisions/2026-08-27-writable-skills-overlay.md +56 -0
  39. package/docs/decisions/2026-09-01-skill-operation-manifests.md +53 -0
  40. package/docs/decisions/2026-09-01-usage-breakdown-is-measured.md +78 -0
  41. package/docs/decisions/2026-09-03-usage-breakdown-reported-by-the-harness.md +136 -0
  42. package/docs/decisions/INDEX.md +38 -0
  43. package/docs/decisions/TEMPLATE.md +32 -0
  44. package/docs/kvcache-reference.md +655 -0
  45. package/package.json +6 -2
  46. package/worker/harness-sidecar.mjs +3 -2
@@ -0,0 +1,86 @@
1
+ ---
2
+ name: asana
3
+ description: Conventions for the QVAC Assistant Asana board when working through the Asana MCP server — what the MCP cannot do and what that silently breaks, the Context field that decides whether a task is visible at all, and the rule against consuming task descriptions. Use before creating, moving, or reading any Asana task for this project.
4
+ ---
5
+
6
+ # Asana — QVAC Assistant board
7
+
8
+ Asana work here goes through the **Asana MCP server**. This skill is not a tool;
9
+ it is the handful of things the MCP does not tell you and will not stop you
10
+ getting wrong.
11
+
12
+ - Workspace `45238840754660` (tether.to)
13
+ - Project `1214754188814246` (QVAC Assistant)
14
+ - Board: <https://app.asana.com/1/45238840754660/project/1214754188814246>
15
+
16
+ ## Do not create tasks through the MCP
17
+
18
+ `asana_create_task` takes `resource_subtype` of only `default_task`, `milestone`
19
+ or `approval`, and neither it nor `asana_update_task` accepts `custom_type` or
20
+ `custom_type_status_option`. This board runs on the **QVAC Basic Task** custom
21
+ type (`1214533632534265`), whose status options _are_ the workflow — the project
22
+ has one real section and tracks status entirely through the custom type.
23
+
24
+ So an MCP-created task is a plain default task that:
25
+
26
+ - is not a `QVAC Basic Task`,
27
+ - has no status (To Do / In Progress / In Code Review / Blocked /
28
+ Completed-Ready for QA / Fully Verified / Closed-Won't Fix), and
29
+ - cannot be given one afterwards through the API.
30
+
31
+ It lands on the board looking almost right and is undriveable. **Ask the user to
32
+ create the task in the Asana UI**, where the custom type is the default, and then
33
+ use the MCP to fill fields or comment on it. Do not create it yourself and
34
+ promise to "fix the type later" — the API has no route to do that.
35
+
36
+ Moving a task's status has the same limitation: the status lives on
37
+ `custom_type_status_option`, which the MCP cannot set. Status changes are a UI
38
+ action.
39
+
40
+ ## Context is mandatory, and the MCP will not warn you
41
+
42
+ The project's Dev Board tabs are saved views filtered on the **Context** custom
43
+ field. A task with Context unset appears only in "Full List" and "Overview" — it
44
+ is invisible on every Dev Board tab and silently slips off the team's radar.
45
+
46
+ Whenever you set fields on a task, set Context. Field `1214754188814251`:
47
+
48
+ | Value | GID | For |
49
+ | -------------- | ------------------ | ------------------------------------------------- |
50
+ | `harness` | `1214754188814252` | engine, mesh and sync, storage, build and release |
51
+ | `integrations` | `1214754188814253` | assistant runtime, agents, tools, skills |
52
+ | `other` | `1214758268571416` | genuinely cross-cutting: org, legal, product docs |
53
+
54
+ Surface which one you picked and why, and let the user correct it. Never guess
55
+ silently, and never leave it blank to avoid choosing.
56
+
57
+ ## Release grouping
58
+
59
+ Each Dev Board tab groups by **QVAC Workbench Release** (field
60
+ `1214111405360914`) first. A task with none lands in an "Untitled" bucket at the
61
+ bottom of every tab. Default to `tbc` (`1214757840453965`) when the release is
62
+ undecided.
63
+
64
+ **That field is the app's release, not a package version.** `@qvac/harness`,
65
+ `@qvac/core` and `@qvac/skills` each ship their own `0.x` line; putting one of
66
+ those numbers here files the task against a release that does not exist.
67
+
68
+ ## Never consume task descriptions
69
+
70
+ Work from task metadata only: GID, name, permalink, completion state, assignee,
71
+ memberships, custom fields, custom type and status, timestamps, and comments.
72
+
73
+ - `asana_get_task` returns the description by default. Pass an explicit
74
+ `opt_fields` list that omits `notes`, `html_notes` and `description`.
75
+ - Do not use Asana full-text search as a fallback — it matches descriptions.
76
+ Find tasks by the QVAC custom field (`1209150993228635`, text) or by GID.
77
+ - If the user wants you to act on a description, ask them to paste the relevant
78
+ excerpt rather than fetching it.
79
+
80
+ ## Before any mutation
81
+
82
+ Show the exact change and wait for a yes. That includes field edits, comments and
83
+ completion — this board is shared with the whole team, and a comment cannot be
84
+ unsent.
85
+
86
+ Never put tokens, secrets or internal-only URLs in a task or comment.
@@ -0,0 +1,181 @@
1
+ ---
2
+ name: gh-stack
3
+ description: >
4
+ Manages stacked PRs and splits multi-part work into reviewable branches with gh-stack.
5
+ Use for stack creation, viewing, edits, push, submit, sync, rebase, merge, or checkout;
6
+ when asked to split or isolate work for review; whenever a user mentions a stack,
7
+ branch layers, dependent PRs, or gh stack; or when a stack is checked out.
8
+ metadata:
9
+ author: github
10
+ version: '0.1.0'
11
+ ---
12
+
13
+ # gh-stack
14
+
15
+ `gh stack` is a [GitHub CLI](https://cli.github.com/) extension for stacked branches and pull
16
+ requests. A stack is an ordered chain of branches rooted on a trunk, where each branch has one PR
17
+ based on the branch below it, so a reviewer sees only that layer's diff.
18
+
19
+ `gh stack` prints a stack trunk-first, left to right:
20
+
21
+ ```
22
+ (main) <- auth <- api <- frontend
23
+ ```
24
+
25
+ Left is the **bottom**, right is the **top**. `auth` is based on `main` and merges first;
26
+ `frontend` merges last. `up` moves toward the top, away from trunk; `down` moves toward it.
27
+ Foundational work belongs at the bottom, code that depends on it above. For how to choose the
28
+ layers, read `references/stack-design.md`.
29
+
30
+ ## Setup
31
+
32
+ ```bash
33
+ gh extension install github/gh-stack
34
+ git config rerere.enabled true # remember conflict resolutions
35
+ git config remote.pushDefault origin # required if the repo has more than one remote
36
+ ```
37
+
38
+ ## Non-interactive use
39
+
40
+ `gh stack` branches on whether **stdout is a TTY**. Piped, most commands error cleanly or print
41
+ static text; under a PTY the same commands open a prompt or a full-screen TUI and block forever.
42
+ Agent harnesses differ, so always pass the flags below instead of relying on that detection.
43
+
44
+ **Multiple remotes:** never run `push`, `submit`, `sync`, `rebase`, or `link` without
45
+ `--remote <name>` unless `remote.pushDefault` is configured. `checkout` and `trunk` have no
46
+ `--remote` flag and require the config.
47
+
48
+ | Always run | Never run bare | Why |
49
+ | ----------------------------------------- | ------------------- | --------------------------------------------- |
50
+ | `gh stack view --json` | `gh stack view` | opens a TUI under a PTY |
51
+ | `gh stack submit --auto` | `gh stack submit` | prompts for a title per new PR |
52
+ | `gh stack merge <target> --yes` | `gh pr merge` | `gh pr merge` cannot merge a stack |
53
+ | `gh stack init <branch>...` | `gh stack init` | prompts for branch names |
54
+ | `gh stack add <branch>` | `gh stack add` | prompts for a name, and fails even when piped |
55
+ | `gh stack checkout <target>` | `gh stack checkout` | opens a selection menu |
56
+ | `gh stack up` / `down` / `top` / `bottom` | `gh stack switch` | `switch` is menu-only |
57
+ | — | `gh stack modify` | TUI-only, no non-interactive path |
58
+
59
+ - `view --short` is safe in both modes, but it is formatted for humans. Use `--json` to parse.
60
+ - **`checkout <pr>` when a different local stack already covers those branches** cannot be forced.
61
+ Run `gh stack unstack --local` first (this keeps the stack on GitHub), then retry.
62
+
63
+ ## Branch placement
64
+
65
+ - **Starting multi-part work:** create the stack before writing files. Do not implement every
66
+ concern on trunk and split it later. Put one dependent concern in each layer, bottom to top.
67
+ - **Editing an existing stack:** check out the layer that owns the change before editing. Never
68
+ commit a lower layer's concern on the current top branch. Run `gh stack view --json`; if
69
+ ownership is unclear, inspect `git log --all -- <path>`. Then check out the owner, edit, commit,
70
+ rebase upstack, and return to top.
71
+
72
+ ```bash
73
+ gh stack down # or: gh stack checkout api
74
+ git add ... && git commit -m "Add get-user endpoint"
75
+ gh stack rebase --upstack # replay every branch above onto the change
76
+ gh stack top # return to where you were
77
+ gh stack push
78
+ ```
79
+
80
+ ## Core loop
81
+
82
+ ```bash
83
+ gh stack init auth # create the stack and check out its branch
84
+ git add ... && git commit -m "Add auth middleware"
85
+ gh stack add api # next layer, branched from the current one
86
+ git add ... && git commit -m "Add API routes"
87
+ gh stack submit --auto # push every branch and open draft PRs
88
+ gh stack view --json # confirm
89
+ ```
90
+
91
+ Add `--open` to `submit` to create PRs ready for review instead of drafts. Branch names are
92
+ verbatim — `gh stack add refactor/foo` creates `refactor/foo`.
93
+
94
+ ## Staying in sync
95
+
96
+ ```bash
97
+ gh stack sync # fetch, reconcile with GitHub, rebase, push, refresh PR state
98
+ gh stack sync --prune # also delete local branches for merged PRs
99
+ ```
100
+
101
+ Pruning never happens without `--prune` when non-interactive. If the local and remote stacks have
102
+ diverged, `sync` prints both chains, makes no changes, and exits 0 with `Sync aborted` — see
103
+ `references/troubleshooting.md`.
104
+
105
+ ## Merging
106
+
107
+ Scope the merge with an argument:
108
+
109
+ ```bash
110
+ gh stack merge 42 --yes # PR #42 plus every unmerged PR below it
111
+ gh stack merge 7 --yes # every unmerged PR in stack #7
112
+ gh stack merge 42 --yes --squash # or --merge, --rebase, --merge-method <method>
113
+ ```
114
+
115
+ Pass a PR number to merge that PR and every unmerged PR below it, or a stack number to merge every
116
+ unmerged PR in that stack. The operation is all-or-nothing: if any PR in that set cannot merge,
117
+ none do.
118
+
119
+ Without a method flag the last-used method is reused. If the base branch uses a merge queue, the
120
+ stack is queued instead and the queue picks the method, ignoring any flag you passed with a
121
+ warning; queued PRs may land in separate groups.
122
+
123
+ ## Reading state
124
+
125
+ `gh stack view --json` writes JSON to **stdout**. Status messages go to **stderr** — do not parse
126
+ them, branch on exit codes instead.
127
+
128
+ ```
129
+ trunk string
130
+ currentBranch string
131
+ branches[] name, head, base, isCurrent, isMerged, isQueued, needsRebase
132
+ branches[].pr number, url, state ("OPEN" | "MERGED" | "QUEUED"); absent when no PR exists
133
+ ```
134
+
135
+ `base` is the saved SHA of the parent branch that this branch was last known to contain. It may be
136
+ older than the parent's current tip. `needsRebase` is true when the current parent tip is no longer
137
+ an ancestor of the branch.
138
+
139
+ ## Exit codes
140
+
141
+ | Code | Meaning | Recovery |
142
+ | ---- | -------------------------- | ---------------------------------------------------------- |
143
+ | 0 | Success | — |
144
+ | 1 | Generic error | Read stderr |
145
+ | 2 | Not in a stack | `gh stack init`, or `gh stack checkout <target>` |
146
+ | 3 | Rebase conflict | Follow the Exit 3 recovery below |
147
+ | 4 | GitHub API failure | Check `gh auth status`, retry |
148
+ | 5 | Invalid arguments | Fix the invocation; see `<command> --help` |
149
+ | 6 | Disambiguation required | Branch is in several stacks; check out a non-shared branch |
150
+ | 7 | Rebase already in progress | `gh stack rebase --continue` or `--abort` |
151
+ | 8 | Stack file locked | Another `gh stack` process is writing; retry after ~5s |
152
+ | 9 | Stacked PRs unavailable | Not enabled on the repository; tell the user |
153
+ | 10 | Modify recovery required | `gh stack modify --abort` |
154
+
155
+ **Exit 3 recovery:**
156
+
157
+ - After `gh stack rebase`: resolve the files, run `git add`, then
158
+ `gh stack rebase --continue`; use `gh stack rebase --abort` to restore the stack.
159
+ - After `gh stack sync`: the stack has already been restored. Run `gh stack rebase` to recreate the
160
+ conflict, then resolve and continue as above.
161
+
162
+ ## Constraints
163
+
164
+ - Stacks are strictly linear: one parent, at most one child. Use separate stacks for parallel work.
165
+ - There is no non-interactive reorder or removal. Errors may suggest `gh stack modify`, but it is
166
+ TUI-only — restructure with `unstack` then `init` instead.
167
+ - PR titles and bodies are auto-generated. Use `gh pr edit` afterwards to change them.
168
+
169
+ ## More detail
170
+
171
+ `gh stack <command> --help` is authoritative for flags and arguments. Note that
172
+ `gh stack help <command>` does **not** work — it prints the top-level help.
173
+
174
+ Open the reference whose trigger matches the task; no need to preload all three.
175
+
176
+ - `references/stack-design.md` — read before creating a stack, when deciding how many layers to
177
+ use, what belongs in each one, or whether work belongs in a new stack.
178
+ - `references/commands.md` — read when a command fails unexpectedly or you need its preconditions,
179
+ side effects, atomicity, or ordering guarantees.
180
+ - `references/troubleshooting.md` — read on a rebase conflict, after a squash-merge, on local and
181
+ remote divergence, when restructuring a stack, or when driving stacks from another tool.
@@ -0,0 +1,177 @@
1
+ # Command behavior
2
+
3
+ `gh stack <command> --help` is authoritative for flags and arguments. (`gh stack help <command>` only prints the top-level help.) This file only covers behavior `--help` does not
4
+ explain: preconditions, side effects, atomicity, and failure modes.
5
+
6
+ ## Contents
7
+
8
+ - [init](#init)
9
+ - [add](#add)
10
+ - [push](#push)
11
+ - [submit](#submit)
12
+ - [link](#link)
13
+ - [sync](#sync)
14
+ - [rebase](#rebase)
15
+ - [view](#view)
16
+ - [checkout](#checkout)
17
+ - [unstack](#unstack)
18
+ - [merge](#merge)
19
+ - [Navigation](#navigation)
20
+
21
+ ## init
22
+
23
+ Creates the stack and checks out the **last** branch in the list, so a single `init` can lay down
24
+ the whole chain: `gh stack init auth api frontend`.
25
+
26
+ `init` processes branch arguments from bottom to top. Existing branches are adopted. If the first
27
+ branch does not exist, it is created from the trunk; each later new branch is created from the
28
+ branch immediately before it. There is no separate adopt mode — existence decides. `--base`
29
+ selects a non-default trunk.
30
+
31
+ `init` also enables `git rerere`. Under a TTY the first run in a repo asks for confirmation; set
32
+ `git config rerere.enabled true` beforehand to skip it.
33
+
34
+ ## add
35
+
36
+ - **Must run from the top branch** of the stack (or the trunk when the stack is still empty).
37
+ Anywhere else it exits **5** with `can only add branches on top of the stack`. Run `gh stack top`
38
+ first.
39
+ - **Uncommitted changes carry over.** Without `-Am`, `add` does not touch the working tree, so
40
+ staged and unstaged changes follow you onto the new branch. Commit or stash first for a clean start.
41
+ - **`add -Am` commits in place when the current branch has no commits yet** — for example
42
+ immediately after `init` — instead of creating a branch. This is deliberate: the first layer
43
+ usually needs its content before a second layer exists.
44
+ - `-A` and `-u` are mutually exclusive, and both require `-m`.
45
+
46
+ ## push
47
+
48
+ Pushes every active (non-merged, non-queued) branch in one multi-ref push with per-branch
49
+ `--force-with-lease`.
50
+
51
+ **Not atomic.** Some branches may update while another is rejected. A rejection means that branch
52
+ moved on the remote; fix that branch and rerun — rerunning is safe and skips what already landed.
53
+
54
+ `push` never creates or updates pull requests. Use `submit` for that.
55
+
56
+ ## submit
57
+
58
+ Pushes each active branch, then creates a PR for every branch that lacks one, basing it on the
59
+ first non-merged ancestor, then links them into a Stack on GitHub.
60
+
61
+ - **Not atomic.** Branches are pushed sequentially with per-branch `--force-with-lease`. If a later
62
+ push is rejected, earlier pushes and PR updates stand. Fix the rejection and rerun the same command.
63
+ - **A fully merged stack cannot be extended.** When every PR in the current stack is already merged,
64
+ `submit` forks the remaining unmerged branches into a **new** stack rooted at the trunk and creates
65
+ it on GitHub, leaving the merged stack untouched.
66
+ - **Title generation with `--auto`:** a branch with a single commit uses that commit's subject as
67
+ the title and its body as the PR body. A branch with multiple commits humanizes the branch name
68
+ (hyphens and underscores become spaces). There is no flag for a custom title or body; use
69
+ `gh pr edit` afterwards.
70
+ - `--open` marks new _and existing_ PRs ready for review; without it new PRs are drafts.
71
+ - Requires stacked PRs to be enabled on the repository. If not, `submit` exits **9** when
72
+ non-interactive (under a TTY it offers to create ordinary unstacked PRs instead).
73
+
74
+ ## link
75
+
76
+ Creates or updates a stack on GitHub **without any local tracking state**. This is the path for
77
+ branches managed by another tool or living in another worktree — see `troubleshooting.md`.
78
+
79
+ - Arguments are given bottom to top. Each is a branch name or a PR number; a numeric argument is
80
+ tried as a PR number first and falls back to a branch name.
81
+ - **A numeric first argument is treated as a stack number only when a stack with that number
82
+ exists.** In that case the remaining arguments are appended to the top of that stack and you do
83
+ not re-list its current PRs: `gh stack link 7 feature-c`. Arguments already in the stack are
84
+ skipped; arguments belonging to a different stack are rejected.
85
+ - Branch arguments are pushed automatically (non-force, atomic). Missing PRs are created with
86
+ auto-generated titles and correctly chained bases; existing PRs with a wrong base are corrected.
87
+ - Stack membership is **additive only** — `link` never removes a PR from a stack.
88
+
89
+ ## sync
90
+
91
+ The routine command. Steps, in order:
92
+
93
+ 1. **Fetch** from the remote.
94
+ 2. **Reconcile with the GitHub stack.** PRs added to the stack on github.com are pulled down and
95
+ appended locally. On divergence, aborts when non-interactive (see `troubleshooting.md`).
96
+ 3. **Fast-forward the trunk.** Skipped when already current; warns when diverged.
97
+ 4. **Cascade rebase when needed.** This runs if the trunk moved, a stack branch was fast-forwarded
98
+ from its remote, or a branch no longer contains its expected parent. Merged PRs are handled
99
+ automatically. On conflict, **all branches are restored** to their pre-rebase state and the
100
+ command exits **3**.
101
+ 5. **Push** all active branches, atomically.
102
+ 6. **Refresh PR state** from GitHub.
103
+ 7. **Sync the stack object** — link open PRs into a stack, additively. Only when two or more PRs
104
+ exist. `sync` never opens PRs; that is `submit`.
105
+ 8. **Prune** local branches for merged PRs, only when `--prune` is passed in a non-interactive
106
+ environment.
107
+
108
+ ## rebase
109
+
110
+ Pulls from the remote and cascade-rebases. Use it when `sync` reported a conflict or when you need
111
+ to rebase only part of the stack.
112
+
113
+ - `--upstack` rebases from the current branch to the top. This is what you run after editing a
114
+ lower layer.
115
+ - `--downstack` rebases from the trunk to the current branch.
116
+ - `--no-trunk` skips fetching and the trunk rebase entirely, aligning stack branches with each
117
+ other only.
118
+ - `--continue` after staging resolutions; `--abort` restores every branch.
119
+ - A merged PR is detected automatically and replayed with `--onto` against the correct target, so a
120
+ squash-merged parent does not produce spurious conflicts.
121
+ - Starting a rebase while one is in progress exits **7**.
122
+
123
+ ## view
124
+
125
+ - `--json` writes the machine-readable payload to stdout. Its schema is in `SKILL.md`.
126
+ - Bare `view` opens a full-screen TUI when stdout is a TTY, and prints static text when piped.
127
+ - `--short` prints a compact one-line-per-branch summary and never opens the TUI, but it is
128
+ formatted for humans; parse `--json` instead.
129
+ - `view` refreshes PR state from GitHub as a side effect, best-effort — it does not fail when the
130
+ API is unreachable.
131
+
132
+ ## checkout
133
+
134
+ Accepts a stack number, PR number, PR URL, or branch name.
135
+
136
+ - A bare number resolves as a **stack number first**, then a PR number, then a branch name.
137
+ - Stack numbers, PR numbers, and PR URLs fetch from GitHub, pull the branches down, and set the
138
+ stack up locally.
139
+ - If a local stack already exists over those branches with a different composition, `checkout`
140
+ cannot be forced past it. Run `gh stack unstack --local` first, then retry.
141
+ - `checkout` has no flags. It relies on `remote.pushDefault` when several remotes exist.
142
+
143
+ ## unstack
144
+
145
+ Removes the stack **grouping** only. It never deletes pull requests or branches.
146
+
147
+ - With no argument it targets the active stack — the one containing the current branch — removing
148
+ it on GitHub and locally.
149
+ - With a stack number it works from anywhere in the repository, tracked locally or not, via the API.
150
+ Local tracking is also removed when present.
151
+ - `--local` removes local tracking only and never contacts GitHub. Combining `--local` with a stack
152
+ number that is not tracked locally is an error.
153
+ - An unknown stack number exits **2**.
154
+
155
+ ## merge
156
+
157
+ - Scope with an argument: pass a PR number to merge that PR and every unmerged PR below it in the
158
+ stack, or pass a stack number to merge every unmerged PR in that stack.
159
+ - **All-or-nothing.** If any PR in that exact merge set cannot be merged, none are, and the reason
160
+ is reported.
161
+ - The method comes from `--squash`, `--rebase`, `--merge`, or `--merge-method <method>`. Without
162
+ one, the last-used method is reused.
163
+ - Only basic PR state is checked before merging: open and not a draft. Bypassing merge requirements
164
+ is not supported for stacks.
165
+ - **A merge queue on the base branch overrides everything.** The stack is added to the queue rather
166
+ than merged; the queue chooses the method and any method flag you passed is ignored with a
167
+ warning. Queued PRs are submitted together but land as the queue processes them, so they may merge
168
+ in separate groups rather than all at once.
169
+ - `gh pr merge` cannot merge a stack. Always use `gh stack merge`.
170
+
171
+ ## Navigation
172
+
173
+ `up`, `down`, `top`, `bottom`, and `trunk` are always non-interactive. `up` and `down` accept a
174
+ count (`gh stack up 3`). Movement clamps at the stack bounds, and merged branches are skipped when
175
+ navigating from an active branch, so `bottom` lands on the lowest _unmerged_ branch.
176
+
177
+ `gh stack switch` is a selection menu with no non-interactive path. Use the commands above instead.
@@ -0,0 +1,97 @@
1
+ # Designing a stack
2
+
3
+ How to decide what goes in each layer. Read this before running `gh stack init`.
4
+
5
+ ## Contents
6
+
7
+ - [Plan the layers before writing code](#plan-the-layers-before-writing-code)
8
+ - [Branch naming](#branch-naming)
9
+ - [Staging changes deliberately](#staging-changes-deliberately)
10
+ - [When to add a layer](#when-to-add-a-layer)
11
+ - [One stack, one story](#one-stack-one-story)
12
+
13
+ ## Plan the layers before writing code
14
+
15
+ A stack is a dependency chain. If code in one layer depends on code in another, the dependency must
16
+ live in the same branch or a lower one. That constraint is much cheaper to satisfy by planning than
17
+ by restructuring later, because there is no non-interactive in-place reorder — fixing the order
18
+ means`unstack` and `init` again.
19
+
20
+ Decide the layers first, then write code into them:
21
+
22
+ ```
23
+ (main) <- todo-app/models <- todo-app/api <- todo-app/frontend <- todo-app/integration
24
+ ```
25
+
26
+ - `todo-app/models` — shared types and schema
27
+ - `todo-app/api` — routes that use the models
28
+ - `todo-app/frontend` — components that call the routes
29
+ - `todo-app/integration` — tests exercising the whole feature
30
+
31
+ This is illustrative. Infer the stack topic and layer names from the actual task; do not reuse
32
+ `todo-app` or these layer names literally.
33
+
34
+ The failure mode to avoid is writing everything on one branch and trying to split it afterwards.
35
+ If a task is large enough to warrant a stack, create the stack at the start.
36
+
37
+ ## Branch naming
38
+
39
+ Prefer a shared topic prefix plus the layer's concern:
40
+ `<topic>/<concern>` — for example, `billing/schema`, `billing/api`, `billing/ui`.
41
+ This keeps related branches recognizable without using generic names that could belong to any
42
+ stack. **User and repository branch naming conventions take precedence; follow them instead.**
43
+
44
+ Names are used exactly as given — nothing is prepended or transformed, and slashes are kept, so
45
+ `gh stack add refactor/foo` creates a branch literally named `refactor/foo`.
46
+
47
+ If you pass `-m` without a branch name, the name is generated from the commit message in
48
+ date-and-slug form (for example `03-24-add_api_routes`). Prefer naming the branch yourself.
49
+
50
+ ## Staging changes deliberately
51
+
52
+ Use `git add` and `git commit` directly rather than the `add -Am` shortcut. The point is control
53
+ over which changes land in which branch. With several modified files in the working tree, stage the
54
+ subset that belongs to the current layer, commit it, then create the next branch and stage the rest
55
+ there:
56
+
57
+ ```bash
58
+ git add internal/models/user.go internal/models/session.go
59
+ git commit -m "Add user and session models"
60
+
61
+ gh stack add api-routes
62
+ git add internal/api/routes.go internal/api/handlers.go
63
+ git commit -m "Add user API routes"
64
+ ```
65
+
66
+ Multiple commits per branch are fine. What matters is that every commit in a branch serves the same
67
+ concern, and that a change belonging to a different concern goes in a different branch.
68
+
69
+ Note that `gh stack add <branch>` without `-Am` does not touch the working tree, so uncommitted
70
+ changes carry over to the new branch. Commit or stash first if you want the new layer to start clean.
71
+
72
+ ## When to add a layer
73
+
74
+ Add a branch when you start a **different concern that depends on what you have built so far**.
75
+ Signals:
76
+
77
+ - Moving from backend to frontend, or from core logic to tests or documentation
78
+ - The next changes have a different reviewer audience
79
+ - The current branch's diff is already large enough to review on its own
80
+
81
+ A layer that cannot be described in one sentence is usually two layers.
82
+
83
+ ## One stack, one story
84
+
85
+ A stack should read as a coherent progression: a reviewer walks the PRs bottom to top and sees the
86
+ feature being built.
87
+
88
+ **Use a single stack** when every branch serves the same feature or project, even if the layers span
89
+ different concerns.
90
+
91
+ **Start a separate stack** for unrelated work — a different feature, an unrelated bug fix, an
92
+ independent refactor. Do not mix efforts into one stack just because you happened to work on both.
93
+ Use `gh stack init` for the new effort, or `gh stack checkout <target>` to move between existing
94
+ stacks.
95
+
96
+ A trivial incidental fix can ride along in the current stack. Once it grows into its own project, it
97
+ deserves its own stack.