create-claude-cabinet 0.45.0 → 0.47.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 (165) hide show
  1. package/README.md +6 -10
  2. package/lib/cli.js +374 -91
  3. package/lib/copy.js +108 -6
  4. package/lib/db-setup.js +122 -17
  5. package/lib/engagement-server-setup.js +34 -9
  6. package/lib/metadata.js +51 -2
  7. package/lib/migrate-from-omega.js +13 -1
  8. package/lib/mux-setup.js +33 -9
  9. package/lib/settings-merge.js +52 -10
  10. package/lib/watchtower-setup.js +230 -0
  11. package/package.json +5 -1
  12. package/templates/cabinet/_cabinet-member-template.md +8 -3
  13. package/templates/cabinet/advisories-state-schema.md +34 -7
  14. package/templates/cabinet/checklist-stats-schema.md +15 -1
  15. package/templates/cabinet/composition-patterns.md +4 -3
  16. package/templates/cabinet/memory-lifecycle-contract.md +135 -0
  17. package/templates/cabinet/pib-db-access.md +13 -0
  18. package/templates/cabinet/skill-output-conventions.md +35 -1
  19. package/templates/cabinet/watchtower-contracts.md +503 -1
  20. package/templates/cabinet/worktree-invocation-contract.md +87 -0
  21. package/templates/engagement/OVERVIEW.md +12 -0
  22. package/templates/engagement/__tests__/engagement.test.mjs +177 -2
  23. package/templates/engagement/__tests__/invoice-doc.test.mjs +195 -0
  24. package/templates/engagement/engagement-preview.mjs +100 -0
  25. package/templates/engagement/engagement-schema.md +240 -0
  26. package/templates/engagement/engagement.mjs +391 -11
  27. package/templates/engagement/pib-db-patches/pib-db-lib.mjs +10 -1
  28. package/templates/engagement/pib-db-patches/pib-db-mcp-server.mjs +5 -44
  29. package/templates/engagement/pib-db-patches/pib-db.mjs +5 -2
  30. package/templates/hooks/action-completion-gate.sh +9 -3
  31. package/templates/hooks/memory-index-guard.sh +17 -11
  32. package/templates/hooks/watchtower-session-start.sh +24 -2
  33. package/templates/mcp/pib-db.json +1 -4
  34. package/templates/mux/__tests__/mux-fail-loud.fixture.sh +44 -0
  35. package/templates/mux/__tests__/station-liveness.fixture.sh +234 -0
  36. package/templates/mux/__tests__/station-liveness.test.mjs +47 -0
  37. package/templates/mux/bin/mux +289 -56
  38. package/templates/mux/config/help.txt +1 -0
  39. package/templates/rules/acknowledge-when-corrected.md +33 -0
  40. package/templates/rules/maintainability.md +11 -0
  41. package/templates/rules/memory-capture.md +26 -4
  42. package/templates/rules/plan-before-bulk-or-irreversible-actions.md +48 -0
  43. package/templates/rules/verify-before-asserting.md +79 -0
  44. package/templates/scripts/__tests__/advisor-pass.test.mjs +238 -0
  45. package/templates/scripts/__tests__/advisories.test.mjs +262 -0
  46. package/templates/scripts/__tests__/ahead-check-origin.test.mjs +355 -0
  47. package/templates/scripts/__tests__/batch-disposition.test.mjs +235 -0
  48. package/templates/scripts/__tests__/claude-churn-authored.test.mjs +90 -0
  49. package/templates/scripts/__tests__/cross-ring-reader.test.mjs +505 -0
  50. package/templates/scripts/__tests__/dx-captures-briefing.test.mjs +169 -0
  51. package/templates/scripts/__tests__/feedback-outbox-flush.test.mjs +232 -0
  52. package/templates/scripts/__tests__/hook-runner.test.mjs +247 -0
  53. package/templates/scripts/__tests__/narrative-corpus.test.mjs +247 -0
  54. package/templates/scripts/__tests__/phase-shim.test.mjs +112 -0
  55. package/templates/scripts/__tests__/qa-handoff-gate.test.mjs +68 -0
  56. package/templates/scripts/__tests__/qa-handoff-merge-state.test.mjs +162 -0
  57. package/templates/scripts/__tests__/resolve-cli.test.mjs +314 -0
  58. package/templates/scripts/__tests__/ring-state-ownership.test.mjs +228 -3
  59. package/templates/scripts/__tests__/ring1-content-detector.test.mjs +168 -0
  60. package/templates/scripts/__tests__/ring1-flagged-actions.test.mjs +135 -0
  61. package/templates/scripts/__tests__/ring1-script-drift.test.mjs +126 -0
  62. package/templates/scripts/__tests__/ring2-queue-reader.test.mjs +80 -0
  63. package/templates/scripts/__tests__/ring2-recall-canary.test.mjs +150 -0
  64. package/templates/scripts/__tests__/ring2-roster-review.test.mjs +311 -0
  65. package/templates/scripts/__tests__/ring2-thread-context.test.mjs +189 -0
  66. package/templates/scripts/__tests__/ring3-chunk-merge.test.mjs +122 -0
  67. package/templates/scripts/__tests__/ring3-close-lenses.test.mjs +359 -0
  68. package/templates/scripts/__tests__/ring3-dedup.test.mjs +467 -0
  69. package/templates/scripts/__tests__/ring3-memory-titles.test.mjs +187 -0
  70. package/templates/scripts/__tests__/ring3-novelty-rescue.test.mjs +148 -0
  71. package/templates/scripts/__tests__/ring3-recent-slice.test.mjs +101 -0
  72. package/templates/scripts/__tests__/ring4-reconcile.test.mjs +393 -0
  73. package/templates/scripts/__tests__/routine-dispatch.test.mjs +312 -0
  74. package/templates/scripts/__tests__/shared-thread-reader.test.mjs +187 -0
  75. package/templates/scripts/__tests__/suppression-ledger.test.mjs +148 -0
  76. package/templates/scripts/__tests__/verify-backfill.test.mjs +103 -0
  77. package/templates/scripts/__tests__/verify-coverage.test.mjs +80 -0
  78. package/templates/scripts/__tests__/watchtower-snapshot.test.mjs +261 -0
  79. package/templates/scripts/__tests__/watchtower-sync.test.mjs +311 -0
  80. package/templates/scripts/load-triage-history.js +5 -2
  81. package/templates/scripts/pib-db-mcp-server.mjs +5 -44
  82. package/templates/scripts/pib-db-path.mjs +61 -0
  83. package/templates/scripts/pib-db.mjs +5 -2
  84. package/templates/scripts/validate-memory.mjs +214 -16
  85. package/templates/scripts/watchtower-advisories.mjs +309 -0
  86. package/templates/scripts/watchtower-build-context.mjs +301 -18
  87. package/templates/scripts/watchtower-cross-ring-reader.mjs +700 -0
  88. package/templates/scripts/watchtower-hook-runner.mjs +422 -0
  89. package/templates/scripts/watchtower-lib.mjs +447 -2
  90. package/templates/scripts/watchtower-narrative-corpus.mjs +385 -0
  91. package/templates/scripts/watchtower-phase-shim.mjs +171 -0
  92. package/templates/scripts/watchtower-queue.mjs +484 -1
  93. package/templates/scripts/watchtower-ring1.mjs +533 -53
  94. package/templates/scripts/watchtower-ring2.mjs +787 -48
  95. package/templates/scripts/watchtower-ring3-close.mjs +1357 -99
  96. package/templates/scripts/watchtower-ring4-runner.sh +85 -0
  97. package/templates/scripts/watchtower-ring4.mjs +753 -0
  98. package/templates/scripts/watchtower-routines.mjs +358 -0
  99. package/templates/scripts/watchtower-snapshot.mjs +452 -0
  100. package/templates/scripts/watchtower-status.sh +1 -1
  101. package/templates/scripts/watchtower-sync.mjs +393 -0
  102. package/templates/skills/audit/SKILL.md +5 -1
  103. package/templates/skills/briefing/SKILL.md +584 -236
  104. package/templates/skills/cabinet-anthropic-insider/SKILL.md +14 -6
  105. package/templates/skills/cabinet-historian/SKILL.md +14 -11
  106. package/templates/skills/cabinet-process-therapist/SKILL.md +28 -0
  107. package/templates/skills/cabinet-security/SKILL.md +11 -0
  108. package/templates/skills/cabinet-system-advocate/SKILL.md +22 -21
  109. package/templates/skills/cabinet-user-advocate/SKILL.md +13 -7
  110. package/templates/skills/catch-up/SKILL.md +113 -0
  111. package/templates/skills/cc-publish/SKILL.md +148 -25
  112. package/templates/skills/cc-remember/SKILL.md +45 -0
  113. package/templates/skills/close/SKILL.md +107 -0
  114. package/templates/skills/collab-client/SKILL.md +22 -5
  115. package/templates/skills/collab-consultant/SKILL.md +110 -2
  116. package/templates/skills/debrief/SKILL.md +148 -16
  117. package/templates/skills/debrief-classic/SKILL.md +696 -0
  118. package/templates/skills/debrief-classic/calibration.md +44 -0
  119. package/templates/skills/debrief-classic/phases/audit-pattern-capture.md +78 -0
  120. package/templates/skills/debrief-classic/phases/auto-maintenance.md +48 -0
  121. package/templates/skills/debrief-classic/phases/checklist-feedback.md +123 -0
  122. package/templates/skills/debrief-classic/phases/close-work.md +163 -0
  123. package/templates/skills/debrief-classic/phases/health-checks.md +54 -0
  124. package/templates/skills/debrief-classic/phases/inventory.md +40 -0
  125. package/templates/skills/debrief-classic/phases/loose-ends.md +52 -0
  126. package/templates/skills/debrief-classic/phases/methodology-capture.md +223 -0
  127. package/templates/skills/debrief-classic/phases/qa-handoff-sweep.md +78 -0
  128. package/templates/skills/debrief-classic/phases/record-lessons.md +177 -0
  129. package/templates/skills/debrief-classic/phases/report.md +59 -0
  130. package/templates/skills/debrief-classic/phases/update-state.md +48 -0
  131. package/templates/skills/debrief-classic/phases/upstream-feedback.md +185 -0
  132. package/templates/skills/debrief-classic/phases/verify-coverage.md +101 -0
  133. package/templates/skills/execute/SKILL.md +77 -6
  134. package/templates/skills/execute/phases/commit-and-deploy.md +8 -0
  135. package/templates/skills/execute-group/SKILL.md +23 -26
  136. package/templates/skills/generate-plan-groups/SKILL.md +20 -0
  137. package/templates/skills/inbox/SKILL.md +124 -7
  138. package/templates/skills/memory/SKILL.md +22 -6
  139. package/templates/skills/orient/SKILL.md +140 -52
  140. package/templates/skills/orient-classic/SKILL.md +770 -0
  141. package/templates/skills/orient-classic/phases/auto-maintenance.md +52 -0
  142. package/templates/skills/orient-classic/phases/briefing.md +53 -0
  143. package/templates/skills/orient-classic/phases/cabinet.md +46 -0
  144. package/templates/skills/orient-classic/phases/checklist-status.md +54 -0
  145. package/templates/skills/orient-classic/phases/context.md +88 -0
  146. package/templates/skills/orient-classic/phases/data-sync.md +35 -0
  147. package/templates/skills/orient-classic/phases/deferred-check.md +55 -0
  148. package/templates/skills/orient-classic/phases/dx-captures.md +53 -0
  149. package/templates/skills/orient-classic/phases/health-checks.md +50 -0
  150. package/templates/skills/orient-classic/phases/verify-backfill.md +109 -0
  151. package/templates/skills/orient-classic/phases/work-scan.md +69 -0
  152. package/templates/skills/plan/SKILL.md +8 -0
  153. package/templates/skills/qa-drain/SKILL.md +157 -0
  154. package/templates/skills/qa-handoff/SKILL.md +287 -46
  155. package/templates/skills/session-handoff/SKILL.md +175 -6
  156. package/templates/skills/setup-accounts/SKILL.md +38 -16
  157. package/templates/skills/threads/SKILL.md +4 -0
  158. package/templates/skills/triage-audit/SKILL.md +6 -0
  159. package/templates/skills/validate/phases/validators.md +41 -0
  160. package/templates/skills/watchtower/SKILL.md +199 -2
  161. package/templates/verify-runtime/CONVENTIONS.md +9 -0
  162. package/templates/verify-runtime/README.md +37 -0
  163. package/templates/watchtower/config.json.template +10 -2
  164. package/templates/watchtower/queue/items/item.json.schema +1 -1
  165. package/templates/workflows/execute-group-complete.js +10 -1
@@ -0,0 +1,696 @@
1
+ ---
2
+ name: debrief-classic
3
+ description: |
4
+ Pre-retirement standalone copy of the classic session close. Inventories
5
+ what was done, closes work items, updates state, captures lessons, and
6
+ prepares the briefing for next time. A self-contained skeleton skill
7
+ (phases/ directory pattern) that keeps working even after the live
8
+ /debrief is retired or redefined by the watchtower transition — it does
9
+ NOT delegate to /debrief. Use when: "debrief-classic", "/debrief-classic",
10
+ or to roll back to the classic session close during the transition. If
11
+ "quick" is mentioned, use the Quick Mode section — run core phases only,
12
+ skip presentation phases.
13
+ related:
14
+ - type: file
15
+ path: .claude/skills/debrief-classic/phases/inventory.md
16
+ role: "Project-specific: how to identify what was done"
17
+ - type: file
18
+ path: .claude/skills/debrief-classic/phases/close-work.md
19
+ role: "Project-specific: how to close work items and resolve feedback"
20
+ - type: file
21
+ path: .claude/skills/debrief-classic/phases/auto-maintenance.md
22
+ role: "Project-specific: recurring session-end tasks"
23
+ - type: file
24
+ path: .claude/skills/debrief-classic/phases/update-state.md
25
+ role: "Project-specific: what state to update"
26
+ - type: file
27
+ path: .claude/skills/debrief-classic/phases/health-checks.md
28
+ role: "Project-specific: session-end health checks"
29
+ - type: file
30
+ path: .claude/skills/debrief-classic/phases/record-lessons.md
31
+ role: "Project-specific: how to capture learnings"
32
+ - type: file
33
+ path: .claude/skills/debrief-classic/phases/loose-ends.md
34
+ role: "Project-specific: non-project items to capture"
35
+ - type: file
36
+ path: .claude/skills/debrief-classic/phases/audit-pattern-capture.md
37
+ role: "Instruction: detect recurring audit findings and write to patterns-project.md"
38
+ - type: file
39
+ path: .claude/skills/debrief-classic/phases/checklist-feedback.md
40
+ role: "Instruction: propose checklist sharpening when bugs were caught this session"
41
+ - type: file
42
+ path: .claude/skills/debrief-classic/phases/upstream-feedback.md
43
+ role: "Instruction: surface CC friction back to source repo"
44
+ - type: file
45
+ path: .claude/skills/debrief-classic/phases/qa-handoff-sweep.md
46
+ role: "Instruction: hand off every worktree→main merge this session still needs QA for"
47
+ - type: file
48
+ path: .claude/skills/debrief-classic/phases/report.md
49
+ role: "Project-specific: how to present the summary"
50
+ - type: file
51
+ path: cabinet/_briefing.md
52
+ role: "Project identity and configuration"
53
+ argument-hint: "mode — e.g., 'quick'"
54
+ ---
55
+
56
+ # /debrief-classic — Session Close (classic)
57
+
58
+ This is the standalone classic copy of the original `/debrief` skill,
59
+ preserved so the session close can be rolled back during the watchtower
60
+ transition. It is fully self-contained: every phase reference below
61
+ resolves to this skill's own `phases/` directory, so it keeps working
62
+ even after the live `/debrief` is retired or redefined.
63
+
64
+ ## Arguments
65
+
66
+ If `$ARGUMENTS` is provided:
67
+ - **'quick'**: Use Quick Mode — run core phases only, skip presentation
68
+ phases (the Quick Mode section below is self-contained).
69
+ - **Any other value**: Ignored; run normal full debrief.
70
+ - **Empty**: Run normal full debrief.
71
+
72
+ ## User Scope Hints
73
+
74
+ When the user invokes debrief with emphasis on specific phases —
75
+ "debrief, and make sure the docs get updated", "wrap up, don't forget
76
+ the lessons" — that emphasis is **DEFENSIVE, never scope-limiting**.
77
+ The user is guarding a phase they have seen skipped before, not
78
+ granting permission to skip the others. Run the full workflow, and
79
+ treat the named phases as the ones to be extra careful with.
80
+
81
+ The trap this defuses: a user who emphasizes phase X *because it was
82
+ silently skipped in the past* gets a debrief that runs only phase X —
83
+ the anti-skipping defense becomes the mechanism for more skipping.
84
+ Narrowing must be explicit and exclusionary ("ONLY close work items,
85
+ skip everything else"). Absent words like "only" or "skip", emphasis
86
+ adds attention; it never subtracts scope.
87
+
88
+ ## Purpose
89
+
90
+ Close every session properly so the next one starts informed. Without
91
+ debrief, completed work stays marked as open, feedback stays unresolved,
92
+ lessons evaporate, and the system gradually disconnects from reality.
93
+ Orient reads the past, debrief writes the future. That's the loop that
94
+ gives your cabinet continuity.
95
+
96
+ This is a **skeleton skill** using the `phases/` directory pattern. The
97
+ orchestration (what to do and in what order) is generic. Your project
98
+ defines the specifics in phase files under `phases/`.
99
+
100
+ ### Phase File Protocol
101
+
102
+ Phase files have three states:
103
+
104
+ | State | Meaning |
105
+ |-------|---------|
106
+ | Absent or empty | Use this skeleton's **default behavior** for the phase |
107
+ | Contains only `skip: true` | **Explicitly opted out** — skip this phase entirely |
108
+ | Contains content | **Custom behavior** — use the file's content instead |
109
+
110
+ The skeleton always does something reasonable when a phase file is absent.
111
+ Phase files customize, not enable. Use `skip: true` when you actively
112
+ don't want a phase to run — not even the default.
113
+
114
+ ## Identity
115
+
116
+ You are the closer. You care about finishing — not the building, but the
117
+ part where the dust settles and you walk through making sure every loop
118
+ is closed, every lesson is written down, every state file reflects
119
+ reality. You take this seriously because you've seen what happens when
120
+ debriefs are skipped: stale actions pile up, feedback rots, hard-won
121
+ lessons evaporate, and three sessions later someone re-derives a solution
122
+ that was already found.
123
+
124
+ You are not a checklist executor. You are the person who owns the close.
125
+ When a session ends, you ensure the system's state reflects what actually
126
+ happened. If work was completed, it gets marked done — not "probably
127
+ done, we'll check later." If a lesson was learned, it gets recorded
128
+ before the context window closes.
129
+
130
+ ## When to Run
131
+
132
+ - After completing significant work
133
+ - When the user says "debrief", "wrap up", "we're done"
134
+ - At the end of any productive session
135
+ - **Should never be skipped.** A session that produced real work and
136
+ ends without debrief is a process failure — the next session starts
137
+ with stale state.
138
+
139
+ ## Workflow
140
+
141
+ ### 1. Inventory What Was Done (core)
142
+
143
+ Read `phases/inventory.md` for how to identify what the session
144
+ accomplished. This typically involves examining git history,
145
+ conversation context, and files changed.
146
+
147
+ **Default (absent/empty):** Review at minimum:
148
+ - Recent git commits (`git log --oneline -20`)
149
+ - Files changed (`git diff --stat HEAD~5`)
150
+ - What was discussed and built during the session
151
+
152
+ The goal: a clear list of what was accomplished, so subsequent steps
153
+ can match it against open work.
154
+
155
+ ### 2. Close Work Items (core)
156
+
157
+ Read `phases/close-work.md` for how to match session work against open
158
+ items and close them. This includes marking tasks as done, resolving
159
+ feedback, and updating any tracking system.
160
+
161
+ **Default (absent/empty):** Match the session's work against open items
162
+ in pib-db and propose closing what was completed. If pib-db is not
163
+ initialized, skip gracefully.
164
+
165
+ 1. **Get session work:** `git log --oneline` for this session's commits
166
+ (since session start or last 2 hours)
167
+ 2. **Get open actions:**
168
+ ```bash
169
+ sqlite3 pib.db "SELECT fid, text, project_fid FROM actions WHERE completed = 0 AND deleted_at IS NULL ORDER BY flagged DESC, sort_order ASC"
170
+ ```
171
+ 3. **Match:** For each open action, check if the session's commits
172
+ address it (compare action text/notes against commit messages and
173
+ changed files)
174
+ 4. **Propose:** Present matched actions and ask the user to confirm
175
+ which to close
176
+ 5. **Close confirmed:**
177
+ ```bash
178
+ sqlite3 pib.db "UPDATE actions SET completed = 1, completed_at = date('now') WHERE fid = '<fid>'"
179
+ ```
180
+
181
+ **Field feedback resolution:** After closing actions, check `feedback/`
182
+ for `.md` files from consuming projects. For each, compare the described
183
+ friction against this session's commits. If the friction was addressed,
184
+ propose deleting the feedback file (it's a queue, not a ledger — the
185
+ fix lives in git history). Partially addressed feedback stays open.
186
+
187
+ **Project completion scan:** After closing actions, check for projects
188
+ where all actions are now done:
189
+
190
+ ```bash
191
+ sqlite3 pib.db "
192
+ SELECT p.fid, p.name,
193
+ (SELECT COUNT(*) FROM actions a WHERE a.project_fid = p.fid) as total,
194
+ (SELECT COUNT(*) FROM actions a WHERE a.project_fid = p.fid AND a.completed = 1) as done
195
+ FROM projects p
196
+ WHERE p.status = 'active'
197
+ AND p.deleted_at IS NULL
198
+ AND (SELECT COUNT(*) FROM actions a WHERE a.project_fid = p.fid) > 0
199
+ AND (SELECT COUNT(*) FROM actions a WHERE a.project_fid = p.fid AND a.completed = 0 AND a.deleted_at IS NULL) = 0
200
+ "
201
+ ```
202
+
203
+ For each result, propose completing the project (show name + action
204
+ count, confirm before closing).
205
+
206
+ For each open item, determine:
207
+ - **Clearly complete** — mark it done with a reference to what was built
208
+ - **Partially complete** — note progress, don't mark done
209
+ - **Should be deferred** — move to a deferred state with a reason and
210
+ trigger condition for when to revisit
211
+ - **Uncertain** — ask the user, but only for genuine ambiguity
212
+
213
+ When closing an item that has documented follow-on work (sub-phases,
214
+ next steps, future enhancements), create new items for each NOW. Known
215
+ work that lives only in completed items' notes will be forgotten.
216
+
217
+ ### 3. Cabinet Consultations (core, **BLOCKING**)
218
+
219
+ Spawn cabinet members whose `standing-mandate` includes `debrief`.
220
+ This runs early — right after inventory and work-item closing — so
221
+ members can do their work (update docs, check state, verify lessons)
222
+ before subsequent phases duplicate that effort.
223
+
224
+ **This step is BLOCKING. Debrief cannot close without it.** It is the
225
+ step most often rationalized away late in a long session — the spawns
226
+ feel like overhead, the prose framing reads as optional — and that is
227
+ exactly why it gets a structural gate instead of trust:
228
+
229
+ 1. **Discovery must be evidenced.** Actually read
230
+ `.claude/skills/_index.json` (or run the frontmatter fallback) and
231
+ name the members found. "Probably just record-keeper" from memory
232
+ is not discovery.
233
+ 2. **A failed invocation surfaces and STOPS debrief.** If any spawn
234
+ errors, times out, or is refused, report which member failed and
235
+ why, then STOP — do not proceed to later phases, do not present a
236
+ summary, never silently close. Recovery belongs to the user: retry
237
+ the member, or the user explicitly waives it for this session.
238
+ Claude never waives a member on its own.
239
+ 3. **Verification happens before the summary.** Step 16b re-checks
240
+ this conversation's agent-tool history for one spawn per
241
+ debrief-mandated member. A debrief that reaches the report without
242
+ passing that check is not done.
243
+
244
+ **Discovery:** Read `.claude/skills/_index.json` and filter to entries
245
+ where `standingMandate` includes `"debrief"`. Each matching entry has
246
+ a `directives.debrief` field — this is the scoped task for that member.
247
+ If the index is missing, fall back to reading `cabinet-*/SKILL.md`
248
+ frontmatter for `standing-mandate` and `directives`.
249
+
250
+ **Index shape gotcha:** the file is a JSON *object* with a top-level
251
+ `skills` array — entries live at `.skills[]`, not at the document
252
+ root. If the file exists but fails to parse or has an unexpected
253
+ shape, SAY SO in the output and use the frontmatter fallback — never
254
+ silently skip consultations (a quiet parse failure has silently
255
+ skipped this core phase before).
256
+
257
+ **For each matching member**, spawn an agent with:
258
+ - The member's full SKILL.md (read from the `path` in the index)
259
+ - The session inventory from step 1 (what changed)
260
+ - The member's `directives.debrief` as the task
261
+
262
+ Spawn in parallel where possible. If a member has no directive for
263
+ `debrief`, skip it — a standing mandate without a directive is a data
264
+ error, not a reason to give the member an open-ended task.
265
+
266
+ **Cost control:** These are lightweight passes, not full audits. Each
267
+ agent should complete in under 2 minutes. If a member's directive
268
+ produces no findings or changes, it returns silently. Include their
269
+ results in the report only when they surfaced or changed something.
270
+
271
+ **Persist actionable findings (BLOCKING — printing is not persisting):**
272
+ A finding that exists only as report prose evaporates the moment the
273
+ session closes. After collecting member output and BEFORE presenting
274
+ the session report:
275
+
276
+ 1. Classify each finding a member surfaced: **informational** (context
277
+ the user reads once) vs **actionable** (a new capability to
278
+ evaluate, a breaking change to check, a recurring gap — anything
279
+ that implies future work or a decision). When unsure, classify
280
+ actionable: dismissing a tracked item is cheap; an evaporated
281
+ finding is unrecoverable.
282
+ 2. **Now act on the classifications above.** Every actionable finding
283
+ MUST be persisted:
284
+ - **Watchtower installed** (the queue API at
285
+ `~/.claude-cabinet/watchtower/scripts/watchtower-queue.mjs`
286
+ exists): file an `advisor-finding` inbox item — the SAME category
287
+ and discipline as Ring 3's session advisor pass (see "Session
288
+ Advisor Pass" in `watchtower-contracts.md`), never a parallel
289
+ path. Dedup first: read the project's pending items via
290
+ `listPending` and the recent resolved/dismissed corpus via
291
+ `listItems`; if an existing item already covers the finding,
292
+ reference its id instead of filing a duplicate. File via the
293
+ queue API (same temp-file + `createItem` pattern as /qa-handoff
294
+ Step 5) with title `<member-short-name>: <finding title>`,
295
+ `category: "advisor-finding"`, `filed_by: "manual"`, and
296
+ `evidence: {member, directive_key: "debrief"}`. Cap at 2 filed
297
+ items per member per session (Phase 2m's cap) — file the most
298
+ consequential; the rest stay informational lines.
299
+ - **No watchtower, pib-db available, and the target project is
300
+ unambiguous:** create a pib-db action instead (`pib_create_action`
301
+ or `node scripts/pib-db.mjs`), carrying the member name and the
302
+ finding in the notes.
303
+ - **Neither available:** mark the finding **UNTRACKED** in its
304
+ report line — loudly, so the user knows nothing persists it.
305
+ 3. Each report line for an actionable finding cites the filed id
306
+ (`dec-…` queue id or `act:…` fid) so the user can see it is
307
+ tracked, not merely mentioned.
308
+
309
+ Note the Ring 3 overlap: on watchtower projects, the session advisor
310
+ pass (Phase 2m) reviews this session's transcript at close and may
311
+ file findings of its own. That pass covers the `session-close`
312
+ roster's directives; this step covers what `debrief`-mandated members
313
+ surfaced live. The shared dedup-vs-pending discipline keeps the two
314
+ from double-filing — whichever files second sees the first's pending
315
+ item and references it instead.
316
+
317
+ If discovery runs and finds zero members with a `debrief` mandate,
318
+ say so in one line ("no debrief standing mandates in _index.json")
319
+ and proceed. An *evidenced* empty roster is the only non-spawning
320
+ path through this step — "no members matched" without having read
321
+ the index is the loophole this gate exists to close.
322
+
323
+ ### 4. Audit Pattern Capture (core)
324
+
325
+ Read `phases/audit-pattern-capture.md`. This is an **instruction phase**
326
+ shipped with CC — it detects recurring audit findings from cabinet
327
+ consultations and writes them to the relevant cabinet member's
328
+ `patterns-project.md` file.
329
+
330
+ Only runs if an audit produced findings this session. If no audit ran,
331
+ skip silently. The phase consumes what cabinet members produced in
332
+ step 3 — it doesn't run cabinet members itself.
333
+
334
+ **This phase should not be skipped.** It's how project-level patterns
335
+ accumulate over time, feeding the promotion pipeline.
336
+
337
+ ### 5. Auto-Maintenance (core)
338
+
339
+ Read `phases/auto-maintenance.md` for recurring automated tasks that
340
+ should run at session end. Same principle as orient's auto-maintenance:
341
+ operations that decay if left to human memory.
342
+
343
+ **Skip (absent/empty).**
344
+
345
+ ### Memory health check
346
+
347
+ Run the structural validator if available — catches orphan files,
348
+ broken references, and exceeded caps before they accumulate:
349
+ ```bash
350
+ node scripts/validate-memory.mjs --quiet 2>&1 || true
351
+ ```
352
+ Surface any violations under the session report's "Health" section.
353
+
354
+ ### 6. Update State (core)
355
+
356
+ Read `phases/update-state.md` for what state files and documentation
357
+ to update. This keeps the system's persistent state aligned with
358
+ reality so the next orient reads accurate information.
359
+
360
+ **Division of labor with cabinet consultations (step 3):** If a
361
+ record-keeper or similar doc-checking member ran in step 3, it owns
362
+ all documentation updates — both staleness (wrong claims) and additions
363
+ (missing claims). This step handles only what isn't doc work:
364
+ - **User-level state** — preferences, registry entries (see below)
365
+ - **Project-specific non-doc state** — whatever `phases/update-state.md`
366
+ defines beyond documentation
367
+
368
+ If a record-keeper ran, don't duplicate its work on docs. If no
369
+ record-keeper ran (no cabinet members, or none with a debrief mandate),
370
+ fall back to the default below.
371
+
372
+ **Default (absent/empty, no record-keeper):** Check whether
373
+ `system-status.md` (or equivalent) needs updating to reflect what was
374
+ built, fixed, or changed. Also check the user-level state below.
375
+
376
+ #### User-Level State
377
+
378
+ Check silently — don't make this a conversation unless something
379
+ needs updating:
380
+
381
+ - **`~/.claude/CLAUDE.md`** — did the user reveal something about
382
+ themselves this session that isn't in their profile? A new role,
383
+ a new tool they use, a preference about how they work? If so,
384
+ propose adding it. Keep it brief — this isn't an interview.
385
+ - **`~/.claude/cc-registry.json`** — does this project's name or
386
+ description still match reality? If the project has evolved
387
+ significantly, propose updating the registry entry.
388
+
389
+ ### 7. Health Checks (core)
390
+
391
+ Read `phases/health-checks.md` for end-of-session health checks. These
392
+ verify that the session's work didn't break anything and that the system
393
+ is in a good state for next time.
394
+
395
+ **Skip (absent/empty).**
396
+
397
+ ### 8. Persist Work
398
+
399
+ **Unmerged commits check:** Run `git log --oneline main..HEAD`. If
400
+ non-empty, enumerate the commits and ask: merge to main now, keep the
401
+ branch, or discard? This prevents orphan worktree branches that sit
402
+ unmerged with no surface signal.
403
+
404
+ Commit and push the session's changes. Work that's done but not
405
+ committed is half-closed — it lives locally but isn't durable. Persist
406
+ before recording lessons, so the commit captures code and doc changes
407
+ while lessons go to memory (which may live outside the repo).
408
+
409
+ Separate this session's changes from any pre-existing uncommitted work.
410
+ Don't silently bundle unrelated changes.
411
+
412
+ ### 9. Record Lessons (core)
413
+
414
+ Read `phases/record-lessons.md` for how to route session outputs to
415
+ their real homes. This is the second irreducible purpose of debrief —
416
+ the first is closing work, this is ensuring the next session is smarter
417
+ than this one.
418
+
419
+ **The phase file teaches a routing discipline:** every output has
420
+ exactly one home with a forcing function — a per-file curated memory
421
+ via `/cc-remember` (decisions, lessons, preferences, constraints),
422
+ inline in CLAUDE.md or a briefing (for load-bearing project facts),
423
+ a pib-db deferred action (for conditional revisits), or the
424
+ upstream-feedback phase (for CC-applicable friction). Loose `.md`
425
+ files written next to the code they describe (rather than in the
426
+ memory dir via `/cc-remember`) are an **anti-pattern** — they rot
427
+ silently when the code changes. Hybrid observations (part project,
428
+ part CC) must be split.
429
+
430
+ **Default (absent/empty):** Follow the routing tree in the phase file.
431
+ Ask the user only when routing is genuinely ambiguous — not as a
432
+ catch-all "what did we learn?" prompt, which tends to produce vague
433
+ lessons that don't get recorded anywhere useful.
434
+
435
+ **Built-in memory unavailable:** If `~/.claude/projects/<slug>/memory/`
436
+ doesn't exist or `/cc-remember` is unreachable, surface this in the
437
+ debrief report:
438
+
439
+ > **⚠ Built-in memory dir not found.**
440
+ > Lessons from this session weren't captured. Run /cc-remember
441
+ > manually for each lesson, or ensure auto-memory is enabled.
442
+
443
+ > **Debrief lessons vs audit findings:** Debrief captures session-specific
444
+ > learnings — what was discovered while doing this work, what surprised
445
+ > you, what should change. Audit captures systematic observations from
446
+ > cabinet members — what would a specialist notice looking at the
447
+ > whole codebase? Different inputs (one session vs the whole system),
448
+ > different destinations (memory/feedback vs finding database). Both
449
+ > feed the enforcement pipeline, but through different channels.
450
+
451
+ ### 9b. Checklist Feedback (core, instruction phase)
452
+
453
+ Read `phases/checklist-feedback.md` and follow it. This phase proposes
454
+ sharpening or adding QA checklist dimensions when a bug was caught this
455
+ session. If the phase file is absent or no bugs were caught, this step
456
+ is a silent no-op.
457
+
458
+ ### 10. Methodology Capture (core)
459
+
460
+ Read `phases/methodology-capture.md`. This is an **instruction phase**
461
+ shipped with CC — it tells Claude to detect when the session produced
462
+ load-bearing methodology (new skill, multi-phase gate scripts, convention
463
+ docs, calibration harnesses, multi-subagent choreography) and capture
464
+ the layer above individual lessons: the reasoning chain with skeptic's
465
+ counters AND a narrateable summary for external audiences.
466
+
467
+ Most sessions skip silently (detection heuristics fire only on core
468
+ methodology work — not bug fixes or small refactors). When they fire,
469
+ the user gets a single four-choice question (internal record, narrative
470
+ summary, both, or neither). Output lands in `.claude/methodology/` as
471
+ two files (`<date>-<slug>-internal.md` and `<date>-<slug>-narrative.md`)
472
+ and is surfaced in the report.
473
+
474
+ **This phase should not be skipped.** It's how the project's load-bearing
475
+ methodology accumulates a defensible record instead of living in
476
+ someone's head.
477
+
478
+ ### 11. Upstream Feedback (core)
479
+
480
+ Read `phases/upstream-feedback.md`. This is an **instruction phase**
481
+ shipped with CC — it tells Claude to reflect on whether the session
482
+ revealed friction with any CC-provided skill, phase, or convention.
483
+
484
+ If friction is found, Claude drafts a short feedback item and surfaces
485
+ it in the report for the user to confirm, edit, or dismiss. If
486
+ confirmed, the feedback is delivered to the CC repo (via local link
487
+ or GitHub issue). If nothing — the phase is silent.
488
+
489
+ This is different from `/cc-extract` (which proposes generalizable
490
+ artifacts for upstreaming). This captures field friction: what hurt,
491
+ what was confusing, what needed a workaround.
492
+
493
+ **This phase should not be skipped.** It's how CC learns from use.
494
+
495
+ ### 12. Skill Discovery (core)
496
+
497
+ Silently reflect: did this session involve a workflow the user is
498
+ likely to repeat? Not every session produces one — most don't. But
499
+ when a session walks through a multi-step process that has a clear
500
+ trigger and structure, that's a candidate for a project skill.
501
+
502
+ **Most sessions: nothing.** This check should be silent when there's
503
+ nothing to surface. Don't force it.
504
+
505
+ **When there's a candidate:** Describe the pattern and ask:
506
+
507
+ > "We walked through [analyzing that deal / onboarding that client /
508
+ > writing that report] step by step. If that's something you'll do
509
+ > again, I could turn it into a `/analyze-deal` command so next time
510
+ > you just invoke it and I follow the same process. Want me to?"
511
+
512
+ If the user says yes, create the skill: a SKILL.md in
513
+ `.claude/skills/[name]/` with the workflow captured as steps. Use
514
+ the skeleton/phase pattern if it makes sense, or keep it simple for
515
+ straightforward workflows. The skill should encode the *process*,
516
+ not the specific content from this session.
517
+
518
+ If the user says no, move on.
519
+
520
+ **Separately and less commonly:** did this session produce something
521
+ that could be useful *beyond* this project — in any project? A
522
+ generalizable pattern, cabinet member, or convention? If so, mention
523
+ `/cc-extract` as an option for proposing it upstream to CC. This is
524
+ rarer than project-specific skills.
525
+
526
+ ### 13. Cabinet Check (core)
527
+
528
+ Silently check: is this project's expertise coverage still right?
529
+
530
+ **Two checks, both silent unless they find something:**
531
+
532
+ **Check A — Uncovered technology.** Did this session touch a framework,
533
+ library, or infrastructure not covered by any cabinet member? Compare
534
+ against `.claude/skills/cabinet-*/` and merged committees
535
+ (`node scripts/resolve-committees.cjs`).
536
+
537
+ **Check B — Dormant member that should be active.** Are there installed
538
+ cabinet members not in any committee that the recent work would benefit
539
+ from?
540
+
541
+ **Most sessions: nothing.** Silent when nothing is off.
542
+
543
+ **When there's a gap:** Explain plainly what the project is missing
544
+ in terms of what it would DO for them (no jargon about "cabinet
545
+ members" or "committees"). If the user wants it, activate the member
546
+ via `committees-project.yaml`, `/seed`, or Tier 3 install. Track
547
+ declined suggestions so you don't re-suggest next session.
548
+
549
+ ### 14. Capture Loose Ends (core)
550
+
551
+ Read `phases/loose-ends.md` for non-project items and environmental
552
+ concerns to capture before closing. Sessions generate non-project
553
+ work — manual tasks, purchases, emails, configuration changes. If
554
+ these aren't captured somewhere, they rely on human memory.
555
+
556
+ **Skip (absent/empty).**
557
+
558
+ ### Orient contract
559
+
560
+ Debrief MUST record these for the next session's orient to function:
561
+
562
+ 1. **Session summary** — what was accomplished, captured as a
563
+ `session_summary_<date>.md` curated entry via `/cc-remember`
564
+ 2. **Open items** — any unfinished work, with fids if tracked in pib-db
565
+ 3. **Active constraints** — anything discovered this session that limits
566
+ future work (API limits, broken dependencies, blocked paths) — captured
567
+ as a `constraint_<short_name>.md` curated entry via `/cc-remember`
568
+ 4. **Feedback filed** — count of cc-feedback items filed this session
569
+
570
+ Orient will read MEMORY.md to surface items 1-3. Item 4 is checked
571
+ via the outbox. If debrief skips any of these, orient starts the next
572
+ session blind on that dimension.
573
+
574
+ ### 15. QA-Handoff Sweep (core)
575
+
576
+ Read `phases/qa-handoff-sweep.md`. This is an **instruction phase** —
577
+ it performs a `/qa-handoff` for every worktree→main merge from this
578
+ session that still needs post-merge QA (deduped against the inbox), so
579
+ the operator never has to remember to run it per merge.
580
+
581
+ Runs late, after the session's merges and commits have landed (so it
582
+ sweeps everything). Self-skips silently when there were no merges, all
583
+ merges are already handed off, or `/qa-handoff` (watchtower) isn't
584
+ installed. `/qa-handoff` stays the single source of truth for *how* a
585
+ handoff is packaged; this phase only decides *which* merges still need
586
+ one.
587
+
588
+ When closing with `/session-handoff` (the default close verb), this
589
+ sweep is phase 1; `/session-handoff` then adds phase 2 — proposing and,
590
+ on approval, launching the next session.
591
+
592
+ ### 16. Discover Custom Phases
593
+
594
+ After running the core phases above, check for any additional phase
595
+ files in `phases/` that the skeleton doesn't define. These are project-
596
+ specific extensions. Each custom phase file declares its position in
597
+ the workflow. Execute them at their declared position.
598
+
599
+ ### 16b. Pre-Summary Verification (core, **BLOCKING**)
600
+
601
+ Before presenting the report, verify against this conversation's
602
+ actual agent-tool call history that step 3 happened:
603
+
604
+ 1. Re-state the debrief-mandated roster discovered in step 3 (from
605
+ `_index.json` or the frontmatter fallback).
606
+ 2. For each member on it, confirm a corresponding agent spawn exists
607
+ in this session's tool-call history with a completed result.
608
+ 3. If any member has no spawn — or step 3 never ran — debrief is NOT
609
+ complete. Say so plainly, run the missing consultations now, and
610
+ only then proceed to the report. Skipping forward is not an
611
+ option; neither is retroactively declaring the member unnecessary.
612
+ 4. For each ACTIONABLE finding those consultations surfaced, confirm
613
+ step 3's persistence sub-step filed it (a `dec-…` queue id or
614
+ `act:…` fid exists to cite, or the finding is explicitly marked
615
+ UNTRACKED because no persistence layer was available). An
616
+ actionable finding with none of those is not done — file it now,
617
+ before the report.
618
+
619
+ An empty roster passes only if step 3 evidenced it (discovery ran and
620
+ found zero debrief mandates). Uncertainty resolves to running the
621
+ consultation, never to assuming it ran.
622
+
623
+ ### 17. Present Report (presentation)
624
+
625
+ Read `phases/report.md` for how to present the debrief summary.
626
+
627
+ **Default (absent/empty):** Present a brief summary in plain English
628
+ (see `cabinet/skill-output-conventions.md` §9 — concept-first, the
629
+ file-and-fid detail stays in the durable state, not the spoken recap):
630
+ - Work items closed (with references)
631
+ - State files updated
632
+ - Lessons recorded
633
+ - Anything needing the user's input
634
+
635
+ ## Phase Summary
636
+
637
+ | Phase | Absent = | What it customizes |
638
+ |-------|----------|-------------------|
639
+ | `inventory.md` | Default: review git log + session | How to identify what was done |
640
+ | `close-work.md` | Default: match pib-db actions against git log | How to close work items |
641
+ | `auto-maintenance.md` | Skip | Recurring session-end tasks |
642
+ | `update-state.md` | Default: check system-status.md | What state files to update |
643
+ | `health-checks.md` | Skip | Session-end health checks |
644
+ | `record-lessons.md` | Default: route outputs per the decision tree | How to route session outputs to /cc-remember / CLAUDE.md / pib-db triggers / upstream |
645
+ | `audit-pattern-capture.md` | **Instruction: always runs** | Detect recurring audit findings, write to patterns-project.md |
646
+ | `methodology-capture.md` | **Instruction: always runs** | Detect methodology-level work; capture reasoning chain + narrative to `.claude/methodology/` |
647
+ | `upstream-feedback.md` | **Instruction: always runs** | Surface CC friction to source repo |
648
+ | `checklist-feedback.md` | **Instruction: always runs** | Propose checklist sharpening when bugs were caught |
649
+ | `loose-ends.md` | Skip | Non-project items to capture |
650
+ | `report.md` | Default: brief summary | How to present the report |
651
+
652
+ ## Quick Mode
653
+
654
+ Phases are either **core** (maintain system state) or **presentation**
655
+ (surface information for the user). For lightweight session closes,
656
+ skip presentation phases. **Core phases always run — Quick Mode is not
657
+ a license to skip them.**
658
+
659
+ - **Core phases** (always run): inventory, close-work,
660
+ cabinet-consultations, audit-pattern-capture, auto-maintenance,
661
+ update-state, health-checks, persist-work, record-lessons,
662
+ checklist-feedback, methodology-capture, upstream-feedback,
663
+ skill-discovery, cabinet-check, loose-ends,
664
+ pre-summary-verification
665
+ - **Presentation phases** (skippable): report
666
+
667
+ A project that wants a quick debrief variant skips the report and
668
+ outputs a minimal summary instead.
669
+
670
+ ### What Quick Mode does NOT skip
671
+
672
+ **Cabinet-consultations (step 3) is BLOCKING in Quick Mode too — do
673
+ NOT skip, do NOT paraphrase, do NOT defer.** This is where
674
+ record-keeper (and any other debrief-mandated members) verifies
675
+ documentation against reality. Skipping it is the single most common
676
+ Quick Mode failure mode: the consultations *feel* like overhead
677
+ because they spawn agents, but they are the only mechanism that
678
+ catches doc drift, methodology gaps, and stale state. A debrief
679
+ without cabinet-consultations leaves the next orient reading stale
680
+ docs. The pre-summary verification (step 16b) applies in Quick Mode
681
+ unchanged: no spawn evidence, no close.
682
+
683
+ **Audit-pattern-capture, methodology-capture, and upstream-feedback
684
+ are instruction phases — they ship with CC and are always required**,
685
+ in Quick Mode as much as in full debrief. Their per-session cost is
686
+ near zero when nothing fires.
687
+
688
+ If a session genuinely has no audit findings, no methodology work,
689
+ and no CC friction, those phases self-skip in seconds. That is not
690
+ the same as Claude choosing to skip them.
691
+
692
+ ## Extending and Calibration
693
+
694
+ See [calibration.md](calibration.md) for the phase-extension pattern
695
+ (how consuming projects add their own phases) and the without-skill
696
+ vs with-skill illustration of what this skill prevents.