flow-workflows 0.86.0 → 0.88.0

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 (41) hide show
  1. package/README.md +1 -0
  2. package/adapters/codex/CORE.md +11 -1
  3. package/adapters/codex/skills/flow-bug-investigate/SKILL.md +3 -3
  4. package/adapters/codex/skills/flow-bug-start/SKILL.md +1 -1
  5. package/adapters/codex/skills/flow-feat-design/SKILL.md +3 -3
  6. package/adapters/codex/skills/flow-feat-plan/SKILL.md +3 -3
  7. package/adapters/codex/skills/flow-feat-start/SKILL.md +1 -1
  8. package/adapters/codex/skills/flow-work-README/SKILL.md +1 -0
  9. package/adapters/codex/skills/flow-work-handoff/SKILL.md +162 -0
  10. package/adapters/codex/skills/flow-work-resume/SKILL.md +1 -1
  11. package/adapters/gemini/CORE.md +11 -1
  12. package/adapters/gemini/commands/flow/bug/investigate.toml +3 -3
  13. package/adapters/gemini/commands/flow/bug/start.toml +1 -1
  14. package/adapters/gemini/commands/flow/feat/design.toml +3 -3
  15. package/adapters/gemini/commands/flow/feat/plan.toml +3 -3
  16. package/adapters/gemini/commands/flow/feat/start.toml +1 -1
  17. package/adapters/gemini/commands/flow/work/README.toml +1 -0
  18. package/adapters/gemini/commands/flow/work/handoff.toml +159 -0
  19. package/adapters/gemini/commands/flow/work/resume.toml +1 -1
  20. package/adapters/hermes/CORE.md +11 -1
  21. package/adapters/hermes/skills/flow-bug-investigate/SKILL.md +3 -3
  22. package/adapters/hermes/skills/flow-bug-start/SKILL.md +1 -1
  23. package/adapters/hermes/skills/flow-feat-design/SKILL.md +3 -3
  24. package/adapters/hermes/skills/flow-feat-plan/SKILL.md +3 -3
  25. package/adapters/hermes/skills/flow-feat-start/SKILL.md +1 -1
  26. package/adapters/hermes/skills/flow-work-README/SKILL.md +1 -0
  27. package/adapters/hermes/skills/flow-work-handoff/SKILL.md +162 -0
  28. package/adapters/hermes/skills/flow-work-resume/SKILL.md +1 -1
  29. package/adapters/opencode/CORE.md +11 -1
  30. package/adapters/opencode/commands/flow-bug-investigate.md +3 -3
  31. package/adapters/opencode/commands/flow-bug-start.md +1 -1
  32. package/adapters/opencode/commands/flow-feat-design.md +3 -3
  33. package/adapters/opencode/commands/flow-feat-plan.md +3 -3
  34. package/adapters/opencode/commands/flow-feat-start.md +1 -1
  35. package/adapters/opencode/commands/flow-work-README.md +1 -0
  36. package/adapters/opencode/commands/flow-work-handoff.md +160 -0
  37. package/adapters/opencode/commands/flow-work-resume.md +1 -1
  38. package/package.json +1 -1
  39. package/plugins/flow/.claude-plugin/plugin.json +1 -1
  40. package/plugins/flow/CHANGELOG.md +29 -0
  41. package/plugins/flow/examples/FLOW.template.md +3 -0
package/README.md CHANGED
@@ -173,6 +173,7 @@ Symmetrically, `guided`/`auto` never ask about the flow's own machinery (panels,
173
173
  | `/flow:work:try` | Point the main checkout at a branch to test it, and print the manual test plan once it is up (then `--back`) |
174
174
  | `/flow:work:clean` | Sweep merged worktrees, dead branches, unarchived folders. Never deletes on a guess |
175
175
  | `/flow:work:abandon` | Close a work item without shipping |
176
+ | `/flow:work:handoff` | Hand a finished study to whoever builds it elsewhere — pushes only its folder to a branch of its own, offers a summary for the ticket |
176
177
  | `/flow:news` | What changed in the plugin since the version you last saw |
177
178
 
178
179
  ## What a work looks like on disk
@@ -17,7 +17,7 @@ Every `$flow-*` command assumes these rules. They are stated once, here, so a co
17
17
  carries what is specific to its phase. Read this once per session; a command that says "load
18
18
  `flow-core`" means this file.
19
19
 
20
- **This file belongs to flow `0.86.0`.** Compare it once, at the start of the session, against
20
+ **This file belongs to flow `0.88.0`.** Compare it once, at the start of the session, against
21
21
  `version` in `~/.claude/flow/.claude-plugin/plugin.json`. The two differing means the session
22
22
  is running a **mixture** — the commands from one copy of the plugin, these shared rules from another
23
23
  — which is exactly what happens when a branch or a release candidate is loaded over an installed
@@ -218,6 +218,16 @@ sensible default and record it.
218
218
 
219
219
  Asking these anyway is how a run in `guided`/`auto` degrades into a manual one.
220
220
 
221
+ **A study made for handoff.** `git.handoff_branch` set and the mode not `unattended` → the study is
222
+ built somewhere else, so wherever a study phase (`start`, `design`, `plan`, `investigate`) or
223
+ `resume` would hand the work to `$flow-feat-build` or `$flow-bug-fix`, it hands it to
224
+ `$flow-work-handoff` instead. Only the target changes: a Close that asks (`manual`) offers **Hand
225
+ off the study** recommended and **Build here** second; a Close that chains (`guided`/`auto`) chains
226
+ into handoff, whose push question is the one confirmation — no stop is added. In `unattended` the
227
+ rule does not apply: the repo's `FLOW.md` reaches the server too, and a run that studies a ticket
228
+ there goes on to build it. A repo that hands its studies off pairs the key with
229
+ `autonomy.mode: auto`, and the study then runs on its own up to the push.
230
+
221
231
  ### 2.1 `unattended` — where a person would have been asked
222
232
 
223
233
  No person is there to answer a question in this mode. A question tool — `AskUserQuestion`, OpenCode's `question`,
@@ -36,7 +36,7 @@ Read `~/.claude/flow/CORE.codex.md` first (shared rules: `FLOW.md` step 0, model
36
36
  **In `unattended`, before this phase's first step, read flow-core §2.1 whole — from its heading to the next section, unless it is already in your context whole; having read parts of it does not count** — the orchestrator command, the question stop and the way its answer comes back are all in it, and a phase that reads only part of it skips them.
37
37
 
38
38
  - Read `meta.json` and `00-summary.md`; open in full only `01-context.md`. (flow-core §5)
39
- - `type` is not `bug` → refuse. `size` is `XS` → suggest `$flow-bug-fix` and stop.
39
+ - `type` is not `bug` → refuse. `size` is `XS` → suggest `$flow-bug-fix` — `git.handoff_branch` set and not `unattended` → `$flow-work-handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff) — and stop.
40
40
  - Require `context` in `phases_done`.
41
41
 
42
42
  ## 1.5 Reproduce — what is failing, before why
@@ -221,5 +221,5 @@ If `knowledge.stage` is set and the root cause reveals a **non-obvious "why"** a
221
221
 
222
222
  - Update `meta.json`: `phase = "investigate"`, add to `phases_done`.
223
223
  - Overwrite `00-summary.md` whole (≤15 lines, flow-core §5).
224
- - Suggest `$flow-bug-fix`.
225
- - **Autonomy handoff** (`autonomy.mode`, flow-core §2): `manual` → propose `$flow-bug-fix` with a single `AskUserQuestion`, invoke it only on confirmation; `guided`/`auto` → chain into it in this same turn.
224
+ - Suggest `$flow-bug-fix` — `git.handoff_branch` set and not `unattended` → `$flow-work-handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff).
225
+ - **Autonomy handoff** (`autonomy.mode`, flow-core §2): `manual` → propose `$flow-bug-fix` with a single `AskUserQuestion`, invoke it only on confirmation; `guided`/`auto` → chain into it in this same turn. Either way: `git.handoff_branch` set and not `unattended` → `$flow-work-handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff).
@@ -228,6 +228,6 @@ Run `tracker.start_cmd` with `{TICKET}` = `meta.json.ticket` and `{ASSIGNEE}` =
228
228
 
229
229
  ## 5. Close
230
230
 
231
- - Suggest the next command by size: `$flow-bug-fix` for XS, `$flow-bug-investigate` for the rest.
231
+ - Suggest the next command by size: `$flow-bug-fix` for XS (`git.handoff_branch` set and not `unattended` → `$flow-work-handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff)), `$flow-bug-investigate` for the rest.
232
232
  - Overwrite `00-summary.md` whole (≤15 lines, flow-core §5).
233
233
  - Apply `autonomy.mode`: `manual` stops and recommends; `guided`/`auto` chain into that command automatically, subject to the hard gates.
@@ -40,7 +40,7 @@ after writing each challenge's Response.
40
40
 
41
41
  - Load `meta.json` by current branch — in `unattended`, the work `$flow-work-run` found (flow-core §2.1). Missing → ask the user to start with `$flow-feat-start`.
42
42
  - Read `meta.json` and `00-summary.md`; open in full only `01-context.md` (ticket, decisions, contracts received). (flow-core §5)
43
- - `size` is `XS` → suggest jumping to `$flow-feat-build` and stop unless the user insists.
43
+ - `size` is `XS` → suggest jumping to `$flow-feat-build` — `git.handoff_branch` set and not `unattended` → `$flow-work-handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff) — and stop unless the user insists.
44
44
 
45
45
  ## 1.5 Approaches — open the option space first (M/L)
46
46
 
@@ -408,6 +408,6 @@ Never invoke `knowledge.save` here — the final save is in `$flow-feat-ship` af
408
408
  - **Confirm the acceptance criteria** within the design review: present the enumerated list. If every criterion is unambiguous and verifiable, the review covers them — no separate prompt. `AskUserQuestion` **only** when a criterion is ambiguous, not verifiable, or one is likely missing for today's ticket (same restraint as the challenger). Apply the user's edits to `03-design.md` before advancing.
409
409
  - **In `manual`/`guided`**, ask the user to review the design; edit the artifact on requested changes before advancing. **In `auto`, do not ask** — record it as accepted per the handoff below. Not an unconditional stop.
410
410
  - Next step by size:
411
- - **XS / S**: suggest `$flow-feat-build` (1 single MR/PR, no planned split).
411
+ - **XS / S**: suggest `$flow-feat-build` (1 single MR/PR, no planned split) — `git.handoff_branch` set and not `unattended` → `$flow-work-handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff).
412
412
  - **M / L**: suggest `$flow-feat-plan` to split the work into independently mergeable MRs/PRs before implementing.
413
- - **Autonomy handoff.** Design review is a genuine decision point: `manual` and `guided` ask for it before advancing. `auto` records the design as accepted in the artifact and **chains into the command for the size** in this same turn. `manual` proposes that command with a single `AskUserQuestion` (recommended option by default), never a written suggestion. Unresolved `high`-severity findings (§6) stop the flow in **every** mode — do not chain over them.
413
+ - **Autonomy handoff.** Design review is a genuine decision point: `manual` and `guided` ask for it before advancing. `auto` records the design as accepted in the artifact and **chains into the command for the size** in this same turn — `build` there: `git.handoff_branch` set and not `unattended` → `$flow-work-handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff). `manual` proposes that command with a single `AskUserQuestion` (recommended option by default), never a written suggestion. Unresolved `high`-severity findings (§6) stop the flow in **every** mode — do not chain over them.
@@ -31,7 +31,7 @@ Delivery planning phase. **No code is written.** Splits the feature into MRs/PRs
31
31
  - Load `meta.json` by current branch — in `unattended`, the work `$flow-work-run` found (flow-core §2.1). Missing → send the user to `$flow-feat-start`.
32
32
  - Require `design` in `phases_done`. Missing → send to `$flow-feat-design` and stop.
33
33
  - Read `meta.json` and `00-summary.md`; open in full only `03-design.md`. (flow-core §5)
34
- - **`size` `XS` or `S`** → warn that this phase does not apply (always 1 MR/PR), add `"plan:skipped"` to `phases_done`, suggest `$flow-feat-build`. Stop.
34
+ - **`size` `XS` or `S`** → warn that this phase does not apply (always 1 MR/PR), add `"plan:skipped"` to `phases_done`, suggest `$flow-feat-build` — `git.handoff_branch` set and not `unattended` → `$flow-work-handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff). Stop.
35
35
 
36
36
  ## 2. Work
37
37
 
@@ -165,5 +165,5 @@ A slice landing in **another repo** is not one of *this* repo's `mrs`: record it
165
165
 
166
166
  `∥` = no dependency between them, can be built in parallel or as a train; `→` = the next wave waits for the previous one to merge. Then the table with `#`, wave, `depends_on`, title and estimate. One line for the split rationale, and — when any pair was merged — one line saying how many were and what they would have cost (`merged #a into #b: would have been a wave of its own`). Nothing else — risks and discarded alternatives live in the artifact.
167
167
  - Changes requested → edit the artifact and `meta.json.mrs` before advancing.
168
- - Suggest `$flow-feat-build` to start the first MR/PR.
169
- - **Autonomy handoff.** Approving the split is a genuine decision point: in `manual` and `guided` ask before advancing. In `auto`, record the plan as accepted in `04-mr-plan.md` and **chain into `$flow-feat-build` automatically** in this same turn. In `manual`, propose it with a single `AskUserQuestion`.
168
+ - Suggest `$flow-feat-build` to start the first MR/PR — `git.handoff_branch` set and not `unattended` → `$flow-work-handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff).
169
+ - **Autonomy handoff.** Approving the split is a genuine decision point: in `manual` and `guided` ask before advancing. In `auto`, record the plan as accepted in `04-mr-plan.md` and **chain into `$flow-feat-build` automatically** in this same turn. In `manual`, propose it with a single `AskUserQuestion`. Either way: `git.handoff_branch` set and not `unattended` → `$flow-work-handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff).
@@ -309,5 +309,5 @@ Run `tracker.start_cmd` with `{TICKET}` = `meta.json.ticket`, `{ASSIGNEE}` = `tr
309
309
  ## 7. Close
310
310
 
311
311
  - Overwrite `00-summary.md` whole (≤15 lines, flow-core §5) — first written in §6; refresh it if §6.5 changed anything.
312
- - Report **following the stop header** (flow-core §3), branch added, body 2-3 lines: ticket, size, branch; recommended next command per the §4 table — in `guided`/`auto` you run it in this same turn, so there is no report and no question here: update the panel and chain (flow-core §3).
312
+ - Report **following the stop header** (flow-core §3), branch added, body 2-3 lines: ticket, size, branch; recommended next command per the §4 table (`build` on XS: `git.handoff_branch` set and not `unattended` → `$flow-work-handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff)) — in `guided`/`auto` you run it in this same turn, so there is no report and no question here: update the panel and chain (flow-core §3).
313
313
  - Apply `autonomy.mode`: `manual` → stop and let the user invoke the recommended command; `guided`/`auto` → chain into it, subject to the hard gates (the §5 branch-base ambiguity already stops on its own).
@@ -249,6 +249,7 @@ Two signals arrive on an open MR/PR, each with its own cross-cutting loop (feat
249
249
  - `$flow-work-daily [question]` — the **work assistant** (daily standup), read-only. **Local** (`.claude/work/` + git) + **forge** (open MRs/PRs, reviews awaiting you, red CI, unmergeable, unresolved threads via `git.cli`) + **tracker** (assigned tickets, priority changes via `tracker.tool`); where they cross, concrete commands (`$flow-feat-start`, `$flow-work-green`, `$flow-work-respond`). No argument → *yesterday · today · blockers*; a question → just that. External sources best-effort, never blocking; the only write is a "last seen" marker, like `$flow-news`.
250
250
  - `$flow-work-status` — all works in `.claude/work/`, current phase, divergence with git.
251
251
  - `$flow-work-run [ticket]` — the **entry an orchestrator launches** for an `unattended` run: asks it `why` (start · answer · merged · review · pipeline), routes to the phase that answers it, and makes no decision of its own. Refuses to run in any other mode.
252
+ - `$flow-work-handoff` — hands a **finished study** to whoever builds it elsewhere (an unattended server, another machine): refuses an unfinished one, pushes only this work's folder as a parentless commit to `git.handoff_branch` without touching the checkout, asks before the push, then offers a marked summary for the ticket body (`tracker.edit_cmd`).
252
253
  - `$flow-work-resume` — detects the branch, reads `meta.json`, recaps, suggests the next step. **Re-reads the ticket's comment thread** (§2.5), reports only what is new since `01-context.md`, appends it to the artifact; never amends the design on its own.
253
254
  - `$flow-work-try <branch>` / `$flow-work-try --back` — point the main checkout at a branch to test it here, then return; re-syncs per `git.worktree_resync`. Resolves the work behind the branch and, once the environment is up, **prints the manual test plan already written** (the `needs-manual`/`unproven` criteria, or the acceptance criteria when `validate` has not run) and offers to collect Pass/Fail/Blocked into the validation artifact. No work behind the branch → the plain switch, as before.
254
255
  - `$flow-work-clean [--dry-run]` — **periodic sweep** of finished work's residue: worktree, local branch, `.claude/work/` folder (intermediate train MR/PRs never set `phase: done`, so the `ship`/`abandon` prompt never fires). Verdict per branch from **the forge** with local fallbacks, including patch-equivalence for **squash merges** (`git branch --merged` misses them); acts only on `merged`/`empty`. `unknown` never a candidate; dirty and unpushed protected; work folders **archived, never deleted**; remote never touched. **`autonomy.mode` does not authorize deletion**: `auto` confirms the list too. `--purge-archive <N>d`: separate opt-in pass over `_archive/`, only folders already committed to git.
@@ -0,0 +1,162 @@
1
+ ---
2
+ name: flow-work-handoff
3
+ description: "Hand a finished study to whoever builds it elsewhere — push only this work's folder to a branch of its own, then offer a summary for the ticket"
4
+ ---
5
+
6
+ <!-- GENERATED by script/adapter-build.py from plugins/flow/commands/work/handoff.md — do not edit; change the plugin file and run the script. -->
7
+
8
+ # `$flow-work-handoff`
9
+
10
+ > **codex adapter — how the Claude Code primitives named below map here.**
11
+ > - `AskUserQuestion` → ask in plain text with numbered options and wait for the reply.
12
+ > - `Agent <role>` / `Agent general-purpose` / subagents → the subagent declared under `[agents.<name>]` in `~/.codex/config.toml`; the name comes from `agents.<role>` in `FLOW.md`, empty → do it in this context.
13
+ > - Parallel fan-out → several subagents in one response, capped at `agents.fanout_max` (empty → 4); `agents.fanout_tool` is Claude Code-only, ignore it.
14
+ > - `ScheduleWakeup` / `Monitor` / `/loop` → not available in-session: run one cycle, persist state in `monitor.md`, let the user schedule `codex exec "<command>"` with cron or Codex automations.
15
+ > - `TaskCreate` → a markdown checklist in the phase artifact.
16
+ > - `Skill commit-commands:commit-push-pr` → `git add` · `git commit` · `git push -u origin HEAD` · the `git.cli` CLI (`gh pr create` / `glab mr create`).
17
+ > - `/model <value>` → the `--model` flag at launch (or `/model` if your Codex version has it).
18
+ > - `knowledge.*` roles → whatever tools `FLOW.md` names there; an MCP tool keeps its name, its server is declared under `[mcp_servers.<name>]` in `config.toml` (see `config.snippet.toml`).
19
+ > - `$ARGUMENTS` → whatever the user typed after the skill name, empty if nothing — Codex substitutes nothing, so read it off their message.
20
+
21
+ Read `~/.claude/flow/CORE.codex.md` first (shared rules: `FLOW.md` step 0, autonomy, how a stop reads, the live panel, `00-summary.md`) — skip if you already read it in this session.
22
+
23
+ **Panel words are closed** — `mark`: `done` · `current` · `pending` · `wait` · `block` · `info`; `style`: `normal` · `dim` · `title` · `accent` · `ok` · `warn` · `error`. Anything else is dropped by the reader in silence: the panel still paints, and nobody is told.
24
+
25
+ For a study made here and built somewhere else — a server running `$flow-work-run` unattended,
26
+ another person, another machine. The builder gets the work folder at the same path and nothing
27
+ else: no conversation, maybe a less capable model. So this command checks the study can stand on
28
+ its own, pushes the folder to a branch that holds only it, and offers to put a summary in the
29
+ ticket for the people who review it.
30
+
31
+ ## 1. Pre-flight
32
+
33
+ - Effective FLOW configuration per flow-core §0. `autonomy.mode: unattended` → refuse in one line:
34
+ an unattended run never pushes (flow-core §2.1); handing off is a person's step.
35
+ - Locate the active `meta.json` by current branch; not found → ask the user for the ticket.
36
+ - `git.handoff_branch` empty → refuse, naming the key and an example
37
+ (`git.handoff_branch: study/{TICKET}`): where the study goes is the receiver's convention, never
38
+ flow's guess. `{TICKET}` = `meta.json.ticket`.
39
+ - `origin` not configured → refuse; there is nowhere to push.
40
+
41
+ ## 2. Is the study finished?
42
+
43
+ The builder can ask no one. Refuse — pushing nothing, naming every reason that holds — when:
44
+
45
+ - **The study's last phase is not in `phases_done`.** A feature: `context` on XS (what `start`
46
+ records), `design` on S, `plan` on M/L. A bug: `context` on XS, `investigate` otherwise.
47
+ - **`meta.json.pending` is set** — a question is still waiting for its answer.
48
+ - **A clarification is still open** — a question under "Decisions clarified at start" in
49
+ `01-context.md` recorded without its answer.
50
+
51
+ Any refusal names the way on: finish what is missing, or **build here** (`$flow-feat-build` /
52
+ `$flow-bug-fix`) — a run that chained here (flow-core §2, a study made for handoff) must not end on
53
+ a dead end.
54
+
55
+ Then, **before anything is pushed**: decisions this session settled while talking that no artifact
56
+ records yet → write them where they belong now (`01-context.md` "Decisions clarified at start",
57
+ `03-design.md` "Decisions (ADR-light)", `04-mr-plan.md`), and say which. What was decided only in
58
+ the chat does not travel.
59
+
60
+ ## 3. Build the commit, without touching the checkout
61
+
62
+ A throwaway index holds only this folder, so the current branch, `HEAD`, the real index (staged
63
+ work included) and the working tree are never read into it nor written to, and a git-ignored
64
+ `.claude/work/` is no obstacle.
65
+
66
+ **Each block below is one shell call, run as it stands** — a harness need not keep variables from
67
+ one call to the next, so every block sets its own. Replace each `@…@` with its literal value first:
68
+ `@WORK@` the work folder relative to the repository root (`.claude/work/<work-dir>`, no trailing
69
+ slash), `@BRANCH@` the resolved `git.handoff_branch`, `@TICKET@` `meta.json.ticket`, `@COMMIT@` the
70
+ sha the build block printed. A value holding a `'` cannot go inside those quotes: refuse it and
71
+ say which.
72
+
73
+ First, the branch must not exist on `origin` — a second push would need a force, and this command
74
+ never forces:
75
+
76
+ ```bash handoff-check
77
+ BRANCH='@BRANCH@'
78
+ git ls-remote --exit-code origin "refs/heads/$BRANCH" >/dev/null; echo "rc=$?"
79
+ ```
80
+
81
+ `rc=0` → the branch exists: refuse, and say what the person does next — delete it on the forge
82
+ (only when nothing still reads it), or set another name in `git.handoff_branch`. `rc=2` → absent,
83
+ continue. Anything else → stop and say why (no network, no access). Then build the commit:
84
+
85
+ ```bash handoff-build
86
+ WORK='@WORK@'; TICKET='@TICKET@'
87
+ cd "$(git rev-parse --show-toplevel)" || exit 1
88
+ [ -d "$WORK" ] || { echo "no such folder: $WORK"; exit 1; }
89
+ tmp=$(mktemp -d) || exit 1
90
+ idx="$tmp/index" # does not exist yet: git starts an empty index there
91
+ GIT_INDEX_FILE="$idx" git add -f -- "$WORK" ":(exclude)$WORK/panel.json" &&
92
+ files=$(GIT_INDEX_FILE="$idx" git ls-files) &&
93
+ tree=$(GIT_INDEX_FILE="$idx" git write-tree) &&
94
+ commit=$(git commit-tree "$tree" -m "study $TICKET")
95
+ rc=$?; rm -rf "$tmp"
96
+ [ "$rc" -eq 0 ] && [ -n "$files" ] || { echo "nothing was built (rc=$rc)"; exit 1; }
97
+ printf '%s\n' "$files"; echo "commit=$commit"
98
+ ```
99
+
100
+ `GIT_INDEX_FILE` is set per command, never exported, so a failure leaves no session pointing git
101
+ at a deleted index. `panel.json` stays out: it is this machine's terminal panel, and on another one
102
+ it would show this session's last state as if it were theirs. The block failing → its message, and
103
+ stop: `commit-tree` with no git identity configured is the usual cause.
104
+
105
+ ## 4. Confirm, then push
106
+
107
+ Show the branch, the remote and the file list the build printed — every path, one per line — then
108
+ ask with `AskUserQuestion` **in every `autonomy.mode`**: a push leaves the machine (flow-core §2).
109
+ **Push** · **Cancel**. Nothing between the list and the question (flow-core §3).
110
+
111
+ ```bash handoff-push
112
+ BRANCH='@BRANCH@'; COMMIT='@COMMIT@'
113
+ case "$COMMIT" in ''|*[!0-9a-f]*) echo "not a commit sha: $COMMIT"; exit 1 ;; esac
114
+ git cat-file -e "$COMMIT^{commit}" || exit 1
115
+ git push origin "$COMMIT:refs/heads/$BRANCH"
116
+ ```
117
+
118
+ The sha is checked first because `git push origin :refs/heads/<branch>` — an empty source —
119
+ deletes the branch on the remote. A rejected push → its message, verbatim, and stop. Never retried
120
+ with `--force`.
121
+
122
+ ## 5. The ticket summary (offer)
123
+
124
+ Only after a successful push, and only in ticket mode with a real tracker id. The people reviewing
125
+ the ticket read it there, never in the work folder; the receiver does not parse it.
126
+
127
+ - **Read the body back** — the summary goes inside the ticket's own text, never over it:
128
+ `gh` → `gh issue view {TICKET} --json body -q .body` · `glab` → `glab issue view {TICKET} -F json`,
129
+ its `description`. Any other tracker → the offer is not made: one line saying flow cannot read that
130
+ body back to keep its text.
131
+ - **The write command** — `tracker.edit_cmd`, `{TICKET}` and `{BODY_FILE}` substituted. Empty →
132
+ `gh issue edit {TICKET} --body-file {BODY_FILE}` for `gh`,
133
+ `glab issue update {TICKET} --description-file {BODY_FILE}` for `glab`.
134
+ - **The block**, short, in the language of the ticket. A feature takes it from `01-context.md`,
135
+ `03-design.md` and `04-mr-plan.md`; a bug from `01-context.md` and `03-investigation.md` — the
136
+ expected behaviour as its criteria, the root cause and the intended fix as its design, "Areas with
137
+ similar risk" as its risks. A section whose source does not exist (an XS study, an S feature with
138
+ no plan) says `none`:
139
+
140
+ ```
141
+ <!-- flow-study -->
142
+ ## What and why
143
+ ## Acceptance criteria
144
+ ## Design in brief
145
+ ## MR/PR plan
146
+ ## Risks
147
+ <!-- end flow-study -->
148
+ ```
149
+
150
+ Criteria keep their literal values. The plan lists each MR/PR with what it covers and what it
151
+ waits on; a bug's plan is its single fix.
152
+ - **The new body**: the body read above with the block between the two markers replaced — or, with
153
+ no markers yet, the block appended after a blank line. Written to a `mktemp` file outside the
154
+ tree — `{BODY_FILE}` — so nothing of it can be committed later.
155
+ - **Show the block and ask** with `AskUserQuestion`, **in every mode**: it writes to a shared
156
+ tracker. **Write it** · **Skip**. Failure → its message in one line; the push stands.
157
+
158
+ ## 6. Close
159
+
160
+ Report following flow-core §3: the branch and the commit, the file count, whether the ticket
161
+ summary was written. Refresh the panel: a `Now` line saying the study was handed off, no `Decision`
162
+ line. `meta.json` gains nothing — the branch on `origin` is the record, and the §3 refusal reads it.
@@ -92,7 +92,7 @@ With what is new (there is already work on disk):
92
92
  ## 4. Next step
93
93
 
94
94
  - An `Unattended:` line → the question is the orchestrator's to bring back: say so, and that answering it here instead means clearing `meta.json.pending` and continuing in this session's mode; the next step itself comes from `phase` as always.
95
- - Suggest the concrete command from `phase` and `size`. Interrupted phase (e.g. `build` with an empty artifact) → suggest rerunning it with `$flow-feat-build` or `$flow-bug-fix`.
95
+ - Suggest the concrete command from `phase` and `size` — a study whose next step is `build` or `fix`: `git.handoff_branch` set and not `unattended` → `$flow-work-handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff). Interrupted phase (e.g. `build` with an empty artifact) → suggest rerunning it with `$flow-feat-build` or `$flow-bug-fix`.
96
96
  - §2.5 found something new → let it inform the suggestion (a contract that arrived after you left may mean rerunning `design` rather than continuing `build`); say why in one line.
97
97
  - `meta.json.related_repos` entries not `done` → remind that a **sibling repo still has a pending part** (`<repo>: <scope>`, plus `contract not handed over` when its `contract_handoff` is `pending`); suggest `$flow-feat-start <TICKET>` there. flow only reminds; it never scans or touches the other repo.
98
98
  - Do not advance on your own. The user decides.
@@ -16,7 +16,7 @@ Every `/flow:*` command assumes these rules. They are stated once, here, so a co
16
16
  carries what is specific to its phase. Read this once per session; a command that says "load
17
17
  `flow-core`" means this file.
18
18
 
19
- **This file belongs to flow `0.86.0`.** Compare it once, at the start of the session, against
19
+ **This file belongs to flow `0.88.0`.** Compare it once, at the start of the session, against
20
20
  `version` in `~/.claude/flow/.claude-plugin/plugin.json`. The two differing means the session
21
21
  is running a **mixture** — the commands from one copy of the plugin, these shared rules from another
22
22
  — which is exactly what happens when a branch or a release candidate is loaded over an installed
@@ -217,6 +217,16 @@ sensible default and record it.
217
217
 
218
218
  Asking these anyway is how a run in `guided`/`auto` degrades into a manual one.
219
219
 
220
+ **A study made for handoff.** `git.handoff_branch` set and the mode not `unattended` → the study is
221
+ built somewhere else, so wherever a study phase (`start`, `design`, `plan`, `investigate`) or
222
+ `resume` would hand the work to `/flow:feat:build` or `/flow:bug:fix`, it hands it to
223
+ `/flow:work:handoff` instead. Only the target changes: a Close that asks (`manual`) offers **Hand
224
+ off the study** recommended and **Build here** second; a Close that chains (`guided`/`auto`) chains
225
+ into handoff, whose push question is the one confirmation — no stop is added. In `unattended` the
226
+ rule does not apply: the repo's `FLOW.md` reaches the server too, and a run that studies a ticket
227
+ there goes on to build it. A repo that hands its studies off pairs the key with
228
+ `autonomy.mode: auto`, and the study then runs on its own up to the push.
229
+
220
230
  ### 2.1 `unattended` — where a person would have been asked
221
231
 
222
232
  No person is there to answer a question in this mode. A question tool — `AskUserQuestion`, OpenCode's `question`,
@@ -32,7 +32,7 @@ Read `~/.claude/flow/CORE.gemini.md` first (shared rules: `FLOW.md` step 0, mode
32
32
  **In `unattended`, before this phase's first step, read flow-core §2.1 whole — from its heading to the next section, unless it is already in your context whole; having read parts of it does not count** — the orchestrator command, the question stop and the way its answer comes back are all in it, and a phase that reads only part of it skips them.
33
33
 
34
34
  - Read `meta.json` and `00-summary.md`; open in full only `01-context.md`. (flow-core §5)
35
- - `type` is not `bug` → refuse. `size` is `XS` → suggest `/flow:bug:fix` and stop.
35
+ - `type` is not `bug` → refuse. `size` is `XS` → suggest `/flow:bug:fix` — `git.handoff_branch` set and not `unattended` → `/flow:work:handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff) — and stop.
36
36
  - Require `context` in `phases_done`.
37
37
 
38
38
  ## 1.5 Reproduce — what is failing, before why
@@ -217,6 +217,6 @@ If `knowledge.stage` is set and the root cause reveals a **non-obvious "why"** a
217
217
 
218
218
  - Update `meta.json`: `phase = "investigate"`, add to `phases_done`.
219
219
  - Overwrite `00-summary.md` whole (≤15 lines, flow-core §5).
220
- - Suggest `/flow:bug:fix`.
221
- - **Autonomy handoff** (`autonomy.mode`, flow-core §2): `manual` → propose `/flow:bug:fix` with a single `AskUserQuestion`, invoke it only on confirmation; `guided`/`auto` → chain into it in this same turn.
220
+ - Suggest `/flow:bug:fix` — `git.handoff_branch` set and not `unattended` → `/flow:work:handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff).
221
+ - **Autonomy handoff** (`autonomy.mode`, flow-core §2): `manual` → propose `/flow:bug:fix` with a single `AskUserQuestion`, invoke it only on confirmation; `guided`/`auto` → chain into it in this same turn. Either way: `git.handoff_branch` set and not `unattended` → `/flow:work:handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff).
222
222
  """
@@ -224,7 +224,7 @@ Run `tracker.start_cmd` with `{TICKET}` = `meta.json.ticket` and `{ASSIGNEE}` =
224
224
 
225
225
  ## 5. Close
226
226
 
227
- - Suggest the next command by size: `/flow:bug:fix` for XS, `/flow:bug:investigate` for the rest.
227
+ - Suggest the next command by size: `/flow:bug:fix` for XS (`git.handoff_branch` set and not `unattended` → `/flow:work:handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff)), `/flow:bug:investigate` for the rest.
228
228
  - Overwrite `00-summary.md` whole (≤15 lines, flow-core §5).
229
229
  - Apply `autonomy.mode`: `manual` stops and recommends; `guided`/`auto` chain into that command automatically, subject to the hard gates.
230
230
  """
@@ -36,7 +36,7 @@ after writing each challenge's Response.
36
36
 
37
37
  - Load `meta.json` by current branch — in `unattended`, the work `/flow:work:run` found (flow-core §2.1). Missing → ask the user to start with `/flow:feat:start`.
38
38
  - Read `meta.json` and `00-summary.md`; open in full only `01-context.md` (ticket, decisions, contracts received). (flow-core §5)
39
- - `size` is `XS` → suggest jumping to `/flow:feat:build` and stop unless the user insists.
39
+ - `size` is `XS` → suggest jumping to `/flow:feat:build` — `git.handoff_branch` set and not `unattended` → `/flow:work:handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff) — and stop unless the user insists.
40
40
 
41
41
  ## 1.5 Approaches — open the option space first (M/L)
42
42
 
@@ -404,7 +404,7 @@ Never invoke `knowledge.save` here — the final save is in `/flow:feat:ship` af
404
404
  - **Confirm the acceptance criteria** within the design review: present the enumerated list. If every criterion is unambiguous and verifiable, the review covers them — no separate prompt. `AskUserQuestion` **only** when a criterion is ambiguous, not verifiable, or one is likely missing for today's ticket (same restraint as the challenger). Apply the user's edits to `03-design.md` before advancing.
405
405
  - **In `manual`/`guided`**, ask the user to review the design; edit the artifact on requested changes before advancing. **In `auto`, do not ask** — record it as accepted per the handoff below. Not an unconditional stop.
406
406
  - Next step by size:
407
- - **XS / S**: suggest `/flow:feat:build` (1 single MR/PR, no planned split).
407
+ - **XS / S**: suggest `/flow:feat:build` (1 single MR/PR, no planned split) — `git.handoff_branch` set and not `unattended` → `/flow:work:handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff).
408
408
  - **M / L**: suggest `/flow:feat:plan` to split the work into independently mergeable MRs/PRs before implementing.
409
- - **Autonomy handoff.** Design review is a genuine decision point: `manual` and `guided` ask for it before advancing. `auto` records the design as accepted in the artifact and **chains into the command for the size** in this same turn. `manual` proposes that command with a single `AskUserQuestion` (recommended option by default), never a written suggestion. Unresolved `high`-severity findings (§6) stop the flow in **every** mode — do not chain over them.
409
+ - **Autonomy handoff.** Design review is a genuine decision point: `manual` and `guided` ask for it before advancing. `auto` records the design as accepted in the artifact and **chains into the command for the size** in this same turn — `build` there: `git.handoff_branch` set and not `unattended` → `/flow:work:handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff). `manual` proposes that command with a single `AskUserQuestion` (recommended option by default), never a written suggestion. Unresolved `high`-severity findings (§6) stop the flow in **every** mode — do not chain over them.
410
410
  """
@@ -27,7 +27,7 @@ Delivery planning phase. **No code is written.** Splits the feature into MRs/PRs
27
27
  - Load `meta.json` by current branch — in `unattended`, the work `/flow:work:run` found (flow-core §2.1). Missing → send the user to `/flow:feat:start`.
28
28
  - Require `design` in `phases_done`. Missing → send to `/flow:feat:design` and stop.
29
29
  - Read `meta.json` and `00-summary.md`; open in full only `03-design.md`. (flow-core §5)
30
- - **`size` `XS` or `S`** → warn that this phase does not apply (always 1 MR/PR), add `"plan:skipped"` to `phases_done`, suggest `/flow:feat:build`. Stop.
30
+ - **`size` `XS` or `S`** → warn that this phase does not apply (always 1 MR/PR), add `"plan:skipped"` to `phases_done`, suggest `/flow:feat:build` — `git.handoff_branch` set and not `unattended` → `/flow:work:handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff). Stop.
31
31
 
32
32
  ## 2. Work
33
33
 
@@ -161,6 +161,6 @@ A slice landing in **another repo** is not one of *this* repo's `mrs`: record it
161
161
 
162
162
  `∥` = no dependency between them, can be built in parallel or as a train; `→` = the next wave waits for the previous one to merge. Then the table with `#`, wave, `depends_on`, title and estimate. One line for the split rationale, and — when any pair was merged — one line saying how many were and what they would have cost (`merged #a into #b: would have been a wave of its own`). Nothing else — risks and discarded alternatives live in the artifact.
163
163
  - Changes requested → edit the artifact and `meta.json.mrs` before advancing.
164
- - Suggest `/flow:feat:build` to start the first MR/PR.
165
- - **Autonomy handoff.** Approving the split is a genuine decision point: in `manual` and `guided` ask before advancing. In `auto`, record the plan as accepted in `04-mr-plan.md` and **chain into `/flow:feat:build` automatically** in this same turn. In `manual`, propose it with a single `AskUserQuestion`.
164
+ - Suggest `/flow:feat:build` to start the first MR/PR — `git.handoff_branch` set and not `unattended` → `/flow:work:handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff).
165
+ - **Autonomy handoff.** Approving the split is a genuine decision point: in `manual` and `guided` ask before advancing. In `auto`, record the plan as accepted in `04-mr-plan.md` and **chain into `/flow:feat:build` automatically** in this same turn. In `manual`, propose it with a single `AskUserQuestion`. Either way: `git.handoff_branch` set and not `unattended` → `/flow:work:handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff).
166
166
  """
@@ -305,6 +305,6 @@ Run `tracker.start_cmd` with `{TICKET}` = `meta.json.ticket`, `{ASSIGNEE}` = `tr
305
305
  ## 7. Close
306
306
 
307
307
  - Overwrite `00-summary.md` whole (≤15 lines, flow-core §5) — first written in §6; refresh it if §6.5 changed anything.
308
- - Report **following the stop header** (flow-core §3), branch added, body 2-3 lines: ticket, size, branch; recommended next command per the §4 table — in `guided`/`auto` you run it in this same turn, so there is no report and no question here: update the panel and chain (flow-core §3).
308
+ - Report **following the stop header** (flow-core §3), branch added, body 2-3 lines: ticket, size, branch; recommended next command per the §4 table (`build` on XS: `git.handoff_branch` set and not `unattended` → `/flow:work:handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff)) — in `guided`/`auto` you run it in this same turn, so there is no report and no question here: update the panel and chain (flow-core §3).
309
309
  - Apply `autonomy.mode`: `manual` → stop and let the user invoke the recommended command; `guided`/`auto` → chain into it, subject to the hard gates (the §5 branch-base ambiguity already stops on its own).
310
310
  """
@@ -245,6 +245,7 @@ Two signals arrive on an open MR/PR, each with its own cross-cutting loop (feat
245
245
  - `/flow:work:daily [question]` — the **work assistant** (daily standup), read-only. **Local** (`.claude/work/` + git) + **forge** (open MRs/PRs, reviews awaiting you, red CI, unmergeable, unresolved threads via `git.cli`) + **tracker** (assigned tickets, priority changes via `tracker.tool`); where they cross, concrete commands (`/flow:feat:start`, `/flow:work:green`, `/flow:work:respond`). No argument → *yesterday · today · blockers*; a question → just that. External sources best-effort, never blocking; the only write is a "last seen" marker, like `/flow:news`.
246
246
  - `/flow:work:status` — all works in `.claude/work/`, current phase, divergence with git.
247
247
  - `/flow:work:run [ticket]` — the **entry an orchestrator launches** for an `unattended` run: asks it `why` (start · answer · merged · review · pipeline), routes to the phase that answers it, and makes no decision of its own. Refuses to run in any other mode.
248
+ - `/flow:work:handoff` — hands a **finished study** to whoever builds it elsewhere (an unattended server, another machine): refuses an unfinished one, pushes only this work's folder as a parentless commit to `git.handoff_branch` without touching the checkout, asks before the push, then offers a marked summary for the ticket body (`tracker.edit_cmd`).
248
249
  - `/flow:work:resume` — detects the branch, reads `meta.json`, recaps, suggests the next step. **Re-reads the ticket's comment thread** (§2.5), reports only what is new since `01-context.md`, appends it to the artifact; never amends the design on its own.
249
250
  - `/flow:work:try <branch>` / `/flow:work:try --back` — point the main checkout at a branch to test it here, then return; re-syncs per `git.worktree_resync`. Resolves the work behind the branch and, once the environment is up, **prints the manual test plan already written** (the `needs-manual`/`unproven` criteria, or the acceptance criteria when `validate` has not run) and offers to collect Pass/Fail/Blocked into the validation artifact. No work behind the branch → the plain switch, as before.
250
251
  - `/flow:work:clean [--dry-run]` — **periodic sweep** of finished work's residue: worktree, local branch, `.claude/work/` folder (intermediate train MR/PRs never set `phase: done`, so the `ship`/`abandon` prompt never fires). Verdict per branch from **the forge** with local fallbacks, including patch-equivalence for **squash merges** (`git branch --merged` misses them); acts only on `merged`/`empty`. `unknown` never a candidate; dirty and unpushed protected; work folders **archived, never deleted**; remote never touched. **`autonomy.mode` does not authorize deletion**: `auto` confirms the list too. `--purge-archive <N>d`: separate opt-in pass over `_archive/`, only folders already committed to git.
@@ -0,0 +1,159 @@
1
+ # GENERATED by script/adapter-build.py from plugins/flow/commands/work/handoff.md — do not edit; change the plugin file and run the script.
2
+ description = "Hand a finished study to whoever builds it elsewhere — push only this work's folder to a branch of its own, then offer a summary for the ticket"
3
+
4
+ prompt = """
5
+ # `/flow:work:handoff`
6
+
7
+ > **gemini adapter — how the Claude Code primitives named below map here.**
8
+ > - `AskUserQuestion` → ask in plain text with numbered options and wait for the reply.
9
+ > - `Agent <role>` / `Agent general-purpose` / subagents → `@<name>` from `.gemini/agents/`; the name comes from `agents.<role>` in `FLOW.md`, empty or absent → do it in this context.
10
+ > - Parallel fan-out → several `@name` in one turn (sequential in this context if none are configured), capped at `agents.fanout_max` (empty → 4); `agents.fanout_tool` is Claude Code-only, ignore it.
11
+ > - `ScheduleWakeup` / `Monitor` / `/loop` → not available in-session: run one cycle, persist state in `monitor.md`, let the user schedule `gemini -p "<command>"` with cron.
12
+ > - `TaskCreate` → a markdown checklist in the phase artifact.
13
+ > - `Skill commit-commands:commit-push-pr` → `git add` · `git commit` · `git push -u origin HEAD` · the `git.cli` CLI (`gh pr create` / `glab mr create`).
14
+ > - `/model <value>` → the `--model` flag at launch.
15
+ > - `knowledge.*` roles → whatever tools `FLOW.md` names there; an MCP tool keeps its name, its server is declared under `mcpServers` in `settings.json` (see `settings.snippet.json`).
16
+
17
+ Read `~/.claude/flow/CORE.gemini.md` first (shared rules: `FLOW.md` step 0, autonomy, how a stop reads, the live panel, `00-summary.md`) — skip if you already read it in this session.
18
+
19
+ **Panel words are closed** — `mark`: `done` · `current` · `pending` · `wait` · `block` · `info`; `style`: `normal` · `dim` · `title` · `accent` · `ok` · `warn` · `error`. Anything else is dropped by the reader in silence: the panel still paints, and nobody is told.
20
+
21
+ For a study made here and built somewhere else — a server running `/flow:work:run` unattended,
22
+ another person, another machine. The builder gets the work folder at the same path and nothing
23
+ else: no conversation, maybe a less capable model. So this command checks the study can stand on
24
+ its own, pushes the folder to a branch that holds only it, and offers to put a summary in the
25
+ ticket for the people who review it.
26
+
27
+ ## 1. Pre-flight
28
+
29
+ - Effective FLOW configuration per flow-core §0. `autonomy.mode: unattended` → refuse in one line:
30
+ an unattended run never pushes (flow-core §2.1); handing off is a person's step.
31
+ - Locate the active `meta.json` by current branch; not found → ask the user for the ticket.
32
+ - `git.handoff_branch` empty → refuse, naming the key and an example
33
+ (`git.handoff_branch: study/{TICKET}`): where the study goes is the receiver's convention, never
34
+ flow's guess. `{TICKET}` = `meta.json.ticket`.
35
+ - `origin` not configured → refuse; there is nowhere to push.
36
+
37
+ ## 2. Is the study finished?
38
+
39
+ The builder can ask no one. Refuse — pushing nothing, naming every reason that holds — when:
40
+
41
+ - **The study's last phase is not in `phases_done`.** A feature: `context` on XS (what `start`
42
+ records), `design` on S, `plan` on M/L. A bug: `context` on XS, `investigate` otherwise.
43
+ - **`meta.json.pending` is set** — a question is still waiting for its answer.
44
+ - **A clarification is still open** — a question under "Decisions clarified at start" in
45
+ `01-context.md` recorded without its answer.
46
+
47
+ Any refusal names the way on: finish what is missing, or **build here** (`/flow:feat:build` /
48
+ `/flow:bug:fix`) — a run that chained here (flow-core §2, a study made for handoff) must not end on
49
+ a dead end.
50
+
51
+ Then, **before anything is pushed**: decisions this session settled while talking that no artifact
52
+ records yet → write them where they belong now (`01-context.md` "Decisions clarified at start",
53
+ `03-design.md` "Decisions (ADR-light)", `04-mr-plan.md`), and say which. What was decided only in
54
+ the chat does not travel.
55
+
56
+ ## 3. Build the commit, without touching the checkout
57
+
58
+ A throwaway index holds only this folder, so the current branch, `HEAD`, the real index (staged
59
+ work included) and the working tree are never read into it nor written to, and a git-ignored
60
+ `.claude/work/` is no obstacle.
61
+
62
+ **Each block below is one shell call, run as it stands** — a harness need not keep variables from
63
+ one call to the next, so every block sets its own. Replace each `@…@` with its literal value first:
64
+ `@WORK@` the work folder relative to the repository root (`.claude/work/<work-dir>`, no trailing
65
+ slash), `@BRANCH@` the resolved `git.handoff_branch`, `@TICKET@` `meta.json.ticket`, `@COMMIT@` the
66
+ sha the build block printed. A value holding a `'` cannot go inside those quotes: refuse it and
67
+ say which.
68
+
69
+ First, the branch must not exist on `origin` — a second push would need a force, and this command
70
+ never forces:
71
+
72
+ ```bash handoff-check
73
+ BRANCH='@BRANCH@'
74
+ git ls-remote --exit-code origin "refs/heads/$BRANCH" >/dev/null; echo "rc=$?"
75
+ ```
76
+
77
+ `rc=0` → the branch exists: refuse, and say what the person does next — delete it on the forge
78
+ (only when nothing still reads it), or set another name in `git.handoff_branch`. `rc=2` → absent,
79
+ continue. Anything else → stop and say why (no network, no access). Then build the commit:
80
+
81
+ ```bash handoff-build
82
+ WORK='@WORK@'; TICKET='@TICKET@'
83
+ cd "$(git rev-parse --show-toplevel)" || exit 1
84
+ [ -d "$WORK" ] || { echo "no such folder: $WORK"; exit 1; }
85
+ tmp=$(mktemp -d) || exit 1
86
+ idx="$tmp/index" # does not exist yet: git starts an empty index there
87
+ GIT_INDEX_FILE="$idx" git add -f -- "$WORK" ":(exclude)$WORK/panel.json" &&
88
+ files=$(GIT_INDEX_FILE="$idx" git ls-files) &&
89
+ tree=$(GIT_INDEX_FILE="$idx" git write-tree) &&
90
+ commit=$(git commit-tree "$tree" -m "study $TICKET")
91
+ rc=$?; rm -rf "$tmp"
92
+ [ "$rc" -eq 0 ] && [ -n "$files" ] || { echo "nothing was built (rc=$rc)"; exit 1; }
93
+ printf '%s\\n' "$files"; echo "commit=$commit"
94
+ ```
95
+
96
+ `GIT_INDEX_FILE` is set per command, never exported, so a failure leaves no session pointing git
97
+ at a deleted index. `panel.json` stays out: it is this machine's terminal panel, and on another one
98
+ it would show this session's last state as if it were theirs. The block failing → its message, and
99
+ stop: `commit-tree` with no git identity configured is the usual cause.
100
+
101
+ ## 4. Confirm, then push
102
+
103
+ Show the branch, the remote and the file list the build printed — every path, one per line — then
104
+ ask with `AskUserQuestion` **in every `autonomy.mode`**: a push leaves the machine (flow-core §2).
105
+ **Push** · **Cancel**. Nothing between the list and the question (flow-core §3).
106
+
107
+ ```bash handoff-push
108
+ BRANCH='@BRANCH@'; COMMIT='@COMMIT@'
109
+ case "$COMMIT" in ''|*[!0-9a-f]*) echo "not a commit sha: $COMMIT"; exit 1 ;; esac
110
+ git cat-file -e "$COMMIT^{commit}" || exit 1
111
+ git push origin "$COMMIT:refs/heads/$BRANCH"
112
+ ```
113
+
114
+ The sha is checked first because `git push origin :refs/heads/<branch>` — an empty source —
115
+ deletes the branch on the remote. A rejected push → its message, verbatim, and stop. Never retried
116
+ with `--force`.
117
+
118
+ ## 5. The ticket summary (offer)
119
+
120
+ Only after a successful push, and only in ticket mode with a real tracker id. The people reviewing
121
+ the ticket read it there, never in the work folder; the receiver does not parse it.
122
+
123
+ - **Read the body back** — the summary goes inside the ticket's own text, never over it:
124
+ `gh` → `gh issue view {TICKET} --json body -q .body` · `glab` → `glab issue view {TICKET} -F json`,
125
+ its `description`. Any other tracker → the offer is not made: one line saying flow cannot read that
126
+ body back to keep its text.
127
+ - **The write command** — `tracker.edit_cmd`, `{TICKET}` and `{BODY_FILE}` substituted. Empty →
128
+ `gh issue edit {TICKET} --body-file {BODY_FILE}` for `gh`,
129
+ `glab issue update {TICKET} --description-file {BODY_FILE}` for `glab`.
130
+ - **The block**, short, in the language of the ticket. A feature takes it from `01-context.md`,
131
+ `03-design.md` and `04-mr-plan.md`; a bug from `01-context.md` and `03-investigation.md` — the
132
+ expected behaviour as its criteria, the root cause and the intended fix as its design, "Areas with
133
+ similar risk" as its risks. A section whose source does not exist (an XS study, an S feature with
134
+ no plan) says `none`:
135
+
136
+ ```
137
+ <!-- flow-study -->
138
+ ## What and why
139
+ ## Acceptance criteria
140
+ ## Design in brief
141
+ ## MR/PR plan
142
+ ## Risks
143
+ <!-- end flow-study -->
144
+ ```
145
+
146
+ Criteria keep their literal values. The plan lists each MR/PR with what it covers and what it
147
+ waits on; a bug's plan is its single fix.
148
+ - **The new body**: the body read above with the block between the two markers replaced — or, with
149
+ no markers yet, the block appended after a blank line. Written to a `mktemp` file outside the
150
+ tree — `{BODY_FILE}` — so nothing of it can be committed later.
151
+ - **Show the block and ask** with `AskUserQuestion`, **in every mode**: it writes to a shared
152
+ tracker. **Write it** · **Skip**. Failure → its message in one line; the push stands.
153
+
154
+ ## 6. Close
155
+
156
+ Report following flow-core §3: the branch and the commit, the file count, whether the ticket
157
+ summary was written. Refresh the panel: a `Now` line saying the study was handed off, no `Decision`
158
+ line. `meta.json` gains nothing — the branch on `origin` is the record, and the §3 refusal reads it.
159
+ """
@@ -88,7 +88,7 @@ With what is new (there is already work on disk):
88
88
  ## 4. Next step
89
89
 
90
90
  - An `Unattended:` line → the question is the orchestrator's to bring back: say so, and that answering it here instead means clearing `meta.json.pending` and continuing in this session's mode; the next step itself comes from `phase` as always.
91
- - Suggest the concrete command from `phase` and `size`. Interrupted phase (e.g. `build` with an empty artifact) → suggest rerunning it with `/flow:feat:build` or `/flow:bug:fix`.
91
+ - Suggest the concrete command from `phase` and `size` — a study whose next step is `build` or `fix`: `git.handoff_branch` set and not `unattended` → `/flow:work:handoff` in its place, **Hand off the study** recommended and **Build here** second where it asks (flow-core §2, a study made for handoff). Interrupted phase (e.g. `build` with an empty artifact) → suggest rerunning it with `/flow:feat:build` or `/flow:bug:fix`.
92
92
  - §2.5 found something new → let it inform the suggestion (a contract that arrived after you left may mean rerunning `design` rather than continuing `build`); say why in one line.
93
93
  - `meta.json.related_repos` entries not `done` → remind that a **sibling repo still has a pending part** (`<repo>: <scope>`, plus `contract not handed over` when its `contract_handoff` is `pending`); suggest `/flow:feat:start <TICKET>` there. flow only reminds; it never scans or touches the other repo.
94
94
  - Do not advance on your own. The user decides.