continuous-improvement 3.9.2 → 3.11.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 (150) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +61 -0
  3. package/QUICKSTART.md +13 -8
  4. package/README.md +84 -153
  5. package/bin/backfill.mjs +0 -0
  6. package/bin/check-doc-runtime-claims.mjs +0 -0
  7. package/bin/check-docs-substrings.mjs +73 -0
  8. package/bin/check-everything-mirror.mjs +0 -0
  9. package/bin/check-routing-targets.mjs +0 -0
  10. package/bin/check-scripts-citation-drift.mjs +210 -0
  11. package/bin/check-skill-count.mjs +110 -0
  12. package/bin/check-skill-law-tag.mjs +0 -0
  13. package/bin/check-skill-mirror.mjs +0 -0
  14. package/bin/check-skill-tiers.mjs +0 -0
  15. package/bin/check-test-imports-only.mjs +126 -0
  16. package/bin/check-third-party-shape.mjs +0 -0
  17. package/bin/companion-preference-status.mjs +231 -0
  18. package/bin/gateguard-clear.mjs +53 -0
  19. package/bin/generate-plugin-manifests.mjs +7 -1
  20. package/bin/harvest-friction.mjs +0 -0
  21. package/bin/hook-stats.mjs +0 -0
  22. package/bin/install.mjs +182 -26
  23. package/bin/lint-transcript.mjs +0 -0
  24. package/bin/mcp-server.mjs +215 -2
  25. package/bin/observe.mjs +0 -0
  26. package/bin/pre-commit-block-strays.sh +0 -0
  27. package/bin/refresh-third-party.mjs +315 -313
  28. package/bin/unified-cli.mjs +0 -0
  29. package/commands/audit.md +34 -0
  30. package/commands/companion-preference.md +58 -0
  31. package/commands/discipline.md +14 -0
  32. package/commands/distill.md +39 -0
  33. package/commands/goal-check.md +53 -0
  34. package/commands/grill-me.md +40 -0
  35. package/commands/grill-with-docs.md +38 -0
  36. package/commands/handoff.md +42 -0
  37. package/commands/proceed-with-the-recommendation.md +20 -0
  38. package/commands/recall.md +49 -0
  39. package/commands/reconcile.md +47 -0
  40. package/commands/superpowers.md +2 -2
  41. package/commands/verify-install.md +55 -0
  42. package/hooks/companion-preference.mjs +190 -0
  43. package/hooks/gateguard.mjs +60 -25
  44. package/hooks/goal-drift-stop.mjs +183 -0
  45. package/hooks/observe.sh +15 -1
  46. package/hooks/route-prompt.mjs +180 -0
  47. package/hooks/route-table.json +35 -0
  48. package/hooks/three-section-close.mjs +134 -132
  49. package/lib/cli-anything.mjs +0 -0
  50. package/lib/compound-engineering.mjs +0 -0
  51. package/lib/gateguard-state.mjs +54 -2
  52. package/lib/goal-drift-gate.mjs +50 -0
  53. package/lib/goal-state.mjs +285 -0
  54. package/lib/observe-event.mjs +0 -0
  55. package/lib/plugin-metadata.mjs +126 -12
  56. package/lib/pm-marketplace.mjs +0 -0
  57. package/lib/pm-skills.mjs +0 -0
  58. package/lib/recall-index.mjs +175 -0
  59. package/lib/resolve-home-dir.mjs +0 -0
  60. package/lib/skill-distill.mjs +222 -0
  61. package/lib/skill-tiers.mjs +0 -0
  62. package/lib/unified-plugin.mjs +0 -0
  63. package/llms.txt +1 -1
  64. package/package.json +11 -7
  65. package/plugins/beginner.json +8 -3
  66. package/plugins/continuous-improvement/.claude-plugin/marketplace.json +2 -2
  67. package/plugins/continuous-improvement/.claude-plugin/plugin.json +2 -2
  68. package/plugins/continuous-improvement/agents/README.md +2 -2
  69. package/plugins/continuous-improvement/bin/backfill.mjs +0 -0
  70. package/plugins/continuous-improvement/bin/gateguard-clear.mjs +53 -0
  71. package/plugins/continuous-improvement/bin/mcp-server.mjs +215 -2
  72. package/plugins/continuous-improvement/bin/observe.mjs +0 -0
  73. package/plugins/continuous-improvement/commands/audit.md +34 -0
  74. package/plugins/continuous-improvement/commands/companion-preference.md +58 -0
  75. package/plugins/continuous-improvement/commands/discipline.md +14 -0
  76. package/plugins/continuous-improvement/commands/distill.md +39 -0
  77. package/plugins/continuous-improvement/commands/goal-check.md +53 -0
  78. package/plugins/continuous-improvement/commands/grill-me.md +40 -0
  79. package/plugins/continuous-improvement/commands/grill-with-docs.md +38 -0
  80. package/plugins/continuous-improvement/commands/handoff.md +42 -0
  81. package/plugins/continuous-improvement/commands/proceed-with-the-recommendation.md +20 -0
  82. package/plugins/continuous-improvement/commands/recall.md +49 -0
  83. package/plugins/continuous-improvement/commands/reconcile.md +47 -0
  84. package/plugins/continuous-improvement/commands/superpowers.md +2 -2
  85. package/plugins/continuous-improvement/commands/verify-install.md +55 -0
  86. package/plugins/continuous-improvement/hooks/companion-preference.mjs +190 -0
  87. package/plugins/continuous-improvement/hooks/gateguard.mjs +60 -25
  88. package/plugins/continuous-improvement/hooks/goal-drift-stop.mjs +183 -0
  89. package/plugins/continuous-improvement/hooks/hooks.json +18 -2
  90. package/plugins/continuous-improvement/hooks/observe.sh +15 -1
  91. package/plugins/continuous-improvement/hooks/route-prompt.mjs +180 -0
  92. package/plugins/continuous-improvement/hooks/route-table.json +35 -0
  93. package/plugins/continuous-improvement/hooks/three-section-close.mjs +134 -132
  94. package/plugins/continuous-improvement/lib/gateguard-state.mjs +137 -0
  95. package/plugins/continuous-improvement/lib/goal-drift-gate.mjs +50 -0
  96. package/plugins/continuous-improvement/lib/goal-state.mjs +285 -0
  97. package/plugins/continuous-improvement/lib/observe-event.mjs +0 -0
  98. package/plugins/continuous-improvement/lib/plugin-metadata.mjs +126 -12
  99. package/plugins/continuous-improvement/lib/recall-index.mjs +175 -0
  100. package/plugins/continuous-improvement/lib/resolve-home-dir.mjs +0 -0
  101. package/plugins/continuous-improvement/lib/skill-distill.mjs +222 -0
  102. package/plugins/continuous-improvement/skills/README.md +8 -0
  103. package/plugins/continuous-improvement/skills/audit/SKILL.md +73 -0
  104. package/plugins/continuous-improvement/skills/deploy-receipt/SKILL.md +13 -17
  105. package/plugins/continuous-improvement/skills/gateguard/SKILL.md +36 -17
  106. package/plugins/continuous-improvement/skills/goal-monitor/SKILL.md +81 -0
  107. package/plugins/continuous-improvement/skills/grill-me/SKILL.md +66 -0
  108. package/plugins/continuous-improvement/skills/grill-with-docs/SKILL.md +252 -0
  109. package/plugins/continuous-improvement/skills/handoff/SKILL.md +59 -0
  110. package/plugins/continuous-improvement/skills/para-memory-files/SKILL.md +1 -1
  111. package/plugins/continuous-improvement/skills/proceed-with-the-recommendation/SKILL.md +82 -6
  112. package/plugins/continuous-improvement/skills/ralph/SKILL.md +1 -0
  113. package/plugins/continuous-improvement/skills/recall/SKILL.md +50 -0
  114. package/plugins/continuous-improvement/skills/reconcile/SKILL.md +80 -0
  115. package/plugins/continuous-improvement/skills/recovery-classification/SKILL.md +1 -0
  116. package/plugins/continuous-improvement/skills/safety-guard/SKILL.md +1 -0
  117. package/plugins/continuous-improvement/skills/skill-distillation/SKILL.md +57 -0
  118. package/plugins/continuous-improvement/skills/state-reconciliation/SKILL.md +1 -0
  119. package/plugins/continuous-improvement/skills/strategic-compact/SKILL.md +1 -0
  120. package/plugins/continuous-improvement/skills/superpowers/SKILL.md +76 -2
  121. package/plugins/continuous-improvement/skills/token-budget-advisor/SKILL.md +1 -1
  122. package/plugins/continuous-improvement/skills/verification-loop/SKILL.md +28 -20
  123. package/plugins/continuous-improvement/skills/wild-risa-balance/SKILL.md +1 -0
  124. package/plugins/continuous-improvement/skills/workspace-surface-audit/SKILL.md +1 -1
  125. package/plugins/continuous-improvement/skills/worktree-safety/SKILL.md +3 -2
  126. package/plugins/expert.json +27 -2
  127. package/skills/README.md +3 -0
  128. package/skills/audit.md +73 -0
  129. package/skills/deploy-receipt.md +13 -17
  130. package/skills/gateguard.md +36 -17
  131. package/skills/goal-monitor.md +81 -0
  132. package/skills/grill-me.md +66 -0
  133. package/skills/grill-with-docs.md +252 -0
  134. package/skills/handoff.md +59 -0
  135. package/skills/para-memory-files.md +1 -1
  136. package/skills/proceed-with-the-recommendation.md +82 -6
  137. package/skills/ralph.md +1 -0
  138. package/skills/recall.md +50 -0
  139. package/skills/reconcile.md +80 -0
  140. package/skills/recovery-classification.md +1 -0
  141. package/skills/safety-guard.md +1 -0
  142. package/skills/skill-distillation.md +57 -0
  143. package/skills/state-reconciliation.md +1 -0
  144. package/skills/strategic-compact.md +1 -0
  145. package/skills/superpowers.md +76 -2
  146. package/skills/token-budget-advisor.md +1 -1
  147. package/skills/verification-loop.md +28 -20
  148. package/skills/wild-risa-balance.md +1 -0
  149. package/skills/workspace-surface-audit.md +1 -1
  150. package/skills/worktree-safety.md +3 -2
@@ -0,0 +1,57 @@
1
+ ---
2
+ name: skill-distillation
3
+ tier: "2"
4
+ description: Enforces Law 7 (Learn From Every Session) of the 7 Laws of AI Agent Discipline. Distills repeated successful tool sequences into reusable draft instincts, so a pattern that worked three times becomes a captured recipe instead of being re-derived from scratch every session.
5
+ origin: continuous-improvement
6
+ user-invocable: true
7
+ ---
8
+
9
+ # Skill Distillation — Turn Repeated Wins Into Reusable Instincts
10
+
11
+ Law 7 says learn from every session. The friction harvester already learns from failures. This skill learns from the other side: when the same tool sequence keeps ending in a passing verification, that is a recipe worth keeping — not a coincidence to forget.
12
+
13
+ ## When to Activate
14
+
15
+ - At end of session, after a successful multi-step task — check whether the pattern is worth keeping.
16
+ - When you notice you have solved a similar problem the same way more than once.
17
+ - During a retrospective, to mine the observation log for patterns that have proven themselves.
18
+
19
+ ## Core Concept
20
+
21
+ Distillation walks the observation log, groups it into contiguous trajectories (split on session change or a long time gap), and keeps only the trajectories that ended in success:
22
+
23
+ ```
24
+ verify-exit-0 — a Bash test/build/verify command with a non-failing output
25
+ reflection-pass — an observation containing "verified" / "phase 4" / "verify:all green"
26
+ ```
27
+
28
+ It then mines the tool-name sequences of successful trajectories for n-grams (length 3–5) that recurred **across multiple distinct sessions**. A pattern repeated only within a single session is rejected — that is repetition, not a reusable skill.
29
+
30
+ ## The Promotion Ladder
31
+
32
+ Drafts never affect behavior until you promote them. Three explicit steps, no auto-promotion:
33
+
34
+ ```
35
+ 1. ci_distill_candidates — list patterns that qualify (read-only)
36
+ 2. ci_distill_propose id=<id> — write a DRAFT to ~/.claude/instincts/<hash>/drafts/
37
+ (placeholder body — you fill in the real recipe)
38
+ 3. <edit the draft body by hand> — the tool sequence is evidence, not a recipe
39
+ 4. ci_distill_promote id=<id> — promote to a live instinct at 0.5 confidence (SUGGEST)
40
+ ```
41
+
42
+ The draft starts at 0.4 confidence and lives in a `drafts/` subdirectory that the instinct loader ignores. Only `ci_distill_promote` writes a live instinct, at 0.5 (SUGGEST tier) — it suggests, it does not auto-apply, until the normal reinforcement loop earns it more confidence.
43
+
44
+ ## Why Drafts, Not Auto-Instincts
45
+
46
+ A tool sequence alone is cargo-cult evidence: `Read → Edit → Bash → Edit → Bash` is a TDD loop, but the *value* is in the preconditions and the specific steps, which the sequence does not capture. Requiring a human to edit the body before promotion is the guard against the system fabricating confident-sounding skills from coincidental call ordering.
47
+
48
+ ## Limitations
49
+
50
+ - **Pattern detection only (no LLM in v1).** The draft body is a placeholder; you write the recipe. An optional model-assisted body draft is a planned follow-up.
51
+ - **Tool-name granularity.** Distillation sees tool names and summaries, not full intent. Two unrelated tasks with the same call shape will look like one pattern — the human edit step resolves this.
52
+
53
+ ## Pairs With
54
+
55
+ - **`continuous-improvement`** (core SKILL.md, Law 7) — distillation is the success-side complement to the friction-harvest failure side of the same observation log.
56
+ - **`recall`** — before promoting, recall whether an existing instinct already covers the pattern.
57
+ - **`tdd-workflow`** — the most common distilled pattern is the RED-GREEN-REFACTOR loop; promote it with project-specific test commands filled in.
@@ -3,6 +3,7 @@ name: state-reconciliation
3
3
  tier: "2"
4
4
  description: "Enforces Law 4 (Verify Before Reporting) of the 7 Laws of AI Agent Discipline. Pre-dispatch invariant: reconcile DB-vs-disk-vs-memory state before any unit runs, so a stale flag, missing artifact, or out-of-sync row never re-dispatches a unit that already completed or never started."
5
5
  origin: continuous-improvement
6
+ user-invocable: false
6
7
  ---
7
8
 
8
9
  # State Reconciliation Skill
@@ -3,6 +3,7 @@ name: strategic-compact
3
3
  tier: "2"
4
4
  description: Enforces Law 5 (Reflect After Every Session) of the 7 Laws of AI Agent Discipline at phase boundaries. Suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction.
5
5
  origin: continuous-improvement
6
+ user-invocable: false
6
7
  ---
7
8
 
8
9
  # Strategic Compact Skill
@@ -5,7 +5,7 @@ description: "Law activator for the 7 Laws of AI Agent Discipline. Unified four-
5
5
  origin: https://github.com/obra/superpowers
6
6
  ---
7
7
 
8
- # Superpowers — Mandatory Agent Workflows (Five-Source Dispatcher)
8
+ # Superpowers — Mandatory Agent Workflows (Four-Source Dispatcher)
9
9
 
10
10
  Superpowers enforces a structured development workflow. Skills activate automatically when their trigger conditions are met. This is not optional guidance — it is mandatory workflow.
11
11
 
@@ -94,6 +94,80 @@ When a task trigger fires, the dispatcher resolves to the first available skill
94
94
 
95
95
  When no installed plugin in the chain resolves, the dispatcher falls back to the inline protocols below (Test-Driven Development, Brainstorming, Plan Format, etc.) so the workflow still works on a clean install.
96
96
 
97
+ ## Companion-Preference Override
98
+
99
+ The four-source routing table above is **CI-first by default**: where a CI-bundled skill (`ci:tdd-workflow`, `ci:verification-loop`, `ci:planning-with-files`, `ci:context-budget`, `ci:ralph`, `ci:learn-eval`) and a companion skill resolve the same trigger, the table lists the CI skill first and the dispatcher picks it. That is the conservative default — the CI plugin ships with the marketplace, the companions are opt-in installs, so a clean install routes to skills that are guaranteed present.
100
+
101
+ Once the operator has explicitly installed a companion plugin (`superpowers@continuous-improvement`, `agent-skills@continuous-improvement`, `ruflo-swarm@continuous-improvement`, `oh-my-claudecode@continuous-improvement`), the default starts working against them: the installed companion is shadowed by the CI fallback for the same trigger. This override flag respects the operator's explicit install choice without forcing every user to relitigate routing per task.
102
+
103
+ ### Setting the flag
104
+
105
+ Add a `continuous_improvement.companion_preference` key to `~/.claude/settings.json`:
106
+
107
+ ```json
108
+ {
109
+ "continuous_improvement": {
110
+ "companion_preference": "companions-first"
111
+ }
112
+ }
113
+ ```
114
+
115
+ Valid values:
116
+
117
+ | Value | Behavior |
118
+ |---|---|
119
+ | `"ci-first"` (default) | Unchanged from the routing tables above. CI-bundled skills win every chain where they appear. |
120
+ | `"companions-first"` | For any routing row that lists both a CI skill and a companion alternative, the dispatcher reads the chain right-to-left: companion first, CI as the silent fallback if the companion plugin is not installed. CI-only rows (`ci:gateguard`, `ci:deploy-receipt`, `ci:workspace-surface-audit`, `ci:proceed-with-the-recommendation`) are unaffected because no companion exists. |
121
+ | `"strict-companions"` | Same as `companions-first`, but the CI fallback is suppressed. If the companion plugin is not installed, the dispatcher hard-halts with the same shape as the missing-companion detection in `/superpowers` and asks the operator to install the companion or change the flag. Use when you want a guarantee that the installed companion ran, not the CI shim. |
122
+
123
+ ### Which rows the override affects
124
+
125
+ These are the routing rows where the override changes the resolved target. Rows not listed here are CI-only or companion-only and route the same under any setting.
126
+
127
+ | Trigger | `ci-first` (default) | `companions-first` |
128
+ |---|---|---|
129
+ | Write a failing test before code | `ci:tdd-workflow` | `superpowers:test-driven-development`, then `agent-skills:test-driven-development` |
130
+ | Verify before declaring done | `ci:verification-loop` | `superpowers:verification-before-completion` |
131
+ | Curate the right context window | `ci:context-budget` | `agent-skills:context-engineering` |
132
+ | Long autonomous run with quality gates | `ci:ralph` | `oh-my-claudecode:ultrawork`, then `ci:ralph` |
133
+ | Reflect after session, extract patterns | `ci:learn-eval` | `oh-my-claudecode:retrospective` |
134
+
135
+ `superpowers:writing-plans` already wins the planning chain under both settings — it is the first entry, with `ci:planning-with-files` as the third fallback — so that row is unchanged.
136
+
137
+ ### Hard halts that remain regardless of the flag
138
+
139
+ The override does not disable:
140
+
141
+ - `gateguard` PreToolUse fact-list enforcement (Law 1, runtime layer in `hooks/gateguard.mjs`)
142
+ - Stop-hook three-section-close discipline (Law 4 + Law 7, runtime layer in `hooks/three-section-close.mjs`)
143
+ - Dispatcher commitments 1–6 above (subagent-driven-development default, parallel fan-out routing, TDD RED-GREEN-REFACTOR, worktree isolation, finishing-a-development-branch before push, distinct Obra/CI variants)
144
+ - Phase 0 P-MAG in `proceed-with-the-recommendation` (Law 5 + Law 7)
145
+
146
+ These are framework invariants, not routing preferences. The flag re-orders which specialist runs; it does not weaken what the framework guarantees.
147
+
148
+ ### Runtime enforcement
149
+
150
+ The override is enforced at the PreToolUse layer by `hooks/companion-preference.mjs`. On every `Skill` tool call, the hook reads `~/.claude/settings.json` for the `companion_preference` value and:
151
+
152
+ - `ci-first` (default): no-op, allow.
153
+ - `companions-first`: emit a one-line stderr advisory naming the preferred companion; allow.
154
+ - `strict-companions`: block the call. Reason names the companion when its plugin is installed, or the `/plugin install <plugin>@continuous-improvement` hint when it is not.
155
+
156
+ The override map inside `hooks/companion-preference.mjs` stays row-aligned with the "Which rows the override affects" table above. Drift surfaces in the hook test suite, which walks the same pairs and fails on any new CI→companion row that the hook does not recognize.
157
+
158
+ The hook fails open. If `~/.claude/settings.json` is missing, malformed, or unreadable, the hook emits `{ "decision": "allow" }` and exits 0. Bugs in the hook never block tool calls — they only fail to enforce.
159
+
160
+ ### Telemetry
161
+
162
+ Every hook invocation that touches a mapped CI skill appends one JSONL line to `~/.claude/instincts/<project-hash>/companion-preference.jsonl`. The line carries `ts`, `mode`, `action`, `ci_skill`, `companion`, `plugin`, and `companion_installed`. The action enum is:
163
+
164
+ - `observation` — mode is `ci-first`; this is the shadow row showing what `companions-first` would have done.
165
+ - `advisory` — mode is `companions-first`; stderr advisory was emitted.
166
+ - `block` — mode is `strict-companions`; companion installed; tool call blocked.
167
+ - `block-not-installed` — mode is `strict-companions`; companion missing; blocked with install hint.
168
+
169
+ Non-mapped skills and non-`Skill` tool calls write nothing. The writer wraps `appendFileSync` in try/catch — telemetry failure never changes the hook decision, preserving the fail-open invariant. The JSONL file is the evidence base for a future default-flip decision: after a 7-day window, the operator can grep / aggregate the file to see which routing rows the override fires on, how often, and whether the companion was installed at the time.
170
+
97
171
  ## Stacked-PR Plan Precondition (≥3 files)
98
172
 
99
173
  Any change touching three or more files — across `skills/`, `src/`, `bin/`, `commands/`, or any combination — must produce a stacked-PR plan as a precondition to the first edit landing. The 28-day usage report shows a clean correlation: sessions that opened with a stacked-PR plan landed at `fully_achieved`; sessions that began as a single big-bang multi-file edit landed at `partially_achieved` (landing-page dark theme, market-data-hub wiring, RAG misrouting). Single-concern PRs are the lever that closes that gap.
@@ -206,7 +280,7 @@ Clean separation, parallel development, easy cleanup.
206
280
 
207
281
  ## Using Superpowers
208
282
 
209
- Superpowers skills activate when their trigger conditions are detected. The dispatcher resolves each trigger through the five-source routing table above:
283
+ Superpowers skills activate when their trigger conditions are detected. The dispatcher resolves each trigger through the four-source routing table above:
210
284
 
211
285
  - "Create a feature" → `superpowers:brainstorming` → `superpowers:writing-plans` → `superpowers:executing-plans`
212
286
  - "Fix this bug" → `superpowers:systematic-debugging` → `superpowers:verification-before-completion`
@@ -38,7 +38,7 @@ Intercept the response flow to offer the user a choice about response depth **be
38
38
 
39
39
  Use the repository's canonical context-budget heuristics to estimate the prompt's token count mentally.
40
40
 
41
- Use the same calibration guidance as [context-budget](../context-budget/SKILL.md):
41
+ Use the same calibration guidance as `context-budget`:
42
42
 
43
43
  - prose: `words × 1.3`
44
44
  - code-heavy or mixed/code blocks: `chars / 4`
@@ -23,7 +23,21 @@ Invoke this skill:
23
23
 
24
24
  Every project has its own actual invocation for build / typecheck / lint / test / security / deploy-receipt. Hardcoding `npm run build` and `npm run test` works when the project happens to use those exact scripts; for everything else (pnpm, yarn, cargo, go, mise, just, custom scripts, monorepos with workspace-scoped commands) it returns "deps not installed" or "config not found" misreads from the wrong invocation. Phase 0 runs first so Phases 1–6 never have to guess.
25
25
 
26
- **Resolution priority** (first match wins):
26
+ **Run [`scripts/resolve-verify-ladder.mjs`](../scripts/resolve-verify-ladder.mjs)** at the repo root. It encodes the full four-step resolution priority and emits the fenced block below. Use `--json` for machine consumption.
27
+
28
+ ```
29
+ $ node scripts/resolve-verify-ladder.mjs
30
+ verify-ladder (resolved):
31
+ build: npm run build (sniff:package.json:scripts.build)
32
+ typecheck: npm run typecheck (sniff:package.json:scripts.typecheck)
33
+ lint: npm run lint (sniff:package.json:scripts.lint)
34
+ test: npm test (sniff:package.json:scripts.test)
35
+ security: (ask operator — no marker found)
36
+ deploy_receipt: (ask operator — no marker found)
37
+ synthetic_checks: (ask operator — no marker found)
38
+ ```
39
+
40
+ **Resolution priority** (first match wins; the script implements this — the prose is documentation):
27
41
 
28
42
  1. **`.claude/verify-ladder.json` manifest** at the repo root. Schema:
29
43
  ```json
@@ -36,24 +50,12 @@ Every project has its own actual invocation for build / typecheck / lint / test
36
50
  "deploy_receipt": "npx wrangler deployments list --json"
37
51
  }
38
52
  ```
39
- Any field omitted falls through to step 2 for that field only. A field set to the literal string `null` means "skip this phase for this project."
40
- 2. **Sniff `package.json` `scripts`** for `build`, `typecheck` or `tsc`, `lint`, `test`, `audit` or `security`. Tie-breaker when multiple scripts could match a phase: prefer `verify:<phase>` over `<phase>` over `<phase>:*`. Do NOT pick `test` when `verify:test` exists; the operator's explicit verification surface always wins over the convenience alias.
41
- 3. **Sniff per-language toolchain files** if `package.json` is absent: `Cargo.toml` → `cargo build` / `cargo test`, `go.mod` → `go build ./...` / `go test ./...`, `pyproject.toml` → `pytest` / `ruff check`, `Gemfile` → `bundle exec rspec`, etc.
42
- 4. **Ask the operator** if none of the above resolves the field. Do not invent.
53
+ Any field omitted falls through to step 2 for that field only. A field set to the literal JSON `null` means "skip this phase for this project" — the resolver records source `manifest:null`. Underscore-prefixed keys (`_doc`, `_node_example`, etc.) are ignored as documentation/examples.
54
+ 2. **Sniff `package.json` `scripts`** for `build`, `typecheck` or `tsc`, `lint`, `test`, `audit` or `security`. Tie-breaker when multiple scripts could match a phase: prefer `verify:<phase>` over `<phase>` over `<phase>:*` (wildcard tail). Do NOT pick `test` when `verify:test` exists; the operator's explicit verification surface always wins over the convenience alias.
55
+ 3. **Sniff per-language toolchain files** if `package.json` is absent: `Cargo.toml` → `cargo build` / `cargo check` / `cargo clippy` / `cargo test` / `cargo audit`, `go.mod` → `go build ./...` / `go vet ./...` / `go test ./...`, `pyproject.toml` → `pyright` / `ruff check .` / `pytest`, `Gemfile` → `bundle exec rspec` / `bundle exec rubocop`.
56
+ 4. **Ask the operator** (source `ask-operator`) if none of the above resolves the field. Do not invent.
43
57
 
44
- **Output the resolved ladder** as a single fenced block before running any phase, so the operator can spot a wrong resolution before it costs a misread:
45
-
46
- ```
47
- verify-ladder (resolved):
48
- build: npm run build
49
- typecheck: npx tsc --noEmit (sniff: package.json scripts.typecheck)
50
- lint: npm run lint
51
- test: npm test
52
- security: (skipped — no script defined)
53
- deploy_receipt: npx wrangler deployments list --json (manifest)
54
- ```
55
-
56
- Each row shows the resolved command + its source (manifest, sniff, or skipped). The fenced block is the contract surface — every later phase reads from this resolved ladder, never from a hardcoded fallback.
58
+ Each row shows the resolved command + its source (`manifest`, `sniff:<file>:<key>`, `manifest:null`, or `ask-operator`). The fenced block is the contract surface every later phase reads from this resolved ladder, never from a hardcoded fallback.
57
59
 
58
60
  A starter manifest is provided at `templates/verify-ladder.example.json`; copy it to `.claude/verify-ladder.json` and trim per project.
59
61
 
@@ -143,7 +145,11 @@ If either is `No`, the verification report goes back to the operator with the ex
143
145
 
144
146
  ### Phase 8: Deploy Receipt (auto-deploy projects only)
145
147
 
146
- For repos whose `verify-ladder.json` declares a `deploy_receipt` field — or whose sniff path detects an auto-deploy target (Railway, Cloudflare Workers, Vercel, Netlify, Fly.io) — the verify is not complete until the deployed SHA matches the merge SHA and a healthcheck returns 200. Hand off to the `deploy-receipt` skill (Law 4 deploy-seam companion landed in PR #83) and treat its `Receipt status: COMPLETE` as the gate.
148
+ For repos whose `verify-ladder.json` declares a `deploy_receipt` field — or whose sniff path detects an auto-deploy target — the verify is not complete until the deployed SHA matches the merge SHA and a healthcheck returns 200. Hand off to the `deploy-receipt` skill (Law 4 deploy-seam companion landed in PR #83) and treat its `Receipt status: COMPLETE` as the gate.
149
+
150
+ **Detection.** Run [`scripts/detect-deploy-target.sh`](../scripts/detect-deploy-target.sh) at the repo root. Output is one of `railway` / `cloudflare` / `vercel` / `netlify` / `fly` / `appengine` / `apprunner` / `gha-deploy` / `none`. Anything except `none` triggers handoff to `deploy-receipt`; `none` means Phase 8 is skipped (no deploy seam exists).
151
+
152
+ **SHA extraction.** For the detected provider, [`scripts/get-deployed-sha.sh <provider>`](../scripts/get-deployed-sha.sh) returns the currently-deployed SHA via the provider CLI; `--show-command <provider>` prints the pipeline shape without executing (useful for dry-runs and citation). `deploy-receipt` owns the receipt's other components (health endpoint, build artifact, on-incomplete modes) and Route B/C fallbacks.
147
153
 
148
154
  INCOMPLETE receipts move to "Immediate operator action" in the close, never to "ready". Library-only / package-published repos skip this phase entirely (no deploy seam exists).
149
155
 
@@ -158,11 +164,13 @@ Phase 8 confirms the deploy seam. Phase 9 confirms the deployed surface matches
158
164
 
159
165
  **What the runner does:**
160
166
 
167
+ Implementation: `scripts/run-synthetic.mjs` encodes the lexical walk, interpreter map, env injection, and exit-code aggregation below. The prose is documentation, not the contract — when the two disagree, the script wins.
168
+
161
169
  1. List every `*.synthetic.{sh,mjs,ts,py}` file in the resolved directory in lexical order.
162
170
  2. For each file, set the input env vars: `BASE_URL` (production base from project config), `BASELINE_URL` (staging baseline from project config), `EXPECTED_SHA` (the merge SHA Phase 8 reported COMPLETE), `DEPLOY_BRANCH` (the deploy branch name), `RECEIPT_TIMESTAMP` (ISO-8601 of the receipt).
163
171
  3. Invoke the file via the right interpreter (`bash` for `.sh`, `node` for `.mjs`, `tsx` for `.ts`, `python` for `.py`). Files with unrecognized extensions are skipped with a warning.
164
172
  4. Capture stdout + stderr + exit code per file. On exit 0, the check passed. On any non-zero exit, the check failed and stdout is the operator-facing diff.
165
- 5. Aggregate: if every file exited 0, Phase 9 is `PASS`. If any file exited non-zero, Phase 9 is `FAIL — synthetic drift on <filenames>` and the captured diffs go into the verification report verbatim (no agent re-summarization).
173
+ 5. Aggregate: if every file exited 0, Phase 9 is `PASS`. If any file exited non-zero, Phase 9 is `FAIL — synthetic drift on <filenames>` and the captured diffs go into the verification report verbatim (no agent re-summarization). Exit code 2 with zero drift (every non-pass was a config error from the check itself) surfaces as `INCOMPLETE — config error` to distinguish "gate did not run" from "gate ran and found drift".
166
174
 
167
175
  **Surfacing rule:**
168
176
 
@@ -3,6 +3,7 @@ name: wild-risa-balance
3
3
  tier: "2"
4
4
  description: Enforces Law 2 (Plan Is Sacred) of the 7 Laws of AI Agent Discipline. Decision-framing lens that pairs WILD generation with RISA execution when emitting recommendation lists. Not a runtime hook.
5
5
  origin: continuous-improvement
6
+ user-invocable: false
6
7
  ---
7
8
 
8
9
  # WILD / RISA Balance
@@ -74,7 +74,7 @@ Probe and record (no destructive commands; quote results inline):
74
74
  - **jq availability.** `command -v jq` (or `Get-Command jq`). When jq is missing, observation-pipeline hooks fall back to a thin schema and curl/JSON one-liners need a node/python rewrite.
75
75
  - **Case-sensitive filesystem.** Test by creating two paths differing only in case in a tempdir. NTFS (Windows) and APFS (macOS default) are case-insensitive; Linux ext4 and case-sensitive APFS are case-sensitive. Affects `CLAUDE.md` vs `claude.md` resolution and import paths.
76
76
  - **CWD baseline.** `pwd` (or `Get-Location`) recorded at session start. `tsc`, build scripts, and some test runners change CWD as a side effect; subsequent commands run from the wrong directory return "deps not installed" or "config not found" misreads.
77
- - **Parallel-actor expectation.** Document whether a second Claude / Codex / Maulana session may operate on the same working tree. If yes, the `gateguard` Parallel-Actor Gate must baseline `git rev-parse HEAD` + `git status --porcelain` + upstream before the first mutation, and re-check on every subsequent mutation.
77
+ - **Parallel-actor expectation.** Document whether a second Claude / Codex / Maulana session may operate on the same working tree. If yes, the `gateguard` Parallel-Actor Gate uses [`scripts/git-state-snapshot.sh`](../scripts/git-state-snapshot.sh) to produce a single JSON envelope (`{head, upstream, dirty, root, branch}`) for the baseline and the divergence check. This skill records whether parallel-actor is expected; gateguard owns the runtime mechanics, so the audit doesn't restate the git-command triple.
78
78
 
79
79
  Output the recorded grain as a single fenced block so it survives context compaction and any later phase can reference it without re-probing:
80
80
 
@@ -3,6 +3,7 @@ name: worktree-safety
3
3
  tier: "2"
4
4
  description: "Enforces Law 4 (Verify Before Reporting) of the 7 Laws of AI Agent Discipline. Pre-dispatch invariant: validate worktree root before any source-writing tool call. Catches missing .git, fallback path-only creation, stale leases, foreign-session ownership, and non-worktree git operations before they corrupt history."
5
5
  origin: continuous-improvement
6
+ user-invocable: false
6
7
  ---
7
8
 
8
9
  # Worktree Safety Skill
@@ -31,10 +32,10 @@ The continuous-improvement repo runs on Windows + Git Bash with `autocrlf=true`
31
32
 
32
33
  Before any source-writing call, verify all five. Fail closed on any miss.
33
34
 
34
- 1. **Root validity** — `git rev-parse --show-toplevel` resolves; the resolved path matches CWD after symlink-safe canonicalization.
35
+ 1. **Root validity** — `git rev-parse --show-toplevel` resolves; the resolved path matches CWD after symlink-safe canonicalization. The `root` field of [`scripts/git-state-snapshot.sh`](../scripts/git-state-snapshot.sh) carries the canonicalized root, and its non-zero exit on `{"error":"not-a-git-repo"}` is itself the fail-closed signal — no second probe needed.
35
36
  2. **`.git` presence** — `.git` exists (file pointer for worktrees, directory for primary checkout). A missing or unreadable `.git` is an immediate stop.
36
37
  3. **Worktree registration** — `git worktree list` includes the resolved root with no `prunable` flag. Prunable worktrees can be deleted by another process at any moment.
37
- 4. **Branch alignment** — current branch matches the lease ledger; `HEAD` is not detached unless the unit explicitly asked for detached state.
38
+ 4. **Branch alignment** — current branch matches the lease ledger; `HEAD` is not detached unless the unit explicitly asked for detached state. The snapshot script's `branch` field carries either the branch name or the literal `"detached"`, so detached-state is observable without a second probe.
38
39
  5. **Lease ownership** — the session ID in `.git/worktrees/<name>/lease` (or your equivalent ledger) matches this session. Stale or foreign leases block the call.
39
40
 
40
41
  Output a single fenced block before any source-writing dispatch:
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "continuous-improvement",
3
- "version": "3.9.2",
3
+ "version": "3.11.0",
4
4
  "mode": "expert",
5
5
  "description": "Expert mode: tune confidence, manage instincts, and persist plans on disk. Adds safety, token-budget, and strategic-compact skills plus the /learn-eval command so long sessions stay disciplined and learnings survive context resets.",
6
6
  "tools": [
@@ -16,6 +16,10 @@
16
16
  "name": "ci_reflect",
17
17
  "what": "Reflect on what you did this session"
18
18
  },
19
+ {
20
+ "name": "ci_gateguard_clear",
21
+ "what": "Clear the GateGuard gate for files after presenting facts"
22
+ },
19
23
  {
20
24
  "name": "ci_reinforce",
21
25
  "what": "Accept or reject instinct suggestions to tune confidence"
@@ -51,6 +55,26 @@
51
55
  {
52
56
  "name": "ci_load_pack",
53
57
  "what": "Load starter instinct packs (react, python, go) into the current project"
58
+ },
59
+ {
60
+ "name": "ci_goal_check",
61
+ "what": "Detect when a session has drifted from its stated goal"
62
+ },
63
+ {
64
+ "name": "ci_recall",
65
+ "what": "Search past sessions for relevant prior activity (episodic recall)"
66
+ },
67
+ {
68
+ "name": "ci_distill_candidates",
69
+ "what": "Find repeated successful tool sequences worth turning into skills"
70
+ },
71
+ {
72
+ "name": "ci_distill_propose",
73
+ "what": "Draft a reusable instinct from a repeated successful pattern"
74
+ },
75
+ {
76
+ "name": "ci_distill_promote",
77
+ "what": "Promote an edited draft into a live instinct"
54
78
  }
55
79
  ],
56
80
  "setup": {
@@ -83,9 +107,10 @@
83
107
  "included": [
84
108
  "PreToolUse",
85
109
  "PostToolUse",
110
+ "UserPromptSubmit",
86
111
  "SessionStart",
87
112
  "SessionEnd"
88
113
  ],
89
- "description": "Full hook suite: observation capture + session-level instinct loading and auto-reflection."
114
+ "description": "Full hook suite: observation capture, lazy prompt routing, session-level instinct loading, and auto-reflection."
90
115
  }
91
116
  }
package/skills/README.md CHANGED
@@ -44,6 +44,9 @@ These ship in the same plugin bundle regardless of mode and are available the mo
44
44
  |-------|--------------|--------|
45
45
  | `ralph` | Autonomous loop that executes a PRD story-by-story with quality checks between iterations | [snarktank/ralph](https://github.com/snarktank/ralph) |
46
46
  | `superpowers` | **Law activator.** Routes tasks to the correct Law-aligned specialist (brainstorming → Law 2, writing-plans → Law 2, TDD → Law 3+4, verification-before-completion → Law 4, etc.) so the right discipline fires automatically. Not a peer skill — a dispatcher for the others. | [obra/superpowers](https://github.com/obra/superpowers) |
47
+ | `handoff` | One-shot session compaction into an `mktemp`-backed markdown brief a fresh agent can pick up cold — goal, current state, decisions, open questions, next step, skills to load | [mattpocock/skills](https://github.com/mattpocock/skills/blob/main/skills/in-progress/handoff/SKILL.md) |
48
+ | `grill-me` | Pre-execution alignment interrogation — interview the user one question at a time, walking every branch of the decision tree with a recommended answer for each, until the spec is shippable cold to a fresh agent | [mattpocock/skills](https://github.com/mattpocock/skills/blob/main/skills/productivity/grill-me/SKILL.md) |
49
+ | `grill-with-docs` | Grilling-with-persistent-outcomes — challenges the plan against the existing `CONTEXT.md` glossary, sharpens fuzzy terminology, cross-references user statements against code, and updates `CONTEXT.md` + `docs/adr/` inline as decisions crystallise. Bundles a CONTEXT.md format spec and an ADR format spec as appendices | [mattpocock/skills](https://github.com/mattpocock/skills/blob/main/skills/engineering/grill-with-docs/SKILL.md) |
47
50
  | `workspace-surface-audit` | Audits the active repo, MCP servers, plugins, and env, then recommends high-value skills/workflows | continuous-improvement |
48
51
 
49
52
  ## How they get to your machine
@@ -0,0 +1,73 @@
1
+ ---
2
+ name: audit
3
+ tier: "2"
4
+ description: Enforces Law 4 (Verify Before Reporting) of the 7 Laws of AI Agent Discipline. Audits a window of recent commits for real defects, confirms each finding before touching code so false positives die first, and checks every surface a change touches — so 'looks done' is never mistaken for 'is correct'.
5
+ origin: continuous-improvement
6
+ user-invocable: true
7
+ ---
8
+
9
+ # Audit — Confirm Recent Commits Before You Trust Them
10
+
11
+ Law 4 says verify before reporting. A merged commit with green CI is a claim, not a proof. This skill runs the audit-driven loop: take a window of recent commits, hunt for real defects, prove each one before touching code, fix on a branch, and verify every surface the fix touches before declaring the audit clean.
12
+
13
+ ## When to Activate
14
+
15
+ - After a batch of commits lands ("audit today's commits"), especially on money-handling, auth, or state-mutating code.
16
+ - When a feature shipped across several surfaces (backend, frontend, admin, migration) and you suspect one was missed.
17
+ - After a large refactor or a conflicted merge — exactly when individually-correct functions can still cancel each other out.
18
+ - Before a release cut, as the last gate over "everything claimed done."
19
+
20
+ ## The Loop
21
+
22
+ ```
23
+ 1. Scope — pick the commit window (e.g. main since last release, or HEAD~N..HEAD)
24
+ 2. Find — hunt for real defects, one concern per pass
25
+ 3. Confirm — prove each finding against the actual code; false positives die here
26
+ 4. Fix — one branch, one concern per commit, smallest diff that closes the defect
27
+ 5. Verify — exercise EVERY surface the fix touches, not just the one you edited
28
+ 6. Report — confirmed defects, dismissed false positives, and no-op items, with evidence
29
+ ```
30
+
31
+ ## Find: One Concern Per Pass
32
+
33
+ Run the find pass once per dimension rather than one undifferentiated sweep. The dimensions that have actually caught defects in this codebase's domain:
34
+
35
+ - **Value/economy drift** — a constant duplicated across surfaces (a prize array hardcoded in the frontend while the backend reads an endpoint; a cap defined twice). Grep both sides; compare.
36
+ - **Concurrency** — a read-modify-write with no guard, a settlement that is not idempotent, a row that can get stuck between two states.
37
+ - **Surface coverage** — a change that updated the backend but not the admin filter or the client cache that mirrors it.
38
+ - **Type/contract** — a payload shape that one side narrowed and the other did not.
39
+
40
+ For a thorough audit, use the `superpowers:dispatching-parallel-agents` skill to fan these out as parallel reviewers — each blind to the others — then merge findings.
41
+
42
+ ## Confirm Before Fixing
43
+
44
+ A finding is a hypothesis until proven against the code. Before writing any fix:
45
+
46
+ - Read the actual lines, not the diff summary. Confirm the defect reproduces in the current tree.
47
+ - State why it is real in one sentence. If you cannot, it is a false positive — record it as dismissed and move on.
48
+ - Prefer a failing test that reproduces the defect, then fix to green (`tdd-workflow`).
49
+
50
+ Defaulting findings to "real" is how plausible-but-wrong fixes get shipped. Default to skeptical; make the code prove the bug.
51
+
52
+ ## Verify Every Surface the Fix Touches
53
+
54
+ The recurring failure this skill exists to stop: a fix that the agent claims is done while the frontend array, admin filter, or cached copy still carries the old value. This is the functional-surface check `audit` gates before reporting — not the build/test/lint ladder itself (that is `verification-loop`). Before reporting an item closed:
55
+
56
+ - List every surface the changed value or behavior touches (backend, frontend, admin, migration, cache, generated artifact).
57
+ - Re-check each surface yourself — do not assume one auto-updates from another.
58
+ - On each surface, run the resolved `verification-loop` ladder against the code that implements it, not a manual spot-check.
59
+
60
+ This applies the `verification-loop` (Law 4) and `goal-monitor` (Law 2) discipline to someone else's recent work.
61
+
62
+ ## Report Honestly
63
+
64
+ Three buckets, with evidence: **confirmed** (defect + fix + the check that proves it), **dismissed** (looked like a bug, here is why it is not), **no-op** (in scope but nothing to change). Silence on a surface is not a pass.
65
+
66
+ ## Pairs With
67
+
68
+ - **`code-review`** / **`security-review`** — the dimension passes; `audit` is the loop that runs them over a commit window and acts on the output.
69
+ - **`superpowers:dispatching-parallel-agents`** — fan the find pass out across dimensions, then verify each finding adversarially.
70
+ - **`verification-loop`** (Law 4) — the build/test/lint ladder `audit` runs on each surface before a finding is closed.
71
+ - **`goal-monitor`** (Law 2) — confirms the fix still serves the task goal, not just that it compiles.
72
+ - **`recall`** (Law 1) — before confirming a finding, recall whether this exact defect was hit and fixed before.
73
+ - **`reconcile`** (Law 1) — when the audit ends in a fix, reconcile the branch state before pushing.
@@ -3,6 +3,7 @@ name: deploy-receipt
3
3
  tier: "1"
4
4
  description: Enforces Law 4 (Verify Before Reporting) of the 7 Laws of AI Agent Discipline at the deploy seam. A merge into a branch that auto-deploys is not "done" until the deploy provider reports the merged commit SHA running and a healthcheck endpoint returns 200. Companion to the vendored `finishing-a-development-branch` skill — does not replace it, runs after it for projects on Railway, Cloudflare Workers, Vercel, Netlify, Fly.io, or any other auto-deploy target.
5
5
  origin: https://github.com/naimkatiman/continuous-improvement
6
+ disable-model-invocation: true
6
7
  ---
7
8
 
8
9
  # Deploy Receipt — Closing the Merge-to-Production Gap
@@ -20,14 +21,7 @@ This skill defines the receipt that closes that gap, without modifying the vendo
20
21
  Activate when ALL of the following are true:
21
22
 
22
23
  1. A merge into the deploy branch (typically `main` or `master`) has just landed
23
- 2. The repo declares an auto-deploy targetdetect via any of:
24
- - `railway.toml`, `railway.json`, or `RAILWAY_*` env vars in `.env.example`
25
- - `wrangler.toml` / `wrangler.jsonc` (Cloudflare Workers)
26
- - `vercel.json` or `.vercel/` directory
27
- - `netlify.toml`
28
- - `fly.toml`
29
- - `app.yaml` (App Engine), `apprunner.yaml` (App Runner)
30
- - GitHub Actions workflow with `deploy:` job triggered on push to the deploy branch
24
+ 2. [`scripts/detect-deploy-target.sh`](../scripts/detect-deploy-target.sh) returns a value other than `none` at the repo root. The script encodes the full file-marker table`railway.toml` / `railway.json` → `railway`, `wrangler.toml` / `wrangler.jsonc` → `cloudflare`, `vercel.json` / `.vercel/` → `vercel`, `netlify.toml` → `netlify`, `fly.toml` → `fly`, `app.yaml` → `appengine`, `apprunner.yaml` → `apprunner`, `.github/workflows/*.yml` with a `deploy:` job → `gha-deploy`. First match wins, in that order. The script is the source of truth; the file list above is documentation
31
25
  3. `finishing-a-development-branch` has reported "merged" — not "PR opened", not "review pending"
32
26
 
33
27
  Do NOT activate when:
@@ -51,17 +45,19 @@ The skill is provider-aware but never hardcodes a specific API key or token shap
51
45
 
52
46
  ### Route A — Provider CLI (preferred when authenticated)
53
47
 
54
- The CLI is the highest-fidelity source.
48
+ The CLI is the highest-fidelity source. Run [`scripts/get-deployed-sha.sh <provider>`](../scripts/get-deployed-sha.sh) — the script owns the per-provider pipeline (CLI + jq filter) and prints just the SHA on stdout. Inspect the pipeline shape without executing via `bash scripts/get-deployed-sha.sh --show-command <provider>`.
55
49
 
56
- | Provider | Command shape | Receipt extraction |
57
- |---|---|---|
58
- | Railway | `railway status --json` | `.deployments[0].meta.commitHash` |
59
- | Cloudflare Workers | `wrangler deployments list --json` | `[0].metadata.deployment_trigger.metadata.commit_hash` |
60
- | Vercel | `vercel inspect <url> --json` | `.gitSource.sha` |
61
- | Netlify | `netlify api listSiteDeploys --data='{"site_id":"<id>"}'` | `[0].commit_ref` |
62
- | Fly.io | `fly releases --json` | `[0].commit_sha` |
50
+ Provider-to-pipeline map (cited from the script, not redefined here):
63
51
 
64
- If the CLI is not installed or not authenticated in this session, fall through to Route B. Do NOT prompt the operator to install the CLI mid-session — that is a drive-by.
52
+ | Provider value | CLI |
53
+ |---|---|
54
+ | `railway` | `railway` |
55
+ | `cloudflare` | `wrangler` |
56
+ | `vercel` | `vercel` |
57
+ | `netlify` | `netlify` |
58
+ | `fly` | `fly` |
59
+
60
+ Exit codes from the script: `0` on success (SHA printed), `2` on missing/unknown provider (usage error), `3` when the required CLI is not installed locally — that is the fall-through signal to Route B, not a hard failure. Do NOT prompt the operator to install the CLI mid-session — that is a drive-by.
65
61
 
66
62
  ### Route B — GitHub Deployments API (works for any provider that posts back)
67
63
 
@@ -3,6 +3,7 @@ name: gateguard
3
3
  tier: "1"
4
4
  description: Enforces Law 1 (Research Before Executing) of the 7 Laws of AI Agent Discipline. Fact-forcing gate that blocks Edit/Write/Bash (including MultiEdit) and demands concrete investigation (importers, data schemas, user instruction) before allowing the action. Measurably improves output quality by +2.25 points vs ungated agents.
5
5
  origin: community
6
+ user-invocable: false
6
7
  ---
7
8
 
8
9
  # GateGuard — Fact-Forcing Pre-Action Gate
@@ -96,30 +97,37 @@ A second Claude/Codex/Maulana session can be running on the same host and the sa
96
97
 
97
98
  **On the first Edit / Write / mutating Bash of a session:**
98
99
 
100
+ Run [`scripts/git-state-snapshot.sh`](../scripts/git-state-snapshot.sh) and quote its JSON envelope verbatim. Example output:
101
+
102
+ ```
103
+ {"head":"966ce51","upstream":"966ce51","dirty":0,"root":"/path/to/repo","branch":"main"}
99
104
  ```
100
- Baseline these three values and quote them in your response:
101
105
 
102
- 1. `git rev-parse HEAD` — record the commit you started on
103
- 2. `git rev-parse @{u}` (if branch tracks an upstream) — record where origin was
104
- 3. `git status --porcelain` — record the working tree state
106
+ Field meanings:
105
107
 
106
- If any value is "unknown" (detached HEAD, no upstream, untracked-only tree),
107
- say so explicitly. Do not proceed past the baseline silently.
108
- ```
108
+ 1. `head` short SHA of the commit you started on
109
+ 2. `upstream` short SHA of `@{u}` if the branch tracks an upstream, else the literal `"none"`
110
+ 3. `dirty` — integer count of `git status --porcelain` lines (0 == clean)
111
+ 4. `root` — repo root path from `git rev-parse --show-toplevel`
112
+ 5. `branch` — current branch name, or the literal `"detached"`
113
+
114
+ If `upstream` is `"none"` or `branch` is `"detached"`, say so explicitly. Do not proceed past the baseline silently. If the script exits non-zero (output is `{"error":"not-a-git-repo"}`), HALT — the harness is not running in a git checkout and no mutation should land here.
109
115
 
110
116
  **On every subsequent Edit / Write / mutating Bash, before allowing the action:**
111
117
 
112
- ```
113
- Re-check the three baselines against current state:
118
+ Re-run [`scripts/git-state-snapshot.sh`](../scripts/git-state-snapshot.sh) and diff against the baseline:
114
119
 
115
- 1. `git rev-parse HEAD` — has it advanced past your baseline without your commits?
116
- 2. `git rev-parse @{u}` — did upstream move while you worked?
117
- 3. `git status --porcelain` — are there modifications you did not introduce?
120
+ 1. `head` — has it advanced past your baseline without your commits?
121
+ 2. `upstream` — did upstream move while you worked?
122
+ 3. `dirty` — are there modifications you did not introduce (count increased)?
123
+ 4. `branch` — did the working tree switch branches under you?
118
124
 
119
125
  If ANY of those drifted from baseline, HALT. Emit:
120
- "Parallel-actor divergence: <field> moved from <baseline> to <current>.
126
+
127
+ ```
128
+ Parallel-actor divergence: <field> moved from <baseline> to <current>.
121
129
  Working tree may belong to another session. Stop, surface to operator,
122
- get clearance before next mutation."
130
+ get clearance before next mutation.
123
131
  ```
124
132
 
125
133
  This gate is what catches the squash-merge / ahead-of-origin trap recorded in the operator's memory (`feedback_pre_branch_check.md`, `feedback_parallel_actor.md`) — both classes of failure occurred because a baseline was never captured at session start.
@@ -132,14 +140,25 @@ This gate is what catches the squash-merge / ahead-of-origin trap recorded in th
132
140
 
133
141
  Smoke-test the runtime gate after install: ask Claude to write a throwaway file with no research first. The hook should return a `block` decision with a fact-list reason; Claude should pause rather than write.
134
142
 
143
+ ### Clearing the gate (after presenting the facts)
144
+
145
+ The block reason prints the exact `gateguard-session.json` path and the clearance commands. Clearance matches a file regardless of drive-letter case or path separator (`d:\x` and `D:/x` resolve to the same key), so it no longer matters whether the hook and the helper spelled the project root differently. Any one of these allows the retry:
146
+
147
+ - **MCP tool** (beginner + expert): `ci_gateguard_clear` with `file_paths: ["<path>", …]`.
148
+ - **CLI** (Bash, never gated): `node "${CLAUDE_PLUGIN_ROOT}/bin/gateguard-clear.mjs" "<path>"`; add `--state <gateguard-session.json>` to write the exact file the block reason printed.
149
+ - **Manual**: append each path to `cleared_files` in the printed `gateguard-session.json` via a non-destructive Bash write.
150
+
151
+ The inline `_gateguard_facts_presented: true` retry still works on harnesses that forward unknown tool params, but Claude Code's strict tool schema (`additionalProperties: false`) rejects it with `InputValidationError` — use one of the above on Claude Code.
152
+
135
153
  ### V1 honest limitations (not mitigated, documented)
136
154
 
137
- - **Honor system.** Once the agent flips `_gateguard_facts_presented: true` in `tool_input`, the hook can't verify the investigation actually happened. The 50-file cap bounds damage from stuck loops or rogue agents.
155
+ - **Honor system.** Clearance is recorded by `ci_gateguard_clear`, the `gateguard-clear.mjs` CLI, a manual state-file write, or the inline `_gateguard_facts_presented` flag where the harness allows it (see "Clearing the gate" above). The hook can't verify the investigation actually happened; the 50-file cap bounds damage from stuck loops or rogue agents.
138
156
  - **State-file deletion.** `rm`-ing the session state resets every gate. Acceptable because the session itself is the trust boundary.
139
157
  - **Parallel-hook race.** Two simultaneous hook invocations can race the read+write of the state file. Acceptable trade-off vs Windows atomic-rename complexity.
140
- - **MultiEdit V1.** Currently gates on `edits[0].file_path` only. Per-file batching is a TODO.
141
158
 
142
- All four documented in `src/hooks/gateguard.mts` and `src/lib/gateguard-state.mts` headers.
159
+ **MultiEdit per-file gating.** The hook clears and checks every `edits[]` path individually, so a mixed-clearance batch blocks until *all* edited files are cleared or facts are presented. The block reason now names the whole batch, not just the first uncleared path.
160
+
161
+ These behaviors are documented in `src/hooks/gateguard.mts` and `src/lib/gateguard-state.mts` headers.
143
162
 
144
163
  ### Future: third-party `gateguard-ai` package
145
164