create-claude-cabinet 0.46.0 → 0.48.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 (189) hide show
  1. package/README.md +3 -6
  2. package/lib/CLAUDE.md +218 -0
  3. package/lib/cli.js +397 -382
  4. package/lib/copy.js +182 -6
  5. package/lib/db-setup.js +122 -17
  6. package/lib/engagement-server-setup.js +1 -17
  7. package/lib/engagement-setup.js +1 -1
  8. package/lib/installer-gate.js +135 -0
  9. package/lib/metadata.js +51 -2
  10. package/lib/modules.js +292 -0
  11. package/lib/mux-setup.js +1 -17
  12. package/lib/project-context.js +16 -96
  13. package/lib/settings-merge.js +194 -13
  14. package/lib/site-audit-setup.js +23 -7
  15. package/lib/verify-setup.js +20 -9
  16. package/lib/watchtower-setup.js +23 -7
  17. package/package.json +1 -1
  18. package/templates/CLAUDE.md +959 -0
  19. package/templates/briefing/_briefing-template.md +6 -11
  20. package/templates/cabinet/advisories-state-schema.md +1 -1
  21. package/templates/cabinet/checklist-stats-schema.md +15 -1
  22. package/templates/cabinet/eval-protocol.md +27 -10
  23. package/templates/cabinet/memory-lifecycle-contract.md +135 -0
  24. package/templates/cabinet/pib-db-access.md +13 -0
  25. package/templates/cabinet/watchtower-contracts.md +453 -0
  26. package/templates/cabinet/worktree-invocation-contract.md +111 -0
  27. package/templates/engagement/OVERVIEW.md +12 -0
  28. package/templates/engagement/__tests__/checklist-visibility.test.mjs +76 -0
  29. package/templates/engagement/__tests__/engagement.test.mjs +177 -2
  30. package/templates/engagement/__tests__/invoice-doc.test.mjs +195 -0
  31. package/templates/engagement/engagement-checklist.mjs +26 -2
  32. package/templates/engagement/engagement-preview.mjs +100 -0
  33. package/templates/engagement/engagement-schema.md +248 -6
  34. package/templates/engagement/engagement.mjs +391 -11
  35. package/templates/engagement/pib-db-patches/pib-db-lib.mjs +49 -9
  36. package/templates/engagement/pib-db-patches/pib-db-mcp-server.mjs +5 -44
  37. package/templates/engagement/pib-db-patches/pib-db-schema.sql +1 -1
  38. package/templates/engagement/pib-db-patches/pib-db.mjs +9 -3
  39. package/templates/engagement/sql-constants.mjs +9 -1
  40. package/templates/engagement-server/__tests__/cross-tenant-auth.test.mjs +87 -0
  41. package/templates/engagement-server/server.mjs +65 -40
  42. package/templates/hooks/action-completion-gate.sh +19 -3
  43. package/templates/hooks/action-quality-gate.sh +10 -0
  44. package/templates/hooks/memory-index-guard.sh +17 -11
  45. package/templates/hooks/skill-telemetry.sh +10 -5
  46. package/templates/hooks/skill-tool-telemetry.sh +11 -5
  47. package/templates/hooks/watchtower-session-start.sh +24 -2
  48. package/templates/mcp/pib-db.json +1 -4
  49. package/templates/mux/bin/mux +8 -1
  50. package/templates/mux/config/help.txt +1 -0
  51. package/templates/rules/acknowledge-when-corrected.md +33 -0
  52. package/templates/rules/enforcement-pipeline.md +0 -12
  53. package/templates/rules/maintainability.md +11 -0
  54. package/templates/rules/memory-capture.md +26 -4
  55. package/templates/rules/plan-before-bulk-or-irreversible-actions.md +48 -0
  56. package/templates/rules/verify-before-asserting.md +79 -0
  57. package/templates/scripts/__tests__/ahead-check-origin.test.mjs +355 -0
  58. package/templates/scripts/__tests__/api-usage-idle-gate.test.mjs +81 -0
  59. package/templates/scripts/__tests__/batch-disposition.test.mjs +98 -0
  60. package/templates/scripts/__tests__/bsql-loader-verify.test.mjs +47 -0
  61. package/templates/scripts/__tests__/claude-churn-authored.test.mjs +90 -0
  62. package/templates/scripts/__tests__/cross-ring-reader.test.mjs +505 -0
  63. package/templates/scripts/__tests__/dx-captures-briefing.test.mjs +169 -0
  64. package/templates/scripts/__tests__/hook-runner.test.mjs +247 -0
  65. package/templates/scripts/__tests__/inbox-assessment.test.mjs +341 -0
  66. package/templates/scripts/__tests__/memory-reachability.test.mjs +150 -0
  67. package/templates/scripts/__tests__/narrative-corpus.test.mjs +247 -0
  68. package/templates/scripts/__tests__/phase-shim.test.mjs +112 -0
  69. package/templates/scripts/__tests__/qa-handoff-merge-state.test.mjs +162 -0
  70. package/templates/scripts/__tests__/resolve-cli.test.mjs +314 -0
  71. package/templates/scripts/__tests__/ring-state-ownership.test.mjs +120 -0
  72. package/templates/scripts/__tests__/ring1-content-detector.test.mjs +168 -0
  73. package/templates/scripts/__tests__/ring1-flagged-actions.test.mjs +135 -0
  74. package/templates/scripts/__tests__/ring1-pib-error-surfacing.test.mjs +69 -0
  75. package/templates/scripts/__tests__/ring1-script-drift.test.mjs +126 -0
  76. package/templates/scripts/__tests__/ring1-stale-open-counts.test.mjs +143 -0
  77. package/templates/scripts/__tests__/ring2-queue-reader.test.mjs +80 -0
  78. package/templates/scripts/__tests__/ring2-recall-canary.test.mjs +150 -0
  79. package/templates/scripts/__tests__/ring2-roster-review.test.mjs +311 -0
  80. package/templates/scripts/__tests__/ring3-chunk-merge.test.mjs +122 -0
  81. package/templates/scripts/__tests__/ring3-close-lenses.test.mjs +359 -0
  82. package/templates/scripts/__tests__/ring3-dedup.test.mjs +92 -12
  83. package/templates/scripts/__tests__/ring3-memory-titles.test.mjs +187 -0
  84. package/templates/scripts/__tests__/ring3-novelty-rescue.test.mjs +148 -0
  85. package/templates/scripts/__tests__/ring3-recent-slice.test.mjs +101 -0
  86. package/templates/scripts/__tests__/ring3-thread-capture.test.mjs +213 -0
  87. package/templates/scripts/__tests__/ring4-reconcile.test.mjs +393 -0
  88. package/templates/scripts/__tests__/shared-thread-reader.test.mjs +187 -0
  89. package/templates/scripts/__tests__/suppression-ledger.test.mjs +148 -0
  90. package/templates/scripts/__tests__/verify-backfill.test.mjs +103 -0
  91. package/templates/scripts/__tests__/verify-coverage.test.mjs +80 -0
  92. package/templates/scripts/__tests__/watchtower-snapshot.test.mjs +261 -0
  93. package/templates/scripts/__tests__/watchtower-status-ring4.test.mjs +89 -0
  94. package/templates/scripts/__tests__/watchtower-sync.test.mjs +311 -0
  95. package/templates/scripts/audit-coherence-check.mjs +123 -0
  96. package/templates/scripts/audit-synth.mjs +117 -0
  97. package/templates/scripts/load-triage-history.js +5 -2
  98. package/templates/scripts/merge-findings.js +4 -1
  99. package/templates/scripts/patterns-scope-check.mjs +122 -0
  100. package/templates/scripts/pib-db-lib.mjs +61 -11
  101. package/templates/scripts/pib-db-mcp-server.mjs +7 -45
  102. package/templates/scripts/pib-db-path.mjs +61 -0
  103. package/templates/scripts/pib-db.mjs +7 -3
  104. package/templates/scripts/review-server.mjs +7 -12
  105. package/templates/scripts/triage-server.mjs +7 -8
  106. package/templates/scripts/validate-memory.mjs +214 -16
  107. package/templates/scripts/watchtower-advisories.mjs +7 -3
  108. package/templates/scripts/watchtower-build-context.mjs +192 -8
  109. package/templates/scripts/watchtower-cross-ring-reader.mjs +714 -0
  110. package/templates/scripts/watchtower-hook-runner.mjs +422 -0
  111. package/templates/scripts/watchtower-inbox-assessment.mjs +706 -0
  112. package/templates/scripts/watchtower-lib.mjs +555 -8
  113. package/templates/scripts/watchtower-narrative-corpus.mjs +385 -0
  114. package/templates/scripts/watchtower-phase-shim.mjs +171 -0
  115. package/templates/scripts/watchtower-queue.mjs +341 -3
  116. package/templates/scripts/watchtower-ring1.mjs +481 -81
  117. package/templates/scripts/watchtower-ring2.mjs +748 -80
  118. package/templates/scripts/watchtower-ring3-close.mjs +1147 -167
  119. package/templates/scripts/watchtower-ring4-runner.sh +85 -0
  120. package/templates/scripts/watchtower-ring4.mjs +753 -0
  121. package/templates/scripts/watchtower-routines.mjs +1 -1
  122. package/templates/scripts/watchtower-snapshot.mjs +452 -0
  123. package/templates/scripts/watchtower-status.sh +17 -0
  124. package/templates/scripts/watchtower-sync.mjs +393 -0
  125. package/templates/scripts/work-tracker-server.mjs +26 -22
  126. package/templates/skills/audit/SKILL.md +18 -5
  127. package/templates/skills/audit/phases/structural-checks.md +22 -0
  128. package/templates/skills/briefing/SKILL.md +289 -41
  129. package/templates/skills/cabinet-accessibility/SKILL.md +1 -1
  130. package/templates/skills/cabinet-process-therapist/SKILL.md +28 -0
  131. package/templates/skills/cabinet-security/SKILL.md +11 -0
  132. package/templates/skills/catch-up/SKILL.md +113 -0
  133. package/templates/skills/cc-publish/SKILL.md +89 -18
  134. package/templates/skills/cc-remember/SKILL.md +45 -0
  135. package/templates/skills/close/SKILL.md +107 -0
  136. package/templates/skills/collab-client/SKILL.md +22 -5
  137. package/templates/skills/collab-consultant/SKILL.md +110 -2
  138. package/templates/skills/debrief/SKILL.md +21 -4
  139. package/templates/skills/debrief/phases/audit-pattern-capture.md +13 -0
  140. package/templates/skills/debrief-classic/SKILL.md +696 -0
  141. package/templates/skills/debrief-classic/calibration.md +44 -0
  142. package/templates/skills/debrief-classic/phases/audit-pattern-capture.md +78 -0
  143. package/templates/skills/debrief-classic/phases/auto-maintenance.md +48 -0
  144. package/templates/skills/debrief-classic/phases/checklist-feedback.md +123 -0
  145. package/templates/skills/debrief-classic/phases/close-work.md +163 -0
  146. package/templates/skills/debrief-classic/phases/health-checks.md +54 -0
  147. package/templates/skills/debrief-classic/phases/inventory.md +40 -0
  148. package/templates/skills/debrief-classic/phases/loose-ends.md +52 -0
  149. package/templates/skills/debrief-classic/phases/methodology-capture.md +223 -0
  150. package/templates/skills/debrief-classic/phases/qa-handoff-sweep.md +78 -0
  151. package/templates/skills/debrief-classic/phases/record-lessons.md +177 -0
  152. package/templates/skills/debrief-classic/phases/report.md +59 -0
  153. package/templates/skills/debrief-classic/phases/update-state.md +48 -0
  154. package/templates/skills/debrief-classic/phases/upstream-feedback.md +185 -0
  155. package/templates/skills/debrief-classic/phases/verify-coverage.md +101 -0
  156. package/templates/skills/execute/SKILL.md +71 -6
  157. package/templates/skills/execute/phases/commit-and-deploy.md +8 -0
  158. package/templates/skills/execute-group/SKILL.md +23 -26
  159. package/templates/skills/generate-plan-groups/SKILL.md +20 -0
  160. package/templates/skills/inbox/SKILL.md +177 -31
  161. package/templates/skills/memory/SKILL.md +22 -6
  162. package/templates/skills/orient/SKILL.md +75 -5
  163. package/templates/skills/orient-classic/SKILL.md +770 -0
  164. package/templates/skills/orient-classic/phases/auto-maintenance.md +52 -0
  165. package/templates/skills/orient-classic/phases/briefing.md +53 -0
  166. package/templates/skills/orient-classic/phases/cabinet.md +46 -0
  167. package/templates/skills/orient-classic/phases/checklist-status.md +54 -0
  168. package/templates/skills/orient-classic/phases/context.md +88 -0
  169. package/templates/skills/orient-classic/phases/data-sync.md +35 -0
  170. package/templates/skills/orient-classic/phases/deferred-check.md +55 -0
  171. package/templates/skills/orient-classic/phases/dx-captures.md +53 -0
  172. package/templates/skills/orient-classic/phases/health-checks.md +50 -0
  173. package/templates/skills/orient-classic/phases/verify-backfill.md +109 -0
  174. package/templates/skills/orient-classic/phases/work-scan.md +69 -0
  175. package/templates/skills/pulse/SKILL.md +10 -8
  176. package/templates/skills/qa-drain/SKILL.md +38 -0
  177. package/templates/skills/qa-handoff/SKILL.md +287 -46
  178. package/templates/skills/setup-accounts/SKILL.md +38 -16
  179. package/templates/skills/spring-clean/SKILL.md +1 -1
  180. package/templates/skills/spring-clean/phases/execute-decisions.md +1 -1
  181. package/templates/skills/threads/SKILL.md +4 -0
  182. package/templates/skills/validate/phases/validators.md +127 -0
  183. package/templates/skills/watchtower/SKILL.md +174 -30
  184. package/templates/verify-runtime/CONVENTIONS.md +9 -0
  185. package/templates/verify-runtime/README.md +37 -0
  186. package/templates/watchtower/config.json.template +8 -2
  187. package/templates/workflows/deliberative-audit.js +258 -87
  188. package/templates/workflows/execute-group-complete.js +26 -3
  189. package/templates/workflows/execute-group-implement.js +16 -2
@@ -0,0 +1,223 @@
1
+ # Methodology Capture — Instruction Phase
2
+
3
+ **Position:** After record-lessons, before upstream-feedback.
4
+
5
+ **This is an instruction phase** — it tells Claude when and how to
6
+ capture methodology-level artifacts from a session. It ships with CC
7
+ and should not be deleted or replaced with `skip: true`. If the phase
8
+ file is removed, the behavior described here still applies via the
9
+ default-from-SKILL.md mechanism.
10
+
11
+ ## What this phase does
12
+
13
+ Standard debrief captures individual lessons ("user scope hints are
14
+ defensive signals"), discrete decisions ("used append-only history
15
+ table"), and documentation fixes. It does NOT capture the **reasoning
16
+ chain** or **self-critique layer** behind load-bearing methodology —
17
+ the kind of work where *how you did it* is as important as *what you
18
+ did*.
19
+
20
+ This phase fills that gap when the session's work warrants it. Most
21
+ sessions don't. The phase is gated on detection heuristics so bug
22
+ fixes and small refactors skip silently.
23
+
24
+ ## Test for "core work"
25
+
26
+ Adapted from the source feedback that motivated this phase:
27
+
28
+ > Not every session, but when the work is core to the product's
29
+ > differentiation or legitimacy — the thing the founder would want
30
+ > on a pitch deck, the thing a customer would ask "how do I know
31
+ > this works?" about.
32
+
33
+ If the session produced methodology that could be asked about, defended,
34
+ demonstrated, or replicated — it's core work. If it was routine
35
+ application of existing methodology, it isn't.
36
+
37
+ ## Workflow
38
+
39
+ ### 1. Detect methodology-level signals (silent)
40
+
41
+ Scan the session for any of these signals. Fire only when one or more
42
+ match. Otherwise skip silently and proceed to upstream-feedback.
43
+
44
+ - **New skill created** in `.claude/skills/` or `templates/skills/`
45
+ (including new `phases/*.md` files that define orchestration logic,
46
+ not just content)
47
+ - **Multi-phase pib-db project** with actions named "Phase N…" where
48
+ N ≥ 2 (or equivalent work-tracker multi-phase structure)
49
+ - **Audit artifacts** written to structured run directories
50
+ (e.g., `audit-runs/<timestamp>/`)
51
+ - **Multi-subagent parallel choreography** used during this session
52
+ (two or more agents spawned in a single parallel batch with
53
+ coordinated roles)
54
+ - **Gate scripts with pass/fail thresholds** created this session
55
+ (exit codes, verification-breadcrumbs, blocking-phase markers)
56
+ - **Disposition registers or calibration harnesses** created this
57
+ session (files that record triage outcomes, calibration examples,
58
+ decision rationales for future reference)
59
+ - **New convention docs** under `templates/cabinet/` or equivalent
60
+ reference-docs location that encode cross-skill or cross-project
61
+ invariants
62
+
63
+ Detection should be based on evidence from this session — git diff,
64
+ files written, subagent spawn counts. Do not guess. If ambiguous,
65
+ err toward not-firing (false positives waste the user's attention;
66
+ false negatives only cost one methodology record).
67
+
68
+ ### 2. Ask once (if signals fire)
69
+
70
+ Present the detected signals in a single sentence, then ask a
71
+ four-choice question. Do not ask open-ended questions. Do not batch
72
+ with other debrief prompts.
73
+
74
+ > "This session produced methodology work: [brief list of detected
75
+ > signals — e.g., 'a new skill, a 4-phase project, a gate script'].
76
+ > Capture:
77
+ > (a) **internal critique-edges record** (reasoning chain, skeptic's
78
+ > counters, off-ramps)
79
+ > (b) **narrateable summary** (200-400 words for external audiences)
80
+ > (c) **both**
81
+ > (d) **neither**"
82
+
83
+ If the user says (d), stop silently — the detection fired but the
84
+ user declined. Do not re-prompt next session for the same work.
85
+
86
+ ### 3. Write the requested artifacts
87
+
88
+ Write to `.claude/methodology/YYYY-MM-DD[-slug]-<type>.md` where
89
+ `<type>` is `internal` or `narrative`. Slug is a short phrase derived
90
+ from the session's focus. If the directory doesn't exist, create it.
91
+
92
+ **Path override:** If `phases/methodology-capture.md` in the project
93
+ overrides the default location (e.g., some projects may want
94
+ `docs/methodology/` instead), respect the override.
95
+
96
+ ### 3a. Internal critique-edges record
97
+
98
+ For each significant decision made this session, record:
99
+
100
+ ```markdown
101
+ ### [Decision in one sentence]
102
+
103
+ **Claim:** What we decided and why it's defensible.
104
+
105
+ **Evidence:** What we had in hand — measurements, prior cases,
106
+ documentation, stakeholder input.
107
+
108
+ **Skeptic's critique:** Where a thoughtful reader could press. What
109
+ would a contrarian cabinet member flag? What dismissals might be
110
+ too quick?
111
+
112
+ **Counter:** Our response to the critique — the reason the decision
113
+ still stands despite the pressure.
114
+
115
+ **Off-ramp:** What would change our mind? What observation, metric,
116
+ or shift in constraints would cause us to revisit this?
117
+ ```
118
+
119
+ A session typically has 2-6 significant decisions worth this treatment.
120
+ Not every micro-choice. The test: "would a future session executing
121
+ this work benefit from knowing the skeptic's critique?"
122
+
123
+ ### 3b. Narrateable summary
124
+
125
+ Write 200-400 words, external-audience-friendly. Readable by a
126
+ non-insider. No skill-specific jargon unless inlined with a
127
+ one-phrase gloss.
128
+
129
+ Structure (flexible — adapt to what the work is):
130
+
131
+ - **The problem** (1-2 sentences about the friction or opportunity)
132
+ - **The approach** (what methodology was applied or built)
133
+ - **Specifics and scale** (concrete numbers, files, components — enough
134
+ that a reader can sense the work's weight)
135
+ - **What makes this work** (the load-bearing mechanism, the non-obvious
136
+ insight)
137
+ - **How you'd know it's working** (what metric, signal, or demonstration
138
+ would confirm it)
139
+
140
+ Format so it could be pasted into a pitch deck section, an about page,
141
+ an investor update, a collaborator email, or a customer FAQ.
142
+
143
+ ### 3c. Index the new artifacts (required)
144
+
145
+ These records are version-controlled **project thought-record**, not
146
+ ephemera (see `.claude/rules/artifacts-of-thought.md`). In the same
147
+ change that writes a doc, add an index line for it to
148
+ `.claude/methodology/README.md` — date, title, one-line hook, and a
149
+ link. Create that index file if it doesn't exist yet. An unindexed
150
+ record is an invisible record, and the `/validate`
151
+ `artifacts-of-thought` check fails on any methodology doc git isn't
152
+ tracking — so a doc left unindexed-and-uncommitted will break
153
+ validation. If the project routes output to a custom location (see
154
+ Path override), index it there instead.
155
+
156
+ ### 4. Integration with the debrief report
157
+
158
+ At the end of the report phase, surface any methodology artifacts
159
+ created this session:
160
+
161
+ > **Methodology captured this session:**
162
+ > - `.claude/methodology/2026-04-18-deferred-trigger-mechanism-internal.md` — 4 decisions with skeptic counters
163
+ > - `.claude/methodology/2026-04-18-deferred-trigger-mechanism-narrative.md` — 340 words
164
+
165
+ One-line preview plus file path for each. Don't paste the content —
166
+ the files are the artifact.
167
+
168
+ ## Project overrides
169
+
170
+ Projects MAY override behavior by editing this phase file:
171
+
172
+ - **`skip: true`** — entire phase skipped, including detection.
173
+ - **Custom detection heuristics** — replace the signal list above with
174
+ project-specific triggers.
175
+ - **Custom templates** for internal/narrative records — some projects
176
+ may want different sections or formats.
177
+ - **Different output location** — e.g., `docs/methodology/` for
178
+ projects that want methodology visible to collaborators via
179
+ standard docs tooling.
180
+
181
+ The default (this file's content as shipped) should be reasonable for
182
+ any project doing occasional core methodology work.
183
+
184
+ ## Calibration
185
+
186
+ **Without this phase (what happens today):**
187
+ Session produces a new multi-phase skill with gate scripts, a convention
188
+ doc, and a calibration harness. Debrief captures three discrete lessons
189
+ ("user scope hints are defensive," "append-only history preserves
190
+ audit trail," etc.) and closes. Six weeks later, someone asks "why did
191
+ you build it this way instead of [X]?" — the answer is fully in
192
+ someone's head (maybe nobody's, if attention has moved on), and the
193
+ skeptic's critique that was considered and addressed during the work
194
+ isn't recoverable. The narrative layer that would let a stakeholder
195
+ understand what was done at a glance doesn't exist.
196
+
197
+ **With this phase:**
198
+ Same session fires the multi-phase + new-skill + convention-doc
199
+ signals. User picks (c) both. Claude writes:
200
+ - `internal.md` with 4 decisions, each including the skeptic's
201
+ critique and the off-ramp (so a future disagreement has ground
202
+ to stand on)
203
+ - `narrative.md` in 340 words, pastable into a roadmap email
204
+ When a stakeholder asks six weeks later, the artifact exists. When
205
+ the project revisits the decision, the off-ramps are legible.
206
+
207
+ The phase costs maybe 3-5 minutes per session it fires. It fires on
208
+ a minority of sessions. Most sessions are untouched.
209
+
210
+ ## Relationship to adjacent phases
211
+
212
+ - **record-lessons** (step 9): captures individual lessons. Parallel
213
+ layer: granular, fact-shaped. This phase captures the layer above:
214
+ compositional, reasoning-shaped.
215
+ - **upstream-feedback** (step 11): captures CC friction. Different
216
+ input (what hurt) and destination (CC source repo feedback/).
217
+ - **skill-discovery** (step 12): asks whether the workflow should
218
+ become a skill. Different output (a skill file), different trigger
219
+ (repeatability, not depth).
220
+
221
+ These four phases together cover: discrete lessons (9), methodology
222
+ layer (this), friction (11), and workflow-worth-encoding (12). Each
223
+ fills a different bucket. None subsumes another.
@@ -0,0 +1,78 @@
1
+ # QA-Handoff Sweep (instruction phase)
2
+
3
+ Hand off every worktree→main merge from this session that still needs
4
+ post-merge QA — so the operator never has to remember to run
5
+ `/qa-handoff` after each merge. A session that merged several branches
6
+ needs several handoffs; this performs all of them.
7
+
8
+ This is an **instruction phase** — it ships with debrief and always
9
+ runs (it is not skipped by the customization-phases default). It
10
+ self-skips at runtime when there is nothing to hand off or when the
11
+ `/qa-handoff` skill is not installed.
12
+
13
+ ## When it self-skips (silent, not a failure)
14
+
15
+ - `/qa-handoff` is not installed (no `templates`/installed
16
+ `skills/qa-handoff/` — the watchtower module is absent). Skip
17
+ silently; the rest of debrief continues.
18
+ - No worktree→main merges happened this session.
19
+ - Every merge this session is already represented in the watchtower
20
+ inbox as a `qa-handoff` item (already handed off).
21
+
22
+ ## Steps
23
+
24
+ 1. **Find this session's merges into main.** Use the inventory from
25
+ debrief step 1. Identify merge commits landed on `main` during this
26
+ session:
27
+
28
+ ```bash
29
+ git log --merges --since='<session start, e.g. 6 hours ago>' \
30
+ --format='%H %P %s' main
31
+ ```
32
+
33
+ Resolve each merge to the branch that was merged from its **second
34
+ parent** (`<merge-sha>^2`), NOT from the subject line. The subject
35
+ regex (`Merge branch 'X'`) is unreliable — a merge made with a
36
+ non-default message, a squash, or a PR-style merge resolves to the
37
+ wrong name (e.g. `main`), which would then be handed off as a bogus
38
+ "branch". The second parent is the actual merged tip regardless of
39
+ message:
40
+
41
+ ```bash
42
+ # the merged branch name for a merge commit <sha>:
43
+ git name-rev --name-only --refs='refs/heads/*' "<sha>^2" 2>/dev/null
44
+ # fall back to the second-parent SHA itself if it has no branch ref
45
+ ```
46
+
47
+ This correctly resolves both `mux/<slug>` and workflow
48
+ `worktree-wf_*` merges. Keep the merge commit SHA on main as the
49
+ dedup key. Include non-merge integrations only if this repo
50
+ fast-forwards `mux/*` work onto main without a merge commit.
51
+
52
+ 2. **Dedup against handoffs already filed.** For each merge SHA, check
53
+ whether a `qa-handoff` inbox item already records it (its
54
+ `evidence.merged_commit` equals the SHA). Read the inbox via the
55
+ installed queue API (see `/qa-handoff` Step 5 for the
56
+ `watchtower-queue.mjs` path) or list `queue/items/*.json` under the
57
+ watchtower dir and match on the merged SHA. Drop merges already
58
+ handed off — never file a duplicate.
59
+
60
+ 3. **Hand off the remainder.** For each remaining merge, invoke
61
+ `/qa-handoff <branch>`. That skill does the full job — packages what
62
+ merged + what it could not runtime-verify, files the inbox item, and
63
+ `mux qa dispatch`es it to the desk's QA station. Run them one at a
64
+ time; each is cheap.
65
+
66
+ 4. **Report.** One line per handoff performed (what merged, the short
67
+ SHA, where it dispatched), and one line if any merges were skipped as
68
+ already-handed-off. If nothing was handed off, say nothing — silence
69
+ is the correct output of an empty sweep.
70
+
71
+ ## Why this is a phase, not a separate skill
72
+
73
+ The sweep belongs to session close: it knows the session's merges from
74
+ debrief's inventory, and it should run whether the operator closes with
75
+ plain `/debrief` or with `/session-handoff` (which wraps debrief). A
76
+ phase gives both verbs the behavior from one definition. `/qa-handoff`
77
+ itself stays the single source of truth for *how* a handoff is
78
+ packaged — this phase only decides *which* merges still need one.
@@ -0,0 +1,177 @@
1
+ # Record Lessons — Route Session Outputs to Their Real Homes
2
+
3
+ This is debrief's second irreducible purpose: make sure the next session
4
+ is smarter than this one. Without it, the system does work but doesn't
5
+ learn from it.
6
+
7
+ Lessons are perishable. A lesson captured while context is fresh is
8
+ worth ten captured from memory next week.
9
+
10
+ ## The Routing Principle
11
+
12
+ Every session output has **exactly one primary home**. The home must
13
+ have a forcing function — something that keeps the content accurate
14
+ when the code it describes changes. Loose `.md` files next to code
15
+ are the wrong home: they rot silently because nothing invalidates
16
+ them when the system evolves.
17
+
18
+ **Each output has one home. Don't double-store.** A decision captured
19
+ via `/cc-remember` doesn't also need a CLAUDE.md entry "for backup."
20
+ Duplication just creates two things to keep in sync.
21
+
22
+ ## Routing Decision Tree
23
+
24
+ For each thing you'd want future sessions to know, pick the single
25
+ best home:
26
+
27
+ ### Decisions — "we chose X over Y because Z"
28
+
29
+ Architectural choices, tradeoff resolutions, accepted gaps, rejected
30
+ alternatives.
31
+
32
+ **Primary home:** built-in memory via `/cc-remember` (or
33
+ `scripts/write-memory-file.mjs` programmatically). One `.md` file per
34
+ decision, descriptive slug, indexed in MEMORY.md.
35
+
36
+ ```bash
37
+ node scripts/write-memory-file.mjs \
38
+ --slug "decided_<short_name>" \
39
+ --description "<one-line summary>" \
40
+ "We chose X over Y because Z. Tradeoffs considered: ..."
41
+ ```
42
+
43
+ **Also add to CLAUDE.md** only if the decision is load-bearing enough
44
+ that *every* session needs to know it at startup (not just sessions
45
+ that touch the relevant code). Examples: "auth is per-user via FastAPI
46
+ Users (no shared passwords)" is load-bearing. "We rejected a specific
47
+ library option after evaluation" is not — memory is enough.
48
+
49
+ ### Project constraints / conventions / gotchas
50
+
51
+ Environmental quirks, dev-workflow requirements, "this project has a
52
+ weird setup" facts.
53
+
54
+ **Primary home:** inline in `CLAUDE.md` or the project briefing. These
55
+ files get edited when the code changes — the forcing function is that
56
+ they're load-bearing for every session, so staleness surfaces fast.
57
+
58
+ Use a built-in memory file (`constraint_<short_name>.md` via
59
+ `/cc-remember`) only for nuanced constraints where the explanation is
60
+ too long for CLAUDE.md. Project-specific quick constraints belong
61
+ inline.
62
+
63
+ ### Conditional revisits — "do X later when Y happens"
64
+
65
+ "If we ever get multiple concurrent users, add a token blocklist."
66
+ "When curl becomes annoying, build a /settings UI."
67
+
68
+ **Primary home:** pib-db deferred action with `trigger_condition`.
69
+
70
+ ```
71
+ pib_create_action text="..." status="deferred" trigger_condition="..."
72
+ ```
73
+
74
+ Orient's deferred-check phase re-evaluates these every session. If the
75
+ condition has fired, the user gets asked; if it's obsolete, it gets
76
+ marked so. No silent rot.
77
+
78
+ ### CC upstream friction embedded in a project observation
79
+
80
+ Sometimes a project-scoped observation contains a CC-applicable piece:
81
+ "in this project auth tests are hard, AND cabinet-qa should flag this
82
+ pattern in any auth work." That's two things, not one.
83
+
84
+ **Split it.** Route the project piece to its home
85
+ (`/cc-remember` / CLAUDE.md / trigger). Route the CC piece to the
86
+ upstream-feedback phase (step 11) where it will be drafted and
87
+ delivered. Don't bury the upstream piece inside a project decision
88
+ doc — it will never find its way home.
89
+
90
+ ### Lessons, gotchas, discoveries (not decisions, not constraints)
91
+
92
+ "We learned that X behaves differently from docs." "This pattern
93
+ works." "The CI was green but prod failed because…"
94
+
95
+ **Primary home:** built-in memory via `/cc-remember --slug
96
+ "lesson_<short_name>" ...`. One `.md` file per lesson.
97
+
98
+ ### User preferences
99
+
100
+ Style choices, workflow preferences, corrections the user made.
101
+
102
+ **Primary home:** built-in memory via `/cc-remember --slug
103
+ "user_prefers_<thing>" ...`. Or CLAUDE.md if it's a preference that
104
+ should fire on every session start (e.g., "always use pnpm").
105
+
106
+ ## Lessons-Applied-to-Own-Output Scan
107
+
108
+ **Before sending this debrief report**, scan the lessons you just
109
+ captured *this session* against the report you're about to write.
110
+ Does the report itself violate what was learned?
111
+
112
+ Concrete example: this session captured a `lesson_dont_trust_estimates`
113
+ memory ("user's time estimates are overcalibrated, recalibrate
114
+ downward"). The debrief report then includes "this took 30 minutes"
115
+ phrasing — directly contradicting the just-captured lesson.
116
+
117
+ For each captured lesson, ask: *Is the debrief report observing this
118
+ lesson?* If not, rewrite the report before sending. Captured but
119
+ not applied is the same failure mode that bit us with omega; the
120
+ write path doesn't matter, the read-and-apply step does.
121
+
122
+ ## The Anti-Pattern: Loose Project-Scoped .md Files Outside the Memory Dir
123
+
124
+ **Do not write `feedback-project-*.md`, `decision-*.md`, or similar
125
+ loose .md files next to code or in arbitrary project subdirectories.**
126
+ This pattern rots — in one audited case, 4 of 5 such files went stale
127
+ within 7 days because the underlying code changed and the files had
128
+ no forcing function to catch it.
129
+
130
+ If you are tempted to write a loose .md file:
131
+ - Is it a decision? → `/cc-remember --slug "decided_..."`
132
+ - Is it a constraint everyone needs? → CLAUDE.md / briefing
133
+ - Is it a conditional revisit? → pib-db deferred trigger
134
+ - Is it CC upstream friction? → upstream-feedback phase
135
+ - None of the above? → it probably doesn't need recording at all
136
+
137
+ ## Before Writing — Contradiction Check
138
+
139
+ For each memory you're about to capture, search the memory dir for
140
+ existing entries on the same topic:
141
+
142
+ ```bash
143
+ grep -i "<topic>" ~/.claude/projects/<slug>/memory/*.md
144
+ ```
145
+
146
+ If an existing entry contradicts or is superseded by the new one,
147
+ edit the old file with a `**Superseded by <new-slug>.md on <date>**`
148
+ header. Keep the old file for history — don't delete unless the old
149
+ entry was wrong (rather than just outdated).
150
+
151
+ This is the forcing function that turns memory into a living record
152
+ instead of another pile of rotting notes.
153
+
154
+ ## What NOT to Record — Anywhere
155
+
156
+ - Code patterns derivable by reading current files
157
+ - Git history (use `git log`)
158
+ - Debugging solutions (the fix is already in the code; the commit
159
+ message has the context)
160
+ - Anything already in CLAUDE.md files
161
+ - Ephemeral task details only relevant to this session
162
+ - "We made progress on X" session summaries — that's what git is for
163
+
164
+ ## Report What Was Routed
165
+
166
+ Tell the user what went where so they can audit the routing:
167
+
168
+ ```
169
+ Routed this session:
170
+ - 1 decision → memory: decided_jwt_revocation.md
171
+ - 1 constraint → article-rewriter/CLAUDE.md (tsc must run from frontend)
172
+ - 1 deferred trigger → pib-db act:xxxxxxxx (add blocklist if multi-user)
173
+ - 1 upstream piece → CC feedback outbox (cabinet-qa testability)
174
+ ```
175
+
176
+ This is also how you catch routing errors: if everything ended up in
177
+ memory files, the routing discipline didn't actually run.
@@ -0,0 +1,59 @@
1
+ # Report — How to Present the Debrief Summary
2
+
3
+ Define how to present the debrief results to the user. This is the
4
+ presentation phase — it can be skipped in quick mode without losing
5
+ any operational value (all core phases still run).
6
+
7
+ When this file is absent or empty, the default behavior is: present a
8
+ brief summary of work closed, state updated, and lessons recorded. To
9
+ explicitly skip the report, write only `skip: true`.
10
+
11
+ ## What to Include
12
+
13
+ - **Format** — what sections to include in the report
14
+ - **Tone** — how to communicate results
15
+ - **Modes** — if your project uses different presentation modes (e.g.,
16
+ evening preview, verbose vs. compact)
17
+ - **What NOT to include** — execution guides, instructions for next
18
+ session (the work items ARE the handoff)
19
+
20
+ ## Example Report Formats
21
+
22
+ Uncomment and adapt these for your project:
23
+
24
+ <!--
25
+ ### Standard Report
26
+
27
+ Present in this order:
28
+ 1. **Work closed** — items marked complete (with references)
29
+ 2. **Feedback resolved** — comments or feedback addressed
30
+ 3. **State updated** — files and docs that were updated
31
+ 4. **Lessons recorded** — memories created or updated
32
+ 5. **Loose ends captured** — non-project items routed
33
+ 6. **Anything needing input** — keep this minimal
34
+
35
+ Tone: brief, factual. The user can read the diffs.
36
+
37
+ Do NOT produce "how to start next session" guides. The work items
38
+ have the full specs. If the items' notes are insufficient, update them
39
+ — don't compensate in chat output that vanishes with the session.
40
+
41
+ ### Compact Report (quick mode fallback)
42
+
43
+ Bullet list, one line per category:
44
+ - Actions completed: [list with fids]
45
+ - Feedback resolved: [count]
46
+ - Lessons: [files updated]
47
+
48
+ No narrative, no suggestions.
49
+
50
+ ### Evening Preview
51
+
52
+ If the session ends in the evening and your project tracks calendar
53
+ events or scheduled work, append a brief preview of tomorrow:
54
+ - Tomorrow's events
55
+ - Items due tomorrow
56
+ - Anything needing morning preparation
57
+
58
+ This is enough to mentally close the session.
59
+ -->
@@ -0,0 +1,48 @@
1
+ # Update State — What to Update After the Session
2
+
3
+ Define what state files and documentation to update so the system's
4
+ persistent state reflects what actually happened.
5
+
6
+ When this file is absent or empty, the default behavior is: check
7
+ whether system-status.md needs updating. To explicitly skip state
8
+ updates, write only `skip: true`. Stale state erodes
9
+ trust — an item marked "planned" that's actually built, or a status
10
+ file that says "incomplete" for something that shipped, makes the
11
+ system less reliable for the next orient.
12
+
13
+ ## What to Include
14
+
15
+ For each state artifact, provide:
16
+ - **File** — what to check and potentially update
17
+ - **What changes** — what kind of updates to look for
18
+ - **How to update** — edit the file, run a command, call an API
19
+
20
+ ## Example State Updates
21
+
22
+ Uncomment and adapt these for your project:
23
+
24
+ <!--
25
+ ### System Status File
26
+ ```
27
+ Read and update system-status.md:
28
+ - Move completed items from "Planned" or "In Progress" to "Built"
29
+ - Add new capabilities that didn't exist before
30
+ - Update any counts or metrics
31
+ - Note new known issues discovered during the session
32
+ ```
33
+
34
+ ### Project Documentation
35
+ Check if any of these need updating based on what changed:
36
+ - Root CLAUDE.md — new workflows, entity types, directories?
37
+ - Directory-level CLAUDE.md files — changed conventions?
38
+ - Schema or configuration files — new fields or types?
39
+ - README — new features or changed setup instructions?
40
+
41
+ Only update what actually changed. Don't rewrite docs for no reason.
42
+
43
+ ### Skills and Process Docs
44
+ Review what happened during the session:
45
+ - Did any skill's instructions prove wrong or incomplete? Fix it.
46
+ - Did a workflow gap surface? Update the relevant skill.
47
+ - Did you discover a better approach? Record it where it helps.
48
+ -->