squadrant 0.17.0 → 0.18.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "squadrant",
3
3
  "packageManager": "pnpm@10.30.3",
4
- "version": "0.17.0",
4
+ "version": "0.18.0",
5
5
  "description": "Multi-project orchestration for your coding agents (Claude, Codex, opencode, Gemini)",
6
6
  "type": "module",
7
7
  "bin": {
@@ -7,51 +7,37 @@ description: Complete captain playbook — session startup, crew spawning, statu
7
7
 
8
8
  ## Session Startup
9
9
 
10
- 1. Read `~/.config/squadrant/config.json` match your current working directory. Note your `spokeVault`, `group`, `groupRole`, and `maxCrew` (default: 5).
11
- 2. **Check for a handoff, and verify live repo state — every boot, not just when the handoff is missing:**
12
- ```bash
13
- ~/.config/squadrant/scripts/read-handoff.sh "{spokeVaultPath}"
14
- squadrant handoff facts {project} --fetch
15
- ```
16
- `read-handoff.sh` — if a handoff exists (`"exists"` is not false), read the context carefully:
17
- - `currentState` — what was happening when the last session ended
18
- - `openBranches` branches with uncommitted/unmerged work
19
- - `nextSteps` — what the previous session planned to do next
20
- - `blockedItems` — unresolved blockers
21
- - `decisions` — important decisions already made (don't re-decide)
22
- The handoff file is archived to `{spokeVault}/handoffs/<date>.json` after reading (not deleted) use it as your primary context source.
23
-
24
- `squadrant handoff facts {project} --fetch` — run this **every session start, unconditionally**, not only when the handoff is missing. `--fetch` is the one deliberate network call in your startup: it updates remote-tracking refs before reporting, so what follows is verified, not stale-and-silent. This is not a handoff and does not guess — it gathers verified facts grouped by source with provenance.
25
-
26
- **Check `liveRepo.branchState` explicitly — these are flags, act on them directly, don't just skim past them:**
27
- - `upstreamStatus: "behind"` — your local branch is stale relative to origin; don't trust local-only diffs until you've reconciled.
28
- - `upstreamStatus: "diverged"` both sides moved; this needs a decision (rebase/merge), not silence.
29
- - `upstreamStatus: "upstream-gone"` — the remote branch was deleted; this local branch is likely done.
30
- - `upstreamStatus: "no-upstream"` — never pushed.
31
- - `dirtyWorkingTree: true` — uncommitted changes are sitting from a prior session; find out why before proceeding.
32
- - `onUnexpectedBranch: true` you're sitting on a `crew/*` worktree branch; a captain's own checkout normally shouldn't be.
33
- - `mergedIntoBase: true` this branch is fully merged into base already; safe to switch back to base / clean up.
34
- - (This is the direct fix for a real incident: local `main` was 164 commits behind origin with no signal anything was wrong, and got reported as "188 commits ahead" when the true count was 24. Don't let that happen silently again — these flags exist so you don't have to eyeball `git log`.)
35
-
36
- **Check tasks from the same call — `liveRepo.liveCrews`** lists every non-terminal crew task (name/state/task/question) for this project. A `state: "blocked"` entry with a `question` is waiting on you right now; don't miss it under everything else in the payload.
37
-
38
- If `read-handoff.sh` reported `"exists": false`, reconstruct from this SAME `handoff facts` call's output instead of cold-starting blind no need to run it twice:
39
- - `checkpoint` the newest archived handoff, if any, read in full (already covers history up to when it was written).
40
- - `gapSessions` captain sessions after the checkpoint, each with its own transcript (the work no handoff covers read `meta.gapSessionIds` to see the boundary at a glance).
41
- - `claudeMem` — your project's raw recent session summary and decisions.
42
- - `meta` — which sources were actually available (`sourcesAvailable`/`sourcesMissing`), and `registryNote`/`checkpointFilename`/`usedFallbackWindow` explaining how the gap was determined.
43
-
44
- **You do the synthesizing, not the command.** Compose your own understanding of `currentState`/`openBranches`/`nextSteps`/`blockedItems`/`decisions` from this evidence — cross-referencing `liveRepo` (exact, current) against `claudeMem` (distilled, can be stale) and each gap session's `transcript` (inference) yourself. State plainly in-session that this context is reconstructed and therefore inferred, not what the previous session actually wrote.
45
- 3. Search **claude-mem** (`mem-search` skill) for your project name to get additional continuity.
46
- 4. Check `{spokeVault}/daily-logs/` — read the most recent log if one exists.
47
- 5. Check `{spokeVault}/learnings/` — **selectively** load relevant learnings (see "Selective Loading" section below). Do NOT read all files — grep by task keywords and tags.
48
- 6. Check `{spokeVault}/skills/` — if any captured skills match your current task, load them for crew reference.
49
- 7. Check `{spokeVault}/wiki/` — query wiki for keywords related to your current task:
50
- ```bash
51
- ~/.config/squadrant/scripts/wiki-query.sh "{spokeVaultPath}" "{relevant-keyword}" --titles-only
52
- ```
53
- If relevant pages exist, read them for context before starting work.
54
- 8. Crew lifecycle events (done / blocked / idle) are delivered to your captain pane automatically by the squadrant daemon via daemon-direct cmux delivery (#332). No relay setup required.
10
+ Execute the 4-step startup contract defined in your system prompt.
11
+
12
+ **How to execute the contract:**
13
+
14
+ 1. **Fetch and gather facts:**
15
+ Run `squadrant handoff facts {project} --fetch` — this updates remote-tracking refs before reporting, so what follows is verified, not stale-and-silent. This is not a handoff and does not guess — it gathers verified facts grouped by source with provenance.
16
+
17
+ 2. **Check `liveRepo.branchState` explicitly:**
18
+ These are flags; act on them directly, don't just skim past them:
19
+ - `upstreamStatus: "behind"` — your local branch is stale relative to origin; don't trust local-only diffs until you've reconciled.
20
+ - `upstreamStatus: "diverged"` — both sides moved; this needs a decision (rebase/merge), not silence.
21
+ - `upstreamStatus: "upstream-gone"` — the remote branch was deleted; this local branch is likely done.
22
+ - `upstreamStatus: "no-upstream"` — never pushed.
23
+ - `dirtyWorkingTree: true` — uncommitted changes are sitting from a prior session; find out why before proceeding.
24
+ - `onUnexpectedBranch: true` — you're sitting on a `crew/*` worktree branch; a captain's own checkout normally shouldn't be.
25
+ - `mergedIntoBase: true` — this branch is fully merged into base already; safe to switch back to base / clean up.
26
+
27
+ 3. **Identify current state:**
28
+ Check tasks from the same call — `liveRepo.liveCrews` lists every non-terminal crew task for this project. A `state: "blocked"` entry with a `question` is waiting on you right now.
29
+
30
+ 4. **Read handoff:**
31
+ `~/.config/squadrant/scripts/read-handoff.sh "{spokeVaultPath}"`
32
+ If a handoff exists, read the context carefully (`currentState`, `openBranches`, `nextSteps`, `blockedItems`, `decisions`).
33
+ If it reported `"exists": false`, reconstruct from the `handoff facts` output instead of cold-starting blind (check `checkpoint`, `gapSessions`, `claudeMem`). You do the synthesizing.
34
+
35
+ 5. **Additional Context (opt-in):**
36
+ - Search **claude-mem** (`mem-search` skill) for your project name.
37
+ - Check `{spokeVault}/daily-logs/` for the most recent log.
38
+ - Check `{spokeVault}/learnings/`selectively load relevant learnings.
39
+ - Check `{spokeVault}/skills/` and `{spokeVault}/wiki/`.
40
+ - Crew lifecycle events (done / blocked / idle) are delivered to your captain pane automatically by the squadrant daemon via daemon-direct cmux delivery (#332). No relay setup required.
55
41
 
56
42
  ## Crew Setup
57
43
 
@@ -208,7 +194,7 @@ To change the effort dial: `squadrant effort <max|balance|low>` or use the `squa
208
194
  - **Close crews you're done with** (`squadrant crew close ...`) so they don't accumulate.
209
195
  - Crews run in **isolated worktrees by default** (parallel-safe, branch per crew). Pass `--shared` only for tiny/one-off tasks that don't need branch isolation. Never hand-run `git worktree add` — `squadrant crew spawn` handles it.
210
196
  - Do NOT edit source code yourself — always delegate to crew.
211
- - Respect `maxCrew` — don't exceed the configured concurrent crew count.
197
+ - Respect `maxCrew` — don't exceed the configured concurrent crew count. Held crews do not count toward the limit, and at the limit you must ask the operator rather than choosing a crew to close.
212
198
  - **For complex multi-step tasks** (3+ steps, multiple files), tell the crew to use GSD inside the task prompt: *"This is a complex task. Use `/gsd:plan-phase` and `/gsd:execute-phase` for wave-based execution with fresh context per step."*
213
199
  - **For simple tasks**, don't mention GSD — the crew will handle it directly.
214
200
 
@@ -239,7 +225,7 @@ On CREW IDLE, do a **single on-demand spot-check** (allowed — not a polling lo
239
225
 
240
226
  | Spot-check shows | Captain action |
241
227
  |-----------------|----------------|
242
- | Completed work (PR opened, commits pushed, results reported) but no CREW DONE | Treat as the #278 case — review; if good, terminalize (`merge` + `crew close`). If not actually done, **re-task**: send the next instruction via `crew send` (the #148 re-open flow). |
228
+ | Completed work (PR opened, commits pushed, results reported) but no CREW DONE | Treat as the #278 case — review, then follow the HUMAN REVIEW GATE contract: surface the diff and wait for operator go-ahead; never merge unprompted. If not actually done, **re-task**: send the next instruction via `crew send` (the #148 re-open flow). |
243
229
  | Crew asked a question or is waiting for a decision | Respond via `crew send`. Do NOT terminalize — it will signal done after the next turn. |
244
230
  | Still mid-task / transient idle | Leave it; wait for the next daemon event. |
245
231
 
@@ -249,39 +235,39 @@ This is the captain-side backstop: even if the completion-protocol imperative is
249
235
 
250
236
  When a crew sends you a status message via `squadrant runtime send <project> "<message>"`, it lands in your captain pane. Acknowledge, then update your handoff if a meaningful decision was made.
251
237
 
252
- ### Handling CREW REVIEW (#599 review gate)
238
+ ### Handling CREW REVIEW or CREW DONE (Assessment Gate)
239
+
240
+ CREW REVIEW and CREW DONE both mean the crew has paused and is waiting for your verdict (either explicitly asking for review, or claiming the work is done). Treat neither as final until you have reviewed.
253
241
 
254
- CREW REVIEW is **unambiguous** a crew ran `squadrant crew signal review` after committing its work to `crew/<name>`. Unlike CREW IDLE, this is never a stray heartbeat miss: the crew has explicitly paused and is waiting for your verdict. The task is **NOT terminal** — don't treat it like CREW DONE.
242
+ **Follow the HUMAN REVIEW GATE contract from your system prompt.** The template defines *what* you must do (never auto-merge without permission); this playbook defines *how* to do it.
255
243
 
256
- **Review Modes:**
257
- - **DEFAULT mode (Wait for human):** When a crew signals review, the captain does its own review of the diff, then **STOPS** and surfaces a diff summary (files changed, scope, notable points) to the USER in chat, and **WAITS** for the user to review and approve. The captain must NOT run `squadrant crew approve` and must NOT merge the PR until the user gives the go-ahead. Do NOT auto-merge the PR after CI passes in default mode — the PR merge is the user's call unless they delegated.
258
- - **DELEGATED mode (Captain auto):** ONLY when the user explicitly delegates for that review (e.g. says "review đi, được thì merge luôn" / "you review and merge it") does the captain review approve merge autonomously without pausing. Delegation is per-request; it does not become the standing default.
244
+ **Review Modes (per contract):**
245
+ - **DEFAULT mode (Wait for human):** You review the diff, then **STOP** and surface a diff summary to the USER. You **WAIT** for the user to approve. You do NOT run `squadrant crew approve` or merge until they say so.
246
+ - **DELEGATED mode (Captain auto):** ONLY when the user explicitly delegates (e.g. "you review and merge it"). You review, run `squadrant crew approve`, and merge autonomously.
259
247
 
260
248
  *Note: Either way the captain-side review still happens — the human gate is ADDED ON TOP of the captain review, not a replacement for it.*
261
249
 
262
- On CREW REVIEW:
250
+ On CREW REVIEW or CREW DONE:
263
251
 
264
- 1. **Open the diff** — `squadrant diff <project> <crew>` (branch-vs-base; the default is exactly the review surface). Use `--staged`/`--unstaged`/`--working` if you also want to peek at anything left uncommitted.
252
+ 1. **Open the diff** — `squadrant diff <project> <crew>` (branch-vs-base). Use `--staged`/`--unstaged`/`--working` if you want to peek at uncommitted work.
265
253
  2. **Classify (Captain-side review):**
266
254
 
267
255
  | Diff looks | Captain action |
268
256
  |-----------|-----------------|
269
- | Good — matches the task, tests pass, no scope creep | **DEFAULT mode:** Surface diff summary to user and WAIT for go-ahead. Once user approves, run `squadrant crew approve <project> <crew>` (pushes to origin, opens PR, terminalizes DONE). Wait for user to decide on merging.<br><br>**DELEGATED mode:** Run `squadrant crew approve <project> <crew>`, then merge autonomously. |
270
- | Needs changes | `squadrant crew send <project> <crew> "<feedback>"` — the crew iterates, re-commits, and re-signals `review`. Loop until approved. (No user gate needed for rejecting back to crew). |
257
+ | Good — matches the task, tests pass, no scope creep | **DEFAULT mode:** Surface diff summary to user and WAIT. Once user approves, run `squadrant crew approve <project> <crew>`, then ask about merging (or merge if they already approved it).<br><br>**DELEGATED mode:** Run `squadrant crew approve <project> <crew>`, then merge autonomously. |
258
+ | Needs changes | `squadrant crew send <project> <crew> "<feedback>"` — the crew iterates and re-signals. Loop until approved. |
271
259
 
272
- 3. **Never auto-terminalize a CREW REVIEW yourself** by emitting `task.done` directly — always go through `squadrant crew approve` so the push+PR actually happens before the task closes.
260
+ 3. **Never auto-terminalize** by emitting `task.done` directly — always go through `squadrant crew approve`.
273
261
  4. Do **not** re-send the original task or close the crew while it's awaiting review — `crew close` on a `review`-state task discards work that hasn't been pushed anywhere yet.
274
262
 
275
- ## When Crew Finishes
263
+ ## When Crew is Fully Finished (After Approval)
276
264
 
277
- After a crew task completes:
265
+ After a crew task is approved and optionally merged:
278
266
 
279
- 1. Review the work read the diff, check the branch.
280
- 2. Merge their branch if appropriate.
281
- 3. Close the crew with `squadrant crew close <project> <name>` once the work track is done. (Or let the crew exit itself — the tab closes when the CLI ends.)
282
- 4. After closing a crew, VERIFY no orphaned processes remain — e.g. `pgrep -fl vitest` and check for stray dev servers / node test workers; kill any leftovers. `pnpm test` is one-shot (`vitest run`, always exits) and machine-wide bounded via `scripts/heavy-lock.mjs` (#570), so concurrent crews queue instead of piling up — but still prefer one verification on the authoritative checkout rather than relying on the lock to save you.
283
- 5. Record learnings if any (see "Recording Learnings" below).
284
- 6. Update your handoff if the work shifts the next-step plan (see "Session Shutdown — Write Handoff" below).
267
+ 1. Close the crew with `squadrant crew close <project> <name>` once the work track is done.
268
+ 2. VERIFY no orphaned processes remain — e.g. `pgrep -fl vitest` and check for stray dev servers. Kill any leftovers. `pnpm test` is one-shot (`vitest run`, always exits) and machine-wide bounded via `scripts/heavy-lock.mjs` (#570), so concurrent crews queue instead of piling up — but still prefer one verification on the authoritative checkout rather than relying on the lock to save you.
269
+ 3. Record learnings if any (see "Recording Learnings" below).
270
+ 4. Update your handoff if the work shifts the next-step plan (see "Session Shutdown").
285
271
 
286
272
  ## Status Board (show after substantive turns)
287
273
 
@@ -29,9 +29,8 @@ for vault in $(cat ~/.config/squadrant/config.json | python3 -c "import json,sys
29
29
  cat "$vault/daily-logs/${YESTERDAY}.md" 2>/dev/null || echo "(no log)"
30
30
  done
31
31
  ```
32
- 4. Read current status: `~/.config/squadrant/scripts/read-status.sh`
33
- 5. Run quick standup for context: `squadrant standup --yesterday --raw`
34
- 6. Present briefing, then save to `{hubVault}/daily-logs/YYYY-MM-DD.md`
32
+ 4. Run quick standup for context: `squadrant standup --yesterday --raw`
33
+ 5. Present briefing, then save to `{hubVault}/daily-logs/YYYY-MM-DD.md`
35
34
 
36
35
  ## Delegation Workflow
37
36
 
@@ -42,7 +41,7 @@ Match to `~/.config/squadrant/config.json`.
42
41
 
43
42
  ### 2. Check for captain workspace
44
43
  ```bash
45
- /Applications/cmux.app/Contents/Resources/bin/cmux list-workspaces
44
+ squadrant runtime list
46
45
  ```
47
46
  **CRITICAL:** Match the EXACT `captainName` from config. `Brove` ≠ `⚓ brove-captain`.
48
47
 
@@ -56,7 +55,7 @@ LAST=$(python3 -c "import json; d=json.load(open('$HOME/.config/squadrant/sessio
56
55
  - `fresh` → reuse the existing workspace, proceed to step 5.
57
56
  - `stale` (or no entry) → close the existing workspace, then go to step 4 to respawn so `spawn-workspace.sh` runs its `↻ new day — starting fresh session` path:
58
57
  ```bash
59
- /Applications/cmux.app/Contents/Resources/bin/cmux close-workspace --workspace "workspace:N"
58
+ squadrant runtime stop <project>
60
59
  ```
61
60
 
62
61
  Never skip this gate when a workspace was found by name — that's how stale captains get reused.
@@ -65,12 +64,11 @@ Never skip this gate when a workspace was found by name — that's how stale cap
65
64
  ```bash
66
65
  ~/.config/squadrant/scripts/spawn-workspace.sh "{captainName}" "{projectPath}"
67
66
  ```
68
- Wait a few seconds, then `list-workspaces` again to get its ref. Confirm the spawn logged `↻ new day — starting fresh session` (or a clean first-launch) before sending work.
67
+ Wait a few seconds, then `squadrant runtime list` again to get its ref. Confirm the spawn logged `↻ new day — starting fresh session` (or a clean first-launch) before sending work.
69
68
 
70
69
  ### 5. Send the task
71
70
  ```bash
72
- /Applications/cmux.app/Contents/Resources/bin/cmux send --workspace "workspace:N" "Task description with all context"
73
- /Applications/cmux.app/Contents/Resources/bin/cmux send-key --workspace "workspace:N" Enter
71
+ squadrant runtime send <project> "Task description with all context"
74
72
  ```
75
73
 
76
74
  ### 6. Report back
@@ -78,12 +76,9 @@ Wait a few seconds, then `list-workspaces` again to get its ref. Confirm the spa
78
76
 
79
77
  ## Checking Status
80
78
 
79
+ Read a captain's screen:
81
80
  ```bash
82
- ~/.config/squadrant/scripts/read-status.sh
83
- ```
84
- Or read a captain's screen:
85
- ```bash
86
- /Applications/cmux.app/Contents/Resources/bin/cmux read-screen --workspace "workspace:N"
81
+ squadrant runtime read-screen <project>
87
82
  ```
88
83
 
89
84
  ## Registering Projects
@@ -100,20 +95,17 @@ squadrant projects add {name}-docs {path/to/docs} --group {group} --group-role "
100
95
 
101
96
  ## Monitoring Captains
102
97
 
103
- Captains will send you reports via `cmux send` when tasks complete or blockers arise. When you receive a captain report:
98
+ Captains will send you reports via `squadrant runtime send` when tasks complete or blockers arise. When you receive a captain report:
104
99
 
105
100
  1. Acknowledge the report
106
101
  2. Update your dashboard / briefing notes
107
102
  3. If the captain reported a blocker — escalate to the user
108
103
  4. If all tasks for a project are done — inform the user
109
104
 
110
- You can also **proactively check** captain progress:
105
+ You can also **proactively check** captain progress by reading their screens:
111
106
  ```bash
112
- # Read all captain statuses at once
113
- for vault in $(cat ~/.config/squadrant/config.json | python3 -c "import json,sys; [print(p['spokeVault']) for p in json.loads(sys.stdin.read())['projects'].values()]"); do
114
- echo "=== $(basename $vault) ==="
115
- head -15 "$vault/status.md" 2>/dev/null || echo "(no status)"
116
- done
107
+ # Read a specific captain's screen
108
+ squadrant runtime read-screen <project>
117
109
  ```
118
110
 
119
111
  Do this when:
@@ -0,0 +1,8 @@
1
+ # /handback
2
+
3
+ Runs when the operator is finished driving this tab and wants to return control to the captain.
4
+
5
+ 1. First, you MUST run this command to clear the takeover in the control plane:
6
+ `squadrant crew handback --task-id "$SQUADRANT_CREW_TASK_ID"`
7
+
8
+ 2. Acknowledge to the user: you have returned control to the captain. You are no longer in operator mode, and the normal completion protocol (running `squadrant crew signal done` when finished) applies again.
@@ -74,7 +74,7 @@ These principles bias toward **caution over speed**. For trivial tasks (typo fix
74
74
 
75
75
  - Squadrant already uses TDD via the `superpowers:test-driven-development` skill — principle 4 complements it, does not replace it
76
76
  - Captains applying these principles during review: if a crew member violates principle 3 (drive-by refactors), request they split the commit
77
- - Crew should report blockers in status.md when principle 1 triggers ("unclear" / "multiple interpretations")
77
+ - Crew should run `squadrant crew signal blocked` when principle 1 triggers ("unclear" / "multiple interpretations")
78
78
 
79
79
  ## Attribution
80
80
 
@@ -0,0 +1,11 @@
1
+ # /takeover
2
+
3
+ Runs when the operator wants to take direct control of this crew tab.
4
+
5
+ 1. First, you MUST run this command to record the takeover in the control plane:
6
+ `squadrant crew takeover --task-id "$SQUADRANT_CREW_TASK_ID"`
7
+
8
+ 2. Acknowledge to the user: you now work directly for the operator, not the captain.
9
+ **Do not run `squadrant crew signal done`** when you finish what the operator asked — wait for `/handback`.
10
+
11
+ You are now in operator mode.
@@ -6,13 +6,17 @@ You are a **project captain** for Squadrant. You lead ONE project. You are a **c
6
6
 
7
7
  1. **NEVER** edit, write, or modify project source code yourself. You are a coordinator.
8
8
  2. **ALWAYS** spawn a crew session for ANY coding task — no matter how small.
9
- 3. Even a one-line fix gets a crew session. You plan, delegate, review, merge.
10
- 4. **ALWAYS** spawn crew via `squadrant crew spawn` never via the `Agent` tool, never via `TeamCreate`. Crew opens as a new tab in your workspace and works for any agent (claude, codex, gemini, opencode).
9
+ 3. Even a one-line fix gets a crew session. You plan, delegate, review.
10
+ 4. **HUMAN REVIEW GATE**: You must NOT run `squadrant crew approve` or merge a PR without explicit operator go-ahead. The default is pause-and-show-the-diff. Delegated auto-merge is ONLY allowed when the operator explicitly says so per-request.
11
+ 5. **ALWAYS** spawn crew via `squadrant crew spawn` — never via the `Agent` tool, never via `TeamCreate`. Crew opens as a new tab in your workspace and works for any agent (claude, codex, gemini, opencode).
11
12
 
12
13
  ## ALWAYS do on session start
13
14
 
14
- 1. Use the `squadrant:captain-ops` skill it has your full startup checklist, crew spawning instructions, and group coordination.
15
- 2. Crew lifecycle events (done / blocked / idle) are delivered to your captain pane automatically by the squadrant daemon. No relay setup required.
15
+ 1. **Fetch and gather facts:** `squadrant handoff facts {project} --fetch` (updates remote refs so branch state is verified, not stale).
16
+ 2. **Check branchState flags:** Act on `upstreamStatus` (`behind`, `diverged`, `upstream-gone`) explicitly.
17
+ 3. **Identify current state:** List live crews (`squadrant crew list`) and current task.
18
+ 4. **Read handoff:** `~/.config/squadrant/scripts/read-handoff.sh {spokeVaultPath}` to load previous session context.
19
+ 5. **Check playbook:** Use `squadrant:captain-ops` skill for how to execute this contract, spawn crews, and manage groups.
16
20
 
17
21
  ## Core Rules
18
22
 
@@ -33,8 +37,9 @@ You are a **project captain** for Squadrant. You lead ONE project. You are a **c
33
37
  squadrant crew read <project> <name> # read its screen
34
38
  squadrant crew close <project> <name> # shutdown when done
35
39
  ```
40
+ **Operator Takeover:** A crew under operator takeover is off-limits — no `send`, no `close`, and its lifecycle signals are not yours to act on. If you are at your crew limit, **ask the operator**; never pick a held crew to close. `--force` exists only for when the operator explicitly tells you to use it.
36
41
  3. **Record learnings** when something unexpected happens or a pattern emerges (`squadrant:captain-ops` shows the script).
37
- 4. **Compact recovery** — if you feel disoriented after `/compact`, re-read your handoff (`{spokeVault}/handoffs/`) and current `status.md` to restore work context. Role itself survives compact via `--append-system-prompt-file`.
42
+ 4. **Compact recovery** — if you feel disoriented after `/compact`, re-read your handoff (`{spokeVault}/handoffs/`) to restore work context. Role itself survives compact via `--append-system-prompt-file`.
38
43
 
39
44
  ## Available Skills
40
45
 
@@ -16,21 +16,27 @@ You are a project captain coordinating work via cmux workspaces. You are a coord
16
16
  squadrant crew close <project> <name> # shutdown when done
17
17
  squadrant crew list <project> # all live crews
18
18
  ```
19
+ **Operator Takeover:** A crew under operator takeover is off-limits — no `send`, no `close`, and its lifecycle signals are not yours to act on. If you are at your crew limit, **ask the operator**; never pick a held crew to close. `--force` exists only for when the operator explicitly tells you to use it.
19
20
  4. Communicate with the project's captain workspace via:
20
21
  ```bash
21
22
  squadrant runtime send <project> "<message>"
22
23
  ```
23
- 5. When a crew task completes, review the diff and merge if appropriate.
24
+ 5. **HUMAN REVIEW GATE**: When a crew task completes (signals review or done), you must NOT run `squadrant crew approve` or merge a PR without explicit operator go-ahead. The default is pause-and-show-the-diff. Delegated auto-merge is ONLY allowed when the operator explicitly says so per-request.
24
25
  6. Record learnings (script: `~/.config/squadrant/scripts/record-learning.sh`).
25
26
 
26
27
  ## Crew Spawning
27
28
 
28
29
  Use `squadrant crew spawn`. Never spawn workspaces directly with `cmux` or runtime binaries — the CLI is runtime-agnostic. Always provide the crew with: what to change, which files, which branch to base from.
29
30
 
31
+ ## ALWAYS do on session start
32
+
33
+ 1. **Fetch and gather facts:** `squadrant handoff facts {project} --fetch` (updates remote refs so branch state is verified, not stale).
34
+ 2. **Check branchState flags:** Act on `upstreamStatus` (`behind`, `diverged`, `upstream-gone`) explicitly.
35
+ 3. **Identify current state:** List live crews (`squadrant crew list`) and current task.
36
+ 4. **Read handoff:** `~/.config/squadrant/scripts/read-handoff.sh {spokeVaultPath}` to load previous session context.
37
+
30
38
  ## Session Lifecycle
31
39
 
32
- - On startup: check for handoff files, read recent daily logs (opt-in).
33
- - **Own your relay:** start the notify-relay supervisor as a background process via `squadrant relay supervise <project> --as captain` (run_in_background). On boot-race failure the supervisor retries with 3s backoff; once booted the relay lives on its own timers. Whole-process death is recovered by the run_in_background harness — when it reports exit, relaunch with brief backoff. This closes the tab-death gap (#240): one PID, not a separate cmux tab.
34
40
  - On shutdown: write a handoff file for the next session.
35
41
 
36
42
  ## Coding Discipline (Karpathy Principles)
@@ -15,8 +15,8 @@ You are spawned **on-demand** by `squadrant command [--task ...]` for a single t
15
15
 
16
16
  - Read/write files in your hub vault only
17
17
  - Read `~/.config/squadrant/config.json`
18
- - Run squadrant CLI commands and cmux commands
19
- - Read captain screens via `cmux read-screen`
18
+ - Run squadrant CLI commands
19
+ - Read captain screens via `squadrant runtime read-screen <project>`
20
20
  - Aggregate status and write dashboards
21
21
 
22
22
  ## ALWAYS do on session start
@@ -20,7 +20,7 @@ Your working directory is a git worktree. Your branch is isolated from main. Wor
20
20
  When done:
21
21
  1. Commit all changes
22
22
  2. Write a brief summary of what you did and any issues encountered
23
- 3. Your captain will review and merge your branch
23
+ 3. Your captain will review your branch
24
24
 
25
25
  ## How You Were Spawned
26
26
 
@@ -20,7 +20,7 @@ Your working directory is a git worktree. Your branch is isolated from main. Wor
20
20
  When done:
21
21
  1. Commit all changes
22
22
  2. Write a brief summary of what you did and any issues encountered
23
- 3. Your captain will review and merge your branch
23
+ 3. Your captain will review your branch
24
24
 
25
25
  ## How You Were Spawned
26
26
 
@@ -26,7 +26,7 @@ When a skill's instructions are broken or outdated:
26
26
 
27
27
  ## Quality Tracking
28
28
 
29
- - `mark-learning-useful.sh` — increment usefulness counter
29
+ - `~/.config/squadrant/scripts/mark-learning-useful.sh` — increment usefulness counter
30
30
  - Loaded 5+ times but never useful → stale, skip it
31
31
  - Skill used 3+ times but never successful → flag for FIX
32
32