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,44 @@
1
+ # debrief-classic Extending and Calibration
2
+
3
+ ## Extending
4
+
5
+ To customize a phase: write content in the corresponding `phases/` file.
6
+ To skip a phase: leave the file empty or don't create it.
7
+ To add a phase the skeleton doesn't define: create a new file in
8
+ `phases/` with a description of when it runs relative to the core
9
+ phases. Claude reads whatever phase files exist at runtime.
10
+
11
+ Examples of phases mature projects add:
12
+ - Project completion scanning (auto-close projects with zero open items)
13
+ - Prep/research passes on open work items
14
+ - Evening preview (tomorrow's calendar, due items, prep needed)
15
+ - Compliance checks (verify required skills were invoked)
16
+ - Machine/environment drift detection
17
+
18
+ ## Calibration
19
+
20
+ **Core failure this targets:** Ending a session without closing loops,
21
+ leaving completed work marked as open, unrecorded lessons, and stale
22
+ state that degrades the next session's orient.
23
+
24
+ ### Without Skill (Bad)
25
+
26
+ Session ends. Work was done — a feature built, a bug fixed — but the
27
+ task tracker still shows it as open. Feedback that was addressed stays
28
+ unresolved. A lesson learned about a tricky API behavior isn't written
29
+ down. Next session, orient shows stale tasks, feedback, and the same
30
+ gotcha is rediscovered from scratch.
31
+
32
+ The system is doing work but not learning from it. Each session starts
33
+ from the same baseline instead of building on the last.
34
+
35
+ ### With Skill (Good)
36
+
37
+ Session ends. The debrief inventories what was done, marks the feature
38
+ as complete with a commit reference, resolves the feedback comment,
39
+ updates the status file, and records the API gotcha in memory. Next
40
+ session, orient shows accurate state, the feedback queue is clean, and
41
+ when the API comes up again, the lesson is already there.
42
+
43
+ The system gets smarter with each session because debrief closes the
44
+ loop that orient opens.
@@ -0,0 +1,78 @@
1
+ # Audit Pattern Capture
2
+
3
+ Runs after cabinet consultations (step 3) and before recording lessons.
4
+ Detects recurring audit findings and writes them to the relevant cabinet
5
+ member's `patterns-project.md` file.
6
+
7
+ ## When This Runs
8
+
9
+ After cabinet members have completed their debrief consultations. This
10
+ phase consumes what they produced — it doesn't run cabinet members itself.
11
+
12
+ ## What to Do
13
+
14
+ ### 1. Collect This Session's Audit Findings
15
+
16
+ If an audit ran this session (check for audit output in the session's
17
+ work), collect the findings by cabinet member. If no audit ran, skip
18
+ this phase entirely.
19
+
20
+ ### 2. Check for Recurrence
21
+
22
+ For each cabinet member that produced findings this session, check
23
+ whether the same CLASS of finding has appeared before:
24
+
25
+ - Check triage history if available: use `pib_triage_history` (or
26
+ `node scripts/pib-db.mjs triage-history` CLI fallback).
27
+ Look for approved findings from the same cabinet member with similar
28
+ descriptions.
29
+
30
+ - Check the member's existing `patterns-project.md` if it exists —
31
+ is this finding already captured?
32
+
33
+ **A pattern is recurring when:** The same cabinet member flags the same
34
+ class of issue (not identical text, but the same underlying problem)
35
+ in 2+ separate audit runs. One-time findings stay as findings; recurring
36
+ ones become patterns.
37
+
38
+ ### 3. Write to patterns-project.md
39
+
40
+ For each newly detected recurring pattern, append it to the member's
41
+ project pattern file:
42
+
43
+ **Path:** `.claude/skills/cabinet-{member-name}/patterns-project.md`
44
+
45
+ Create the file if it doesn't exist. Append if it does.
46
+
47
+ **Entry format:**
48
+ ```markdown
49
+ ### [Short pattern name]
50
+
51
+ **Occurrences:** [N] times across [N] audits (first: YYYY-MM-DD, latest: YYYY-MM-DD)
52
+
53
+ [1-2 sentence description of the pattern — what the issue is and why
54
+ it recurs. Be specific enough that the cabinet member can detect it
55
+ in future audits without re-reading the original findings.]
56
+ ```
57
+
58
+ ### 4. Surface Pattern Promotion Candidates
59
+
60
+ After writing project patterns, check if any patterns in
61
+ `patterns-project.md` look universal (not specific to this project's
62
+ domain, codebase, or technology choices). If so, note them for the
63
+ CC feedback phase — they may be candidates for upstream promotion.
64
+
65
+ Signals that a pattern is universal:
66
+ - It describes a general coding practice, not a project-specific convention
67
+ - It would apply to any project using the same technology
68
+ - The pattern name doesn't reference project-specific entities
69
+
70
+ Do NOT auto-promote. Just surface the candidate so the CC feedback
71
+ phase can decide whether to file it.
72
+
73
+ ## What NOT to Do
74
+
75
+ - Don't capture one-time findings as patterns
76
+ - Don't duplicate patterns already in `patterns-project.md`
77
+ - Don't modify the upstream SKILL.md section — that's CC-owned
78
+ - Don't create `patterns-project.md` for members with no recurring findings
@@ -0,0 +1,48 @@
1
+ # Auto-Maintenance — Recurring Session-End Tasks
2
+
3
+ Define automated tasks that should run at the end of every session.
4
+ Same principle as orient's auto-maintenance: operations that decay if
5
+ left to human memory.
6
+
7
+ Session-end maintenance differs from session-start: orient's maintenance
8
+ prepares for work, debrief's maintenance cleans up after it.
9
+
10
+ When this file is absent or empty, this step is skipped. (`skip: true`
11
+ is equivalent to absent here.)
12
+
13
+ ## What to Include
14
+
15
+ For each task, provide:
16
+ - **What** — the operation to perform
17
+ - **Why every session** — what decays if this is skipped
18
+ - **Command** — how to run it
19
+ - **Auto-execute?** — yes (run silently) or surface (ask user first)
20
+
21
+ ## Example Maintenance Tasks
22
+
23
+ Uncomment and adapt these for your project:
24
+
25
+ <!--
26
+ ### Scan for Stale Work Items
27
+ ```bash
28
+ # Find items that should have been closed but weren't
29
+ sqlite3 project.db "SELECT id, text FROM tasks WHERE status = 'active' AND updated_at < date('now', '-14 days')"
30
+ ```
31
+ Items that haven't been touched in two weeks may be stale. Surface for
32
+ user decision: still active, defer, or close.
33
+
34
+ ### Clean Build Artifacts
35
+ ```bash
36
+ rm -rf .build-cache/tmp/*
37
+ ```
38
+ Temporary build artifacts that accumulate. Silent cleanup.
39
+
40
+ ### Refresh Research / Prep
41
+ ```bash
42
+ # Scan open items for ones that could benefit from background research
43
+ sqlite3 project.db "SELECT id, text FROM tasks WHERE status = 'active' AND prep_status IS NULL"
44
+ ```
45
+ Identify work items where doing a quick research pass now would save
46
+ time in a future session. Auto-execute for quick items; surface complex
47
+ ones.
48
+ -->
@@ -0,0 +1,123 @@
1
+ # Checklist Feedback — bug → sharpen dimension
2
+
3
+ Runs after Record Lessons (step 9), before Methodology Capture (step 10).
4
+ This phase closes the learning loop for the change-impact checklist: when
5
+ a bug slips through, the checklist should learn from it.
6
+
7
+ ## No-op guards (checked in order)
8
+
9
+ 1. **No bugs caught this session.** If the session inventory (step 1) and
10
+ close-work (step 2) didn't identify any bug fixes, unexpected failures,
11
+ or regressions, skip silently. The trigger is "something went wrong
12
+ that shouldn't have" — not every session has one.
13
+
14
+ 2. **qa-dimensions.yaml doesn't exist.** If `.claude/cabinet/qa-dimensions.yaml`
15
+ is absent, the checklist engine isn't active for this project. Instead
16
+ of skipping silently, emit a one-time bootstrap nudge:
17
+
18
+ > A bug was caught this session. If you had a change-impact checklist,
19
+ > this category could be flagged automatically next time. Want to set
20
+ > one up? Copy `.claude/cabinet/qa-dimensions-template.yaml` to
21
+ > `.claude/cabinet/qa-dimensions.yaml` and customize it, or run
22
+ > `/checklist-discover` to build one from your codebase.
23
+
24
+ Then stop — don't try to update a file that doesn't exist.
25
+
26
+ ## What to do (when both guards pass)
27
+
28
+ ### 1. Identify the bug category
29
+
30
+ For each bug caught/fixed this session, ask:
31
+
32
+ - **What files were involved?** (the surface area of the fix)
33
+ - **What class of problem was it?** (data integrity, API contract break,
34
+ UI rendering, security gap, missing validation, etc.)
35
+ - **Was it caught by the checklist?** Check the session's CP3 output —
36
+ did the change-impact checklist surface a relevant check, or did this
37
+ bug slip through uncovered?
38
+
39
+ If the checklist DID surface a relevant check and the bug was caught
40
+ via that check, this is a hit — the system worked. Record it: append
41
+ `{date, check (quoted as written), note}` to that dimension's `catches`
42
+ in `.claude/cabinet/checklist-stats.json` (write protocol:
43
+ `cabinet/checklist-stats-schema.md`; atomic temp + rename, fail-open).
44
+ Catches are the evidence that keeps a dimension alive when the audit
45
+ skill's `checklist-pruning` phase reviews hit rates. Then no further
46
+ action for this bug.
47
+
48
+ If the bug slipped through, continue to step 2.
49
+
50
+ ### 2. Map to a dimension
51
+
52
+ Read `.claude/cabinet/qa-dimensions.yaml`. For the bug's file paths and
53
+ category, determine:
54
+
55
+ - **Existing dimension covers it:** A dimension's paths match the bug's
56
+ files, but the checks weren't specific enough to catch this class of
57
+ problem. Propose sharpening — add a new check to the existing dimension.
58
+
59
+ - **No dimension covers it:** No dimension's paths match the bug's files,
60
+ or no dimension's category is relevant. Propose a new dimension with
61
+ path patterns derived from the bug's file paths and an initial check
62
+ derived from the bug's class.
63
+
64
+ ### 3. Propose the change (one at a time)
65
+
66
+ If this is the user's first time seeing a checklist proposal, precede
67
+ it with a one-sentence orientation:
68
+
69
+ > The change-impact checklist is organized by *dimensions* — categories
70
+ > of code change that need verification. Each dimension has path patterns
71
+ > (which files trigger it) and checks (what to verify). Here's a
72
+ > suggested change based on what slipped through today:
73
+
74
+ Then present each proposed change individually. For a sharpened check:
75
+
76
+ > **Sharpen dimension: data-coherence**
77
+ > Add check: `[review] Verify migration handles NULL values in existing rows`
78
+ > Reason: session bug — migration assumed non-null column, broke on legacy data
79
+ >
80
+ > Accept / Edit / Skip?
81
+
82
+ For a new dimension:
83
+
84
+ > **New dimension: config-drift**
85
+ > Paths: `["**/config*", "**/.env*"]`
86
+ > Severity: moderate
87
+ > Initial check: `[review] Verify config change is reflected in all environments`
88
+ > Reason: session bug — .env.production missed a new variable
89
+ >
90
+ > Accept / Edit / Skip?
91
+
92
+ Never batch — one proposal at a time so the user can think about each.
93
+
94
+ ### 4. Apply approved changes
95
+
96
+ For accepted proposals, update `.claude/cabinet/qa-dimensions.yaml`:
97
+ - Sharpened check → append to the dimension's `checks` list
98
+ - New dimension → append to the `dimensions` map
99
+
100
+ **Back up before writing:**
101
+
102
+ ```bash
103
+ cp .claude/cabinet/qa-dimensions.yaml .claude/cabinet/qa-dimensions.yaml.bak
104
+ ```
105
+
106
+ Read the file, apply the change, write the file. Preserve existing
107
+ formatting and comments.
108
+
109
+ **Post-write validation:** re-read the file and confirm the top-level
110
+ `dimensions:` key is still present and the new entry has `paths`,
111
+ `severity`, and `checks`. If validation fails, restore from `.bak`
112
+ and report the error.
113
+
114
+ ## Constraints
115
+
116
+ - **Add-only.** This phase NEVER proposes removing or weakening checks.
117
+ Pruning is a separate concern at audit cadence — the audit skill's
118
+ `checklist-pruning` phase, fed by the hit-rate sidecar this phase
119
+ writes catches to — not session-end debrief.
120
+ - **User approves every change.** No silent modifications to
121
+ qa-dimensions.yaml.
122
+ - **One proposal at a time.** Don't batch multiple proposals into a
123
+ single question.
@@ -0,0 +1,163 @@
1
+ # Close Work — Match, Close, and Resolve
2
+
3
+ Define how to match the session's work against open items and close them.
4
+ This includes marking tasks done, resolving feedback, and updating any
5
+ tracking system. The /debrief skill reads this file after inventorying
6
+ what was done.
7
+
8
+ When this file is absent or empty, the default behavior is: query the
9
+ reference data layer (pib-db) for open actions, match against the
10
+ session's git log, and propose marking matched actions as done. If
11
+ pib-db is not initialized, skip gracefully.
12
+
13
+ ## Default Behavior (pib-db)
14
+
15
+ **Access method:** Use `pib_*` MCP tools when available (see
16
+ `.claude/cabinet/pib-db-access.md`), fall back to `node scripts/pib-db.mjs`
17
+ CLI.
18
+
19
+ When no custom close-work is configured:
20
+
21
+ 1. **Get session work:** Review `git log --oneline` for this session's
22
+ commits (since session start or last 2 hours)
23
+ 2. **Get open actions:** Use `pib_list_actions` (or `node scripts/pib-db.mjs list-actions`)
24
+ 3. **Match:** For each open action, check if this session's work
25
+ addresses it (compare action text/notes against commit messages
26
+ and changed files)
27
+ 4. **Propose:** Present matched actions and ask the user to confirm
28
+ which to close
29
+ 5. **Close confirmed:** Use `pib_complete_action` (or `node scripts/pib-db.mjs complete-action <fid>`)
30
+
31
+ If pib-db doesn't exist, skip with a note.
32
+
33
+ ## What to Include
34
+
35
+ - **How to query open items** — where your work tracker lives, how to
36
+ read it
37
+ - **How to mark items done** — the command or API to update status
38
+ - **How to resolve feedback** — if your project tracks feedback or
39
+ comments, how to mark them addressed
40
+ - **What to include in completion notes** — commit references, summary
41
+ of what was built
42
+
43
+ ## Example Close-Work Patterns
44
+
45
+ Uncomment and adapt these for your project:
46
+
47
+ <!--
48
+ ### Task Tracker (Database)
49
+ ```bash
50
+ # Query open tasks
51
+ sqlite3 project.db "SELECT id, text, status FROM tasks WHERE status != 'done'"
52
+
53
+ # Mark a task done with commit reference
54
+ COMMIT=$(git log -1 --format=%h)
55
+ sqlite3 project.db "UPDATE tasks SET status = 'done', notes = notes || '\n\nCompleted in $COMMIT' WHERE id = 'TASK_ID'"
56
+ ```
57
+
58
+ ### Task Tracker (API)
59
+ ```bash
60
+ # Query open tasks
61
+ curl -s https://your-api.example.com/api/tasks?status=open
62
+
63
+ # Mark done
64
+ curl -X PATCH https://your-api.example.com/api/tasks/TASK_ID \
65
+ -H "Content-Type: application/json" \
66
+ -d '{"status": "done", "completedRef": "COMMIT_HASH"}'
67
+ ```
68
+
69
+ ### Task Tracker (Markdown)
70
+ ```bash
71
+ # Find open tasks
72
+ grep -n '- \[ \]' tasks.md
73
+
74
+ # Mark done (replace checkbox)
75
+ # Edit the file to change `- [ ]` to `- [x]` for completed items
76
+ ```
77
+
78
+ ### Feedback / Comments
79
+ ```bash
80
+ # Query unresolved feedback
81
+ sqlite3 project.db "SELECT id, text FROM feedback WHERE resolved = 0"
82
+
83
+ # Cross-reference against session work — if the feedback was addressed,
84
+ # resolve it with a note about what fixed it
85
+ sqlite3 project.db "UPDATE feedback SET resolved = 1, resolution = 'Fixed in COMMIT' WHERE id = FEEDBACK_ID"
86
+ ```
87
+
88
+ ### Follow-On Work
89
+ When closing an item that has documented sub-phases or next steps in its
90
+ notes, create new items for each. Known work that lives only in completed
91
+ items' notes will be forgotten. There is no "later" — create it now.
92
+ -->
93
+
94
+ ## Resolve Field Feedback
95
+
96
+ After closing actions, check the `feedback/` directory for field feedback
97
+ files from consuming projects. For each file, evaluate whether this
98
+ session's work addressed the friction described.
99
+
100
+ **Trigger conditions** (check ALL, not just git-log matching):
101
+ 1. **Git-log matching:** Cross-reference feedback files against this
102
+ session's changed files and commit messages.
103
+ 2. **Project-name matching:** If any closed project's name or description
104
+ contains "feedback", "remediation", or "field feedback", explicitly
105
+ scan ALL feedback files and present them for resolution — the project
106
+ was likely created to address them.
107
+ 3. **Component matching:** If this session edited files in a component
108
+ mentioned by a feedback file (e.g., session edited `cc-publish/SKILL.md`
109
+ and a feedback file has `component: skills/cc-publish`), surface it.
110
+
111
+ **How to check:**
112
+ 1. Scan `feedback/` for `.md` files (skip `.gitkeep`)
113
+ 2. For each file, read the `component` from frontmatter and the friction
114
+ description
115
+ 3. Apply all trigger conditions above — any match means the feedback
116
+ should be presented for resolution
117
+ 4. For each resolved item, present to the user:
118
+ > "Field feedback resolved: [title] from [source] — [one-line summary
119
+ > of what fixed it]. Delete the feedback file? (yes/no)"
120
+ 5. On confirmation, delete the feedback file. It served its purpose —
121
+ the friction was addressed and the fix is in the commit history.
122
+
123
+ **Why delete rather than mark resolved?** Feedback files are a queue, not
124
+ a ledger. The commit history records what was fixed and when. Keeping
125
+ resolved feedback files around creates stale noise that orient has to
126
+ filter through every session.
127
+
128
+ **Partially addressed feedback** stays open. If the session fixed one
129
+ aspect but not another, note what was fixed in the file (append a
130
+ `## Partial resolution` section) but don't delete it.
131
+
132
+ ## Project Completion Scan
133
+
134
+ After closing individual actions, check for projects that may be ready
135
+ to complete. A project with actions where all are done is finished —
136
+ leaving it active is stale state that erodes trust in the work tracker.
137
+
138
+ When using pib-db (default):
139
+
140
+ Use `pib_query` (or `node scripts/pib-db.mjs query`) with:
141
+ ```sql
142
+ SELECT p.fid, p.name,
143
+ (SELECT COUNT(*) FROM actions a WHERE a.project_fid = p.fid) as total,
144
+ (SELECT COUNT(*) FROM actions a WHERE a.project_fid = p.fid AND a.completed = 1) as done
145
+ FROM projects p
146
+ WHERE p.status = 'active'
147
+ AND p.deleted_at IS NULL
148
+ AND (SELECT COUNT(*) FROM actions a WHERE a.project_fid = p.fid) > 0
149
+ AND (SELECT COUNT(*) FROM actions a WHERE a.project_fid = p.fid AND a.completed = 0 AND a.deleted_at IS NULL) = 0
150
+ ```
151
+
152
+ For each result: all actions are complete. Propose completing the project:
153
+ - Show the project name and action count (e.g., "prj:abc — My Project (5/5 actions done)")
154
+ - Ask the user to confirm before closing
155
+ - On confirmation, use `pib_query` (or `node scripts/pib-db.mjs query`) with:
156
+ `UPDATE projects SET status = 'done', completed_at = date('now') WHERE fid = '<fid>'`
157
+
158
+ **Design notes:**
159
+ - Projects with zero total actions are excluded — they may be containers
160
+ or newly created, not "done."
161
+ - This runs AFTER individual action closing, so newly-completed actions
162
+ from this session are counted.
163
+ - If pib-db doesn't exist, skip this check.
@@ -0,0 +1,54 @@
1
+ # Health Checks — Session-End Verification
2
+
3
+ Define health checks to run at the end of the session. These verify that
4
+ the session's work didn't break anything and that the system is in a
5
+ good state for the next session.
6
+
7
+ When this file is absent or empty, this step is skipped. (`skip: true`
8
+ is equivalent to absent here.)
9
+
10
+ End-of-session health checks differ from start-of-session: orient checks
11
+ catch pre-existing problems; debrief checks catch problems the session
12
+ may have introduced.
13
+
14
+ ## What to Include
15
+
16
+ For each check, provide:
17
+ - **Name** — short label for reporting
18
+ - **Command** — how to run the check
19
+ - **What it catches** — what could have gone wrong during the session
20
+ - **If it fails** — fix now, or note for next session?
21
+
22
+ ## Example Health Checks
23
+
24
+ Uncomment and adapt these for your project:
25
+
26
+ <!--
27
+ ### Memory Index Freshness
28
+ ```bash
29
+ # Verify all memory files are listed in the index
30
+ ls memory/*.md | while read f; do
31
+ basename="$(basename $f)"
32
+ grep -q "$basename" memory/MEMORY.md || echo "MISSING: $basename"
33
+ done
34
+ ```
35
+ Catches memory files created during the session that weren't added to
36
+ the index. Fix immediately — an unlisted memory file is invisible.
37
+
38
+ ### State File Consistency
39
+ ```bash
40
+ # Verify system-status.md was updated if code changed
41
+ CHANGED=$(git diff --name-only HEAD~5 | grep -v '.md$' | wc -l)
42
+ STATUS_CHANGED=$(git diff --name-only HEAD~5 | grep 'system-status.md' | wc -l)
43
+ [ "$CHANGED" -gt 0 ] && [ "$STATUS_CHANGED" -eq 0 ] && echo "WARN: code changed but status not updated"
44
+ ```
45
+ If code was changed but the status file wasn't updated, the next
46
+ orient will read stale state. Fix before closing.
47
+
48
+ ### Build Verification
49
+ ```bash
50
+ npm run build 2>&1 | tail -5
51
+ ```
52
+ Verify the project still builds after changes. If broken, fix before
53
+ committing or note the failure clearly.
54
+ -->
@@ -0,0 +1,40 @@
1
+ # Inventory — How to Identify What Was Done
2
+
3
+ Define how to determine what the session accomplished. The /debrief skill
4
+ reads this file to build a list of completed work before matching it
5
+ against open items.
6
+
7
+ When this file is absent or empty, the default behavior is: review git
8
+ log, files changed, and session context. To explicitly skip inventory,
9
+ write only `skip: true`.
10
+
11
+ ## What to Include
12
+
13
+ For each evidence source, provide:
14
+ - **Source** — where to look for what changed
15
+ - **Command** — how to query it
16
+ - **What it reveals** — commits, file changes, conversation actions
17
+
18
+ ## Example Inventory Methods
19
+
20
+ Uncomment and adapt these for your project:
21
+
22
+ <!--
23
+ ### Git History
24
+ ```bash
25
+ git log --oneline -20 # recent commits
26
+ git diff --stat HEAD~5 # files changed
27
+ ```
28
+ The primary evidence of what was built, fixed, or modified.
29
+
30
+ ### Conversation Context
31
+ Review what was discussed, what plans were executed, what features were
32
+ built, what bugs were fixed. This catches work that isn't yet committed.
33
+
34
+ ### Deployment Log
35
+ ```bash
36
+ cat deploy/latest.log
37
+ ```
38
+ If the session included a deployment, note what was deployed and whether
39
+ it succeeded.
40
+ -->
@@ -0,0 +1,52 @@
1
+ # Loose Ends — Non-Project Items to Capture
2
+
3
+ Define how to sweep for non-project items and environmental concerns
4
+ before closing the session. Sessions generate work that isn't part of
5
+ the main project — manual tasks, purchases, emails, configuration
6
+ changes, appointments. If these aren't captured, they rely on human
7
+ memory, which violates the anti-entropy principle.
8
+
9
+ When this file is absent or empty, this step is skipped. (`skip: true`
10
+ is equivalent to absent here.)
11
+
12
+ ## What to Include
13
+
14
+ - **What to scan for** — categories of non-project items
15
+ - **Where to route them** — inbox, task tracker, notes, specific lists
16
+ - **How to capture** — API calls, file edits, commands
17
+
18
+ ## Example Loose Ends Patterns
19
+
20
+ Uncomment and adapt these for your project:
21
+
22
+ <!--
23
+ ### Non-Project Tasks
24
+ Scan the session for anything that came up which isn't a project task
25
+ but should be tracked:
26
+ - Manual steps the user needs to take outside the terminal
27
+ - Purchases or orders to place
28
+ - Emails or messages to send
29
+ - License acceptances or account actions
30
+ - Appointments or scheduling tasks
31
+
32
+ Route each to its proper home — don't dump everything in a generic
33
+ inbox if you know the category. An item that's already classified
34
+ should go directly to the right place.
35
+
36
+ ### Environment Changes
37
+ If the session changed anything that lives outside of git:
38
+ - New background processes or services started
39
+ - System permissions granted
40
+ - New tools or dependencies installed globally
41
+ - Environment variables added or changed
42
+ - Configuration files outside the project directory
43
+
44
+ Record these in a setup or environment file so the configuration can
45
+ be reproduced. An environment change that isn't documented is a change
46
+ that gets lost on the next machine.
47
+
48
+ ### If Nothing Surfaced
49
+ This is the most common outcome. If no non-project items came up during
50
+ the session, skip this phase silently — don't report "no loose ends
51
+ found."
52
+ -->