claude-dev-env 2.4.0 → 2.5.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 (195) hide show
  1. package/CLAUDE.md +53 -49
  2. package/_shared/pr-loop/scripts/_claude_permissions_common.py +84 -0
  3. package/_shared/pr-loop/scripts/code_rules_gate.py +4 -2
  4. package/_shared/pr-loop/scripts/grant_project_claude_permissions.py +306 -306
  5. package/_shared/pr-loop/scripts/pr_loop_shared_constants/claude_permissions_constants.py +44 -0
  6. package/_shared/pr-loop/scripts/pr_loop_shared_constants/copilot_quota_constants.py +24 -24
  7. package/_shared/pr-loop/scripts/pr_loop_shared_constants/stale_worktree_rule_sweep_constants.py +107 -107
  8. package/_shared/pr-loop/scripts/revoke_project_claude_permissions.py +290 -48
  9. package/_shared/pr-loop/scripts/tests/test_claude_permissions_common.py +42 -2
  10. package/_shared/pr-loop/scripts/tests/test_claude_permissions_constants.py +36 -0
  11. package/_shared/pr-loop/scripts/tests/test_code_rules_gate.py +100 -1
  12. package/_shared/pr-loop/scripts/tests/test_fix_hookspath.py +497 -497
  13. package/_shared/pr-loop/scripts/tests/test_revoke_project_claude_permissions.py +311 -2
  14. package/_shared/pr-loop/scripts/tests/test_stale_worktree_rule_sweep.py +301 -301
  15. package/_shared/pr-loop/scripts/tests/test_stale_worktree_rule_sweep_constants.py +85 -85
  16. package/_shared/pr-loop/worker-spawn.md +1 -1
  17. package/agents/CLAUDE.md +2 -1
  18. package/agents/caveman.md +0 -1
  19. package/agents/clasp-deployment-orchestrator.md +0 -1
  20. package/agents/clean-coder.md +0 -1
  21. package/agents/code-advisor.md +0 -1
  22. package/agents/code-quality-agent.md +1 -2
  23. package/agents/code-verifier.md +0 -1
  24. package/agents/deep-research.md +0 -1
  25. package/agents/docs-agent.md +0 -1
  26. package/agents/git-commit-crafter.md +0 -1
  27. package/agents/issue-tracker.md +42 -0
  28. package/agents/plan-packet-validator.md +0 -1
  29. package/agents/pr-description-writer.md +0 -1
  30. package/agents/test_agent_frontmatter.py +67 -18
  31. package/audit-rubrics/category_rubrics/category-o-docstring-vs-impl-drift.md +143 -141
  32. package/bin/CLAUDE.md +68 -5
  33. package/bin/ever-shipped-skills.mjs +1 -0
  34. package/bin/install-constants.mjs +88 -0
  35. package/bin/install.mjs +1138 -114
  36. package/bin/install.prune.test.mjs +869 -19
  37. package/bin/install.test.mjs +906 -2
  38. package/commands/implement.md +1 -1
  39. package/commands/right-size.md +1 -1
  40. package/docs/CLAUDE.md +1 -0
  41. package/docs/host-pool-health-monitor.md +102 -0
  42. package/docs/references/CLAUDE.md +4 -2
  43. package/docs/references/advisor-tool.md +13 -0
  44. package/docs/references/code-review-enforcement.md +10 -0
  45. package/docs/references/team-advisor-skill.md +14 -0
  46. package/hooks/blocking/CLAUDE.md +1 -0
  47. package/hooks/blocking/code_review_pr_create_gate.py +7 -3
  48. package/hooks/blocking/code_review_push_gate.py +9 -4
  49. package/hooks/blocking/code_review_stamp_directory_write_blocker.py +8 -0
  50. package/hooks/blocking/config/__init__.py +5 -5
  51. package/hooks/blocking/config/code_review_enforcement_constants.py +4 -1
  52. package/hooks/blocking/config/test_code_review_enforcement_constants.py +5 -0
  53. package/hooks/blocking/config/verified_commit_constants.py +160 -159
  54. package/hooks/blocking/orchestrator_refresh_reschedule_gate.py +256 -0
  55. package/hooks/blocking/pre_tool_use_dispatcher.py +24 -24
  56. package/hooks/blocking/test_code_review_pr_create_gate.py +14 -0
  57. package/hooks/blocking/test_code_review_push_gate.py +16 -0
  58. package/hooks/blocking/test_code_review_stamp_directory_write_blocker.py +19 -0
  59. package/hooks/blocking/test_orchestrator_refresh_reschedule_gate.py +231 -0
  60. package/hooks/blocking/test_pre_tool_use_dispatcher.py +10 -1
  61. package/hooks/blocking/test_verdict_directory_write_blocker.py +808 -808
  62. package/hooks/blocking/test_verification_verdict_store.py +54 -0
  63. package/hooks/blocking/test_verified_commit_gate.py +581 -581
  64. package/hooks/blocking/test_verified_commit_message_accuracy_blocker.py +131 -131
  65. package/hooks/blocking/verdict_directory_write_blocker.py +687 -687
  66. package/hooks/blocking/verification_verdict_store.py +1039 -1036
  67. package/hooks/blocking/verified_commit_message_accuracy_blocker.py +167 -167
  68. package/hooks/blocking/verifier_verdict_minter.py +280 -280
  69. package/hooks/git-hooks/test_pre_push.py +25 -0
  70. package/hooks/hooks.json +10 -0
  71. package/hooks/hooks_constants/CLAUDE.md +2 -1
  72. package/hooks/hooks_constants/enter_worktree_prefetch_constants.py +18 -18
  73. package/hooks/hooks_constants/orchestrator_refresh_reschedule_gate_constants.py +48 -0
  74. package/hooks/hooks_constants/ruff_integration_constants.py +16 -0
  75. package/hooks/lifecycle/enter_worktree_origin_prefetch.py +163 -146
  76. package/hooks/lifecycle/test_enter_worktree_origin_prefetch.py +185 -178
  77. package/hooks/pyproject.toml +1 -0
  78. package/hooks/validators/CLAUDE.md +1 -0
  79. package/hooks/validators/config/__init__.py +0 -0
  80. package/hooks/validators/config/directory_exemption_constants.py +183 -0
  81. package/hooks/validators/config/test_directory_exemption_constants.py +21 -0
  82. package/hooks/validators/conftest.py +4 -0
  83. package/hooks/validators/ruff_integration.py +49 -5
  84. package/hooks/validators/run_all_validators.py +206 -9
  85. package/hooks/validators/test_directory_exemption_constants.py +185 -0
  86. package/hooks/validators/test_python_antipattern_checks.py +110 -5
  87. package/hooks/validators/test_ruff_integration.py +92 -1
  88. package/hooks/validators/test_run_all_validators.py +115 -68
  89. package/hooks/validators/test_run_all_validators_pretooluse.py +159 -1
  90. package/package.json +10 -2
  91. package/rules/CLAUDE.md +1 -0
  92. package/rules/docstring-prose-matches-implementation.md +45 -44
  93. package/rules/state-what-is.md +25 -0
  94. package/rules/verified-commit-gate-skip.md +1 -1
  95. package/scripts/CLAUDE.md +1 -0
  96. package/scripts/Capture-PoolHealth.ps1 +410 -0
  97. package/scripts/_code_review_test_support.py +404 -0
  98. package/scripts/claude_chain_runner.py +141 -1
  99. package/scripts/conftest.py +16 -1
  100. package/scripts/dev_env_scripts_constants/CLAUDE.md +1 -1
  101. package/scripts/dev_env_scripts_constants/claude_chain_constants.py +9 -0
  102. package/scripts/resolve_worker_spawn.py +626 -626
  103. package/scripts/spawn_grok_batch.py +672 -672
  104. package/scripts/test_claude_chain_runner.py +131 -0
  105. package/scripts/test_invoke_code_review_chain.py +70 -0
  106. package/scripts/test_invoke_code_review_cli.py +192 -0
  107. package/scripts/test_invoke_code_review_contract.py +256 -0
  108. package/scripts/test_invoke_code_review_git.py +123 -0
  109. package/scripts/test_invoke_code_review_mode.py +99 -0
  110. package/scripts/test_resolve_worker_spawn.py +1014 -1014
  111. package/skills/CLAUDE.md +2 -0
  112. package/skills/auditing-claude-config/SKILL.md +114 -114
  113. package/skills/autoconverge/SKILL.md +427 -427
  114. package/skills/autoconverge/reference/convergence.md +24 -3
  115. package/skills/autoconverge/workflow/CLAUDE.md +1 -0
  116. package/skills/autoconverge/workflow/converge.clean-audit.test.mjs +3 -3
  117. package/skills/autoconverge/workflow/converge.contract.test.mjs +1263 -1263
  118. package/skills/autoconverge/workflow/converge.mjs +167 -0
  119. package/skills/autoconverge/workflow/converge.p2-advance.test.mjs +202 -0
  120. package/skills/autoconverge/workflow/fixtures/wf_run/subagents/workflows/wf_881252e6-700/agent-a11d903476b803493.jsonl +2 -2
  121. package/skills/autoconverge/workflow/fixtures/wf_run/subagents/workflows/wf_881252e6-700/agent-a26213978adeef6fb.jsonl +2 -2
  122. package/skills/autoconverge/workflow/fixtures/wf_run/subagents/workflows/wf_881252e6-700/agent-a3def0d15ed9d9110.jsonl +2 -2
  123. package/skills/autoconverge/workflow/fixtures/wf_run/subagents/workflows/wf_881252e6-700/agent-a41f41b1b708ee3b7.jsonl +2 -2
  124. package/skills/autoconverge/workflow/fixtures/wf_run/subagents/workflows/wf_881252e6-700/agent-a758b880abecc3ff7.jsonl +2 -2
  125. package/skills/autoconverge/workflow/fixtures/wf_run/subagents/workflows/wf_881252e6-700/agent-a8897b89656b1bd16.jsonl +2 -2
  126. package/skills/autoconverge/workflow/fixtures/wf_run/subagents/workflows/wf_881252e6-700/agent-abd463d744a1437bc.jsonl +2 -2
  127. package/skills/autoconverge/workflow/fixtures/wf_run/subagents/workflows/wf_881252e6-700/agent-ad19d027ae8ee1816.jsonl +2 -2
  128. package/skills/autoconverge/workflow/fixtures/wf_run/workflows/wf_881252e6-700.json +265 -265
  129. package/skills/closeout/SKILL.md +33 -50
  130. package/skills/codex-review/scripts/codex_review_scripts_constants/run_constants.py +8 -0
  131. package/skills/codex-review/scripts/run_codex_review.py +233 -1
  132. package/skills/codex-review/scripts/test_run_codex_review.py +189 -0
  133. package/skills/condensing-instructions/SKILL.md +81 -0
  134. package/skills/copilot-review/SKILL.md +119 -119
  135. package/skills/e-code-review/SKILL.md +52 -0
  136. package/skills/e-code-review/reference/fix.md +54 -0
  137. package/skills/e-code-review/reference/loop.md +43 -0
  138. package/skills/e-code-review/reference/low.md +57 -0
  139. package/skills/e-code-review/reference/medium.md +153 -0
  140. package/skills/e-code-review/reference/xhigh.md +182 -0
  141. package/skills/e-simplify/SKILL.md +97 -0
  142. package/skills/issue-tracker/SKILL.md +92 -0
  143. package/skills/issue-tracker/reference/epic-and-sub-issue-model.md +55 -0
  144. package/skills/issue-tracker/reference/handoff-schema.md +64 -0
  145. package/skills/issue-tracker/reference/operation-matrix.md +41 -0
  146. package/skills/orchestrator/SKILL.md +162 -21
  147. package/skills/orchestrator/scripts/status_gate.py +625 -0
  148. package/skills/orchestrator/scripts/status_gate_constants/__init__.py +1 -0
  149. package/skills/orchestrator/scripts/status_gate_constants/config/__init__.py +1 -0
  150. package/skills/orchestrator/scripts/status_gate_constants/config/constants.py +47 -0
  151. package/skills/orchestrator/scripts/test_status_gate.py +439 -0
  152. package/skills/orchestrator-refresh/SKILL.md +110 -35
  153. package/skills/plan-to-pr/SKILL.md +155 -0
  154. package/skills/plan-to-pr/reference/final-validation-tasks.md +15 -0
  155. package/skills/plan-to-pr/reference/model-routing.md +36 -0
  156. package/skills/plan-to-pr/reference/packet-contract.md +43 -0
  157. package/skills/plan-to-pr/reference/packet-schema.json +57 -0
  158. package/skills/plan-to-pr/reference/process-inventory.md +22 -0
  159. package/skills/plan-to-pr/reference/review-loop.md +33 -0
  160. package/skills/plan-to-pr/reference/run-record.schema.json +27 -0
  161. package/skills/plan-to-pr/reference/self-audit-tasks.md +15 -0
  162. package/skills/plan-to-pr/reference/task-seeds.md +14 -0
  163. package/skills/plan-to-pr/reference/task-ticket.md +38 -0
  164. package/skills/plan-to-pr/scripts/config/__init__.py +1 -0
  165. package/skills/plan-to-pr/scripts/config/constants.py +193 -0
  166. package/skills/plan-to-pr/scripts/create_packet.py +173 -0
  167. package/skills/plan-to-pr/scripts/test_create_packet.py +102 -0
  168. package/skills/plan-to-pr/scripts/test_validate_packet.py +256 -0
  169. package/skills/plan-to-pr/scripts/test_validate_protocol.py +135 -0
  170. package/skills/plan-to-pr/scripts/test_validate_run.py +158 -0
  171. package/skills/plan-to-pr/scripts/validate_packet.py +655 -0
  172. package/skills/plan-to-pr/scripts/validate_protocol.py +622 -0
  173. package/skills/plan-to-pr/scripts/validate_run.py +173 -0
  174. package/skills/plan-to-pr/test_skill_contract.py +207 -0
  175. package/skills/plan-to-pr/test_task_ticket_contract.py +151 -0
  176. package/skills/pr-converge/SKILL.md +472 -469
  177. package/skills/pr-converge/reference/examples.md +3 -3
  178. package/skills/pr-converge/reference/fix-protocol.md +1 -1
  179. package/skills/pr-converge/reference/ground-rules.md +7 -4
  180. package/skills/pr-converge/reference/multi-pr-orchestration.md +4 -1
  181. package/skills/pr-converge/reference/per-tick.md +5 -5
  182. package/skills/pr-converge/reference/progress-checklist.md +1 -1
  183. package/skills/pr-converge/scripts/check_convergence_gates.py +279 -279
  184. package/skills/pr-converge/scripts/test_check_convergence_codex.py +507 -507
  185. package/skills/pr-converge/scripts/test_check_convergence_gates.py +84 -84
  186. package/skills/pr-converge/test_step5_host_branch.py +1 -1
  187. package/skills/pr-fix-protocol/SKILL.md +1 -1
  188. package/skills/privacy-hygiene/SKILL.md +68 -68
  189. package/skills/prototype/workflows/promotion.md +1 -1
  190. package/skills/release-notes-html/SKILL.md +164 -0
  191. package/skills/task-build/CLAUDE.md +8 -7
  192. package/skills/task-build/SKILL.md +16 -8
  193. package/skills/task-build/reference/tool-routing.md +19 -0
  194. package/scripts/test_invoke_code_review.py +0 -966
  195. package/skills/closeout/reference/issue-body-templates.md +0 -108
@@ -5,7 +5,7 @@ allowed-tools: Task, Read, Grep, Glob
5
5
 
6
6
  **Implementation with Full Context - XML-Structured Guidance**
7
7
 
8
- Launch a clean-coder agent with COMPREHENSIVE implementation context provided in structured XML format.
8
+ Launch a clean-coder agent — `model: sonnet`, worker-model routing per [`skills/orchestrator/SKILL.md`](../skills/orchestrator/SKILL.md#workflow-agent-routing); resolver-supplied sonnet-equivalent on third-party hosts — with COMPREHENSIVE implementation context provided in structured XML format.
9
9
 
10
10
  ## Process:
11
11
 
@@ -3,7 +3,7 @@ description: Prevent over/under-engineering
3
3
  allowed-tools: Task
4
4
  ---
5
5
 
6
- Launch the clean-coder agent to review code for appropriate engineering practices.
6
+ Launch the clean-coder agent — `model: sonnet`, worker-model routing per [`skills/orchestrator/SKILL.md`](../skills/orchestrator/SKILL.md#workflow-agent-routing); resolver-supplied sonnet-equivalent on third-party hosts — to review code for appropriate engineering practices.
7
7
 
8
8
  The agent will evaluate whether abstractions, patterns, and practices match the actual needs of the project, ensuring code is neither over-engineered nor under-engineered for its current scale and purpose.
9
9
 
package/docs/CLAUDE.md CHANGED
@@ -18,6 +18,7 @@ Reference documentation installed into `~/.claude/docs/` by `bin/install.mjs`. T
18
18
  | `nas-ssh-invocation.md` | Full NAS ssh policy behind the `rules/nas-ssh-invocation.md` kernel: the OpenSSH binary form, config sources, and hook enforcement |
19
19
  | `worker-completion-gate.md` | Full worker-completion gate behind the `rules/workers-done-before-complete.md` kernel: the checklist, examples, and run-state records |
20
20
  | `wsl-docker-cowork-starter-matrix.md` | Host matrix: WSL/Docker/cowork component → starter → required? → shutdown; policy options with costs; no unmeasured `.wslconfig` memory cap |
21
+ | `host-pool-health-monitor.md` | Operator recipe for Windows pool/handle health: thresholds, clean-shell re-run of `Capture-PoolHealth.ps1`, RC2/RC3/RC4 remediation map |
21
22
 
22
23
  ## Subdirectory
23
24
 
@@ -0,0 +1,102 @@
1
+ # Host pool health monitor
2
+
3
+ Operator recipe for kernel pool counters, handle pressure, and pool tags on a Windows host that runs Claude Code / agent tooling. Ships as `scripts/Capture-PoolHealth.ps1` (installed to `~/.claude/scripts/`).
4
+
5
+ ## Verdict this monitor tracks
6
+
7
+ Evidence capture (`results/04-pool-tags.md` in the ram-process-sprawl plan pack) shows:
8
+
9
+ | Tag | Pool | Role |
10
+ |-----|------|------|
11
+ | **File** | nonpaged (~multi-GB when bad) | File objects |
12
+ | **IoFE** | nonpaged | I/O / file-object adjacent |
13
+ | **Toke** | paged (~multi-GB when bad) | Security token objects |
14
+ | **Key** | paged | Registry key objects (often Git `find` storms) |
15
+
16
+ **Primary story:** process-object / object-manager pressure from agent sprawl — not a single third-party driver leak. Fix sprawl with RC2 / RC3 / RC4; re-run this recipe after those land to confirm File/Toke fall.
17
+
18
+ ## Alert thresholds
19
+
20
+ | Signal | Alert when |
21
+ |--------|------------|
22
+ | `\Memory\Pool Nonpaged Bytes` | **> 2 GB** |
23
+ | Any process `HandleCount` | **> 2000** |
24
+ | `\Process(_Total)\Handle Count` | **> 500000** |
25
+
26
+ Also watch pool tags **File**, **Toke**, **IoFE**, **Key**, **FMfn** whenever any threshold fires.
27
+
28
+ ## Clean-shell re-run
29
+
30
+ From a new PowerShell window (no profile, no prior session state):
31
+
32
+ ```powershell
33
+ # After package install (npx claude-dev-env / node bin/install.mjs)
34
+ pwsh -NoProfile -File "$HOME\.claude\scripts\Capture-PoolHealth.ps1"
35
+
36
+ # Or from a checkout
37
+ pwsh -NoProfile -File "packages\claude-dev-env\scripts\Capture-PoolHealth.ps1"
38
+
39
+ # Save a snapshot
40
+ pwsh -NoProfile -File "$HOME\.claude\scripts\Capture-PoolHealth.ps1" `
41
+ -OutPath "$env:TEMP\pool-health-$(Get-Date -Format yyyyMMdd-HHmmss).txt"
42
+ ```
43
+
44
+ Exit code: `0` = all thresholds clear; `1` = one or more alerts. Hard capture failures (for example Get-Counter) stop with a non-zero exit. Soft failures (for example pool-tag walk unavailable) print a warning and can still exit `0` when thresholds are clear.
45
+
46
+ ### What the script prints
47
+
48
+ 1. **Counters** — nonpaged/paged pool, commit, available MB, total handles/threads
49
+ 2. **High-handle processes** — every process over the handle threshold (top N by default)
50
+ 3. **Pool tags** — top nonpaged, top paged, plus File/IoFE/Toke/Key/FMfn watchlist via `NtQuerySystemInformation` class 22 (same source PoolMon uses; no admin and no WDK required)
51
+ 4. **Remediation map** — RC issue pointers below
52
+ 5. **Threshold verdict** — `OK` or `ALERT ...` lines (last; drives exit code)
53
+
54
+ ### Counters-only one-liner (no tags)
55
+
56
+ ```powershell
57
+ pwsh -NoProfile -Command "
58
+ Get-Date -Format 'yyyy-MM-dd HH:mm:ss zzz'
59
+ Get-Counter '\Memory\Pool Nonpaged Bytes','\Memory\Pool Paged Bytes',
60
+ '\Memory\Committed Bytes','\Memory\Available MBytes',
61
+ '\Process(_Total)\Handle Count','\Process(_Total)\Thread Count' |
62
+ Select-Object -ExpandProperty CounterSamples |
63
+ Format-Table Path, CookedValue -AutoSize
64
+ "
65
+ ```
66
+
67
+ ## Remediation map
68
+
69
+ When nonpaged, handles, or File/Toke tags are high, apply the sprawl fixes — not a random driver unload.
70
+
71
+ | RC | Issue | What it cuts | Expected pool/handle effect |
72
+ |----|-------|--------------|-----------------------------|
73
+ | **RC2** | [#255](https://github.com/jl-cmd/claude-dev-env/issues/255) Cap MCP servers — stop per-session mcpvault/playwright/serena spawn-without-reap | Extra `node`/MCP process trees | Lower **File** / **Toke** / **Thre** object pressure |
74
+ | **RC3** | [#254](https://github.com/jl-cmd/claude-dev-env/issues/254) `Show-Asset.ps1` exit on parent death + timeout | Orphan UI/`Application.Run` processes | Lower process count and handle tables |
75
+ | **RC4** | [#253](https://github.com/jl-cmd/claude-dev-env/issues/253) Block Git `find` filesystem walks; `es.exe` primary; kill runaway `find` (>2k handles) | Orphan `Git\usr\bin\find.exe` with 10^5–10^6 **Key** handles | Sharp drop in total handles and **Key** paged; secondary relief on object manager |
76
+ | **RC5** | [#256](https://github.com/jl-cmd/claude-dev-env/issues/256) Attribute WSL/Docker/cowork VM starters | `vmmem*` / **VdMm** | Secondary only — measure first; no blind `.wslconfig` memory cap |
77
+
78
+ **Do not** treat multi-GB **File**/**Toke** as “install poolmon and hunt NVRM.” NVRM/VdMm appear as tens of MB in the evidence pack; the multi-GB leaders are object-class tags.
79
+
80
+ ### Emergency: runaway `find.exe`
81
+
82
+ ```powershell
83
+ Get-CimInstance Win32_Process -Filter "Name='find.exe'" |
84
+ Select-Object ProcessId, ParentProcessId, HandleCount, CommandLine
85
+ # If HandleCount > 2000 and parent is dead → stop the process (RC4 policy)
86
+ ```
87
+
88
+ ## After RC2 / RC3 / RC4 land
89
+
90
+ 1. Idle the agent host (no active find storms, no orphan Show-Asset, MCP set capped).
91
+ 2. Re-run `Capture-PoolHealth.ps1` from a clean shell.
92
+ 3. Confirm: nonpaged trend down, total handles under 500k when idle, **File**/**Toke** tag bytes down vs the 04-pool-tags baseline.
93
+
94
+ ## Optional: stock `poolmon.exe`
95
+
96
+ This recipe does **not** need the WDK. Operators who prefer the Microsoft binary can install Windows Driver Kit tools and run elevated `poolmon -b` snapshots. Tag names still map through `pooltag.txt` under Windows Kits Debuggers when present.
97
+
98
+ ## Related
99
+
100
+ - Parent epic: [#252](https://github.com/jl-cmd/claude-dev-env/issues/252)
101
+ - This child: [#257](https://github.com/jl-cmd/claude-dev-env/issues/257)
102
+ - Script: `packages/claude-dev-env/scripts/Capture-PoolHealth.ps1`
@@ -1,6 +1,6 @@
1
1
  # docs/references
2
2
 
3
- Pointer documents to external sources and standard terminology. Files here are loaded on demand by rules that cite external resources.
3
+ Pointer documents to external sources, standard terminology, and internal tool or skill usage. Files here are loaded on demand by rules that cite them.
4
4
 
5
5
  ## Files
6
6
 
@@ -8,7 +8,9 @@ Pointer documents to external sources and standard terminology. Files here are l
8
8
  |---|---|
9
9
  | `dead-code-elimination.md` | External sources and standard terms behind CODE_RULES §9.8 (remove code you orphan): DCE, tree shaking, reachability analysis, and the Lava Flow anti-pattern |
10
10
  | `code-review-enforcement.md` | How the code-review gates work: the two required efforts (push at low, PR creation at xhigh), the stamp bound to the branch-surface hash, the single sanctioned minter, the two-layer stamp-directory guard, and the bypass surfaces the gates leave open |
11
+ | `advisor-tool.md` | The `advisor()` tool: a no-parameter review call that forwards the full conversation history to a stronger reviewer model, and when to call it |
12
+ | `team-advisor-skill.md` | The `/team-advisor` skill: spawning a standing review agent at the strongest reachable tier, and how it relates to the `advisor()` tool |
11
13
 
12
14
  ## Role
13
15
 
14
- Each file names an external concept, gives a one-line definition, and links a direct source. They back the rule text in `rules/` and `packages/claude-dev-env/docs/CODE_RULES.md` without embedding full third-party content inline.
16
+ A file naming an external concept gives a one-line definition and links a direct source. A file naming an internal tool or skill describes what it does and when to use it. They back the rule text in `rules/` and `packages/claude-dev-env/docs/CODE_RULES.md` without embedding full third-party content inline.
@@ -0,0 +1,13 @@
1
+ # Advisor Tool
2
+
3
+ `advisor()` is a review tool backed by a stronger reviewer model. It takes no parameters — calling it forwards the entire conversation history automatically, so the reviewer sees the task, every tool call made, and every result seen so far.
4
+
5
+ ## When to call it
6
+
7
+ Call `advisor()` before substantive work: before writing, before committing to an interpretation, before building on an assumption. Orientation work — finding files, fetching a source, seeing what exists — comes first; call `advisor()` once that orientation is done and before the substantive step begins.
8
+
9
+ Treat the advisor as more experienced than the calling agent. Consult it whenever a path forward is uncertain.
10
+
11
+ ## Availability
12
+
13
+ `advisor()` is present only in environments where it has been configured as a tool. Check the available tools before relying on it; when it is absent, fall back to `/team-advisor` (see `team-advisor-skill.md` in this directory).
@@ -9,6 +9,16 @@ This feature ties two git actions to a clean run of the built-in
9
9
 
10
10
  The gates follow the same shape as the `verified_commit` gate family.
11
11
 
12
+ ## Opt-in (default off)
13
+
14
+ Enforcement is **off by default**. The master flag is
15
+ `CODE_REVIEW_ENFORCEMENT_ENABLED` in
16
+ `hooks/blocking/config/code_review_enforcement_constants.py`. Set it to
17
+ `True` to enable the push gate, the PR-create gate, the native pre-push
18
+ backstop (via the shared deny decision), and the stamp-directory write
19
+ blocker. When the flag is `False`, every gate allows the action and the
20
+ write-blocker allows stamp-directory access.
21
+
12
22
  ## How a stamp works
13
23
 
14
24
  A stamp is a small JSON file that records one fact: a clean `/code-review` pass
@@ -0,0 +1,14 @@
1
+ # Team-Advisor Skill Invocation
2
+
3
+ `/team-advisor` spawns a standing review agent for the session at the strongest reachable model tier, run at the highest reasoning effort. Use it to get a second opinion from a distinct model line than the one driving the session. For example:
4
+
5
+ - Claude session -> consult Fable xhigh
6
+ - Codex session -> consult Sol xhigh
7
+
8
+ ## When to use it
9
+
10
+ Consult the spawned advisor before big decisions, before declaring work complete, before any commit, when a failure repeats, or when reconsidering a chosen approach.
11
+
12
+ ## Relationship to the advisor tool
13
+
14
+ `/team-advisor` works standalone; it needs no `advisor()` tool present. When both are available (see `advisor-tool.md` in this directory), use `advisor()` for a fast, history-forwarding check before substantive work, and `/team-advisor` for a standing reviewer consulted at decision points.
@@ -69,6 +69,7 @@ The check modules it calls are the `code_rules_<concern>.py` files below.
69
69
 
70
70
  | File | Event | What it blocks |
71
71
  |---|---|---|
72
+ | `orchestrator_refresh_reschedule_gate.py` | PreToolUse (ScheduleWakeup/CronCreate) | `/orchestrator-refresh` re-arm when run status is not `active` |
72
73
  | `block_main_commit.py` | PreToolUse (Bash) | `git commit`/`git push` directly to `main` |
73
74
  | `bot_mention_comment_blocker.py` | PreToolUse (Write/Edit) | PR review comments that @-mention a bot |
74
75
  | `claude_md_orphan_file_blocker.py` | PreToolUse (Write/Edit/MultiEdit) | Per-directory `CLAUDE.md` table cells naming a bare filename absent from the directory subtree |
@@ -1,7 +1,8 @@
1
1
  """PreToolUse gate: PR create lands only behind a clean xhigh code-review stamp.
2
2
 
3
- Fires on Bash/PowerShell ``gh pr create`` and on the MCP
4
- ``create_pull_request`` tool. Resolves the repository from the session
3
+ Fires when ``CODE_REVIEW_ENFORCEMENT_ENABLED`` is on (default off). Runs on
4
+ Bash/PowerShell ``gh pr create`` and on the MCP ``create_pull_request``
5
+ tool. Resolves the repository from the session
5
6
  working directory (or the payload cwd), computes the live change-surface
6
7
  hash, and allows the create only when a clean stamp at effort ``xhigh`` or
7
8
  higher covers that exact hash under ``~/.claude/code-review-stamps/``.
@@ -40,6 +41,7 @@ try:
40
41
  from code_review_stamp_store import live_surface_hash, stamp_covers_surface
41
42
  from config.code_review_enforcement_constants import (
42
43
  ALL_GATED_SHELL_TOOL_NAMES,
44
+ CODE_REVIEW_ENFORCEMENT_ENABLED,
43
45
  GH_PR_CREATE_INVOCATION_PATTERN,
44
46
  HASH_PREVIEW_LENGTH,
45
47
  MCP_CREATE_PULL_REQUEST_TOOL_NAME,
@@ -98,7 +100,7 @@ def deny_reason_for_directory(target_directory: str) -> str | None:
98
100
 
99
101
  ::
100
102
 
101
- no repo / empty surface / covering xhigh stamp -> None (allow)
103
+ enforcement off / no repo / empty surface / covering xhigh stamp -> None
102
104
  production surface without xhigh-or-higher stamp -> corrective (deny)
103
105
 
104
106
  Args:
@@ -108,6 +110,8 @@ def deny_reason_for_directory(target_directory: str) -> str | None:
108
110
  The deny reason when the surface needs a clean xhigh stamp and none
109
111
  covers it; None when the create may proceed.
110
112
  """
113
+ if not CODE_REVIEW_ENFORCEMENT_ENABLED:
114
+ return None
111
115
  repo_root = resolve_repo_root(target_directory)
112
116
  if repo_root is None:
113
117
  return None
@@ -1,7 +1,8 @@
1
1
  """PreToolUse gate: git push lands only behind a clean low code-review stamp.
2
2
 
3
- Fires on Bash/PowerShell tool calls. When the command carries a ``git push``,
4
- the gate resolves each repository the push targets, computes the live
3
+ Fires on Bash/PowerShell tool calls when ``CODE_REVIEW_ENFORCEMENT_ENABLED``
4
+ is on (default off). When the command carries a ``git push``, the gate
5
+ resolves each repository the push targets, computes the live
5
6
  change-surface hash against the merge base, and allows the push only when a
6
7
  clean stamp at effort ``low`` or higher covers that exact hash under
7
8
  ``~/.claude/code-review-stamps/``.
@@ -44,6 +45,7 @@ try:
44
45
  from config.code_review_enforcement_constants import (
45
46
  ALL_GATED_SHELL_TOOL_NAMES,
46
47
  CODE_REVIEW_BYPASS_MARKER,
48
+ CODE_REVIEW_ENFORCEMENT_ENABLED,
47
49
  GATED_PUSH_SUBCOMMANDS,
48
50
  HASH_PREVIEW_LENGTH,
49
51
  PUSH_GATE_CORRECTIVE_MESSAGE,
@@ -69,8 +71,9 @@ except ImportError as import_error:
69
71
  def deny_reason_for_directory(target_directory: str) -> str | None:
70
72
  """Decide whether a push from a directory must be blocked.
71
73
 
72
- Allowed when the directory is no repo, has no upstream base, is a
73
- mechanically exempt surface, or a clean low-or-higher stamp covers it.
74
+ Allowed when enforcement is off, the directory is no repo, has no upstream
75
+ base, is a mechanically exempt surface, or a clean low-or-higher stamp
76
+ covers it.
74
77
 
75
78
  Args:
76
79
  target_directory: The directory the push targets.
@@ -78,6 +81,8 @@ def deny_reason_for_directory(target_directory: str) -> str | None:
78
81
  Returns:
79
82
  The deny reason when the surface lacks a covering low stamp, else None.
80
83
  """
84
+ if not CODE_REVIEW_ENFORCEMENT_ENABLED:
85
+ return None
81
86
  repo_root = resolve_repo_root(target_directory)
82
87
  if repo_root is None:
83
88
  return None
@@ -1,6 +1,9 @@
1
1
  #!/usr/bin/env python3
2
2
  """PreToolUse guard: deny shell and file-tool access to the stamp directory.
3
3
 
4
+ Runs only when ``CODE_REVIEW_ENFORCEMENT_ENABLED`` is on (default off); with
5
+ the flag off the guard allows every stamp-directory access.
6
+
4
7
  The push and PR-create gates trust a single invariant: only
5
8
  ``invoke_code_review.py --record-stamp`` mints stamp files under
6
9
  ``~/.claude/code-review-stamps/``. settings.json cannot be the only shipped
@@ -53,6 +56,7 @@ try:
53
56
  ALL_GATED_SHELL_TOOL_NAMES,
54
57
  ALL_STAMP_STORE_FORGE_PATTERNS,
55
58
  ALL_WRITE_EDIT_TOOL_NAMES,
59
+ CODE_REVIEW_ENFORCEMENT_ENABLED,
56
60
  DENY_PERMISSION_DECISION,
57
61
  PRE_TOOL_USE_HOOK_EVENT_NAME,
58
62
  RELATIVE_STAMP_DIRECTORY_PATTERN,
@@ -296,6 +300,8 @@ def decision_for_payload(
296
300
  ) -> dict[str, dict[str, str]] | None:
297
301
  """Build the deny decision for stamp-directory shell or file-tool access.
298
302
 
303
+ Returns None immediately when `CODE_REVIEW_ENFORCEMENT_ENABLED` is off.
304
+
299
305
  Args:
300
306
  all_pretooluse_payload: The PreToolUse hook payload.
301
307
 
@@ -303,6 +309,8 @@ def decision_for_payload(
303
309
  The deny decision mapping when a gated tool targets the stamp
304
310
  directory; None when the tool call may proceed.
305
311
  """
312
+ if not CODE_REVIEW_ENFORCEMENT_ENABLED:
313
+ return None
306
314
  tool_name = all_pretooluse_payload.get("tool_name", "")
307
315
  if not isinstance(tool_name, str):
308
316
  return None
@@ -1,5 +1,5 @@
1
- """Configuration package for the blocking hooks.
2
-
3
- A regular package (not a namespace package) so it resolves ahead of any
4
- same-named package later on ``sys.path``.
5
- """
1
+ """Configuration package for the blocking hooks.
2
+
3
+ A regular package (not a namespace package) so it resolves ahead of any
4
+ same-named package later on ``sys.path``.
5
+ """
@@ -6,11 +6,14 @@ out because it needs an interactive terminal), the effort a push and a
6
6
  pull-request creation each require, the stamp record keys, the gate and
7
7
  write-blocker messages, the store-forge shell patterns, the MCP create-PR
8
8
  tool name, and the effort comparison every gate and the stamp store share so
9
- the thresholds never drift between them.
9
+ the thresholds never drift between them, and the master enable flag
10
+ (``CODE_REVIEW_ENFORCEMENT_ENABLED``, default off) that every gate and
11
+ the stamp-directory write-blocker read before they enforce anything.
10
12
  """
11
13
 
12
14
  from __future__ import annotations
13
15
 
16
+ CODE_REVIEW_ENFORCEMENT_ENABLED = False
14
17
  STAMP_DIRECTORY_NAME = "code-review-stamps"
15
18
  ALL_EFFORT_TOKENS_IN_ASCENDING_ORDER = ("low", "medium", "high", "xhigh", "max")
16
19
  PUSH_REQUIRED_EFFORT = "low"
@@ -23,6 +23,7 @@ _constants_module = importlib.util.module_from_spec(_constants_spec)
23
23
  _constants_spec.loader.exec_module(_constants_module)
24
24
 
25
25
  effort_meets_threshold = _constants_module.effort_meets_threshold
26
+ CODE_REVIEW_ENFORCEMENT_ENABLED = _constants_module.CODE_REVIEW_ENFORCEMENT_ENABLED
26
27
  PUSH_REQUIRED_EFFORT = _constants_module.PUSH_REQUIRED_EFFORT
27
28
  PR_CREATE_REQUIRED_EFFORT = _constants_module.PR_CREATE_REQUIRED_EFFORT
28
29
  GATED_PUSH_SUBCOMMANDS = _constants_module.GATED_PUSH_SUBCOMMANDS
@@ -106,3 +107,7 @@ def test_push_gate_message_names_the_push_action_and_low_effort() -> None:
106
107
 
107
108
  def test_guard_message_directs_users_to_the_sanctioned_minter_flag() -> None:
108
109
  assert SANCTIONED_STAMP_MINTER_FLAG in STAMP_DIRECTORY_GUARD_MESSAGE
110
+
111
+
112
+ def test_enforcement_defaults_to_off() -> None:
113
+ assert CODE_REVIEW_ENFORCEMENT_ENABLED is False