@softspark/ai-toolkit 4.2.3 → 4.2.5

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 (52) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +10 -9
  3. package/action.yml +1 -1
  4. package/app/.claude-plugin/plugin.json +1 -1
  5. package/app/hooks/_hook-io.sh +64 -0
  6. package/app/hooks/_locate-toolkit.sh +39 -0
  7. package/app/hooks/_search-capability.sh +46 -0
  8. package/app/hooks/commit-quality.sh +3 -1
  9. package/app/hooks/config-desync-guard.sh +95 -0
  10. package/app/hooks/governance-capture.sh +5 -3
  11. package/app/hooks/guard-config.sh +5 -3
  12. package/app/hooks/guard-destructive.sh +3 -1
  13. package/app/hooks/guard-path.sh +8 -1
  14. package/app/hooks/instructions-audit.sh +43 -0
  15. package/app/hooks/post-tool-use.sh +20 -8
  16. package/app/hooks/quality-gate.sh +47 -0
  17. package/app/hooks/revert-guard.sh +84 -0
  18. package/app/hooks/search-tracker.sh +18 -0
  19. package/app/hooks/session-start.sh +14 -2
  20. package/app/hooks/stop-search-check.sh +37 -0
  21. package/app/hooks/test-cohesion-map.json +77 -0
  22. package/app/hooks/test-cohesion.sh +93 -0
  23. package/app/hooks/track-usage.sh +3 -1
  24. package/app/hooks/user-prompt-submit.sh +33 -6
  25. package/app/hooks.json +65 -1
  26. package/app/skills/ci/SKILL.md +1 -1
  27. package/app/skills/ci/templates/github-actions-node.yml +2 -2
  28. package/app/skills/ci/templates/github-actions-python.yml +1 -1
  29. package/app/skills/ci-cd-patterns/SKILL.md +8 -8
  30. package/app/skills/csharp-patterns/SKILL.md +1 -1
  31. package/app/skills/docker-devops/SKILL.md +4 -4
  32. package/benchmarks/ecosystem-doctor-snapshot.json +8 -8
  33. package/kb/procedures/ecosystem-sync-sop.md +1 -1
  34. package/kb/procedures/release-verification-sop.md +2 -2
  35. package/kb/reference/architecture-overview.md +1 -1
  36. package/kb/reference/ci-integration.md +2 -2
  37. package/kb/reference/hooks-catalog.md +149 -24
  38. package/kb/reference/unique-features.md +11 -5
  39. package/llms-full.txt +166 -35
  40. package/manifest.json +1 -1
  41. package/package.json +1 -1
  42. package/scripts/doctor.py +13 -0
  43. package/scripts/generate_augment_hooks.py +5 -1
  44. package/scripts/generate_codex_hooks.py +2 -0
  45. package/scripts/generate_cursor_hooks.py +6 -0
  46. package/scripts/generate_gemini_hooks.py +5 -1
  47. package/scripts/generate_windsurf_hooks.py +6 -0
  48. package/scripts/install_steps/hooks.py +5 -0
  49. package/scripts/merge-hooks.py +10 -1
  50. package/scripts/plugin_schema.py +4 -0
  51. package/scripts/session_state.py +150 -0
  52. package/scripts/test_cohesion.py +133 -0
@@ -1,5 +1,5 @@
1
1
  {
2
- "last_run": "2026-05-12T10:01:38Z",
2
+ "last_run": "2026-05-12T19:04:22Z",
3
3
  "schema_version": 1,
4
4
  "tools": {
5
5
  "aider": {
@@ -24,7 +24,7 @@
24
24
  }
25
25
  },
26
26
  "augment": {
27
- "docs_hash": "b746d5dbbc5a2936",
27
+ "docs_hash": "ceaf27b7126f44dd",
28
28
  "headings": [
29
29
  "Agent",
30
30
  "Chat",
@@ -57,7 +57,7 @@
57
57
  }
58
58
  },
59
59
  "claude-code": {
60
- "docs_hash": "9e0292a9f92392e0",
60
+ "docs_hash": "6ea2ec6ef023c1bd",
61
61
  "headings": [
62
62
  "Claude Code overview",
63
63
  "Documentation Index",
@@ -137,7 +137,7 @@
137
137
  }
138
138
  },
139
139
  "codex-cli": {
140
- "docs_hash": "3f963da56d00add9",
140
+ "docs_hash": "c8fb328bf1954fc2",
141
141
  "headings": [
142
142
  "About",
143
143
  "Contributing",
@@ -189,7 +189,7 @@
189
189
  "version": "codex-cli 0.130.0"
190
190
  },
191
191
  "cursor": {
192
- "docs_hash": "705adfd617433088",
192
+ "docs_hash": "787203a4eee076f7",
193
193
  "headings": [],
194
194
  "markers": {
195
195
  ".cursor/rules": false,
@@ -205,7 +205,7 @@
205
205
  }
206
206
  },
207
207
  "gemini-cli": {
208
- "docs_hash": "93694630a3d04327",
208
+ "docs_hash": "26555623f610ff8e",
209
209
  "headings": [
210
210
  "Breadcrumbs",
211
211
  "Directory actions",
@@ -244,7 +244,7 @@
244
244
  }
245
245
  },
246
246
  "github-copilot": {
247
- "docs_hash": "d9b9fcdfe3b67469",
247
+ "docs_hash": "1566c05f84f5c1a7",
248
248
  "headings": [
249
249
  "About Copilot auto model selection",
250
250
  "About Copilot integrations",
@@ -353,7 +353,7 @@
353
353
  }
354
354
  },
355
355
  "windsurf": {
356
- "docs_hash": "66295add1d0f0645",
356
+ "docs_hash": "7a8a7569f81eba1b",
357
357
  "headings": [
358
358
  "Advanced",
359
359
  "App Deploys",
@@ -231,7 +231,7 @@ jobs:
231
231
  doctor:
232
232
  runs-on: ubuntu-latest
233
233
  steps:
234
- - uses: actions/checkout@v4
234
+ - uses: actions/checkout@v6
235
235
  - run: python3 scripts/ecosystem_doctor.py --format text | tee /tmp/doctor.txt
236
236
  - run: python3 scripts/ecosystem_doctor.py --check
237
237
  ```
@@ -144,7 +144,7 @@ ai-toolkit doctor
144
144
  - Environment: node, bash, python3, bats
145
145
  - Global Install: .claude exists, agents/skills symlinks (0 broken), settings.json hooks
146
146
  - Hook Scripts: all present and executable
147
- - Hook Configuration: 12 events registered
147
+ - Hook Configuration: 14 events registered
148
148
  - Generated Artifacts: AGENTS.md, llms.txt, llms-full.txt
149
149
  - Planned Assets: plugin.json, benchmarks, plugin packs
150
150
  - Benchmark Freshness: < 30 days
@@ -194,7 +194,7 @@ python3 scripts/audit_skills.py --ci
194
194
 
195
195
  **Verify validate.py:**
196
196
  - [ ] Agents >= 44, Skills >= 99, Tests >= 900
197
- - [ ] Hook events: 12, Hook scripts: >= 20
197
+ - [ ] Hook events: 14, Hook scripts: >= 30
198
198
  - [ ] Plugin packs >= 10, KB documents >= 20
199
199
  - [ ] `Errors: 0 | Warnings: 0` → `VALIDATION PASSED`
200
200
 
@@ -264,7 +264,7 @@ Agents (code-reviewer, debugger, devops-implementer, ...)
264
264
 
265
265
  ## Quality Hooks
266
266
 
267
- 22 entries across 12 lifecycle events. See [hooks-catalog.md](hooks-catalog.md) for full details.
267
+ 28 entries across 14 lifecycle events. See [hooks-catalog.md](hooks-catalog.md) for full details.
268
268
 
269
269
  | Hook | Trigger | Script | Action |
270
270
  |------|---------|--------|--------|
@@ -25,7 +25,7 @@ jobs:
25
25
  validate:
26
26
  runs-on: ubuntu-latest
27
27
  steps:
28
- - uses: actions/checkout@v4
28
+ - uses: actions/checkout@v6
29
29
  - uses: softspark/ai-toolkit@v1
30
30
  with:
31
31
  command: validate
@@ -50,7 +50,7 @@ jobs:
50
50
  For simpler setups without the action:
51
51
 
52
52
  ```yaml
53
- - uses: actions/setup-node@v4
53
+ - uses: actions/setup-node@v6
54
54
  with:
55
55
  node-version: 20
56
56
  - run: npx @softspark/ai-toolkit validate
@@ -13,7 +13,7 @@ description: "Complete reference of all ai-toolkit hooks: events, scripts, insta
13
13
 
14
14
  ## Overview
15
15
 
16
- ai-toolkit provides 22 global hook entries across 12 lifecycle events that enforce quality, safety, and workflow rules across all Claude Code sessions. Hooks are merged into `~/.claude/settings.json` on install, with logic in standalone scripts at `~/.softspark/ai-toolkit/hooks/`.
16
+ ai-toolkit provides 28 global hook entries across 14 lifecycle events that enforce quality, safety, and workflow rules across all Claude Code sessions. Hooks are merged into `~/.claude/settings.json` on install, with logic in standalone scripts at `~/.softspark/ai-toolkit/hooks/`.
17
17
 
18
18
  ## Supported Surface
19
19
 
@@ -327,6 +327,114 @@ Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
327
327
 
328
328
  **Action:** Captures an environment snapshot to `~/.softspark/ai-toolkit/sessions/current-context.json`. Records working directory, git branch, git status summary, Node.js version, Python version, and timestamp. Used by other hooks and tools to access session metadata without re-running discovery commands. Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
329
329
 
330
+ ---
331
+
332
+ ## New Hooks (Constitution Art. VI Enforcement)
333
+
334
+ These six hooks turn Constitution Article VI ("Repair Discipline") from prose into executable enforcement. Each one closes a specific gap that previously relied on agent goodwill.
335
+
336
+ ### PreToolUse (revert protection) — `revert-guard.sh`
337
+
338
+ | Field | Value |
339
+ |-------|-------|
340
+ | Event | `PreToolUse` |
341
+ | Matcher | `Bash` |
342
+ | Script | `~/.softspark/ai-toolkit/hooks/revert-guard.sh` |
343
+ | Fires | Before any Bash command |
344
+
345
+ **Action:** Blocks (exit 2) `git checkout/restore -- <file>`, `git reset --hard`, or `git clean -fd` when the affected files were edited in the current session (per `session_state.py` log). Forces the agent to fix root causes instead of reverting work-in-progress (Art. VI.2). Branch switches (`git checkout main`) and reverts on untouched files pass through unchanged.
346
+
347
+ **Override (one-off):** `CLAUDE_REVERT_OK=1`. Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
348
+
349
+ ### PostToolUse (test cohesion) — `test-cohesion.sh`
350
+
351
+ | Field | Value |
352
+ |-------|-------|
353
+ | Event | `PostToolUse` |
354
+ | Matcher | `Edit\|MultiEdit\|Write` |
355
+ | Script | `~/.softspark/ai-toolkit/hooks/test-cohesion.sh` |
356
+ | Fires | After every file edit |
357
+
358
+ **Action:** Runs the test commands mapped to the edited path via `test-cohesion-map.json`. Lookup order: project-local `.claude/test-cohesion-map.json`, then toolkit default `app/hooks/test-cohesion-map.json`. Blocks (exit 2) when the related test command fails. Runs **only** related tests, not the full suite (one of the user-stated requirements).
359
+
360
+ Map schema:
361
+ ```json
362
+ [
363
+ {
364
+ "match": "src/auth/*.py",
365
+ "tests": ["tests/test_auth.py"],
366
+ "runner": "pytest",
367
+ "command": null
368
+ }
369
+ ]
370
+ ```
371
+ First-match-wins per file. Built-in runners: `bats`, `pytest`, `vitest`, `jest`. Use `"command"` for full overrides.
372
+
373
+ **Overrides:** `CLAUDE_SKIP_COHESION=1` (one-off), `CLAUDE_HOOK_BOOTSTRAP=1` (when editing the hook itself). Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
374
+
375
+ ### PostToolUse (search-first tracker) — `search-tracker.sh`
376
+
377
+ | Field | Value |
378
+ |-------|-------|
379
+ | Event | `PostToolUse` |
380
+ | Matcher | `mcp__rag-mcp__smart_query\|mcp__rag-mcp__hybrid_search_kb\|mcp__rag-mcp__crag_search\|mcp__rag-mcp__multi_hop_search\|mcp__rag-mcp__verify_answer\|WebSearch\|WebFetch` |
381
+ | Script | `~/.softspark/ai-toolkit/hooks/search-tracker.sh` |
382
+ | Fires | After any search-style tool call |
383
+
384
+ **Action:** Clears `~/.softspark/ai-toolkit/state/search-required.flag`. Pairs with `user-prompt-submit.sh` (sets flag on long technical prompts only when a search provider is detected or strict mode is enabled) and `stop-search-check.sh` (blocks Stop if flag still set). Together they enforce the global CLAUDE.md GOLDEN RULE without breaking offline/no-RAG installs.
385
+
386
+ Non-blocking (exit 0). Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
387
+
388
+ ### Stop (search-first enforcement) — `stop-search-check.sh`
389
+
390
+ | Field | Value |
391
+ |-------|-------|
392
+ | Event | `Stop` |
393
+ | Matcher | *(all)* |
394
+ | Script | `~/.softspark/ai-toolkit/hooks/stop-search-check.sh` |
395
+ | Fires | When Claude finishes a response |
396
+
397
+ **Action:** If `search-required.flag` is still present (no search tool ran during this turn) and a search provider is still detectable, emits `{"decision":"block","reason":"..."}` to continue the conversation with a search-first reminder. If no RAG/Web provider is detected, it clears the stale flag and exits 0, so offline/no-MCP users are not blocked.
398
+
399
+ **Overrides:** `CLAUDE_SKIP_SEARCH_FIRST=1`, `AI_TOOLKIT_SEARCH_FIRST=off`, or `AI_TOOLKIT_SEARCH_FIRST=strict` to force enforcement. Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
400
+
401
+ ### InstructionsLoaded — `instructions-audit.sh`
402
+
403
+ | Field | Value |
404
+ |-------|-------|
405
+ | Event | `InstructionsLoaded` |
406
+ | Matcher | *(all)* |
407
+ | Script | `~/.softspark/ai-toolkit/hooks/instructions-audit.sh` |
408
+ | Fires | Whenever CLAUDE.md / `.claude/rules/*.md` is loaded into context |
409
+
410
+ **Action:** Appends `<ts>\t<memory_type>\t<load_reason>\t<file_path>` to `~/.softspark/ai-toolkit/state/loaded-instructions.log`. Provides audit visibility: when a rule does NOT enter context (silently dropped, token budget, glob miss), the absence is observable. Auto-rotates at 2000 lines.
411
+
412
+ Non-blocking (exit 0). Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
413
+
414
+ ### ConfigChange — `config-desync-guard.sh`
415
+
416
+ | Field | Value |
417
+ |-------|-------|
418
+ | Event | `ConfigChange` |
419
+ | Matcher | `user_settings` |
420
+ | Script | `~/.softspark/ai-toolkit/hooks/config-desync-guard.sh` |
421
+ | Fires | When `~/.claude/settings.json` changes |
422
+
423
+ **Action:** Compares `_source: ai-toolkit` entries between `~/.claude/settings.json` (installed) and the toolkit source `app/hooks.json`. If they diverge (missing/stale entries), emits an advisory to stderr suggesting `ai-toolkit update` or `ai-toolkit doctor --fix`. Non-blocking by design — user's legitimate settings edits never get rejected.
424
+
425
+ **Override (silence advisory):** `CLAUDE_SKIP_CONFIG_DESYNC=1`. Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
426
+
427
+ ### Supporting Infrastructure
428
+
429
+ | Component | Purpose |
430
+ |-----------|---------|
431
+ | `scripts/session_state.py` | Append-only edit log keyed by session_id. Cleared on SessionStart. Read by revert-guard, test-cohesion, quality-gate. |
432
+ | `scripts/test_cohesion.py` | Resolves changed paths → test commands via cohesion map. First-match-wins. Stdlib-only. |
433
+ | `app/hooks/test-cohesion-map.json` | Toolkit-default path → tests mapping (used when no project map exists). |
434
+ | `app/hooks/_locate-toolkit.sh` | Shared bash helper that exports `$TOOLKIT_DIR` for hooks needing scripts/. |
435
+ | `app/hooks/_hook-io.sh` | Shared bash helper that normalizes hook payloads across Claude, Augment, Gemini, Windsurf, and Cursor-style JSON. |
436
+ | `app/hooks/_search-capability.sh` | Shared bash helper that enables search-first blocking only when RAG/Web is configured or strict mode is requested. |
437
+
330
438
  ## Runtime Profiles
331
439
 
332
440
  Set in `.claude/settings.local.json`:
@@ -346,42 +454,59 @@ Set in `.claude/settings.local.json`:
346
454
  ```
347
455
  ~/.softspark/ai-toolkit/
348
456
  ├── rules/ # Registered rules (add-rule.sh)
457
+ ├── state/ # Per-session runtime state (NEW)
458
+ │ ├── session-edits.json # Append-only edit log per session
459
+ │ ├── search-required.flag # Set by user-prompt-submit, cleared by search-tracker
460
+ │ ├── loaded-instructions.log # Audit trail of which rules entered context
461
+ │ └── test-cohesion-last.log # Last cohesion test command output
349
462
  └── hooks/ # Hook scripts (copied on install)
350
- ├── _profile-check.sh # Shared: profile skip logic (sourced by hooks)
463
+ ├── _profile-check.sh # Shared: profile skip logic (sourced by hooks)
464
+ ├── _locate-toolkit.sh # NEW: shared $TOOLKIT_DIR locator
465
+ ├── _hook-io.sh # NEW: shared multi-editor payload/output adapter
466
+ ├── _search-capability.sh # NEW: capability-aware search-first enforcement
351
467
  ├── session-start.sh
352
- ├── session-context.sh # NEW: capture session env snapshot
468
+ ├── session-context.sh
353
469
  ├── guard-destructive.sh
354
470
  ├── guard-path.sh
355
- ├── guard-config.sh # NEW: block config file edits
356
- ├── mcp-health.sh # NEW: check MCP runtime availability
357
- ├── user-prompt-submit.sh
358
- ├── post-tool-use.sh
359
- ├── governance-capture.sh # NEW: log security-sensitive operations
471
+ ├── guard-config.sh
472
+ ├── revert-guard.sh # NEW: block revert on session-edited files (Art. VI.2)
473
+ ├── mcp-health.sh
474
+ ├── user-prompt-submit.sh # extended: arms search-required flag
475
+ ├── post-tool-use.sh # extended: appends edits to session state
476
+ ├── governance-capture.sh
477
+ ├── test-cohesion.sh # NEW: runs mapped tests after edits (Art. VI.3)
478
+ ├── test-cohesion-map.json # NEW: path → tests mapping
479
+ ├── search-tracker.sh # NEW: clears search-required flag
360
480
  ├── quality-check.sh
361
- ├── quality-gate.sh
481
+ ├── quality-gate.sh # extended: cohesion-tests session edits
482
+ ├── stop-search-check.sh # NEW: enforces search-first on Stop
362
483
  ├── save-session.sh
363
484
  ├── subagent-start.sh
364
485
  ├── subagent-stop.sh
365
486
  ├── track-usage.sh
366
487
  ├── pre-compact.sh
367
- ├── pre-compact-save.sh # NEW: timestamped context snapshot
368
- ├── commit-quality.sh # NEW: advisory commit message check
488
+ ├── pre-compact-save.sh
489
+ ├── commit-quality.sh
490
+ ├── instructions-audit.sh # NEW: logs CLAUDE.md / rules loads
491
+ ├── config-desync-guard.sh # NEW: warns on settings ↔ source drift
369
492
  └── session-end.sh
370
493
 
371
494
  ~/.claude/settings.json
372
495
  └── hooks: # Hook definitions referencing ~/.softspark/ai-toolkit/hooks/
373
- ├── SessionStart → session-start.sh, mcp-health.sh, session-context.sh
374
- ├── Notification osascript (inline)
375
- ├── PreToolUse → guard-destructive.sh, guard-path.sh, guard-config.sh, commit-quality.sh
376
- ├── UserPromptSubmit → user-prompt-submit.sh, track-usage.sh
377
- ├── PostToolUse → post-tool-use.sh, governance-capture.sh
378
- ├── Stop → quality-check.sh, save-session.sh, quality-gate.sh
379
- ├── TaskCompleted → quality-gate.sh
380
- ├── TeammateIdle → echo (inline)
381
- ├── SubagentStart → subagent-start.sh
382
- ├── SubagentStop → subagent-stop.sh
383
- ├── PreCompact → pre-compact.sh, pre-compact-save.sh
384
- └── SessionEnd → session-end.sh
496
+ ├── SessionStart → session-start.sh, mcp-health.sh, session-context.sh
497
+ ├── Notification notify-waiting.sh
498
+ ├── PreToolUse → guard-destructive.sh, guard-path.sh, guard-config.sh, commit-quality.sh, revert-guard.sh
499
+ ├── UserPromptSubmit → user-prompt-submit.sh, track-usage.sh
500
+ ├── PostToolUse → post-tool-use.sh, governance-capture.sh, test-cohesion.sh, search-tracker.sh
501
+ ├── Stop → quality-check.sh, save-session.sh, quality-gate.sh, stop-search-check.sh
502
+ ├── TaskCompleted → quality-gate.sh
503
+ ├── TeammateIdle → echo (inline)
504
+ ├── SubagentStart → subagent-start.sh
505
+ ├── SubagentStop → subagent-stop.sh
506
+ ├── PreCompact → pre-compact.sh, pre-compact-save.sh
507
+ ├── SessionEnd → session-end.sh
508
+ ├── InstructionsLoaded → instructions-audit.sh
509
+ └── ConfigChange → config-desync-guard.sh
385
510
  ```
386
511
 
387
512
  **Key design decisions:**
@@ -399,7 +524,7 @@ Set in `.claude/settings.local.json`:
399
524
 
400
525
  **Hook script not found:**
401
526
  ```bash
402
- ls ~/.softspark/ai-toolkit/hooks/ # should list 21 .sh files (plus _profile-check.sh helper)
527
+ ls ~/.softspark/ai-toolkit/hooks/ # should list 27 .sh files (plus _profile-check.sh + _locate-toolkit.sh + _hook-io.sh + _search-capability.sh helpers + test-cohesion-map.json)
403
528
  ai-toolkit update # re-copies scripts
404
529
  ```
405
530
 
@@ -21,11 +21,11 @@ Unlike other toolkits that put safety rules in documentation only, ai-toolkit en
21
21
 
22
22
  Hook logic lives in `app/hooks/*.sh` — not inline JSON one-liners. Scripts are copied to `~/.softspark/ai-toolkit/hooks/` on install and referenced from `~/.claude/settings.json`. Easy to read, debug, and extend.
23
23
 
24
- **12 lifecycle events / 22 global hook entries:**
24
+ **14 lifecycle events / 28 global hook entries:**
25
25
 
26
26
  | Event | Script | Action |
27
27
  |-------|--------|--------|
28
- | SessionStart | `session-start.sh` | MANDATORY rules reminder + session context + instincts |
28
+ | SessionStart | `session-start.sh` | MANDATORY rules reminder + session context + instincts + reset session-edit state |
29
29
  | SessionStart | `mcp-health.sh` | Check MCP server command availability (non-blocking warning) |
30
30
  | SessionStart | `session-context.sh` | Capture environment snapshot to `~/.softspark/ai-toolkit/sessions/current-context.json` |
31
31
  | Notification | `notify-waiting.sh` | Cross-platform desktop notification |
@@ -33,19 +33,25 @@ Hook logic lives in `app/hooks/*.sh` — not inline JSON one-liners. Scripts are
33
33
  | PreToolUse | `guard-path.sh` | Block wrong-user path hallucination |
34
34
  | PreToolUse | `guard-config.sh` | Block edits to linter/formatter config files unless explicitly requested |
35
35
  | PreToolUse | `commit-quality.sh` | Advisory validation of git commit messages |
36
- | UserPromptSubmit | `user-prompt-submit.sh` | Prompt governance reminder |
36
+ | PreToolUse | `revert-guard.sh` | Block `git checkout/restore/reset --hard/clean` on files edited this session (Art. VI.2) |
37
+ | UserPromptSubmit | `user-prompt-submit.sh` | Prompt governance reminder + arm search-first flag only when RAG/Web is available |
37
38
  | UserPromptSubmit | `track-usage.sh` | Record skill invocations to local stats |
38
- | PostToolUse | `post-tool-use.sh` | Lightweight validation reminders after edits |
39
+ | PostToolUse | `post-tool-use.sh` | Lightweight validation reminders + append edit to session state |
39
40
  | PostToolUse | `governance-capture.sh` | Log security-sensitive operations to JSONL |
41
+ | PostToolUse | `test-cohesion.sh` | Run cohesion-mapped tests after edits; block on failure (Art. VI.3) |
42
+ | PostToolUse | `search-tracker.sh` | Clear search-first flag when smart_query/hybrid_search_kb/Web* runs |
40
43
  | Stop | `quality-check.sh` | Multi-language lint (ruff/tsc/phpstan/dart/go) |
41
44
  | Stop | `save-session.sh` | Persist session context for cross-session continuity |
42
- | Stop | `quality-gate.sh` | Block final response on lint/type errors |
45
+ | Stop | `quality-gate.sh` | Block final response on lint/type errors + cohesion tests for session edits |
46
+ | Stop | `stop-search-check.sh` | Continue conversation if search-first rule was skipped and a provider exists; no-op offline |
43
47
  | TaskCompleted | `quality-gate.sh` | Block task completion on lint/type errors |
44
48
  | SubagentStart | `subagent-start.sh` | Narrow-scope reminder for spawned subagents |
45
49
  | SubagentStop | `subagent-stop.sh` | Completion checklist for subagent handoff |
46
50
  | PreCompact | `pre-compact.sh` | Smart compaction: prioritized context |
47
51
  | PreCompact | `pre-compact-save.sh` | Save timestamped context backup |
48
52
  | SessionEnd | `session-end.sh` | Persist a session-end handoff note |
53
+ | InstructionsLoaded | `instructions-audit.sh` | Append every CLAUDE.md / rules load to audit log (which rules actually entered context) |
54
+ | ConfigChange | `config-desync-guard.sh` | Warn when `~/.claude/settings.json` drifts from `app/hooks.json` (advisory) |
49
55
  | TeammateIdle | *(inline)* | Completeness reminder |
50
56
 
51
57
  **5 skill-scoped hooks:**