claude-dev-env 2.13.0 → 2.14.1

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 (263) hide show
  1. package/AGENTS.md +135 -0
  2. package/CLAUDE.md +1 -57
  3. package/_shared/AGENTS.md +15 -0
  4. package/_shared/CLAUDE.md +1 -15
  5. package/_shared/advisor/AGENTS.md +22 -0
  6. package/_shared/advisor/CLAUDE.md +1 -22
  7. package/_shared/pr-loop/AGENTS.md +27 -0
  8. package/_shared/pr-loop/CLAUDE.md +1 -27
  9. package/_shared/pr-loop/scripts/AGENTS.md +35 -0
  10. package/_shared/pr-loop/scripts/CLAUDE.md +1 -35
  11. package/_shared/pr-loop/scripts/code_rules_gate_parts/AGENTS.md +42 -0
  12. package/_shared/pr-loop/scripts/code_rules_gate_parts/CLAUDE.md +1 -42
  13. package/_shared/pr-loop/scripts/pr_loop_shared_constants/AGENTS.md +26 -0
  14. package/_shared/pr-loop/scripts/pr_loop_shared_constants/CLAUDE.md +1 -26
  15. package/_shared/pr-loop/scripts/tests/AGENTS.md +44 -0
  16. package/_shared/pr-loop/scripts/tests/CLAUDE.md +1 -44
  17. package/_shared/process-tree/AGENTS.md +41 -0
  18. package/_shared/process-tree/CLAUDE.md +1 -41
  19. package/agents/AGENTS.md +26 -0
  20. package/agents/CLAUDE.md +1 -31
  21. package/agents/clean-coder.md +6 -6
  22. package/agents/test_agent_frontmatter.py +11 -11
  23. package/audit-rubrics/AGENTS.md +43 -0
  24. package/audit-rubrics/CLAUDE.md +1 -43
  25. package/audit-rubrics/category_rubrics/AGENTS.md +37 -0
  26. package/audit-rubrics/category_rubrics/CLAUDE.md +1 -37
  27. package/audit-rubrics/prompts/AGENTS.md +37 -0
  28. package/audit-rubrics/prompts/CLAUDE.md +1 -37
  29. package/bin/AGENTS.md +112 -0
  30. package/bin/CLAUDE.md +1 -112
  31. package/bin/ever-shipped-skills.mjs +1 -0
  32. package/bin/install-constants.mjs +6 -7
  33. package/bin/install.mjs +24 -5
  34. package/bin/install.test.mjs +34 -0
  35. package/commands/AGENTS.md +13 -0
  36. package/commands/CLAUDE.md +1 -23
  37. package/docs/AGENTS.md +32 -0
  38. package/docs/CLAUDE.md +1 -32
  39. package/docs/CODE_RULES.md +1 -1
  40. package/docs/imagegen.md +22 -0
  41. package/docs/references/AGENTS.md +17 -0
  42. package/docs/references/CLAUDE.md +1 -17
  43. package/hooks/AGENTS.md +31 -0
  44. package/hooks/CLAUDE.md +1 -31
  45. package/hooks/_gh_pr_author_swap_utils.py +14 -0
  46. package/hooks/advisory/AGENTS.md +16 -0
  47. package/hooks/advisory/CLAUDE.md +1 -16
  48. package/hooks/blocking/AGENTS.md +123 -0
  49. package/hooks/blocking/CLAUDE.md +1 -123
  50. package/hooks/blocking/claude_md_orphan_file_blocker_parts/AGENTS.md +28 -0
  51. package/hooks/blocking/claude_md_orphan_file_blocker_parts/CLAUDE.md +1 -28
  52. package/hooks/blocking/code_rules_banned_identifiers.py +1 -1
  53. package/hooks/blocking/code_rules_dead_module_constant.py +149 -37
  54. package/hooks/blocking/code_rules_probe_chains.py +6 -2
  55. package/hooks/blocking/config/AGENTS.md +10 -0
  56. package/hooks/blocking/config/CLAUDE.md +1 -10
  57. package/hooks/blocking/gh_pr_author_restore.py +7 -2
  58. package/hooks/blocking/intent_only_ending_blocker.py +11 -16
  59. package/hooks/blocking/inventory_intent_records/AGENTS.md +26 -0
  60. package/hooks/blocking/inventory_intent_records/CLAUDE.md +1 -26
  61. package/hooks/blocking/package_inventory_stale_blocker_parts/AGENTS.md +26 -0
  62. package/hooks/blocking/package_inventory_stale_blocker_parts/CLAUDE.md +1 -26
  63. package/hooks/blocking/pii_prevention_blocker_parts/AGENTS.md +24 -0
  64. package/hooks/blocking/pii_prevention_blocker_parts/CLAUDE.md +1 -24
  65. package/hooks/blocking/tdd_enforcer_parts/AGENTS.md +30 -0
  66. package/hooks/blocking/tdd_enforcer_parts/CLAUDE.md +1 -30
  67. package/hooks/blocking/test_claude_md_orphan_file_blocker.py +1 -1
  68. package/hooks/blocking/test_code_rules_enforcer_banned_prefixes.py +1 -1
  69. package/hooks/blocking/test_code_rules_enforcer_dead_module_constant.py +171 -0
  70. package/hooks/blocking/test_code_rules_enforcer_magic_allowlist.py +1 -1
  71. package/hooks/blocking/test_gh_pr_author_restore.py +2 -1
  72. package/hooks/blocking/test_intent_only_ending_blocker.py +4 -0
  73. package/hooks/diagnostic/AGENTS.md +75 -0
  74. package/hooks/diagnostic/CLAUDE.md +1 -43
  75. package/hooks/diagnostic/hook_log_extractor.py +2 -2
  76. package/hooks/diagnostic/hook_log_init.py +2 -2
  77. package/hooks/diagnostic/migrations/AGENTS.md +16 -0
  78. package/hooks/diagnostic/migrations/CLAUDE.md +1 -16
  79. package/hooks/diagnostic/queries/AGENTS.md +19 -0
  80. package/hooks/diagnostic/queries/CLAUDE.md +1 -19
  81. package/hooks/diagnostic/test_hook_log_extractor.py +2 -2
  82. package/hooks/git-hooks/AGENTS.md +31 -0
  83. package/hooks/git-hooks/CLAUDE.md +1 -31
  84. package/hooks/git-hooks/git_hooks_constants/AGENTS.md +21 -0
  85. package/hooks/git-hooks/git_hooks_constants/CLAUDE.md +1 -21
  86. package/hooks/git-hooks/git_hooks_constants/__init__.py +4 -6
  87. package/hooks/git-hooks/pre_push.py +47 -34
  88. package/hooks/git-hooks/test_pre_push.py +111 -7
  89. package/hooks/hooks_constants/AGENTS.md +104 -0
  90. package/hooks/hooks_constants/CLAUDE.md +1 -104
  91. package/hooks/hooks_constants/hook_log_extractor_constants.py +1 -2
  92. package/hooks/hooks_constants/task_list_loop_starter_constants.py +4 -3
  93. package/hooks/hooks_constants/working_style_prompt_constants.py +29 -20
  94. package/hooks/lifecycle/AGENTS.md +18 -0
  95. package/hooks/lifecycle/CLAUDE.md +1 -18
  96. package/hooks/observability/AGENTS.md +20 -0
  97. package/hooks/observability/CLAUDE.md +1 -20
  98. package/hooks/session/AGENTS.md +33 -0
  99. package/hooks/session/CLAUDE.md +1 -33
  100. package/hooks/session/gh_pr_author_session_cleanup.py +7 -2
  101. package/hooks/session/task_list_loop_starter.py +3 -3
  102. package/hooks/session/test_gh_pr_author_session_cleanup.py +2 -1
  103. package/hooks/session/test_task_list_loop_starter.py +10 -2
  104. package/hooks/session/test_working_style_prompt.py +9 -4
  105. package/hooks/validation/AGENTS.md +20 -0
  106. package/hooks/validation/CLAUDE.md +1 -20
  107. package/hooks/validators/AGENTS.md +51 -0
  108. package/hooks/validators/CLAUDE.md +1 -51
  109. package/hooks/validators/health_check.py +52 -19
  110. package/hooks/validators/python_style_checks.py +1 -1
  111. package/hooks/validators/test_health_check.py +112 -27
  112. package/hooks/workflow/AGENTS.md +16 -0
  113. package/hooks/workflow/CLAUDE.md +1 -16
  114. package/installable-surfaces.manifest.json +1 -0
  115. package/output-styles/AGENTS.md +15 -0
  116. package/output-styles/CLAUDE.md +1 -15
  117. package/package.json +2 -1
  118. package/rules/AGENTS.md +61 -0
  119. package/rules/CLAUDE.md +1 -61
  120. package/rules/code-standards.md +5 -9
  121. package/rules/doc-prose-cuts.md +1 -1
  122. package/scripts/AGENTS.md +62 -0
  123. package/scripts/CLAUDE.md +1 -62
  124. package/scripts/codex_compat_materializer.py +4 -0
  125. package/scripts/dev_env_scripts_constants/AGENTS.md +21 -0
  126. package/scripts/dev_env_scripts_constants/CLAUDE.md +1 -21
  127. package/scripts/sync_to_cursor/AGENTS.md +23 -0
  128. package/scripts/sync_to_cursor/CLAUDE.md +1 -23
  129. package/scripts/test_active_capability_references.py +2 -2
  130. package/scripts/test_validate_instruction_pairs.py +90 -0
  131. package/scripts/test_verify_installable_package.py +5 -1
  132. package/scripts/tests/AGENTS.md +33 -0
  133. package/scripts/tests/CLAUDE.md +1 -33
  134. package/scripts/tests/test_codex_compat_materializer.py +36 -1
  135. package/scripts/validate_instruction_pairs.py +183 -0
  136. package/skills/AGENTS.md +72 -0
  137. package/skills/CLAUDE.md +1 -72
  138. package/skills/_shared/AGENTS.md +44 -0
  139. package/skills/_shared/CLAUDE.md +1 -44
  140. package/skills/_shared/advisor/AGENTS.md +9 -0
  141. package/skills/_shared/advisor/CLAUDE.md +1 -9
  142. package/skills/_shared/pr-loop/AGENTS.md +50 -0
  143. package/skills/_shared/pr-loop/CLAUDE.md +1 -50
  144. package/skills/_shared/pr-loop/prompts/AGENTS.md +9 -0
  145. package/skills/_shared/pr-loop/prompts/CLAUDE.md +1 -9
  146. package/skills/_shared/pr-loop/scripts/AGENTS.md +35 -0
  147. package/skills/_shared/pr-loop/scripts/CLAUDE.md +1 -35
  148. package/skills/_shared/pr-loop/scripts/skills_pr_loop_constants/AGENTS.md +24 -0
  149. package/skills/_shared/pr-loop/scripts/skills_pr_loop_constants/CLAUDE.md +1 -24
  150. package/skills/anthropic-plan/AGENTS.md +34 -0
  151. package/skills/anthropic-plan/CLAUDE.md +1 -34
  152. package/skills/anthropic-plan/SKILL.md +1 -1
  153. package/skills/anthropic-plan/scripts/AGENTS.md +11 -0
  154. package/skills/anthropic-plan/scripts/CLAUDE.md +1 -11
  155. package/skills/anthropic-plan/scripts/anthropic_plan_scripts_constants/AGENTS.md +16 -0
  156. package/skills/anthropic-plan/scripts/anthropic_plan_scripts_constants/CLAUDE.md +1 -16
  157. package/skills/anthropic-plan/templates/AGENTS.md +13 -0
  158. package/skills/anthropic-plan/templates/CLAUDE.md +1 -13
  159. package/skills/anthropic-plan/test_skill_contract.py +8 -6
  160. package/skills/anthropic-plan/workflow/AGENTS.md +14 -0
  161. package/skills/anthropic-plan/workflow/CLAUDE.md +1 -14
  162. package/skills/auditing-claude-config/AGENTS.md +21 -0
  163. package/skills/auditing-claude-config/CLAUDE.md +1 -21
  164. package/skills/autoconverge/AGENTS.md +36 -0
  165. package/skills/autoconverge/CLAUDE.md +1 -36
  166. package/skills/autoconverge/reference/AGENTS.md +16 -0
  167. package/skills/autoconverge/reference/CLAUDE.md +1 -16
  168. package/skills/autoconverge/workflow/AGENTS.md +26 -0
  169. package/skills/autoconverge/workflow/CLAUDE.md +1 -26
  170. package/skills/autoconverge/workflow/autoconverge_report_constants/AGENTS.md +16 -0
  171. package/skills/autoconverge/workflow/autoconverge_report_constants/CLAUDE.md +1 -16
  172. package/skills/bugteam/AGENTS.md +30 -0
  173. package/skills/bugteam/CLAUDE.md +1 -30
  174. package/skills/bugteam/reference/AGENTS.md +20 -0
  175. package/skills/bugteam/reference/CLAUDE.md +1 -20
  176. package/skills/bugteam/reference/obstacles/AGENTS.md +24 -0
  177. package/skills/bugteam/reference/obstacles/CLAUDE.md +1 -24
  178. package/skills/bugteam/scripts/AGENTS.md +30 -0
  179. package/skills/bugteam/scripts/CLAUDE.md +1 -30
  180. package/skills/bugteam/scripts/bugteam_scripts_constants/AGENTS.md +18 -0
  181. package/skills/bugteam/scripts/bugteam_scripts_constants/CLAUDE.md +1 -18
  182. package/skills/closeout/reference/handoff-prompt-template.md +1 -1
  183. package/skills/codex-review/AGENTS.md +46 -0
  184. package/skills/codex-review/CLAUDE.md +1 -46
  185. package/skills/codex-review/reference/AGENTS.md +15 -0
  186. package/skills/codex-review/reference/CLAUDE.md +1 -15
  187. package/skills/codex-review/scripts/codex_review_scripts_constants/AGENTS.md +18 -0
  188. package/skills/codex-review/scripts/codex_review_scripts_constants/CLAUDE.md +1 -18
  189. package/skills/codex-review/test_skill_scaffold.py +3 -3
  190. package/skills/copilot-review/AGENTS.md +18 -0
  191. package/skills/copilot-review/CLAUDE.md +1 -18
  192. package/skills/everything-search/AGENTS.md +17 -0
  193. package/skills/everything-search/CLAUDE.md +1 -17
  194. package/skills/fresh-branch/AGENTS.md +14 -0
  195. package/skills/fresh-branch/CLAUDE.md +1 -14
  196. package/skills/grok-spawn/AGENTS.md +28 -0
  197. package/skills/grok-spawn/CLAUDE.md +1 -28
  198. package/skills/pr-converge/AGENTS.md +32 -0
  199. package/skills/pr-converge/CLAUDE.md +1 -32
  200. package/skills/pr-converge/pr_converge_skill_constants/AGENTS.md +26 -0
  201. package/skills/pr-converge/pr_converge_skill_constants/CLAUDE.md +1 -26
  202. package/skills/pr-converge/reference/AGENTS.md +28 -0
  203. package/skills/pr-converge/reference/CLAUDE.md +1 -28
  204. package/skills/pr-converge/reference/obstacles/AGENTS.md +23 -0
  205. package/skills/pr-converge/reference/obstacles/CLAUDE.md +1 -23
  206. package/skills/pr-converge/scripts/AGENTS.md +46 -0
  207. package/skills/pr-converge/scripts/CLAUDE.md +1 -46
  208. package/skills/pr-converge/scripts/pr_converge_scripts_constants/AGENTS.md +18 -0
  209. package/skills/pr-converge/scripts/pr_converge_scripts_constants/CLAUDE.md +1 -18
  210. package/skills/pr-converge/workflows/AGENTS.md +16 -0
  211. package/skills/pr-converge/workflows/CLAUDE.md +1 -16
  212. package/skills/prototype/SKILL.md +1 -2
  213. package/skills/prototype/reference/honest-limitations.md +1 -1
  214. package/skills/prototype/reference/promotion-tasks.md +1 -1
  215. package/skills/prototype/workflows/promotion.md +1 -1
  216. package/skills/rebase/AGENTS.md +32 -0
  217. package/skills/rebase/CLAUDE.md +1 -32
  218. package/skills/recall/AGENTS.md +30 -0
  219. package/skills/recall/CLAUDE.md +1 -30
  220. package/skills/remember/AGENTS.md +31 -0
  221. package/skills/remember/CLAUDE.md +1 -31
  222. package/skills/reviews/SKILL.md +1 -1
  223. package/skills/session-log/AGENTS.md +32 -0
  224. package/skills/session-log/CLAUDE.md +1 -32
  225. package/skills/session-tidy/AGENTS.md +36 -0
  226. package/skills/session-tidy/CLAUDE.md +1 -36
  227. package/skills/skill-builder/AGENTS.md +49 -0
  228. package/skills/skill-builder/CLAUDE.md +1 -49
  229. package/skills/skill-builder/references/AGENTS.md +25 -0
  230. package/skills/skill-builder/references/CLAUDE.md +1 -25
  231. package/skills/skill-builder/references/deterministic-elements.md +1 -1
  232. package/skills/skill-builder/templates/AGENTS.md +14 -0
  233. package/skills/skill-builder/templates/CLAUDE.md +1 -14
  234. package/skills/skill-builder/workflows/AGENTS.md +19 -0
  235. package/skills/skill-builder/workflows/CLAUDE.md +1 -19
  236. package/skills/task-build/AGENTS.md +29 -0
  237. package/skills/task-build/CLAUDE.md +1 -29
  238. package/skills/update/AGENTS.md +38 -0
  239. package/skills/update/CLAUDE.md +1 -38
  240. package/system-prompts/AGENTS.md +17 -0
  241. package/system-prompts/CLAUDE.md +1 -17
  242. package/system-prompts/software-engineer.xml +3 -3
  243. package/agents/caveman.md +0 -73
  244. package/agents/clasp-deployment-orchestrator.md +0 -608
  245. package/agents/code-advisor.md +0 -23
  246. package/agents/deep-research.md +0 -152
  247. package/agents/docs-agent.md +0 -85
  248. package/commands/commit.md +0 -28
  249. package/commands/docupdate.md +0 -322
  250. package/commands/hook-log-extract.md +0 -70
  251. package/commands/hook-log-init.md +0 -76
  252. package/commands/implement.md +0 -102
  253. package/commands/plan.md +0 -14
  254. package/commands/pr-comments.md +0 -47
  255. package/commands/review-plan.md +0 -5
  256. package/commands/right-size.md +0 -15
  257. package/commands/sum.md +0 -30
  258. package/skills/imagegen/SKILL.md +0 -21
  259. package/skills/imagegen/scripts/config/__init__.py +0 -1
  260. package/skills/imagegen/scripts/config/constants.py +0 -28
  261. package/skills/imagegen/scripts/imagegen.py +0 -45
  262. package/skills/imagegen/scripts/imagegen_core.py +0 -528
  263. package/skills/imagegen/scripts/test_imagegen.py +0 -204
@@ -22,9 +22,8 @@ object name is the base when no default-branch ref resolves and when the
22
22
  pushed branch is the default branch. When every remote object name is zero
23
23
  (new branch) or stdin is empty, the gate falls back to the remote's default
24
24
  branch symbolic ref. When a default-branch ref resolves and git still reports
25
- no merge base, the base is unknown, so CODE_RULES enforcement is skipped with
26
- a printed reason rather than scoped to the stdin remote object name, which on
27
- a rebased tip would re-flag replayed commits.
25
+ no merge base, the base stays pending and the hook reports the infrastructure
26
+ status with a printed reason, preserving the scope boundary for rebased tips.
28
27
 
29
28
  Gate scope: the gate process this hook launches diffs its `--base` against the
30
29
  current checkout's HEAD, so the surface is the commits between that base and
@@ -32,14 +31,13 @@ HEAD. A push whose pushed object is HEAD reads as the branch's own work; a
32
31
  push of any other object is still scoped to HEAD.
33
32
 
34
33
  Exit codes:
35
- 0 - the push destination is allowed and its commits pass the gate (or
36
- the gate is not installed, or CODE_RULES is skipped because a
37
- default-branch ref resolved and git still reported no merge base).
34
+ 0 - the push destination is allowed and its commits pass the gate, or the
35
+ gate is not installed.
38
36
  1 - the push would land a non-protected local branch onto a protected
39
37
  remote branch, or a commit introduces a blocking violation.
40
- 2 - unexpected invocation failure (e.g., subprocess could not launch),
41
- stdin carried no parseable line, or a new-branch/empty-stdin base
42
- could not be turned into a usable commit name.
38
+ 2 - infrastructure attention is required because a subprocess could not
39
+ launch, stdin carried no parseable line, a base could not be resolved,
40
+ or a usable commit name could not be produced.
43
41
  """
44
42
 
45
43
  from __future__ import annotations
@@ -49,8 +47,9 @@ import sys
49
47
  from pathlib import Path
50
48
  from typing import NamedTuple
51
49
 
50
+ from gate_utils import is_safe_regular_file, resolve_gate_script_path
52
51
  from git_hooks_constants import (
53
- ALL_DEFAULT_BRANCH_FALLBACK_REFERENCES,
52
+ ALL_FALLBACK_REMOTE_DEFAULT_BRANCH_NAMES,
54
53
  ALL_GIT_MERGE_BASE_COMMAND_PREFIX,
55
54
  ALL_GIT_SYMBOLIC_REFERENCE_COMMAND_PREFIX,
56
55
  ALL_GIT_VERIFY_REFERENCE_COMMAND_PREFIX,
@@ -58,6 +57,7 @@ from git_hooks_constants import (
58
57
  ALL_ZEROS_OBJECT_NAME_CHARACTER,
59
58
  BASE_REFERENCE_ARGUMENT,
60
59
  DEFAULT_REMOTE_BASE_REFERENCE,
60
+ DEFAULT_REMOTE_NAME,
61
61
  GATE_INFRASTRUCTURE_FAILURE_EXIT_CODE,
62
62
  GIT_COMMAND_TIMEOUT_SECONDS,
63
63
  GIT_COMMAND_UNAVAILABLE_MESSAGE,
@@ -72,11 +72,10 @@ from git_hooks_constants import (
72
72
  MALFORMED_STDIN_LINE_MESSAGE,
73
73
  NO_PARSEABLE_STDIN_LINES_MESSAGE,
74
74
  NO_PARSEABLE_STDIN_LINES_SENTINEL,
75
- ORIGIN_HEAD_SYMBOLIC_REFERENCE,
76
- ORIGIN_REMOTE_TRACKING_REFERENCE_PREFIX,
77
75
  PRE_PUSH_GATE_SCRIPT_NOT_FOUND_MESSAGE,
78
76
  PROTECTED_BRANCH_PUSH_BLOCK_EXIT_CODE,
79
77
  PROTECTED_BRANCH_PUSH_BLOCK_MESSAGE,
78
+ REMOTE_BRANCH_REFERENCE_TEMPLATE,
80
79
  REMOTE_REFERENCE_FIELD_INDEX,
81
80
  STDIN_LINE_FIELD_COUNT,
82
81
  STDIN_READ_FAILURE_MESSAGE,
@@ -84,7 +83,6 @@ from git_hooks_constants import (
84
83
  UNRESOLVABLE_MERGE_BASE_MESSAGE,
85
84
  UNRESOLVABLE_MERGE_BASE_SENTINEL,
86
85
  )
87
- from gate_utils import is_safe_regular_file, resolve_gate_script_path
88
86
  from pre_push_base_reference import (
89
87
  resolve_remote_name_from_arguments,
90
88
  resolve_usable_base_reference,
@@ -294,24 +292,24 @@ def run_git_reference_query(all_git_arguments: tuple[str, ...]) -> str | None:
294
292
  return decoded_output.strip() or None
295
293
 
296
294
 
297
- def resolve_default_branch_reference() -> str | None:
295
+ def resolve_default_branch_reference(remote_name: str = DEFAULT_REMOTE_NAME) -> str | None:
298
296
  """Return the remote-tracking ref name of the remote's default branch.
299
297
 
300
- The remote's HEAD symbolic ref answers first. When it is unset, each
301
- candidate default-branch remote-tracking ref answers in turn.
298
+ The remote's HEAD symbolic ref answers first. When it is unset, the
299
+ supported default-branch tracking refs answer in turn.
302
300
 
303
- Resolution reads ``origin`` alone and never the remote name git passes as
304
- argv[1], and its unset-``origin/HEAD`` fallback prefers ``origin/main``
305
- over ``origin/master``, so a repo whose default is another branch beside a
306
- legacy ``main`` resolves the wrong base ΓÇö the assumption set tracked at
307
- ~/.claude/orchestrator-runs/falsify-first/parked-items.md row 3.
301
+ Args:
302
+ remote_name: Remote whose default branch provides the gate base.
308
303
 
309
304
  Returns:
310
305
  A remote-tracking ref name, or None when no default-branch ref
311
306
  resolves.
312
307
  """
308
+ remote_head_reference = REMOTE_BRANCH_REFERENCE_TEMPLATE.format(
309
+ remote=remote_name, branch="HEAD"
310
+ )
313
311
  symbolic_reference = run_git_reference_query(
314
- (*ALL_GIT_SYMBOLIC_REFERENCE_COMMAND_PREFIX, ORIGIN_HEAD_SYMBOLIC_REFERENCE)
312
+ (*ALL_GIT_SYMBOLIC_REFERENCE_COMMAND_PREFIX, remote_head_reference)
315
313
  )
316
314
  if symbolic_reference is not None:
317
315
  verified_symbolic_target = run_git_reference_query(
@@ -319,7 +317,10 @@ def resolve_default_branch_reference() -> str | None:
319
317
  )
320
318
  if verified_symbolic_target is not None:
321
319
  return symbolic_reference
322
- for each_candidate_reference in ALL_DEFAULT_BRANCH_FALLBACK_REFERENCES:
320
+ for each_branch_name in ALL_FALLBACK_REMOTE_DEFAULT_BRANCH_NAMES:
321
+ each_candidate_reference = REMOTE_BRANCH_REFERENCE_TEMPLATE.format(
322
+ remote=remote_name, branch=each_branch_name
323
+ )
323
324
  verified_reference = run_git_reference_query(
324
325
  (*ALL_GIT_VERIFY_REFERENCE_COMMAND_PREFIX, each_candidate_reference)
325
326
  )
@@ -360,7 +361,9 @@ def find_branch_update_push(stdin_text: str) -> PushLine | None:
360
361
 
361
362
 
362
363
  def resolve_default_branch_merge_base(
363
- remote_branch_name: str, pushed_object_name: str
364
+ remote_branch_name: str,
365
+ pushed_object_name: str,
366
+ remote_name: str = DEFAULT_REMOTE_NAME,
364
367
  ) -> str | None:
365
368
  """Return the merge base of the pushed object and the default branch.
366
369
 
@@ -371,6 +374,7 @@ def resolve_default_branch_merge_base(
371
374
  Args:
372
375
  remote_branch_name: The remote branch the push updates.
373
376
  pushed_object_name: The object name the push carries.
377
+ remote_name: The remote whose default branch provides the gate base.
374
378
 
375
379
  Returns:
376
380
  The merge-base object name; None when no default-branch ref resolves or
@@ -378,12 +382,13 @@ def resolve_default_branch_merge_base(
378
382
  no merge base applies; or the unresolvable-merge-base sentinel when a
379
383
  default-branch ref resolves and git still reports no merge base.
380
384
  """
381
- default_branch_reference = resolve_default_branch_reference()
385
+ default_branch_reference = resolve_default_branch_reference(remote_name)
382
386
  if default_branch_reference is None:
383
387
  return None
384
- default_branch_name = default_branch_reference.removeprefix(
385
- ORIGIN_REMOTE_TRACKING_REFERENCE_PREFIX
388
+ default_branch_prefix = REMOTE_BRANCH_REFERENCE_TEMPLATE.format(
389
+ remote=remote_name, branch=""
386
390
  )
391
+ default_branch_name = default_branch_reference.removeprefix(default_branch_prefix)
387
392
  if remote_branch_name == default_branch_name:
388
393
  return None
389
394
  # Anchors to the pushed object; deferring to the gate's HEAD-based merge-base would change behavior on non-HEAD pushes.
@@ -399,7 +404,9 @@ def resolve_default_branch_merge_base(
399
404
  return merge_base_object_name
400
405
 
401
406
 
402
- def resolve_gate_base_reference(stdin_text: str) -> str | None:
407
+ def resolve_gate_base_reference(
408
+ stdin_text: str, remote_name: str = DEFAULT_REMOTE_NAME
409
+ ) -> str | None:
403
410
  """Return the reference the gate scopes its changed lines to.
404
411
 
405
412
  A branch update reads from the merge base with the remote default branch,
@@ -414,20 +421,24 @@ def resolve_gate_base_reference(stdin_text: str) -> str | None:
414
421
 
415
422
  Args:
416
423
  stdin_text: The pre-push stdin payload.
424
+ remote_name: The remote whose default branch provides the gate base.
417
425
 
418
426
  Returns:
419
427
  The gate's base reference, the no-parseable-lines sentinel, the
420
428
  unresolvable-merge-base sentinel, or None when the push only deletes
421
429
  remote branches.
422
430
  """
423
- return _resolve_gate_base_from_parsed(_parse_push_stdin(stdin_text))
431
+ return _resolve_gate_base_from_parsed(_parse_push_stdin(stdin_text), remote_name)
424
432
 
425
433
 
426
- def _resolve_gate_base_from_parsed(parsed_stdin: ParsedPushStdin) -> str | None:
434
+ def _resolve_gate_base_from_parsed(
435
+ parsed_stdin: ParsedPushStdin, remote_name: str = DEFAULT_REMOTE_NAME
436
+ ) -> str | None:
427
437
  """Return the gate's base reference for an already-parsed stdin payload.
428
438
 
429
439
  Args:
430
440
  parsed_stdin: The parsed stdin payload.
441
+ remote_name: The remote whose default branch provides the gate base.
431
442
 
432
443
  Returns:
433
444
  The merge base with the remote default branch for a branch update, the
@@ -440,7 +451,9 @@ def _resolve_gate_base_from_parsed(parsed_stdin: ParsedPushStdin) -> str | None:
440
451
  if branch_update is None:
441
452
  return _resolve_base_reference_from_lines(parsed_stdin)
442
453
  merge_base_object_name = resolve_default_branch_merge_base(
443
- branch_update.remote_branch_name, branch_update.local_object_name
454
+ branch_update.remote_branch_name,
455
+ branch_update.local_object_name,
456
+ remote_name,
444
457
  )
445
458
  if merge_base_object_name is None:
446
459
  return branch_update.remote_object_name
@@ -542,7 +555,8 @@ def main() -> int:
542
555
  file=sys.stderr,
543
556
  )
544
557
  return 0
545
- base_reference = _resolve_gate_base_from_parsed(parsed_stdin)
558
+ remote_name = resolve_remote_name_from_arguments(sys.argv)
559
+ base_reference = _resolve_gate_base_from_parsed(parsed_stdin, remote_name)
546
560
  if base_reference is None:
547
561
  return 0
548
562
  if base_reference == no_parseable_stdin_lines_sentinel:
@@ -550,8 +564,7 @@ def main() -> int:
550
564
  return gate_infrastructure_failure_exit_code
551
565
  if base_reference == unresolvable_merge_base_sentinel:
552
566
  print(unresolvable_merge_base_message, file=sys.stderr)
553
- return 0
554
- remote_name = resolve_remote_name_from_arguments(sys.argv)
567
+ return gate_infrastructure_failure_exit_code
555
568
  try:
556
569
  usable_base_reference = resolve_usable_base_reference(
557
570
  base_reference, remote_name, run_git_text_command
@@ -156,11 +156,10 @@ def test_run_git_reference_query_returns_replaced_text_on_locale_invalid_bytes(
156
156
  assert resolved_output == expected_replaced_reference
157
157
 
158
158
 
159
- def test_unresolvable_merge_base_message_does_not_claim_dangling_origin_head() -> None:
159
+ def test_unresolvable_merge_base_message_describes_pending_validation() -> None:
160
160
  skip_message = git_hooks_constants.UNRESOLVABLE_MERGE_BASE_MESSAGE
161
- assert "origin/HEAD names a ref" not in skip_message
162
- assert "unrelated histories" in skip_message
163
- assert "merge-base still could not name a shared commit" in skip_message
161
+ assert "CODE_RULES validation is pending" in skip_message
162
+ assert "Restore shared history" in skip_message
164
163
 
165
164
 
166
165
  def test_run_git_text_command_raises_when_git_cannot_launch(
@@ -239,6 +238,11 @@ def resolve_remote_head_reference(monkeypatch: pytest.MonkeyPatch) -> None:
239
238
  return GIT_RESOLVED_EXIT_CODE, RESOLVED_COMMIT_OBJECT_NAME
240
239
 
241
240
  monkeypatch.setattr(pre_push, "run_git_text_command", fake_run_git_text_command)
241
+ monkeypatch.setattr(
242
+ sys,
243
+ "argv",
244
+ [HOOK_INVOCATION_NAME, git_hooks_constants.DEFAULT_REMOTE_NAME, PUSHED_REMOTE_URL],
245
+ )
242
246
 
243
247
 
244
248
 
@@ -994,6 +998,46 @@ def test_resolve_default_branch_reference_reads_the_origin_head_symbolic_referen
994
998
  assert pre_push.resolve_default_branch_reference() == ORIGIN_DEFAULT_BRANCH_REFERENCE
995
999
 
996
1000
 
1001
+ def test_resolve_default_branch_reference_reads_the_requested_remote_head(
1002
+ tmp_path: Path,
1003
+ monkeypatch: pytest.MonkeyPatch,
1004
+ ) -> None:
1005
+ repository, default_branch_tip, _topic_branch_tip = _build_default_branch_repository(
1006
+ tmp_path
1007
+ )
1008
+ upstream_reference = "refs/remotes/upstream/main"
1009
+ upstream_head_reference = "refs/remotes/upstream/HEAD"
1010
+ _run_fixture_git(repository, "update-ref", upstream_reference, default_branch_tip)
1011
+ _run_fixture_git(
1012
+ repository, "symbolic-ref", upstream_head_reference, upstream_reference
1013
+ )
1014
+ monkeypatch.chdir(repository)
1015
+
1016
+ assert pre_push.resolve_default_branch_reference("upstream") == upstream_reference
1017
+
1018
+
1019
+ def test_resolve_default_branch_merge_base_uses_requested_remote_trunk_fallback(
1020
+ tmp_path: Path,
1021
+ monkeypatch: pytest.MonkeyPatch,
1022
+ ) -> None:
1023
+ repository, default_branch_tip, topic_branch_tip = _build_default_branch_repository(
1024
+ tmp_path
1025
+ )
1026
+ upstream_trunk_reference = "refs/remotes/upstream/trunk"
1027
+ _run_fixture_git(
1028
+ repository, "update-ref", upstream_trunk_reference, default_branch_tip
1029
+ )
1030
+ monkeypatch.chdir(repository)
1031
+
1032
+ merge_base_object_name = pre_push.resolve_default_branch_merge_base(
1033
+ FEATURE_BRANCH_NAME,
1034
+ topic_branch_tip,
1035
+ "upstream",
1036
+ )
1037
+
1038
+ assert merge_base_object_name == default_branch_tip
1039
+
1040
+
997
1041
  def test_resolve_default_branch_reference_returns_none_without_remote_tracking_refs(
998
1042
  tmp_path: Path,
999
1043
  monkeypatch: pytest.MonkeyPatch,
@@ -1198,7 +1242,7 @@ def test_main_allows_the_push_when_origin_head_names_an_absent_reference(
1198
1242
  assert recorded_arguments == ["--base", remote_object_name]
1199
1243
 
1200
1244
 
1201
- def test_main_skips_the_gate_when_no_merge_base_resolves(
1245
+ def test_main_keeps_the_gate_pending_when_no_merge_base_resolves(
1202
1246
  tmp_path: Path,
1203
1247
  monkeypatch: pytest.MonkeyPatch,
1204
1248
  capsys: pytest.CaptureFixture[str],
@@ -1230,13 +1274,73 @@ def test_main_skips_the_gate_when_no_merge_base_resolves(
1230
1274
 
1231
1275
  exit_code = pre_push.main()
1232
1276
 
1233
- assert exit_code == 0
1277
+ assert exit_code == git_hooks_constants.GATE_INFRASTRUCTURE_FAILURE_EXIT_CODE
1234
1278
  assert not recorded_arguments_path.exists(), (
1235
- "the gate ran on a base the hook could not verify"
1279
+ "the gate remains pending until the hook verifies a usable base"
1236
1280
  )
1237
1281
  assert git_hooks_constants.UNRESOLVABLE_MERGE_BASE_MESSAGE in capsys.readouterr().err
1238
1282
 
1239
1283
 
1284
+ def test_main_uses_the_pushed_remote_when_origin_has_unrelated_history(
1285
+ tmp_path: Path,
1286
+ monkeypatch: pytest.MonkeyPatch,
1287
+ ) -> None:
1288
+ repository, default_branch_tip, topic_branch_tip = _build_default_branch_repository(
1289
+ tmp_path
1290
+ )
1291
+ _run_fixture_git(repository, "checkout", "--orphan", "unrelated-origin")
1292
+ _run_fixture_git(repository, "rm", "-rf", ".")
1293
+ unrelated_origin_tip = _commit_file(repository, "unrelated.txt")
1294
+ _run_fixture_git(repository, "checkout", FEATURE_BRANCH_NAME)
1295
+ _run_fixture_git(
1296
+ repository,
1297
+ "update-ref",
1298
+ ORIGIN_DEFAULT_BRANCH_REFERENCE,
1299
+ unrelated_origin_tip,
1300
+ )
1301
+ _set_origin_head(repository, ORIGIN_DEFAULT_BRANCH_REFERENCE)
1302
+ upstream_reference = "refs/remotes/upstream/main"
1303
+ upstream_head_reference = "refs/remotes/upstream/HEAD"
1304
+ _run_fixture_git(repository, "update-ref", upstream_reference, default_branch_tip)
1305
+ _run_fixture_git(
1306
+ repository, "symbolic-ref", upstream_head_reference, upstream_reference
1307
+ )
1308
+ recorded_arguments_path = tmp_path / "upstream_recorded_arguments.txt"
1309
+ recording_gate_script_path = tmp_path / "upstream_recording_gate.py"
1310
+ recording_gate_script_path.write_text(
1311
+ "import pathlib, sys\n"
1312
+ f'pathlib.Path(r"{recorded_arguments_path}").write_text('
1313
+ "'\\n'.join(sys.argv[1:]), encoding='utf-8')\n"
1314
+ "sys.exit(0)\n",
1315
+ encoding="utf-8",
1316
+ )
1317
+ monkeypatch.setenv("CODE_RULES_GATE_PATH", str(recording_gate_script_path))
1318
+ monkeypatch.chdir(repository)
1319
+ monkeypatch.setattr(
1320
+ sys, "argv", [HOOK_INVOCATION_NAME, PUSHED_REMOTE_NAME, PUSHED_REMOTE_URL]
1321
+ )
1322
+ monkeypatch.setattr(
1323
+ sys,
1324
+ "stdin",
1325
+ io.StringIO(
1326
+ _push_stdin_line(
1327
+ FEATURE_BRANCH_NAME,
1328
+ topic_branch_tip,
1329
+ FEATURE_BRANCH_NAME,
1330
+ NON_ZERO_REMOTE_SHA_ONE,
1331
+ )
1332
+ ),
1333
+ )
1334
+
1335
+ exit_code = pre_push.main()
1336
+
1337
+ assert exit_code == 0
1338
+ assert recorded_arguments_path.read_text(encoding="utf-8").splitlines() == [
1339
+ "--base",
1340
+ default_branch_tip,
1341
+ ]
1342
+
1343
+
1240
1344
  def test_main_allows_default_branch_file_the_rebase_replayed_onto(
1241
1345
  tmp_path: Path,
1242
1346
  monkeypatch: pytest.MonkeyPatch,
@@ -0,0 +1,104 @@
1
+ # hooks/hooks_constants
2
+
3
+ Shared constant modules imported by hooks throughout the `hooks/` tree. Each file holds the tunables for one hook or one cross-cutting concern, keeping magic values out of the hook scripts themselves.
4
+
5
+ ## Files
6
+
7
+ | File | What it holds |
8
+ |---|---|
9
+ | `__init__.py` | Package marker (`# pragma: no-tdd-gate`) |
10
+ | `any_type_config.py` | Config for the `Any`-type escape-hatch check |
11
+ | `ask_user_question_shape.py` | Pure AskUserQuestion lean-block shape analyzer: grades question and option-description prose against shared chat-detail markers and sentence/word caps with no hook I/O |
12
+ | `banned_identifiers_constants.py` | The set of banned short identifiers and banned function-name prefixes |
13
+ | `bash_pre_tool_use_dispatcher_constants.py` | Permission outcomes, tool-name sets, and the ordered hosted-hook roster for the Bash PreToolUse dispatcher (also covers PowerShell-shared gates) |
14
+ | `blocking_check_limits.py` | Max issue counts and preview lengths for blocking hooks |
15
+ | `bot_mention_comment_blocker_constants.py` | Patterns for detecting bot @-mentions in PR comments |
16
+ | `claude_md_orphan_file_blocker_constants.py` | Table patterns, file extensions, scan budget, and block-message text for the CLAUDE.md orphan-file blocker |
17
+ | `code_rules_enforcer_constants.py` | File-extension sets, test-path patterns, advisory line thresholds, boolean-name prefixes |
18
+ | `enter_worktree_prefetch_constants.py` | Tool name, origin-remote ref names, and git-command timeouts for the EnterWorktree origin-prefetch hook |
19
+ | `env_var_table_code_drift_constants.py` | Table patterns, env-var-name and code-file recognizers, scan budget, and block-message text for the env-var-table code-drift blocker |
20
+ | `code_rules_path_utils_constants.py` | Path-matching helpers used by the code-rules check modules |
21
+ | `command_dispatch_constants.py` | Command-word regex, command-key access pattern, tokenization pattern, and anchors for the unanchored command-dispatch meta-gate |
22
+ | `conventional_pr_title_gate_constants.py` | Bash tool name, gh executable basenames and pr create/edit subcommand tokens, title/repo flag names, semantic-title-CI workflow markers, the Conventional Commits type list and title pattern, the semantic-pull-request action `types:` input pattern, and block-message text for the conventional-PR-title gate |
23
+ | `dead_argparse_argument_constants.py` | Patterns for detecting unused argparse arguments |
24
+ | `dead_config_field_constants.py` | Patterns for detecting unused `*Config` / `*Selectors` dataclass fields |
25
+ | `dead_dataclass_field_constants.py` | Patterns for detecting unused dataclass fields |
26
+ | `dead_module_constant_constants.py` | Patterns for detecting unexported `UPPER_SNAKE` constants in `*_constants.py` modules |
27
+ | `destructive_command_segment_constants.py` | The list of destructive shell command patterns the blocker matches |
28
+ | `docstring_rule_gate_count_blocker_constants.py` | Target rule basename, spelled-out-number lookup, count-clause and `check_*` validator patterns, and block-message text for the docstring-rule gate-count staleness blocker |
29
+ | `duplicate_function_body_constants.py` | Hashing and comparison config for the duplicate-body check |
30
+ | `duplicate_rmtree_helper_blocker_constants.py` | Sanctioned Windows-safe rmtree helper names, the definition pattern, and the exempt-path set for the duplicate-rmtree-helper blocker |
31
+ | `dynamic_stderr_handler.py` | `DynamicStderrHandler` — a logging handler that resolves `sys.stderr` at emit time (for testability) |
32
+ | `eli11_reply_enforcer_constants.py` | Reply-shape thresholds (bullet cap, lead-line window, per-list-line word cap, overpacked list-line cap), the bullet / numbered-step / table-row / link-target / word patterns, the imperative instruction verbs, and the user-facing notice for the ELI11 reply-shape Stop hook |
33
+ | `fable_spawn_gate_constants.py` | The spawn tool-name set, the fable model alias and the model-id segment split pattern, the `FABLE-SPAWN-AUTHORIZED` authorization token, the advisor-protocol document path, payload field names, the deny message, and the deny `additionalContext` recovery text for the fable-tier spawn gate |
34
+ | `gh_pr_author_swap_constants.py` | Constants for the PR-author swap enforcement hooks |
35
+ | `hardcoded_user_path_constants.py` | Patterns for detecting hardcoded home-directory paths |
36
+ | `harness_scratchpad_constants.py` | Fixed path components (`claude` / `claude-` user-directory name and prefix, `scratchpad` leaf name), the PreToolUse session-id payload key, and the `CLAUDE_CODE_SESSION_ID` environment variable name that the code-rules and TDD gates use to recognize an existing harness session scratchpad directory |
37
+ | `hedging_uncertainty_constants.py` | Sentence-boundary pattern, explicit uncertainty label patterns, hedge-term list separator, and positive corrective block text for OP-07C sentence-scoped hedging |
38
+ | `hook_block_logger.py` | `log_hook_block()` — shared fail-safe logger every blocking hook calls to append a JSON record of each block decision to `~/.claude/logs/hook-blocks.log` |
39
+ | `hook_log_extractor_constants.py` | Neon table name, offset state file path, timeouts, and outcome-type mapping for the hook-log extractor |
40
+ | `hook_prose_detector_consistency_constants.py` | Trigger patterns and corrective messages for the hook-prose consistency checker |
41
+ | `hosted_hook_runner.py` | `run_hook_capturing_output()` — shared runner that runs one dispatcher-hosted hook in-process via runpy and returns its captured stdout and crash flag |
42
+ | `inline_tuple_string_magic_constants.py` | Patterns for detecting magic strings in inline tuple literals |
43
+ | `js_conventions_constants.py` | Banned identifier set, boolean-prefix pattern, and declaration/JSDoc patterns for the JavaScript convention checks |
44
+ | `local_identity.py` | Loader for local machine values: NAS host, ssh user, and ssh port the ssh enforcer guards (`CLAUDE_NAS_*` / `~/.claude/local-identity.json` with placeholder defaults), the PII commit-scan exempt-repo slug set (`CLAUDE_PII_EXEMPT_REPOS` / `pii_exempt_repositories`), and the per-repository allowlisted-values mapping (`pii_allowlisted_values`, keyed by owner/repo slug) read from the git-ignored local file whose path `CLAUDE_LOCAL_IDENTITY_PATH` may point elsewhere; also composes the ssh enforcer's two deny messages that quote the NAS values |
45
+ | `messages.py` | Short user-facing notice strings shown when a Stop hook redirects agent behavior |
46
+ | `multi_edit_reconstruction.py` | `apply_edits()` / `edits_for_tool()` — shared helpers that reconstruct the post-edit content of an Edit or MultiEdit, imported by the blockers that judge post-edit content |
47
+ | `mypy_integration_constants.py` | Path markers (``.git``, ``.py``, ``pyproject.toml``) for mypy project-root resolution |
48
+ | `mypy_validator_cache_constants.py` | Cache paths and tunables for the mypy_validator per-session caches |
49
+ | `nas_ssh_binary_enforcer_constants.py` | Bash tool name, ssh-family basenames, OpenSSH binary path suffixes, and the batch-mode pattern for the NAS ssh binary enforcer; segment helpers come from `shell_command_segments.py` |
50
+ | `open_questions_in_plans_blocker_constants.py` | Patterns for detecting unresolved open questions in plan documents |
51
+ | `orphan_css_class_constants.py` | Scan radius and selector patterns for the orphan-CSS-class check |
52
+ | `package_inventory_stale_blocker_constants.py` | Inventory document names, production code extensions, backtick token pattern, smallest inventory size, exempt names, scan budget, and block-message text for the package-inventory stale-entry blocker |
53
+ | `paired_test_coverage_constants.py` | Test-directory name, stem-test filename affixes, test-file globs, exempt public-function names, scan budget, coverage threshold, and guidance text for the public-function paired-test coverage check |
54
+ | `path_rewriter_constants.py` | Path rewriting patterns for the Everything-search path rewriter |
55
+ | `pii_prevention_constants.py` | Patterns, allowlists, path exemptions, and deny-message text for `pii_prevention_blocker` |
56
+ | `piped_pytest_blocker_constants.py` | Bash tool name, pytest program basenames and the python-interpreter basename pattern, the pipe and segment-reset operator token sets, and the deny message for the piped-pytest blocker; classification that consumes those program and wrapper constants lives in `pytest_invocation.py` |
57
+ | `pytest_invocation.py` | Pure parsed-segment classifier for pytest runs through interpreters, shims, wrappers, and shell string-exec forms; no pipeline deny decision |
58
+ | `plain_language_blocker_constants.py` | The list of heavy words and their everyday replacements |
59
+ | `prose_matcher_precision_constants.py` | Sample floor, keep/narrow precision floors, matcher ids, label decisions, advisory log path, emit caps, and context fingerprint length for OP-07B prose-matcher advisory telemetry |
60
+ | `pre_tool_use_stdin.py` | `read_hook_input_dictionary_from_stdin()` — shared stdin parser for PreToolUse hooks |
61
+ | `precommit_code_rules_gate_constants.py` | Scope argument and exit-code constants for the precommit gate |
62
+ | project_paths_reader.py | Loads ~/.claude/project-paths.json and finds a home-bounded git root for registry checks |
63
+ | `pyproject_config_discovery_constants.py` | Table names (``tool`` key, ``mypy``, ``ruff``) for resolving a validator's config from a pyproject.toml `[tool.<name>]` table |
64
+ | `pytest_testpaths_orphan_blocker_constants.py` | Marker filename, section and key names, test-file pattern, search budget, and block-message text for the pytest unregistered-test-directory blocker |
65
+ | `python_style_checks_constants.py` | Command-line argument count and blank-line count between top-level functions for the style validator |
66
+ | `ruff_integration_constants.py` | ``NO_COLOR`` / ``FORCE_COLOR`` environment variable names for plain ruff diagnostics |
67
+ | `send_user_file_open_locally_blocker_constants.py` | Tool name, proactive status, and the block message for the open-locally attach blocker |
68
+ | `sensitive_file_protector_constants.py` | Sensitive filename patterns, the committed-template suffixes that earn an exemption, the write/edit tool names, and the deny decision and message template for `sensitive_file_protector` |
69
+ | `session_edit_stage_gate_constants.py` | Tracker filename prefix/suffix, JSON payload key, edit tool name set, session-id sanitize pattern, lock filename suffix and lock-acquire timing, git diff command, commit flag escapes, and deny-message template shared by the session edit stage gate trio |
70
+ | `session_env_cleanup_constants.py` | Stale-age threshold and directory names for the session-env cleanup hook |
71
+ | `session_start_injector.py` | Pure SessionStart context injector: normalize `source` (`startup`/`resume`/`clear`/`compact`), honor enable/timeout, return structured injection results for starter hooks |
72
+ | `session_start_injector_constants.py` | Known SessionStart source values, injection status codes, enable env var, default timeout for the shared injector |
73
+ | `test_session_start_injector.py` | Behavioral tests for every known source, disabled, timeout, and unknown-source paths |
74
+ | `orchestrator_auto_starter_constants.py` | Opt-in env var, enable values, timeout, and SessionStart directive text for the orchestrator auto-starter |
75
+ | `issue_tracker_session_starter_constants.py` | Opt-in env var, enable values, timeout, and SessionStart directive text for the repository-gated issue-tracker starter |
76
+ | `session_handoff_blocker_constants.py` | Trigger phrases for the session-handoff blocker |
77
+ | `setup_project_paths_constants.py` | Encoding policy, BOM marker, and registry meta-key used across multiple hooks |
78
+ | `shell_command_pipeline.py` | Quote-aware shell pipeline parsing: operator-paired segments after line-continuation join, comment strip, heredoc body drop, and parenthesis-group join |
79
+ | `shell_command_segments.py` | Shell tokenization helpers shared by the segment-walking blockers: segment splitting on control operators, a segment's effective leading program, and a token's basename |
80
+ | `shell_substitution_blocker_constants.py` | Tool name, payload keys, the four substitution-detection patterns, the deny decision shape, and the corrective message for the shell-substitution blocker |
81
+ | `stale_comment_reference_blocker_constants.py` | Identifier pattern, comment stopwords, and denial text for the stale-comment-reference blocker |
82
+ | `state_description_blocker_constants.py` | The set of historical/comparative phrases the state-description blocker rejects, plus the docstring-extraction and mention-span patterns for its Python docstring scan |
83
+ | `stop_dispatcher_constants.py` | Ordered hosted-hook roster and Stop block payload field names for the Stop-chain dispatcher |
84
+ | `stuttering_check_config.py` | Config for the stuttering (repeated-phrase) check |
85
+ | `stuttering_import_binding_constants.py` | Import-binding patterns for the stuttering check |
86
+ | `subprocess_budget_completeness_constants.py` | Required argument names for the subprocess-budget completeness check |
87
+ | `sys_path_insert_constants.py` | Patterns for detecting unguarded `sys.path.insert` calls |
88
+ | `task_list_loop_starter_constants.py` | The one-line task-list instruction and the full session-start directive text for the task-list loop starter hook |
89
+ | `test_layout_constants.py` | The named constants for the test-layout write-time checks |
90
+ | `text_stripping.py` | `strip_code_and_quotes()` — shared helper that removes fenced code blocks, inline code, and blockquotes from prose, imported by the Stop-hook prose blockers |
91
+ | `unscoped_search_blocker_constants.py` | Tool names, `find` and listing program basenames, Get-ChildItem option sets, unscoped-root patterns, the flag/value token stride, and the deny message for the unscoped-search blocker |
92
+ | `unused_module_import_constants.py` | Patterns for detecting unused module-level imports |
93
+ | `volatile_path_in_post_blocker_constants.py` | Volatile path markers, affected `gh` post subcommands, MCP body param names, and the corrective message for the volatile-path post blocker |
94
+ | `windows_rmtree_blocker_constants.py` | The unsafe `shutil.rmtree` pattern and the safe replacement pattern |
95
+ | `workflow_substitution_slot_blocker_constants.py` | Per-iteration token patterns for the workflow-slot blocker |
96
+ | `working_style_prompt_constants.py` | The fixed multi-paragraph working-style prompt text for the SessionStart working_style_prompt hook |
97
+
98
+ ## Conventions
99
+
100
+ - Most files in this package are pure constants modules — no side effects, no I/O.
101
+ - Hooks import from this package with `from hooks_constants.<module> import <CONSTANT>`.
102
+ - Tests for these modules live beside them as `test_<module>.py`. Run with `python -m pytest hooks_constants/test_<name>.py`.
103
+ - `dynamic_stderr_handler.py`, `pre_tool_use_stdin.py`, `multi_edit_reconstruction.py`, `hosted_hook_runner.py`, and `text_stripping.py` are utility modules (not pure constants) but live here because they hold logic shared across hook surfaces.
104
+ - `local_identity.py` is a loader: it reads the environment or `~/.claude/local-identity.json` (its path overridable via `CLAUDE_LOCAL_IDENTITY_PATH`) to resolve private NAS values (with committed placeholder defaults), the PII commit-scan exempt-repo slug set (`CLAUDE_PII_EXEMPT_REPOS` / `pii_exempt_repositories`), and the per-repository allowlisted-values mapping (`pii_allowlisted_values`).
@@ -1,104 +1 @@
1
- # hooks/hooks_constants
2
-
3
- Shared constant modules imported by hooks throughout the `hooks/` tree. Each file holds the tunables for one hook or one cross-cutting concern, keeping magic values out of the hook scripts themselves.
4
-
5
- ## Files
6
-
7
- | File | What it holds |
8
- |---|---|
9
- | `__init__.py` | Package marker (`# pragma: no-tdd-gate`) |
10
- | `any_type_config.py` | Config for the `Any`-type escape-hatch check |
11
- | `ask_user_question_shape.py` | Pure AskUserQuestion lean-block shape analyzer: grades question and option-description prose against shared chat-detail markers and sentence/word caps with no hook I/O |
12
- | `banned_identifiers_constants.py` | The set of banned short identifiers and banned function-name prefixes |
13
- | `bash_pre_tool_use_dispatcher_constants.py` | Permission outcomes, tool-name sets, and the ordered hosted-hook roster for the Bash PreToolUse dispatcher (also covers PowerShell-shared gates) |
14
- | `blocking_check_limits.py` | Max issue counts and preview lengths for blocking hooks |
15
- | `bot_mention_comment_blocker_constants.py` | Patterns for detecting bot @-mentions in PR comments |
16
- | `claude_md_orphan_file_blocker_constants.py` | Table patterns, file extensions, scan budget, and block-message text for the CLAUDE.md orphan-file blocker |
17
- | `code_rules_enforcer_constants.py` | File-extension sets, test-path patterns, advisory line thresholds, boolean-name prefixes |
18
- | `enter_worktree_prefetch_constants.py` | Tool name, origin-remote ref names, and git-command timeouts for the EnterWorktree origin-prefetch hook |
19
- | `env_var_table_code_drift_constants.py` | Table patterns, env-var-name and code-file recognizers, scan budget, and block-message text for the env-var-table code-drift blocker |
20
- | `code_rules_path_utils_constants.py` | Path-matching helpers used by the code-rules check modules |
21
- | `command_dispatch_constants.py` | Command-word regex, command-key access pattern, tokenization pattern, and anchors for the unanchored command-dispatch meta-gate |
22
- | `conventional_pr_title_gate_constants.py` | Bash tool name, gh executable basenames and pr create/edit subcommand tokens, title/repo flag names, semantic-title-CI workflow markers, the Conventional Commits type list and title pattern, the semantic-pull-request action `types:` input pattern, and block-message text for the conventional-PR-title gate |
23
- | `dead_argparse_argument_constants.py` | Patterns for detecting unused argparse arguments |
24
- | `dead_config_field_constants.py` | Patterns for detecting unused `*Config` / `*Selectors` dataclass fields |
25
- | `dead_dataclass_field_constants.py` | Patterns for detecting unused dataclass fields |
26
- | `dead_module_constant_constants.py` | Patterns for detecting unexported `UPPER_SNAKE` constants in `*_constants.py` modules |
27
- | `destructive_command_segment_constants.py` | The list of destructive shell command patterns the blocker matches |
28
- | `docstring_rule_gate_count_blocker_constants.py` | Target rule basename, spelled-out-number lookup, count-clause and `check_*` validator patterns, and block-message text for the docstring-rule gate-count staleness blocker |
29
- | `duplicate_function_body_constants.py` | Hashing and comparison config for the duplicate-body check |
30
- | `duplicate_rmtree_helper_blocker_constants.py` | Sanctioned Windows-safe rmtree helper names, the definition pattern, and the exempt-path set for the duplicate-rmtree-helper blocker |
31
- | `dynamic_stderr_handler.py` | `DynamicStderrHandler` — a logging handler that resolves `sys.stderr` at emit time (for testability) |
32
- | `eli11_reply_enforcer_constants.py` | Reply-shape thresholds (bullet cap, lead-line window, per-list-line word cap, overpacked list-line cap), the bullet / numbered-step / table-row / link-target / word patterns, the imperative instruction verbs, and the user-facing notice for the ELI11 reply-shape Stop hook |
33
- | `fable_spawn_gate_constants.py` | The spawn tool-name set, the fable model alias and the model-id segment split pattern, the `FABLE-SPAWN-AUTHORIZED` authorization token, the advisor-protocol document path, payload field names, the deny message, and the deny `additionalContext` recovery text for the fable-tier spawn gate |
34
- | `gh_pr_author_swap_constants.py` | Constants for the PR-author swap enforcement hooks |
35
- | `hardcoded_user_path_constants.py` | Patterns for detecting hardcoded home-directory paths |
36
- | `harness_scratchpad_constants.py` | Fixed path components (`claude` / `claude-` user-directory name and prefix, `scratchpad` leaf name), the PreToolUse session-id payload key, and the `CLAUDE_CODE_SESSION_ID` environment variable name that the code-rules and TDD gates use to recognize an existing harness session scratchpad directory |
37
- | `hedging_uncertainty_constants.py` | Sentence-boundary pattern, explicit uncertainty label patterns, hedge-term list separator, and positive corrective block text for OP-07C sentence-scoped hedging |
38
- | `hook_block_logger.py` | `log_hook_block()` — shared fail-safe logger every blocking hook calls to append a JSON record of each block decision to `~/.claude/logs/hook-blocks.log` |
39
- | `hook_log_extractor_constants.py` | Neon table name, offset state file path, timeouts, and outcome-type mapping for the hook-log extractor |
40
- | `hook_prose_detector_consistency_constants.py` | Trigger patterns and corrective messages for the hook-prose consistency checker |
41
- | `hosted_hook_runner.py` | `run_hook_capturing_output()` — shared runner that runs one dispatcher-hosted hook in-process via runpy and returns its captured stdout and crash flag |
42
- | `inline_tuple_string_magic_constants.py` | Patterns for detecting magic strings in inline tuple literals |
43
- | `js_conventions_constants.py` | Banned identifier set, boolean-prefix pattern, and declaration/JSDoc patterns for the JavaScript convention checks |
44
- | `local_identity.py` | Loader for local machine values: NAS host, ssh user, and ssh port the ssh enforcer guards (`CLAUDE_NAS_*` / `~/.claude/local-identity.json` with placeholder defaults), the PII commit-scan exempt-repo slug set (`CLAUDE_PII_EXEMPT_REPOS` / `pii_exempt_repositories`), and the per-repository allowlisted-values mapping (`pii_allowlisted_values`, keyed by owner/repo slug) read from the git-ignored local file whose path `CLAUDE_LOCAL_IDENTITY_PATH` may point elsewhere; also composes the ssh enforcer's two deny messages that quote the NAS values |
45
- | `messages.py` | Short user-facing notice strings shown when a Stop hook redirects agent behavior |
46
- | `multi_edit_reconstruction.py` | `apply_edits()` / `edits_for_tool()` — shared helpers that reconstruct the post-edit content of an Edit or MultiEdit, imported by the blockers that judge post-edit content |
47
- | `mypy_integration_constants.py` | Path markers (``.git``, ``.py``, ``pyproject.toml``) for mypy project-root resolution |
48
- | `mypy_validator_cache_constants.py` | Cache paths and tunables for the mypy_validator per-session caches |
49
- | `nas_ssh_binary_enforcer_constants.py` | Bash tool name, ssh-family basenames, OpenSSH binary path suffixes, and the batch-mode pattern for the NAS ssh binary enforcer; segment helpers come from `shell_command_segments.py` |
50
- | `open_questions_in_plans_blocker_constants.py` | Patterns for detecting unresolved open questions in plan documents |
51
- | `orphan_css_class_constants.py` | Scan radius and selector patterns for the orphan-CSS-class check |
52
- | `package_inventory_stale_blocker_constants.py` | Inventory document names, production code extensions, backtick token pattern, smallest inventory size, exempt names, scan budget, and block-message text for the package-inventory stale-entry blocker |
53
- | `paired_test_coverage_constants.py` | Test-directory name, stem-test filename affixes, test-file globs, exempt public-function names, scan budget, coverage threshold, and guidance text for the public-function paired-test coverage check |
54
- | `path_rewriter_constants.py` | Path rewriting patterns for the Everything-search path rewriter |
55
- | `pii_prevention_constants.py` | Patterns, allowlists, path exemptions, and deny-message text for `pii_prevention_blocker` |
56
- | `piped_pytest_blocker_constants.py` | Bash tool name, pytest program basenames and the python-interpreter basename pattern, the pipe and segment-reset operator token sets, and the deny message for the piped-pytest blocker; classification that consumes those program and wrapper constants lives in `pytest_invocation.py` |
57
- | `pytest_invocation.py` | Pure parsed-segment classifier for pytest runs through interpreters, shims, wrappers, and shell string-exec forms; no pipeline deny decision |
58
- | `plain_language_blocker_constants.py` | The list of heavy words and their everyday replacements |
59
- | `prose_matcher_precision_constants.py` | Sample floor, keep/narrow precision floors, matcher ids, label decisions, advisory log path, emit caps, and context fingerprint length for OP-07B prose-matcher advisory telemetry |
60
- | `pre_tool_use_stdin.py` | `read_hook_input_dictionary_from_stdin()` — shared stdin parser for PreToolUse hooks |
61
- | `precommit_code_rules_gate_constants.py` | Scope argument and exit-code constants for the precommit gate |
62
- | project_paths_reader.py | Loads ~/.claude/project-paths.json and finds a home-bounded git root for registry checks |
63
- | `pyproject_config_discovery_constants.py` | Table names (``tool`` key, ``mypy``, ``ruff``) for resolving a validator's config from a pyproject.toml `[tool.<name>]` table |
64
- | `pytest_testpaths_orphan_blocker_constants.py` | Marker filename, section and key names, test-file pattern, search budget, and block-message text for the pytest unregistered-test-directory blocker |
65
- | `python_style_checks_constants.py` | Command-line argument count and blank-line count between top-level functions for the style validator |
66
- | `ruff_integration_constants.py` | ``NO_COLOR`` / ``FORCE_COLOR`` environment variable names for plain ruff diagnostics |
67
- | `send_user_file_open_locally_blocker_constants.py` | Tool name, proactive status, and the block message for the open-locally attach blocker |
68
- | `sensitive_file_protector_constants.py` | Sensitive filename patterns, the committed-template suffixes that earn an exemption, the write/edit tool names, and the deny decision and message template for `sensitive_file_protector` |
69
- | `session_edit_stage_gate_constants.py` | Tracker filename prefix/suffix, JSON payload key, edit tool name set, session-id sanitize pattern, lock filename suffix and lock-acquire timing, git diff command, commit flag escapes, and deny-message template shared by the session edit stage gate trio |
70
- | `session_env_cleanup_constants.py` | Stale-age threshold and directory names for the session-env cleanup hook |
71
- | `session_start_injector.py` | Pure SessionStart context injector: normalize `source` (`startup`/`resume`/`clear`/`compact`), honor enable/timeout, return structured injection results for starter hooks |
72
- | `session_start_injector_constants.py` | Known SessionStart source values, injection status codes, enable env var, default timeout for the shared injector |
73
- | `test_session_start_injector.py` | Behavioral tests for every known source, disabled, timeout, and unknown-source paths |
74
- | `orchestrator_auto_starter_constants.py` | Opt-in env var, enable values, timeout, and SessionStart directive text for the orchestrator auto-starter |
75
- | `issue_tracker_session_starter_constants.py` | Opt-in env var, enable values, timeout, and SessionStart directive text for the repository-gated issue-tracker starter |
76
- | `session_handoff_blocker_constants.py` | Trigger phrases for the session-handoff blocker |
77
- | `setup_project_paths_constants.py` | Encoding policy, BOM marker, and registry meta-key used across multiple hooks |
78
- | `shell_command_pipeline.py` | Quote-aware shell pipeline parsing: operator-paired segments after line-continuation join, comment strip, heredoc body drop, and parenthesis-group join |
79
- | `shell_command_segments.py` | Shell tokenization helpers shared by the segment-walking blockers: segment splitting on control operators, a segment's effective leading program, and a token's basename |
80
- | `shell_substitution_blocker_constants.py` | Tool name, payload keys, the four substitution-detection patterns, the deny decision shape, and the corrective message for the shell-substitution blocker |
81
- | `stale_comment_reference_blocker_constants.py` | Identifier pattern, comment stopwords, and denial text for the stale-comment-reference blocker |
82
- | `state_description_blocker_constants.py` | The set of historical/comparative phrases the state-description blocker rejects, plus the docstring-extraction and mention-span patterns for its Python docstring scan |
83
- | `stop_dispatcher_constants.py` | Ordered hosted-hook roster and Stop block payload field names for the Stop-chain dispatcher |
84
- | `stuttering_check_config.py` | Config for the stuttering (repeated-phrase) check |
85
- | `stuttering_import_binding_constants.py` | Import-binding patterns for the stuttering check |
86
- | `subprocess_budget_completeness_constants.py` | Required argument names for the subprocess-budget completeness check |
87
- | `sys_path_insert_constants.py` | Patterns for detecting unguarded `sys.path.insert` calls |
88
- | `task_list_loop_starter_constants.py` | The one-line task-list instruction and the full session-start directive text for the task-list loop starter hook |
89
- | `test_layout_constants.py` | The named constants for the test-layout write-time checks |
90
- | `text_stripping.py` | `strip_code_and_quotes()` — shared helper that removes fenced code blocks, inline code, and blockquotes from prose, imported by the Stop-hook prose blockers |
91
- | `unscoped_search_blocker_constants.py` | Tool names, `find` and listing program basenames, Get-ChildItem option sets, unscoped-root patterns, the flag/value token stride, and the deny message for the unscoped-search blocker |
92
- | `unused_module_import_constants.py` | Patterns for detecting unused module-level imports |
93
- | `volatile_path_in_post_blocker_constants.py` | Volatile path markers, affected `gh` post subcommands, MCP body param names, and the corrective message for the volatile-path post blocker |
94
- | `windows_rmtree_blocker_constants.py` | The unsafe `shutil.rmtree` pattern and the safe replacement pattern |
95
- | `workflow_substitution_slot_blocker_constants.py` | Per-iteration token patterns for the workflow-slot blocker |
96
- | `working_style_prompt_constants.py` | The fixed multi-paragraph working-style prompt text for the SessionStart working_style_prompt hook |
97
-
98
- ## Conventions
99
-
100
- - Most files in this package are pure constants modules — no side effects, no I/O.
101
- - Hooks import from this package with `from hooks_constants.<module> import <CONSTANT>`.
102
- - Tests for these modules live beside them as `test_<module>.py`. Run with `python -m pytest hooks_constants/test_<name>.py`.
103
- - `dynamic_stderr_handler.py`, `pre_tool_use_stdin.py`, `multi_edit_reconstruction.py`, `hosted_hook_runner.py`, and `text_stripping.py` are utility modules (not pure constants) but live here because they hold logic shared across hook surfaces.
104
- - `local_identity.py` is a loader: it reads the environment or `~/.claude/local-identity.json` (its path overridable via `CLAUDE_LOCAL_IDENTITY_PATH`) to resolve private NAS values (with committed placeholder defaults), the PII commit-scan exempt-repo slug set (`CLAUDE_PII_EXEMPT_REPOS` / `pii_exempt_repositories`), and the per-repository allowlisted-values mapping (`pii_allowlisted_values`).
1
+ @AGENTS.md
@@ -123,7 +123,7 @@ SUMMARY_COLUMN_HEADINGS: tuple[str, str, str, str] = (
123
123
  "top_blocked_command_preview",
124
124
  )
125
125
 
126
- SUMMARY_NO_NEW_BLOCKS_MESSAGE: str = "No new blocks since last run."
126
+ SUMMARY_ZERO_BLOCKED_EVENTS_MESSAGE: str = "Blocked events recorded in the last 24 hours: 0."
127
127
 
128
128
  QUERY_NO_ROWS_RETURNED_MESSAGE: str = "No rows returned."
129
129
 
@@ -231,4 +231,3 @@ WINDOWS_CREATE_NEW_PROCESS_GROUP_FLAG: int = 0x00000200
231
231
 
232
232
  LOCK_MAXIMUM_RETRY_COUNT: int = 30
233
233
  LOCK_RETRY_SLEEP_SECONDS: float = 0.1
234
-
@@ -11,8 +11,9 @@ TASK_LIST_MAINTENANCE_INSTRUCTION = "build or update the task list using the tas
11
11
 
12
12
  TASK_LIST_LOOP_DIRECTIVE = (
13
13
  "TASK LIST MAINTENANCE: Keep this session's task list current on a 10-minute "
14
- "cadence. If a task-list maintenance loop is not already running this session, "
15
- "start one now with Claude Code's built-in /loop skill on a 10-minute interval: "
14
+ "cadence. Reuse the active task-list maintenance loop when available. Start "
15
+ "Claude Code's built-in /loop skill with a 10-minute interval when this session "
16
+ "needs its first loop: "
16
17
  f'/loop 10m "{TASK_LIST_MAINTENANCE_INSTRUCTION}". Run that instruction once '
17
- "immediately, then let the loop refresh the list every 10 minutes."
18
+ "immediately when starting the loop, then let the loop refresh the list every 10 minutes."
18
19
  )