Repository navigation
Expand file tree
/
Copy pathhooks.json
More file actions
2827 lines (2827 loc) · 298 KB
/
Copy pathhooks.json
File metadata and controls
2827 lines (2827 loc) · 298 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"_comment": [
"Native Claude Code plugin-hooks schema (hooks = object keyed by event).",
"This file is dual-purpose:",
" 1. The plugin loader reads it directly when the ai-config plugin is",
" enabled, so each entry's `command` uses ${CLAUDE_PLUGIN_ROOT}.",
" 2. scripts/install-hooks.py reads it to register the same hooks into",
" ~/.claude/settings.json for the opt-in per-machine path; it rebuilds",
" its own $HOME/.claude command from the preserved `script` key and",
" ignores the `command`/`why`/`_note_*` fields.",
"",
"Extra keys (`script`, `why`, `_note_*`) are metadata the plugin schema",
"tolerates and ignores. `event` is the object key; `matcher` sits at the",
"group level; `timeout` and an optional `if` sit on the hook entry."
],
"hooks": {
"SessionStart": [
{
"matcher": "startup|clear|compact",
"hooks": [
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/inject-core-rules.py\"",
"timeout": 10,
"script": "inject-core-rules.py",
"why": "ai-config#4206 -- a plugin has no instruction-file slot, so AGENTS.md and CLAUDE.md shipped inside the plugin and were never read; a project thread saw the rules only after cloning ai-config by hand. At session start, names AGENTS.md and CLAUDE.md, orders AGENTS.md read in full and lists its headings, within the 10,000-character hook-output cap, wherever the plugin is enabled; uses an ai-config checkout's own files when the project is one."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-stale-plugin-pin.py\"",
"timeout": 10,
"script": "warn-stale-plugin-pin.py",
"why": "ai-config#2439 -- the plugin cache pin that runs hooks does not advance when the marketplace clone updates, so merged hook fixes went unrun for weeks with nothing saying so. At session start, compares each applicable ai-config pin in installed_plugins.json against the local marketplace clone's HEAD and the tip of the clone's origin (one git ls-remote, no fetch; ai-config#5309) and, when it lags either, says which it lags (with the commit count behind the clone, where the clone holds the pin) and gives the per-scope update commands."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/refresh-stale-plugin-pin-cloud.py\"",
"timeout": 120,
"script": "refresh-stale-plugin-pin-cloud.py",
"why": "A cloud container installs the plugin once at setup and a thread session reuses it for days; a repo's own refresh hook runs only when the session starts in that repo, and warn-stale-plugin-pin.py compares against a marketplace clone that is equally old. Measured 2026-11-04: a pin from 2026-11-03T19:43Z lacked block-project-memory-write.py (#4931), so the memory write it refuses went through. In CLAUDE_CODE_REMOTE sessions, updates the marketplace and, when the user-scope pin lags, runs claude plugin update and reports the move. Opt out with AI_CONFIG_NO_AUTO_REFRESH=1."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/refresh-synced-plugin-copy.py\"",
"timeout": 180,
"script": "refresh-synced-plugin-copy.py",
"why": "ai-config#6004. Every claude.ai cloud or project session loads the account-synced copy under ~/.claude/plugins/synced/, which is only as fresh as the last Sync, and a deny from any copy wins. On 2026-11-20 the synced guard-slide-major-tag.py predated #5414 and blocked the gha v3 slides after gha#2174 and gha#2177, so they waited on Ezra. In CLAUDE_CODE_REMOTE sessions, copies the marketplace plugin's files over each synced ai-config copy (keeping files only it has), installing ai-config@Morrison-Lab first when the environment never did, so the synced hooks run current code from the next tool call. Opt out with AI_CONFIG_NO_SYNCED_REFRESH=1, or of the install alone with AI_CONFIG_NO_SYNCED_INSTALL=1."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/sync-auto-mode-approvals.py\"",
"timeout": 10,
"script": "sync-auto-mode-approvals.py",
"why": "ai-config#5853 -- Ezra's standing autoMode approvals (#5623, #5682, #5752) reached a local machine only when bootstrap.sh ran, so a lab machine lacked the verdict-post rule and its classifier denied a cross-model verdict post on gha#2115 until Ezra typed the approval. On a local (non-remote) machine, applies wire-user-config.py's three autoMode steps in write mode (add-only, the exact approved text) and reports any write, which takes effect next session. Ezra chose this on 2026-11-19. Opt out with AI_CONFIG_NO_APPROVAL_SYNC=1."
}
]
},
{
"matcher": "compact",
"hooks": [
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/remind-ums-on-trigger-events.py\"",
"timeout": 10,
"script": "remind-ums-on-trigger-events.py",
"why": "After compaction, learnings held only in the old context may be summarized away: run UMS over what remains (ai-config#4480)."
}
]
}
],
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/inject-local-time.sh\"",
"timeout": 10,
"script": "inject-local-time.sh",
"why": "AGENTS.md 'Timestamp recaps in local time' -- supplies the real local time each turn, because a fabricated timestamp is indistinguishable from a remembered one."
},
{
"type": "command",
"command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/warn-python3-cannot-read-hooks.sh\"",
"timeout": 20,
"script": "warn-python3-cannot-read-hooks.sh",
"why": "ai-config#3624 -- names the interpreter when `python3` cannot read the plugin root. A PreToolUse hook that fails to launch DENIES the call, so that condition blocks Bash, Edit, Write and Agent at once while every denial names a hook rather than the interpreter. Shell rather than Python because in the failure this hook reports, no Python hook can run."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-overdue-scheduled-wake.py\"",
"timeout": 10,
"script": "warn-overdue-scheduled-wake.py",
"why": "ai-config#4873 -- a one-time scheduled task (send_later / create_trigger) can be skipped by the dispatcher with no error and no last_run, so the session that armed it waits forever. Warn-only: on the next prompt, names any task this session armed that is more than 15 minutes past due with no later get_trigger / list_triggers call and no scheduled continuation, and tells the agent to call get_trigger and delete the dead task. Once per task per session."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/ensure-open-pr-monitor.py\"",
"timeout": 10,
"script": "ensure-open-pr-monitor.py",
"why": "Ensures one detached timer continuously reconciles every open GitHub PR and GitLab merge request authored by the authenticated user, including ones opened outside this session."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/inject-pr-monitor-status.py\"",
"timeout": 10,
"script": "inject-pr-monitor-status.py",
"why": "Surfaces changed state from the detached pollers on the next prompt: the per-PR watchers no-unmonitored-pr.py starts (GitHub only) and the all-open-PR monitor, which also polls GitLab merge requests. A poller observes while the session is absent but cannot wake a terminated model."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/remind-generalize-maintainer-pr-comment.py\"",
"timeout": 10,
"script": "remind-generalize-maintainer-pr-comment.py",
"why": "Ezra 2026-10-17 'learn from every comment I make on every PR, as soon as I make it'. A maintainer's PR comment arrives as a GitHub event, which no chat-prose hook reads. Injects, never blocks, on a GitHub comment or review event authored by the maintainer: sweep the class across the PR and record the rule or check in its global home in the same turn."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/remind-treat-wording-as-draft.py\"",
"timeout": 10,
"script": "remind-treat-wording-as-draft.py",
"why": "Ezra 2026-10-28 (ai-config#4813): 'something like' and similar hedges mean he is open to suggestions, and no instruction of his is to be followed blindly. AGENTS.md 'Don't take anyone's word for it' and 'Proactively suggest better alternatives' are the rules; this injects, never blocks, a reminder that hedged or example wording is a draft to improve on, not text to copy or relay verbatim."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/remind-start-or-file-on-question.py\"",
"timeout": 10,
"script": "remind-start-or-file-on-question.py",
"why": "Ezra 2026-11-10 (ai-config#5287): a whether-or-how question gets a recommendation and a start-now-or-file-for-later ask; only a declarative instruction starts implementation. Injects, never blocks, on question-form prompts: question versus instruction is a reading of intent, so no deny can decide it (shared/workflow/start-or-file.md)."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/remind-record-standing-guidance.py\"",
"timeout": 10,
"script": "remind-record-standing-guidance.py",
"why": "AGENTS.md 'Generalize instructions to every AI agent by default': a standing rule is recorded in its global home (ai-config for agent rules, psw for prose rules, gha for checks) in the same turn it is given, and followed from then on. Injects, never blocks, when the new prompt or the previous user message reads as standing guidance and no ai-config or psw write or dispatch followed it. Project memory is allowed but not enough alone."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/remind-ums-after-error.py\"",
"timeout": 10,
"script": "remind-ums-after-error.py",
"why": "CLAUDE.md 'Run UMS proactively' -- discovering you were wrong is a trigger with no artifact, so nothing else prompts the pass; this injects a reminder naming the admitted error when no memory/skill write followed it.",
"_note_not_a_stop_hook": [
"Deliberately UserPromptSubmit rather than Stop, which is the shape",
"the Stop guards use. A Stop guard suppresses a message that is",
"wrong to send. An error admission is RIGHT to send: blocking it would",
"suppress the honest correction, delay it reaching the user, and remove",
"the very signal that surfaces the mistake. So this reminds on the next",
"prompt and can only ever ADD context -- there is no code path in it",
"that suppresses, delays, or alters a message."
]
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/no-mistake-without-a-hook.py\"",
"timeout": 10,
"script": "no-mistake-without-a-hook.py",
"why": "cai 2026-08-02 'every time you make a mistake, write a hook to prevent it recurring', extended 2026-09-22: recognizing redundant prose/content is evidence that prior prose was insufficient, so it also owes an explicit hook or algorithmic-check decision. Injects rather than blocks, because an error admission is RIGHT to send -- only the follow-up is owed. Complements remind-ums-after-error.py: that one wants a recorded learning, this one wants a mechanism."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/remind-deserialize-before-binary-claim.py\"",
"timeout": 10,
"script": "remind-deserialize-before-binary-claim.py",
"why": "ucdavis/bcs#579, 2026-08-05: `gh pr diff --name-only` listed three .rds artifacts, that path list was read as a claim about their CONTENTS, and a boxed BLOCKER asked the maintainer to authorize ~1.5h of serial compute plus a 500-task SLURM array -- from the path list alone. Measured afterward against d1dd05e3^, two of the three carried values equal to their predecessors and differed only in freshly stamped provenance, while msm-validation-accuracy-results.rds had genuinely moved (bias 121%, rmse 18%). The escalation was not baseless; it was unmeasured, and nothing in the path list separated the one real change from the two re-serializations. Injects rather than blocks: an escalation about a binary artifact's size, path, or tracking is right to send, and a guard that misfires on those gets switched off.",
"_note_discharge_is_path_scoped": [
"The discharge matches a deserialization and the artifact path in",
"the SAME tool_use blob. A readRDS of file B must not discharge a",
"claim about file A -- an over-broad discharge produces silence,",
"which is indistinguishable from compliance (algorithmatize-checks,",
"'A reminder guard's discharge condition is a second matcher').",
"It also requires a command that RAN: prose asserting the check",
"happened is the claim under suspicion, not evidence for it",
"(fail-fast, 'A guard's discharge fires on positive success')."
]
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/remind-learn-from-review.py\"",
"timeout": 10,
"script": "remind-learn-from-review.py",
"why": "ai-config#1065 'any time a reviewer brings up valid concerns, learn from that'. Injects, never blocks, when an accepted reviewer finding has no recorded learning or mechanism after it -- the external-correction sibling of remind-ums-after-error.py, which fires only on first-person admissions.",
"_note_covers_external_correction": [
"UserPromptSubmit, inject-only, for the same reason as the two",
"reminders above: accepting a reviewer's finding and fixing it is",
"RIGHT, so this can only ADD context and never blocks. It fills the",
"hole those two leave -- both key on a FIRST-PERSON admission and",
"remind-ums-after-error.py explicitly excludes correcting someone",
"else, so agreeing with a reviewer triggers neither. That is the",
"commonest way a mistake surfaces and the class ai-config#1065 is",
"about.",
"",
"Activation follows this file's uniform model (see the top-level",
"_comment and README): the plugin loads it on enable, and",
"install-hooks.py --fix registers it for a non-plugin install."
]
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/remind-ums-on-scrutiny.py\"",
"timeout": 10,
"script": "remind-ums-on-scrutiny.py",
"why": "ai-config#2261 'run UMS when work is scrutinized'. Injects, never blocks, when a review of your work was read, or a questioned claim was then corrected, with no explicit UMS after it -- the scrutiny sibling of remind-ums-after-error.py (first-person admission) and remind-learn-from-review.py (accepted finding).",
"_note_not_a_stop_hook": [
"UserPromptSubmit, inject-only, for the same reason as",
"remind-ums-after-error.py and remind-learn-from-review.py:",
"reading a review and correcting a claim are RIGHT, so this can",
"only ADD context and never blocks. It covers a review-read",
"before Address, and a closed Q&A whose correction never said",
"'I was wrong'. Those overlap the admission sibling when the",
"correction also matches ADMISSION; that overlap is deliberate.",
"Critical feedback that is not lexically decidable stays a",
"written rule, not a matcher.",
"",
"Activation follows this file's uniform model (see the top-level",
"_comment and README): the plugin loads it on enable, and",
"install-hooks.py --fix registers it for a non-plugin install."
]
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/remind-retry-before-declaring-blocked.py\"",
"timeout": 10,
"script": "remind-retry-before-declaring-blocked.py",
"why": "ai-config#2994, measured 2026-09-02: an `ALLOW_UNREVIEWED_PUSH=1 git push`, and the attempt to grant it a permission rule, were denied by the auto-mode permission classifier three times over; the session reported the path as permanently closed -- to the user, in a memory entry, and on this repo's own tracker -- and the byte-identical command then succeeded, with no settings change and no permission rule added. (#2994 is not self-consistent about how many of those three denials were the push itself rather than the `update-config` edit that followed it, so every claim here is worded to hold under both readings; #3008 tracks settling it.) Injects, never blocks, when a classifier denial has no later re-attempt of the same command.",
"_note_not_a_stop_hook": [
"UserPromptSubmit, inject-only, for the same reason as the",
"reminders above: reporting a denial is RIGHT to send. The",
"classifier's own message says to stop and explain when a",
"capability is essential, and a user waiting on a stalled task",
"needs to hear it. What is premature is the PERMANENCE, not the",
"report, so this can only ADD context and never suppresses,",
"delays, or alters a message.",
"",
"Scoped to the classifier's own denial and nothing else. A",
"user's own rejection is a decision to respect rather than a",
"sample to re-draw, and a deterministic permission-rule or hook",
"refusal returns the same answer by construction. All four",
"denial shapes were measured from real transcripts; the hook's",
"docstring carries the counts.",
"",
"Activation follows this file's uniform model (see the top-level",
"_comment and README): the plugin loads it on enable, and",
"install-hooks.py --fix registers it for a non-plugin install."
]
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/remind-both-sides-from-git.py\"",
"timeout": 10,
"script": "remind-both-sides-from-git.py",
"why": "ai-config#1185, an incident of 2026-08-05. A ucdavis/bcs session ran `git show d1dd05e3^:inst/extdata/ett-validation-true-effects.rds > /tmp/te-old.rds` and compared it against the WORKING TREE copy of that same path. The branch did not contain the merge in question, so both operands were the same blob, `identical()` returned TRUE, and the session concluded the opposite of the truth -- then published it to an issue, retracted a correct earlier finding on it, and closed a second issue as invalid. All three had to be corrected. Only one operand of that comparison names a revision; the other is whatever the checkout happens to hold.",
"_note_warns_never_blocks": [
"UserPromptSubmit, inject-only, for the same reason as the",
"reminders above: it can only ADD context, and no code path in it",
"suppresses, delays, or alters a message.",
"",
"Blocking was rejected on the merits rather than by analogy.",
"Comparing a committed blob against the working tree is",
"frequently CORRECT -- checking whether your own uncommitted edit",
"changed something is exactly that comparison. What separates the",
"hazard from the correct use is what the comparison is used to",
"CLAIM, which is not observable from the commands. A blocking",
"guard would therefore misfire on every legitimate",
"did-my-edit-change-anything check, and per README a hook that",
"misfires is worse than a missing one.",
"",
"Sibling of the deserialize-before-binary-claim guard proposed",
"in ai-config#1181 -- not on main yet, and nothing here depends",
"on it landing. It covers a hole in that one rather than",
"overlapping it. That guard",
"fires when NOTHING deserialized the artifact; its discharge is a",
"deserialization naming that path. The broken comparison above",
"SATISFIES that discharge, because a readRDS of the path did run.",
"Verified rather than assumed: that hook, run against a transcript",
"of this incident, produces no output. That one asks whether the",
"check happened; this one asks whether it compared the right two",
"things."
]
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/remind-ci-crosscheck-sim-verdict.py\"",
"timeout": 10,
"script": "remind-ci-crosscheck-sim-verdict.py",
"why": "Lacaedemon/sparta incident of 2026-08-22 -- a local simulation run reading FAIL was used to publish a decision, while CI transcript on the same clip/seed read PASS. Injects a reminder on the prompt following a local sim/transcript check when used to assert a verdict, prompting a CI-side reading."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/remind-encode-user-correction.py\"",
"timeout": 10,
"script": "remind-encode-user-correction.py",
"why": "ai-config#4208 -- the user had to repeat a correction across sessions and projects. The UMS reminders key on the agent's own admission or an accepted review finding, so a correction from the user triggered none of them, and the natural landing place outside ai-config was host memory no other project reads. Injects, never blocks, the procedure that commits the general rule in the same turn to the repo that owns it, ai-config for anything beyond one repo."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/require-ums-before-resolve.py\"",
"timeout": 10,
"script": "require-ums-before-resolve.py",
"why": "AGENTS.md 'Leave every pause honest and resumable' (Run UMS before every pause): a merged-PR event reminds the thread to run its wrap-up (post-merge, including UMS) before resolving. Injects, never blocks."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/remind-ums-on-trigger-events.py\"",
"timeout": 10,
"script": "remind-ums-on-trigger-events.py",
"why": "A coordinator note that steers a thread, or a user reply that is only a grant ('daytb', 'yes, do it'), owes a UMS pass. Injects, never blocks (ai-config#4480)."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/remind-plain-english-merge-word.py\"",
"timeout": 10,
"script": "remind-plain-english-merge-word.py",
"why": "ai-config#4698. Ezra, 2026-10-23: a typed 'merge when ready' was not recognized as a merge word and he had to retype 'mwc'. skills/mwc/SKILL.md listed fixed phrases and a model does not generalize a list. Injects, never grants: when the user's typed message is a merge instruction in plain English ('merge when ready', 'merge them all', 'merge', 'go ahead and merge', 'mwc them all'), tells the agent to treat it as a bare mwc (mwc all) and not ask for a retype or PR numbers. A question, quoted or code text, or a system reminder is ignored. The merge guards still decide. Since ai-config#5612 no-unauthorized-merge.py reads the grant from the transcript with this file's merge_word() and revokes(), so the reminder asks for no Bash step: in a cloud session enable-mwc prompted for approval on every call and its marker still did not reach the guard for an MCP merge."
}
]
}
],
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/require-ruleset-on-repo-create.py\"",
"timeout": 10,
"script": "require-ruleset-on-repo-create.py",
"why": "Ezra, 2026-11-17: 'why didn't you add branch protections to Morrison-Lab/answer-space when you created it?' The ruleset-at-creation rule (shared/workflow/repo-templates.md, ai-config#4671) was prose only, and 32 qwt course repos missed it too (ai-config#5610). DENIES a `gh repo create` whose own command chain does not also apply the ruleset (apply-all.sh --apply <name>, a template's apply-rulesets.sh, or a gh api ruleset write), and denies mcp__github__create_repository outright because the cloud proxy refuses ruleset writes. Stateless, so no pending repo can be lost between turns. Fails open on a broken shellcmd import."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-local-render-when-ci-built.py\"",
"timeout": 10,
"script": "warn-local-render-when-ci-built.py",
"why": "ai-config#4724. Ezra, 2026-10-25: \"isn't it already rendered in mlg ... remember that going forward\". Warns (never blocks) when a Bash command runs quarto render in a repo with a gh-pages ref, because CI has probably built the output already; download the PDF or HTML from gh-pages or the published site instead. Canvas uploads always use the CI-built PDF. Fails open on any parse or git trouble."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-one-sided-conflict-resolution.py\"",
"timeout": 10,
"script": "warn-one-sided-conflict-resolution.py",
"why": "ai-config#5407, split from #4716. Ezra, 2026-10-23: agents should resolve merge conflicts carefully, deciding for each hunk what to keep from each side, what to drop, and what to modify. Warns (never blocks) on git checkout/restore --ours|--theirs, which take the whole file from one side; on merge-file --ours|--theirs and -X ours|theirs on merge, rebase, cherry-pick, revert or pull, which keep one side of every conflicting hunk; and on -s ours, which drops the other branch entirely. Checks inside bash -c; quoted text and --abort/--quit runs do not fire. Fails open on a parse error."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/prefer-mcp-over-bash-in-cloud.py\"",
"timeout": 10,
"script": "prefer-mcp-over-bash-in-cloud.py",
"why": "ai-config#5613. Ezra, 2026-11-13: \"remember that cloud sessions should use mcp tools rather than bash commands wherever possible\". In a cloud session (CLAUDE_CODE_REMOTE=true) DENIES a Bash command whose program, at a command position, is gh pr|issue|run|workflow|release, gh api on a non-search path, or curl/wget to api.github.com on a non-search path, and names the GitHub MCP tool that does the job. Search passes, since the cloud harness has no MCP search tool. git, gh auth/search/secret/label and quoted or heredoc mentions are not touched. A deny rather than a warning because a warning is read past (ai-config#4741) and the Bash call it would allow is the approval prompt Ezra asked to stop. ALLOW_BASH_OVER_MCP=1 covers an endpoint no MCP tool has. Silent outside cloud sessions; fails open on parse trouble."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/prefer-dedicated-tools-over-bash.py\"",
"timeout": 10,
"script": "prefer-dedicated-tools-over-bash.py",
"why": "ai-config#6065. Ezra, 2026-11-21: \"can you use tools instead of bash\", after a cloud thread kept stopping on Bash approval prompts he answers from his phone. In every session DENIES a Bash pipeline that only reads or searches files (cat FILE, head/tail FILE, grep/rg, sed -n 'N,Mp', a name-only find, with later stages limited to head, tail, grep, rg and cat), an in-place sed -i or perl -i, and cat, echo or printf overwriting a file with > (or tee fed by a heredoc), naming the Read, Grep, Glob, Edit or Write tool to use. Pipelines with any other program, appends (>>, tee -a), searches whose exit status is used (-q, -s, /dev/null, && or || after), if/case/loop bodies, sudo, $-expanded words, /dev targets and quoted or heredoc mentions pass. A deny rather than a warning because a warning is read past (ai-config#4741). ALLOW_BASH_OVER_TOOL=1 covers a real need. Fails open on parse trouble."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/no-chained-edit-and-commit-in-cloud.py\"",
"timeout": 10,
"script": "no-chained-edit-and-commit-in-cloud.py",
"why": "ai-config#5688, from #5687. Ezra, 2026-11-15: \"avoid asking for approvals when there's another idiomatic path forward\". In a cloud session (CLAUDE_CODE_REMOTE=true) DENIES a Bash command that chains an in-place edit (sed or perl -i, or a >/>> redirect into a file outside /dev, /tmp and a scratchpad directory) with git commit, also inside bash -c, and points to the Edit tool for the edit and a separate Bash call for the commit. Either half alone passes, as do quoted mentions. A deny rather than a warning because a warning is read past (ai-config#4741) and the chain is what raised the approval prompts. ALLOW_CHAINED_EDIT_COMMIT=1 covers a chain that is needed. Silent outside cloud sessions; fails open on parse trouble."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/require-gh-repo-flag.py\"",
"timeout": 10,
"script": "require-gh-repo-flag.py",
"why": "Blocks mutating repo-scoped gh commands lacking -R, so a write never silently targets whatever repo the cwd happens to be.",
"_note_no_if": [
"Deliberately carries no `if` prefilter. `Bash(gh *)` was tried and",
"verified working in the live harness -- it fires on `cd /tmp && gh ...`",
"and on `GH_TOKEN=x gh ...`, so it is not a strict prefix glob today.",
"It is still removed, because the asymmetry is bad: if that matching",
"ever tightens to a prefix check, the guard stops firing on exactly the",
"compound and env-prefixed shapes it exists to catch, and it stops",
"SILENTLY -- a disabled guard and a guard with nothing to block look",
"identical. The prefilter buys one Python startup (~30ms) per gh-less",
"Bash call; that is not worth a silent-failure mode."
]
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/no-unauthorized-merge.py\"",
"timeout": 20,
"script": "no-unauthorized-merge.py",
"why": "cai 2026-08-04 'I want a mechanistic prohibition, not just a guideline' -- mechanistically blocks unauthorized PR/MR merge commands (gh pr merge, glab mr merge, gh api .../merge) at the PreToolUse boundary unless an explicit ALLOW_MERGE=1 flag is provided."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/enforce-mwc-review-gate.py\"",
"timeout": 30,
"script": "enforce-mwc-review-gate.py",
"why": "ai-config#4323 -- enforces that any PR merge executed under MWC or ALLOW_MERGE=1 has a verified clean automated review (or explicit clean adversarial review) on its head commit before allowing the merge, closing the review gate gap in Claude Code."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/no-whole-file-punct-replace.py\"",
"timeout": 10,
"script": "no-whole-file-punct-replace.py",
"why": "shared/coding/ascii-punctuation-in-source.md's over-application warning. A whole-file glyph replace converts pre-existing glyphs on untouched lines, and the resulting mechanical diff HIDES real changes -- on 2026-08-02 it concealed two dropped paragraphs. Blocks only when a glyph replace, a write-back, and no scoping token all co-occur under an interpreter."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/no-find-root-on-windows.py\"",
"timeout": 10,
"script": "no-find-root-on-windows.py",
"why": "ai-config#3897 -- PreToolUse guard denying `find /` and bare drive roots in Git Bash on Windows, preventing whole-system traversals that crash paging and spawn long-running orphaned processes."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/flag-unchained-branch-switch.py\"",
"timeout": 10,
"script": "flag-unchained-branch-switch.py",
"why": "One Bash call ran `git checkout feat/some-branch -q && git merge --ff-only ...` on line 1 and `git merge origin/main` on line 2. The checkout failed -- the branch was already checked out in another worktree -- and the `&&` protected only line 1, so line 2's merge ran against `main`. Nothing errored: the failing checkout wrote to stderr and the call still exited 0. That time it fast-forwarded onto an already-published commit; in general it commits or merges onto the wrong branch, which is the failure shared/workflow/incidents-dont-repeal-decisions.md records costing a commit on the wrong PR's branch and a history rewrite to separate.",
"_note_warns_never_blocks": [
"Emits `additionalContext` and a `systemMessage` and nothing else --",
"no `permissionDecision` key at all, so the normal permission flow is",
"untouched. Naming `allow` there would BYPASS a prompt the user would",
"otherwise have seen.",
"",
"Deny was rejected on the merits, not by analogy. A multi-line git",
"script whose later lines mutate is frequently CORRECT: the author may",
"know the checkout cannot fail, may have run it already, or may intend",
"the mutation on the current branch regardless. That is a fact about",
"intent, which the command does not carry -- so a blocking guard would",
"refuse a large class of legitimate scripts, and per README a hook that",
"misfires is worse than a missing one.",
"",
"Measured against 15184 real Bash tool_use records in this machine's",
"transcripts: 4396 mention `git `, and this fires on 66 of them --",
"0.43% of all Bash calls, 1.50% of the git-bearing ones. Two clauses",
"were added BECAUSE that measurement found them: a switch used as an",
"`if` condition, and a cascade where a second chained checkout",
"supersedes the first."
]
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/flag-stale-branch-mutation.py\"",
"timeout": 10,
"script": "flag-stale-branch-mutation.py",
"why": "2026-09-04 incident: a session ran `git checkout -b fix/909-...`, then an unisolated adversarial-reviewer subagent's own git commands left the checkout on a different branch (fix/892-...), then the session's `git commit` and `git push -u origin fix/909-...` both ran silently against the wrong branch -- the push even printed the usual \"Create a pull request\" hint. Warns, never blocks, when a MUTATING git command (or a `git push` naming the branch) runs while the actually-checked-out branch has drifted from what THIS session most recently, explicitly selected via `git checkout`/`git switch`, tracked in a small per-session per-repository state file across separate Bash calls (ai-config#3204).",
"_note_warns_never_blocks": [
"Emits `additionalContext` and a `systemMessage` and nothing else --",
"no `permissionDecision` key at all, so the normal permission flow is",
"untouched. A drifted checkout can be exactly what is wanted, so a",
"blocking guard would refuse legitimate work whenever the answer is",
"'yes, work on whatever is actually checked out'."
]
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/no-heavy-work-on-head-node.py\"",
"timeout": 10,
"script": "no-heavy-work-on-head-node.py",
"why": "On 2026-07-31 a shiva sysadmin reported login-node CPU-load alerts from two R devtools::test() processes at 262 and 90 CPU-minutes. The rule they broke was already written down twice, and a passive prose rule only fires if you happen to read it as you type the command -- so the check has to run at the command. Whether this host is a SLURM compute node needs no judgment: sinfo answers it exactly.",
"_note_safe_off_cluster": [
"Belongs in the shared registry rather than under dotfiles/shiva/,",
"even though its subject is one cluster, because the cost of",
"carrying it everywhere is ~50ms of Python startup -- the same",
"shape as the two PreToolUse guards above -- and dotfiles/ has no",
"hook plumbing at all, so scoping it there would mean building a",
"second registration mechanism for a single hook.",
"",
"Measured 2026-08-04 on shiva: a non-Bash call and an ordinary",
"Bash call each cost ~52ms and never reach sinfo, because the",
"regex prefilter returns first. Only a command that would",
"actually be blocked pays the sinfo subprocess.",
"",
"Fails OPEN in three separate ways, each verified: sinfo missing",
"(OSError), sinfo present but erroring (non-zero return), and",
"already-on-a-compute-node. Off a cluster the first branch is the",
"one taken, so the guard is inert rather than merely quiet."
]
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/no-rm-live-render-intermediate.py\"",
"timeout": 10,
"script": "no-rm-live-render-intermediate.py",
"why": "2026-09-24, health-analytics-core/abridge: an agent deleted a gitignored paper-with-supplement.rmarkdown, reasoning it was a leftover from its own failed render -- it was not, the user was rendering that exact worktree from their own terminal, and Quarto recreates that intermediate at the START of every render. The render had already knitted all 251 chunks (~10 min, including a forced cache rebuild) before failing on the missing file. AGENTS.md's 'verify a dispatched agent's liveness before touching a worktree' rule already existed and did not fire at composition time. DENIES rm/trash/find -delete/git clean of *.rmarkdown, *.knit.md, *.knit.qmd, *_files/, *.quarto_ipynb, or .quarto/ ONLY when a live quarto render/preview or an Rscript/R process running knitr/rmarkdown/rmd_render is also found (pgrep -fl, injectable in tests). Clearable with ALLOW_RM_RENDER_INTERMEDIATE=1 on the same command. Fails open with no live-process check available, on any parse trouble, and when scripts/lib/shellcmd.py cannot be imported."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/no-recursive-chown-system-path.py\"",
"timeout": 10,
"script": "no-recursive-chown-system-path.py",
"why": "ai-config#5317, shared/workflow/destructive-actions-catalog.md: `sudo chown -R $USER:$(id -gn) /usr && sudo chmod -R u+w /usr` broke sudo (anthropics/claude-code#168), and an agent's `chown -R root:root /usr/` and `/etc/` repair cleared setuid bits on sudo and su (anthropics/claude-code#39283). DENIES chown, chmod or chgrp with -R/--recursive when a target resolves to /, a top-level directory, a path inside a system tree, or the home directory or a directory containing it, including a variable that an earlier Bash call set and is empty in this one. Clearable with ALLOW_RECURSIVE_SYSTEM_CHOWN=1 on the same command. Fails open on parse trouble."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/no-recursive-rm-unset-variable.py\"",
"timeout": 10,
"script": "no-recursive-rm-unset-variable.py",
"why": "ai-config#5476, part of #5317: each Bash call starts a fresh shell, so a variable set in an earlier call is empty in the next, and `rm -rf \"$D/\"` becomes `rm -rf /` (anthropics/claude-code#75859). CC Safety Net at its standard level passes that form, and its strict level refuses too much ordinary work. DENIES a recursive rm, or a find with -delete or -exec rm, when a target uses a variable that is empty or unset in the hook's environment and not assigned earlier in the same command. Clearable with ALLOW_RM_UNSET_VARIABLE=1 on the same command. Fails open on parse trouble."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/flag-add-a-outside-pathspec.py\"",
"timeout": 10,
"script": "flag-add-a-outside-pathspec.py",
"why": "ucdavis/bcs's CLAUDE.md bans a bare `git add -A` and prescribes `git add -A ':!inst/extdata'` as the sanctioned replacement, after a 2026-07-30 incident where an untracked-and-unignored directory leaked a credential and participant identifiers. On 2026-08-09 that sanctioned form was followed verbatim and still swept in two unrelated untracked scratch files at the repo root, because the exclusion pathspec protects only the path it names -- nothing checks the LIVE working tree for what else is untracked. Warns rather than blocks, per README's 'A hook that misfires is worse than a missing one': a bare `git add -A` is frequently exactly right, and this hook cannot tell intended untracked content from accidental.",
"_note_reads_live_git_status": [
"Unlike most hooks here, this one shells out to `git status`",
"at match time to compute what is actually untracked -- a",
"pure text match on the command string cannot answer 'does the",
"exclusion pathspec actually cover everything untracked',",
"since that depends on the live working tree, not the command.",
"Fails open on any git failure, timeout, or non-repo cwd.",
"",
"Emits only `additionalContext` and a `systemMessage`; no",
"`permissionDecision`, so the normal permission flow is",
"untouched."
]
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/flag-commit-a-sweeps-submodule.py\"",
"timeout": 10,
"script": "flag-commit-a-sweeps-submodule.py",
"why": "2026-10-15, Morrison-Lab/lds#1026: `git commit -am` ran in a checkout whose `latex-macros` submodule sat at a different commit than the index pinned, so `-a` staged the gitlink along with the intended CLAUDE.md edit and moved the pin from 6e227b6 to the older 85c285b; the PR bot flagged it as blocking. flag-add-a-outside-pathspec.py covers `git add -A` and untracked files but not `git commit -a`/`-am`, `git add -u`, or a modified submodule (ai-config#4534). Warns rather than blocks: a deliberate pin bump is legitimate and the hook cannot tell it from an accident. Only fires when `git status --porcelain` shows a submodule whose HEAD differs from the commit the index pins (mode 160000 per `git ls-files -s`); a submodule with only dirty content stays silent.",
"_note_reads_live_git_status": [
"Reads live `git status`, `git ls-files -s` and the",
"submodule's own HEAD at match time, since whether a pin is",
"about to move is a fact about the working tree, not the",
"command text. Fails open on any git failure, timeout,",
"missing `-C` directory, or non-repo cwd.",
"",
"Emits only `additionalContext` and a `systemMessage`; no",
"`permissionDecision`, so the normal permission flow is",
"untouched."
]
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/no-commit-with-conflict-markers.py\"",
"timeout": 10,
"script": "no-commit-with-conflict-markers.py",
"why": "2026-10-27, Morrison-Lab/lds#1364, during an `ardia` sweep: a `main` merge left six files conflicted, a helper script that read only its first argument resolved one, and `git add -A && git commit --no-edit` committed the other five with their `<<<<<<< HEAD` / `=======` / `>>>>>>> origin/main` blocks. The Quarto render passed because Markdown prints the markers as text, and the push-time check-term-links caught it only incidentally. DENIES a `git commit` (incl. `-a`, `--amend`, paths, `-C <dir>`, `cd <dir> &&`) or `git merge|rebase|cherry-pick|revert|am --continue` when `git diff --check` reports `leftover conflict marker` on what the commit would carry: the working tree of the `-a` paths, named paths, and paths an earlier `git add` in the same command stages, and the index for every other path, each against every parent the commit will have (HEAD plus MERGE_HEAD, HEAD's parents under --amend, the empty tree for a root commit). A flagged `=======` counts only inside an open `<<<<<<<` block, since git 2.43 flags a Markdown setext underline; aider's `<<<<<<< SEARCH`/`>>>>>>> REPLACE` blocks are exempt, and a file with real marker lines raises `conflict-marker-size` in .gitattributes. No escape variable.",
"_note_reads_live_git_state": [
"Runs `git diff --check`, `git show :<path>` and",
"`git rev-parse` at match time, with fsmonitor and optional",
"locks off. Fails open on any git failure or timeout, a",
"directory the text does not name, --git-dir/GIT_DIR, a",
"dry run, an interactive commit or add, and when the sibling",
"flag-commit-a-sweeps-submodule.py or scripts/lib/shellcmd.py",
"cannot be loaded."
]
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/flag-reset-hard-uncommitted-work.py\"",
"timeout": 10,
"script": "flag-reset-hard-uncommitted-work.py",
"why": "On 2026-08-09, in the same session as the git-add incident above, a `git reset --hard <ref>` run to drop a throwaway probe commit also discarded UNRELATED uncommitted edits to .Rbuildignore and NEWS.md sitting in the same working tree -- both had to be redone. `reset --hard` resetting the entire working tree (not just the commit being undone) is exactly its documented behaviour; the mistake was reaching for it in a tree with unrelated live edits, for an experiment that never needed to touch that tree. Warns rather than blocks: discarding a commit is frequently exactly the point, and this hook cannot tell 'this dirty state is unrelated' from 'this dirty state is what I meant to discard'. Extended in ai-config#2560 to `git checkout <pathspec>` and `git restore <pathspec>`: those forms revert the named paths to the INDEX rather than to the pre-edit tree, so an edit made since the last `git add` is discarded silently at exit 0. A plain branch switch (`git checkout <ref>`) stays out of scope because git refuses one that would clobber local changes and otherwise carries them across, and `git restore --staged` without `--worktree` stays out of scope because it rewrites only the index. The FORCED `git checkout` forms discard tracked working-tree changes too, and ai-config#2524 closed that gap rather than justifying it. Measured 2026-09-04 on git 2.43.0: `git checkout -f other` over a modified tracked file printed only 'Switched to branch' and exited 0 with the edit gone, `git checkout --force -b feature` did the same, and `git checkout -f` with no operand at all reverted every tracked file to HEAD with no output whatsoever -- so a forced checkout that resolves to no pathspec is now scoped to the whole tracked tree, exactly like `reset --hard`. That needed no new command parsing: `git checkout` was already read and `-f` was already a known flag. `git switch -f` / `--discard-changes` stays uncovered, and that one IS a scope decision: `switch` is a fourth command this guard does not read at all, and reading it would widen the guard past the three it was built for. The catalogs name that remaining gap.",
"_note_reads_live_git_status": [
"Also reads live `git status`, same reasoning as the sibling",
"hook above: whether uncommitted tracked-file changes exist is",
"a fact about the working tree, not about the command text.",
"Untracked files are deliberately out of scope -- `reset",
"--hard` does not touch them, `git clean` does -- so an",
"untracked scratch file alone does not trigger this.",
"",
"Emits only `additionalContext` and a `systemMessage`; no",
"`permissionDecision`."
]
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-paginate-without-slurp.py\"",
"timeout": 10,
"script": "warn-paginate-without-slurp.py",
"why": "mwc's \"Another session's PR\" section states that the -s and the double flatten are load-bearing, and that their absence is invisible on any resource small enough to test on: gh api --paginate emits one array PER PAGE, so an aggregating jq filter (last, first, length, max_by, add, sort_by, ...) runs once per page and returns one answer per page. The rule is read at load time and broken at composition time. Measured 2026-09-10 on Morrison-Lab/wai: a session that had read that rule ran `gh api ... --paginate --jq '[...] | last'` across twelve PRs to check which reviews named a real commit, got an empty result for every one, and reported a false conclusion (that the defect was systemic when it affected two of twelve). WARNS rather than denies: a non-aggregating --jq filter streams correctly across pages and is common, and the aggregator list cannot be exhaustive, so a refusal would block correct commands. Fails open."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/no-handrolled-verdict-parse.py\"",
"timeout": 10,
"script": "no-handrolled-verdict-parse.py",
"why": "shared/workflow/ardi.md mandates check-pr-fully-clean.py as verdict authority. PreToolUse guard that refuses hand-rolled regex/grep verdict parses of review comments without running the script or setting ALLOW_HANDROLLED_VERDICT_PARSE=1."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-pr-create-without-dupe-check.py\"",
"timeout": 10,
"script": "warn-pr-create-without-dupe-check.py",
"why": "pr-on-claim.md makes an issue's cross-referenced open PRs the authoritative in-flight signal; issue-first.md and report-mistakes-proactively.md require the same search before gh issue create. Both rules are consulted at read time while the omission happens at composition time. PR half measured on Morrison-Lab/wai 2026-08-19/20: five branches fixed the same CI failure across five hours, two reaching duplicate PRs (#77, #78). Issue half measured on Morrison-Lab/ai-config 2026-08: one cp1252 decode crash had four open issues (#1984, #2040, #2048, #2049) before #2086 closed them. Issue discharge requires --state all --search (or gh search issues / MCP search_issues), not --state open, per check-open-prs-before-duplicating.md. Warns rather than blocks -- a duplicate is cheap to close and a blocked creation is expensive, since creating the PR or filing the issue is the act that makes work visible. Anchored on a command position with heredoc bodies stripped. Fails open. Tracked as #1748 (PR) and #2088 (issue)."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-unlabelled-agent-issue.py\"",
"timeout": 10,
"script": "warn-unlabelled-agent-issue.py",
"why": "shared/workflow/issue-first.md, 'Label an agent-filed issue with its authorship and its model'. disclose-agent-authorship.md scopes its marker line to comment BODIES and excludes an issue body, so an agent-filed issue is the one artifact that discloses nothing -- it goes out under the account holder's login as type: User. The labels close that, and the rule is consulted at read time while the omission happens at composition time. The same section's 'Set the priority when you file' (ai-config#3140) asks for one of P1, P2 or P3 in the creating command, and the hook reminds about each missing label separately. WARNS, never blocks: an unlabelled issue is fixed by one `gh issue edit --add-label` while a blocked create loses the act that makes work visible (report-mistakes-proactively.md, 'filing is not gated on approval'), the rule is scoped to repos we administrate and this hook cannot tell which repo is ours (sup files upstream with neither label), and a repo whose labels cannot be created still gets the issue. Anchored on a command position with heredoc bodies stripped, for the reason warn-pr-create-without-dupe-check.py records: this corpus quotes `gh issue create` constantly. Fails open. Tracked as #3111."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-deferred-closing-keyword.py\"",
"timeout": 10,
"script": "warn-deferred-closing-keyword.py",
"why": "shared/workflow/issue-first.md, 'A closing keyword plus #N closes #N even when the sentence negates it'. GitHub's parser is purely lexical, so a body saying a LATER PR will close #N, or that #N is NOT being closed, closes it on merge. Scoped to a PR/issue DESCRIPTION and a commit message, since GitHub never scans a plain comment. Warns when a closing keyword sits next to an issue reference mid-line AND its sentence carries a deferral or negation cue; a bare `Closes #N` line never fires. Three measured occurrences: ai-config#1718/#1717, Morrison-Lab/gha#460/#322, ucdavis/bcs#982/#923. Warns rather than blocks -- the guard cannot read intent and the remedy costs one word. Fails open. Tracked as #3512."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/flag-stale-adjacent-comment.py\"",
"timeout": 15,
"script": "flag-stale-adjacent-comment.py",
"why": "shared/workflow/learn-from-review-findings.md, from ucdavis/bcs#679. Warns, never blocks, when a `git commit` changes a literal value while an unchanged comment within ten lines still asserts the old one."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-unparseable-staged-config.py\"",
"timeout": 15,
"script": "warn-unparseable-staged-config.py",
"why": "ai-config#4086 -- PreToolUse hook on git commit that parses staged .toml, .json, and .yaml/.yml config files (tomllib, json, yaml.safe_load) and warns with the parser error when any fails to load, catching syntax errors (such as invalid TOML escapes) before commit."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/no-bare-stash-pop.py\"",
"timeout": 15,
"script": "no-bare-stash-pop.py",
"why": "ai-config#1907 and #3584: the stash stack is shared by every worktree, so a bare `git stash pop` or `apply` takes whatever entry is on top, often another session's; a clean pop drops it into the wrong worktree and exits 0. DENIES `git stash pop|apply` naming no entry (redirections are not entries) when the repository it runs in (cwd moved by cd and git -C, nested sh -c lines included) lists more than one live worktree; an explicit ref or SHA, -h and --help are allowed; eval, xargs and a $VAR git are not followed. Override: ALLOW_BARE_STASH_POP=1. Fails open when shellcmd cannot load, the command does not parse, --git-dir, --work-tree, GIT_DIR or GIT_WORK_TREE redirect the repository, or git worktree list fails."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/no-add-sweeping-scratch.py\"",
"timeout": 20,
"script": "no-add-sweeping-scratch.py",
"why": "ai-config#3884: `git add -A` staged a worktree-isolated agent's `.claude/worktrees/agent-*` as an unresolvable gitlink. DENIES a `git add` (cwd moved by cd and git -C) when `git ls-files -o --exclude-standard` (without the exclude for a forced add, -f) on its own pathspecs lists a directory holding `.git`; read-only, so it takes no index lock. -u, -n/--dry-run and --pathspec-from-file are not checked. ai-config#3558: `git add -A && git commit -F msg.txt` shipped msg.txt in three sparta PRs. DENIES a `git commit -F/--file/-aF <f>` when f is staged, or when an earlier add-everything (-A, --all, .) on the same line covers f, untracked and not ignored; a commit limited to pathspecs without -i is allowed. Override: ALLOW_SCRATCH_ADD=1. Fails open when shellcmd, flag-add-a-outside-pathspec.py or no-bare-stash-pop.py cannot load, the command does not parse, --git-dir, --work-tree, GIT_DIR or GIT_WORK_TREE redirect the repository, or git fails."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/no-switch-in-main-checkout.py\"",
"timeout": 20,
"script": "no-switch-in-main-checkout.py",
"why": "ai-config#4233, #3204: the main worktree of a repository with linked worktrees is read by other sessions and subagents, and a switch there left it on a fixer's branch with a stale index; denies git switch and a branch-changing git checkout there."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/no-delete-branch-under-stacked-pr.py\"",
"timeout": 25,
"script": "no-delete-branch-under-stacked-pr.py",
"why": "Measured on ucdavis/bcs 2026-08-27. Covers `gh pr close --delete-branch` as well as `gh pr merge`: both carry the same -d flag, and the branch deletion is the hazard rather than the merge. Merging #749 with --delete-branch removed the branch that was #750's base, and #750 went to CLOSED rather than being retargeted to main, while gh reported the merge as successful and said nothing about it. Retargeting is GitHub's DOCUMENTED behaviour for exactly this sequence and usually happens; why it failed here is not established, and this hook does not claim to know -- it warns that the flag MAY close a stacked child, which is the part that is certain. Recovery deadlocks: a closed PR cannot be retargeted, and cannot be reopened while its base branch is gone, so the only way out is to push the deleted branch back, reopen, retarget, then delete again -- possible only while a copy survives. WARNS, never blocks: the condition needs a network query, so blocking would fail closed whenever gh is unavailable, and the flag is the tidy habit on every unstacked merge. Silent when nothing is stacked, when the query fails or returns an unexpected shape, when gh is absent, when the command carries no -R or PR target, and when the delete flag is explicitly disabled (--delete-branch=false)."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/no-history-compare-in-shallow-clone.py\"",
"timeout": 15,
"script": "no-history-compare-in-shallow-clone.py",
"why": "ai-config#5323, measured on Morrison-Lab/lds 2026-11-11. A cloud session's shallow clone made git log --reverse, merge-base and rev-list --count answer from truncated history, so 23 branches were reported as sharing no history with main and 41 were recommended for deletion, 12 of them holding unmerged work; Ezra stopped it seconds before the deletion ran ('make sure that can never happen again'). DENIES, in a shallow repo, a revision range, merge-base A B or cherry when, checked both ways round, one side's walk reaches a cut-off commit from the shallow file that the other's does not, or the other side reaches a cut-off and the walk lists a root commit or a commit no newer than that cut-off, which may be a hidden ancestor of it (so origin/main..HEAD stays allowed; any failure to check refuses); a log, rev-list or shortlog with no range when its walk lists a cut-off commit before its limit (-n N, or a pipe to head), or, filtered by author/grep/date/path, when it lists fewer than N commits or reaches commits as old as a cut-off; show/format-patch/cherry-pick/revert ranges and diff/rev-parse A...B by the same comparison check; commands inside $(...) and backticks too; and always: a range with --all/--branches/--tags/--remotes, an endpoint starting with '-', --merged/--contains filters and accepted prefixes, ahead-behind, show-branch, range-diff, bundle create, and non-dry-run pushes that can delete a ref. A deny because the failure is silent (every command exits 0). Fix named in the message: git fetch --unshallow. Override: ALLOW_SHALLOW_HISTORY=1 on the one command. Fails open when shellcmd cannot load, the command does not parse, or the repo's shallowness cannot be read."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/no-clobbering-push.py\"",
"timeout": 20,
"script": "no-clobbering-push.py",
"why": "shared/workflow/check-before-pushing.md. A branch you cut and whose PR you opened is the one you are least likely to check before pushing to, and claim-pr.md records three ways it gains another agent's commits anyway (the @claude agent's main-sync, a second CLI session, a human). Every recovery procedure in claim-pr.md runs AFTER the collision. DENIES a bare `git push --force`/`-f`, whose remedy (`--force-with-lease --force-if-includes`) costs one word and is never the worse command, clearable with an `ALLOW_FORCE_PUSH=1` prefix for the unsatisfiable-lease case memories/git.md records. WARNS on everything else from a live read-only `git ls-remote` reading taken at push time, and stays silent on a fast-forward. Fails open on parse trouble, outside a repo, and on any network timeout. Tracked as #1883."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/no-oversized-pr-push.py\"",
"timeout": 20,
"script": "no-oversized-pr-push.py",
"why": "ai-config#4698. Ezra, 2026-10-23: \"don't allow massive sweep PRs like pds#244 anymore; do them in minimal batches\" and \"every PR should be as small and focused as it can be while completely solving its stated task\". DENIES a `git push` of a branch that changes more than 40 files or 1200 lines against the merge base with the remote default branch, or for a stacked branch against the branch it is stacked on (generated, lock, image and data paths, and lines moved between files, not counted), before CI is spent; gha's check-pr-size (gha#1188) fails the same PR in CI. Clearable with an ALLOW_LARGE_PR=1 prefix for a stacked branch whose parent is not on the server or a maintainer-requested mechanical PR. See shared/workflow/small-prs.md. Fails open on any parse or git trouble."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-sweep-pr-without-ask.py\"",
"timeout": 10,
"script": "warn-sweep-pr-without-ask.py",
"why": "ai-config#4829. Ezra, 2026-10-29: \"don't sweep new rules unless I explicitly tell you to sweep; by default, just fix incrementally when you are editing a passage anyway\". Warns, never blocks, when `gh pr create` has a title or label containing \"sweep\" and the command holds no `Sweep authorized:` marker quoting or linking Ezra's ask. See shared/workflow/no-sweeps-by-default.md. Fails open on parse trouble."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/no-unrequested-sweep-pr.py\"",
"timeout": 10,
"script": "no-unrequested-sweep-pr.py",
"why": "ai-config#5773. Ezra, 2026-11-17: \"how did a sweep get started without my authorization?\" after a spelling-check thread opened about 25 unrequested fix PRs, none titled \"sweep\". WARNS (never denies, ai-config#6148) on a PR creation once 10 PRs were opened since the user's latest message, unless a message the user wrote (not a coordinator note) asks for a sweep. See shared/workflow/no-sweeps-by-default.md. Fails open on a missing transcript."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/no-push-with-failing-notes-checks.py\"",
"timeout": 120,
"script": "no-push-with-failing-notes-checks.py",
"why": "Coordinator, 2026-10-26: lds#1409, lds#1422 and lds#1424 each failed CI's check-term-links or check-new-line-breaks within an hour because the thread skipped the local run that lds .claude/project-memory.md already prescribes. DENIES a `git push` when the repo's own doc checks fail locally. It reads the repo's caller workflows for Morrison-Lab/gha check-term-links, check-new-line-breaks and check-title-references jobs and their literal `with:` inputs, and every diff-scoped `.gha/run-check/run-check.sh` line of a bundled-checks workflow such as lds's cluster-checks.yml (ai-config#4986), so every notes repo is covered with no per-repo list, runs gha's own scripts at the pinned ref (a bundled line runs only its own check's script, with no arguments, from a named ref, with only its prefix and a fixed set of suffixes, each value held to the form its suffix allows) from a daily-refreshed cache in ~/.cache/ai-config/gha against origin/main, and names the findings. Clearable with an AI_CONFIG_SKIP_PUSH_CHECKS='<reason>' prefix (a bare 1 is refused; each bypass is appended to ~/.cache/ai-config/push-check-bypass.log). Fails open with a visible note when gha cannot be fetched, a check times out or origin/main is missing. Covers repos that only call the reusable workflow, the gap warn-new-line-breaks-on-push.py leaves (ai-config#3747)."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-nonglobal-substitution.py\"",
"timeout": 20,
"script": "warn-nonglobal-substitution.py",
"why": "shared/workflow/algorithmatize-checks.md. A non-global `s///` changes only the FIRST occurrence, which may not be the one meant. It bites hardest in mutation testing: a mutation that silently failed to apply reads as a surviving mutation, or worse a verified one, because the test stays green from nothing having changed. Measured four times in one session on 2026-08-21, twice where the substitution rewrote a neighbouring comment instead of the code. WARNS, never blocks: it fires only when perl/sed is the segment's leading command AND carries a genuine in-place flag, and scans script text only, never filenames. Tracked as #1900."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-duplicate-key-blind-verification.py\"",
"timeout": 10,
"script": "warn-duplicate-key-blind-verification.py",
"why": "shared/workflow/algorithmatize-checks.md. yaml.safe_load/load/full_load silently keeps the LAST of a duplicate mapping key, so a check that only inspects the parsed mapping's keys or their count (.keys(), len(...), a membership test, ==set(...)) cannot see a duplicate-key defect -- the duplicate is already gone by the time either analysis runs. Measured on gha#839: a sweep asking which caller stubs would uncomment into a DUPLICATE `with:` key used exactly this shape and reported 1 broken file where the true count, under a duplicate-rejecting loader, was 5. WARNS, never blocks, and only when a Bash command actually EXECUTES python (a -c argument, a heredoc piped to python's stdin, or a heredoc that writes a .py file the same command then runs) -- parsed with `ast`, not text search, so a phrase merely quoted inside a string literal (this corpus's own docs discussing the rule) cannot trip it, and a load already guarded by a registered add_constructor is silent, since that IS the fix this hook recommends."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/no-interpreter-heredoc.py\"",
"timeout": 20,
"script": "no-interpreter-heredoc.py",
"why": "CLAUDE.md 'Tool transport collapses doubled backslashes'; shared/coding/heredoc-backslash-collapse.md. The rule says do not carry content in a heredoc, and its only enforcement was the warn-only warn-heredoc-doubled-backslash.py, which did not change behaviour: measured 2026-10-05 in a Morrison-Lab/psw session, about 15 `python - <<'EOF'` heredocs despite the rule and the warnings, one of which silently turned `\\\\frac` in a LaTeX formula into a form feed plus `rac`, caught only by reading the file back. DENIES a heredoc whose body is the script an interpreter (python, py, node, Rscript, perl, ruby, bash/sh) reads from stdin AND contains a backslash or a backtick: the remedy (Write tool to a scratchpad file, run it by path) is always available and costs one call, so the refusal is always satisfiable. A heredoc fed to anything else (cat, git commit -F -) keeps the warn-only behaviour. Escape hatch: a real leading `ALLOW_INTERPRETER_HEREDOC=1` env assignment (or the hook's own environment); a mere mention of the string does not disarm it. Reuses the heredoc body parser of warn-heredoc-doubled-backslash.py and scripts/lib/shellcmd.py's RX_HEREDOC_OPEN. Fails open. Tracked as #4298."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-heredoc-doubled-backslash.py\"",
"timeout": 20,
"script": "warn-heredoc-doubled-backslash.py",
"why": "CLAUDE.md 'Tool transport collapses doubled backslashes'. On this Windows/MINGW64 transport a doubled backslash typed inside a Bash-tool heredoc body -- even with a quoted delimiter, which should be fully literal -- can arrive at the interpreter as a single backslash (measured 2026-08-22, ai-config#1923). It fails silently and plausibly: a match/assert reads as a slightly-wrong anchor, or a regex/escape sequence written this way is corrupted with no syntax error and a still-green suite. Recurred twice in one session on 2026-09-08 (ai-config#3362): a printf format string's `\\n` collapsed to a literal newline in an emitted snippet, and a Python-heredoc edit writing `\\\\n` escapes into a test fixture produced literal newlines and a pushed SyntaxError. WARNS, never blocks: a doubled backslash inside a heredoc body is not always the mistake (content destined for a regex that will itself be re-escaped downstream is a legitimate exception this hook cannot distinguish), so it only ever adds context naming the offending line and the remedy (build the character with chr(92) rather than typing it doubled; print repr() before writing). Tracked as #3362."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-glab-without-host.py\"",
"timeout": 10,
"script": "warn-glab-without-host.py",
"why": "ai-config#4387. A session ran `glab api` from a folder that is not a git checkout; glab resolved no host, fell back to gitlab.com, answered \"Unauthenticated\", and the agent told the user their token had expired (it had not: the same token returned 200 from the self-hosted /api/v4/user). WARN-ONLY (additionalContext plus systemMessage, never a permissionDecision): fires when a host-sensitive glab subcommand (api, issue, mr, ci, ...) names no host -- no --hostname, no host-qualified -R/--repo, no GITLAB_HOST prefix or earlier export -- and the hook input's cwd (moved by any earlier cd in the command) is not inside a git repo whose remote is a host other than gitlab.com/github.com. Warns rather than blocks because gitlab.com can be the intended host and a profile-level GITLAB_HOST is invisible to the hook. Fails open. Tracked as #4387."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-permission-prefix-mismatch.py\"",
"timeout": 10,
"script": "warn-permission-prefix-mismatch.py",
"why": "memories/claude-code-hooks.md 'A `git -C` probably defeats a permission allow-rule's prefix match (one observation)'. Claude Code appears to match Bash allow rules against the literal command prefix, so `ALLOW_UNREVIEWED_PUSH=1 git -C <path> push` likely misses the user's `Bash(ALLOW_UNREVIEWED_PUSH=1 git push:*)` rule, the classifier denied the override, and the agent asked for a rule that existed (one observation, 2026-10-07, Morrison-Lab/mlr; cause not isolated). WARN-ONLY (additionalContext/systemMessage, never a permissionDecision): fires when a command starts with VAR=val assignments then git with a global option (-C, -c, --git-dir, ...) before the subcommand, and an allow rule in the user or project settings would match with that option removed. Fails open. Tracked as #4351."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-blanket-worktree-force-remove.py\"",
"timeout": 20,
"script": "warn-blanket-worktree-force-remove.py",
"why": "skills/clean-worktrees/SKILL.md step 5: a `git worktree remove` refusal is a safety net -- do NOT blindly --force it; the refusal means the worktree was likely misclassified (dirty tree, unpushed work), so the prescribed response is to re-inspect, not retry forced. Self-hit during a clean-git session on 2026-09-10: a blanket `git worktree remove \"$p\" || git worktree remove --force \"$p\"` fallback was written, contradicting the skill's own explicit warning read earlier the same session -- flagged by hooks/no-mistake-without-a-hook.py as a mistake worth mechanizing, and the auto-mode permission classifier's denial of the command is the only reason nothing was lost. WARNS, never blocks: the skill documents one legitimate single-shot --force (a genuinely clean worktree that merely contains a submodule, refused with a DIFFERENT error -- 'fatal: working trees containing submodules cannot be moved or removed' -- not the dirty-tree refusal), and that exact case occurred later in the same session and was correct, so this hook can never safely deny; it only ever adds context naming the fallback/loop shape and the submodule exception. Fires on the tokenized argv (via scripts/lib/shellcmd.py's git_subcommand, plus its own bespoke operator/segment tokenizer -- not simple_commands, which drops the operator tokens this hook needs), not raw text, so a command merely quoting or documenting the pattern (a commit message, a heredoc writing this file) does not trip it."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/flag-chained-push.py\"",
"timeout": 10,
"script": "flag-chained-push.py",
"why": "Lacaedemon/sparta, 2026-09-05: three refusals in one session, each a `git push` either chained after another command with `&&`/`;`/`||` or suffixed by a pipe/redirect. no-clobbering-push.py and the plugin's own no-push-without-self-review.py push policy both parse the WHOLE command text for a push rather than the isolated push segment, so a trailing `2>&1` hands either parser a bare `2` sitting where a commit-ish token would sit in other shapes, and a chained prefix reads as part of the same invocation. A PreToolUse deny rejects the whole Bash call, so a refused chain runs NOTHING -- not the commands before the push either -- and the refusal naming only the push invites the misreading that the prefix succeeded. WARNS, never blocks: neither shape is wrong on its own (an ordinary `git fetch && git push`, a push piped to `tee` for a log), so the message asks the author to run the push alone and, after any refusal, re-check state rather than assume the prefix ran."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-generated-file-stale.py\"",
"timeout": 45,
"script": "warn-generated-file-stale.py",
"why": "algorithmatize-checks -- warns when a push changes a generated file's SOURCE (hooks/hooks.json) while the repo's own generator reports its output stale. Consumes scripts/gen-hooks-plugin.py --check rather than re-deriving; the gap it closes is timing, since validate.yml runs the same check minutes later and costs a red round. Warn-only: the condition is a path in the diff plus a generator exit code, so it is decidable, but a mid-stack push can legitimately be stale. Added after ai-config#3524 went red on exactly this."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-dupe-check-chained-to-create.py\"",
"timeout": 10,
"script": "warn-dupe-check-chained-to-create.py",
"why": "shared/workflow/report-mistakes-proactively.md, whose step 2 is the tracker dupe-check this defeats, plus ai-config#1954 which records the rule. The section stating it in that fragment arrives with ai-config#1955, so cite the issue rather than the section title until that PR merges. Measured 2026-08-22: a dupe-search and a `gh issue create` ran in ONE Bash call, the search returned the right match (#1737), and #1952 was created anyway. Nothing can branch on a result that arrives at the same instant as the action, so the check was decorative. WARNS, never blocks -- a duplicate is cheap to close, and the false positive it accepts (a list whose output FEEDS the create) costs one line. Fires only when a check and a create of the SAME object kind both sit at command positions with the check first, over text whose heredoc bodies and quoted spans have been stripped. Registered under Bash only: an MCP call carries one operation, so the shape cannot arise there. Fails open. Tracked as #1956.",
"_note_cannot_see_the_general_failure": [
"This detects ONE LEXICAL SHAPE: two commands sharing a call.",
"A search run in its own call whose result was never read is",
"indistinguishable from one that was read, so a silent run is",
"evidence only that the two commands were not in one string --",
"never that a dupe-check happened or that its answer was",
"consulted. Its sibling warn-pr-create-without-dupe-check.py has",
"the mirror limit: a session-wide lexical scan establishes that a",
"query ran and never that its result mattered."
]
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-status-read-after-pipe.py\"",
"timeout": 10,
"script": "warn-status-read-after-pipe.py",
"why": "shared/coding/errexit-is-not-uniform.md, which owns the mechanism, plus the exit-status section of shared/workflow/algorithmatize-checks.md. Without `pipefail` a pipeline's status is its RIGHTMOST command's, so `checker | head -20; echo \"exit=$?\"` reports whether `head` succeeded. Measured 2026-08-24 on UCD-SERG/ucd-serg.github.io#111: that exact line reported `exit=0` while the checker exited 1, and the PR's cleanliness was reasoned from it. NOTE the honest justification -- errexit-is-not-uniform already named this exact shape, with `head` named, and was simply not consulted, so this is a guard because the condition is decidable at composition time rather than because the corpus lacked a rule. WARNS, never blocks: reading the last stage's status is correct under `pipefail` and correct when that stage is the one meant. Fires only when an expandable `$?` sits in the segment IMMEDIATELY after a pipeline, with `set ... pipefail` opening no strictly-earlier segment and appearing at the own command level of no enclosing paren group (a nested group's option does not protect its parent, measured). Excludes single-quoted spans, heredoc bodies and `#` comments (so the corpus's own documentation cannot trip it), process substitution, argument-position command substitution, any `$?` that FOLLOWS a substitution in its segment, `[[ ]]` alternation, `$(( ))` and `(( ))` arithmetic, extglob `@(a|b)`, `>|`, fd-duplication redirects like `2>&1`, and backgrounded pipelines. An assignment's substitution and a bare subshell are NOT excluded: bash reads the pipeline's status there, measured. Negative control 2026-08-24 at branch HEAD, method stated in the hook docstring so it reproduces: 657 fenced blocks over 358 tracked files, 8 of them discriminating (containing both `$?` and `|`), 2 fired, both genuine. Report the 8, not the 657; the rest could not fire under any implementation. An earlier run scored 3, and the third was a false positive caught in review -- see the docstring. Fails open. Tracked as #2149.",
"_note_deliberate_under_approximation": [
"A `$?` inside SINGLE quotes is literal to the shell, so it is",
"never recorded -- which also means `bash -c '... | head; echo",
"$?'` gets no warning. That is accepted rather than overlooked:",
"this corpus writes such demonstration lines constantly, and a",
"warn-only guard should miss a real case before it fires on",
"every fragment that describes the rule it enforces."
]
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-stderr-suppressed-then-parsed.py\"",
"timeout": 10,
"script": "warn-stderr-suppressed-then-parsed.py",
"why": "shared/principles/fail-fast.md, silent-fallback family. A command that suppresses stderr (2>/dev/null, 2>>/dev/null, 2>&-) while its stdout is consumed (redirected to a file, piped, or captured with $(...)) turns a diagnosable failure into an empty result indistinguishable from a legitimately empty one. Measured 2026-09-02 mirroring ucdavis/hac.sap to GitLab: a glab api call with 2>/dev/null wrote an empty file, the emptiness was diagnosed as a sandbox redirect problem, and the suppressed stderr held the real cause (DNS: no such host, the VPN had dropped). WARNS, never blocks: the suppression is sometimes deliberate. Does not fire when stdout is discarded too, which is what &>/dev/null and >/dev/null 2>&1 both do, when stderr is merged (2>&1), or when nothing is suppressed. Tracked as #2998."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-verdict-line-filter.py\"",
"timeout": 10,
"script": "warn-verdict-line-filter.py",
"why": "Warns, never blocks, when a review round is read through a verdict-line jq filter, which drops non-blocking findings carried in the body and in the review-data findings array (ai-config#3493, measured 2026-09-09)."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-recursive-search-cloud-mount.py\"",
"timeout": 10,
"script": "warn-recursive-search-cloud-mount.py",
"why": "memories/course-repos.md 'List a cloud-sync mount's top level before searching it' (ai-config#4072). A recursive search (find, grep -r, rg, fd, ls -R, glob **) over a cloud-sync or network mount (Google Drive G:\\My Drive, /g/My Drive, OneDrive, Dropbox, SMB UNC shares) faults in and streams every folder it touches, causing severe system lag, client disconnects, and false-negative timeout truncations. Warns to list the top level first (e.g. find -maxdepth 1, ls, or a top-level index like Texts_by_Title) and descend only into specific folders."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/flag-uncited-rebuttal.py\"",
"timeout": 15,
"script": "flag-uncited-rebuttal.py",
"why": "shared/workflow/address-every-comment.md's 'read the cited source' rule, from Morrison-Lab/ai-config#2070 (2026-08-24): a rebuttal disputing a finding that cited an external URL was posted using only local grep evidence, never fetching the URL the reviewer named -- and the rebuttal was wrong. Warns, never blocks, when a PR/issue comment about to be posted disputes a finding whose most recently fetched citation named an external URL that no earlier WebFetch/WebSearch in the transcript touched."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-claim-without-comments-read.py\"",
"timeout": 10,
"script": "warn-claim-without-comments-read.py",
"why": "Measured on Lacaedemon/sparta#1544 (2026-09-18): a session posted a claim comment on an issue after reading only its BODY. The body posed a diagnostic question; the issue's COMMENTS -- two above the one posted -- recorded that the diagnosis had already merged (PR #1553) and the residual had been escalated elsewhere. Wasted a claim, a draft PR (#1608, closed as obsolete), and drew a public correction. Warns, never blocks, when `gh issue comment <N>` or `glab issue note <N>` posts a body carrying claim vocabulary ('claiming', 'is working on this', 'picking this up', 'grabbing this', 'please hold off') and no earlier command in the transcript read that same issue's comments (`gh issue view <N> --comments`/`--json comments`, `glab issue view|show <N> --comments`, `gh api .../issues/<N>/comments` GET, or a GitHub MCP issue_read with method=get_comments) -- a plain `gh issue view <N>` with no comments flag does NOT discharge it, since reading the body alone is exactly the failure measured."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/require-agent-disclosure.py\"",
"timeout": 10,
"script": "require-agent-disclosure.py",
"why": "cai 2026-08-24 'all comments online posted by bots should say so', citing UCD-SERG/ucd-serg.github.io#108's agent-authored claim comment posted under the repository owner as type: User, author_association MEMBER -- indistinguishable from a human's. memories/github.md already recorded auditors making that mistake. shared/workflow/disclose-agent-authorship.md is the rule; this is the instrument, since the rule is read at read time and the omission happens at composition time. WARNS, never blocks: a missing marker is cheap to repair with a follow-up comment, while a blocked `gh pr comment` interrupts the one action that makes a claim visible to other sessions -- trading a labelling defect for a collision. Anchored at a command position over text whose heredoc BODIES have been stripped -- the opener tail is kept, so piping a heredoc into `--body-file -` still fires while a doc-writing heredoc quoting `gh pr comment` does not. This corpus quotes that command constantly, and matching such a quote is the near-miss require-gh-repo-flag.py shipped with. Fails open.",
"_note_marker_avoids_the_robot_emoji": [
"The disclosure marker is prose, NOT the robot emoji, and the hook",
"warns separately when a body discloses with the emoji instead.",
"scripts/check-pr-fully-clean.py matches that emoji as a",
"REVIEW_BODY_MARKERS entry, so a disclosed claim comment would be",
"admitted into the fully-clean verdict scan as a review -- and a claim",
"carries no findings, so nothing blocking is found there. That is the",
"false-clean failure shared/workflow/fully-clean.md already records for",
"a human-authored self-review, arriving through the very mechanism",
"added to make authorship legible.",
"",
"Admission is necessary and not sufficient: the comment must",
"also name the head SHA to count toward criterion 2. The emoji",
"removes the one filter standing between a claim comment and",
"that scan, rather than single-handedly manufacturing a clean",
"verdict. Corrected after a cross-vendor review; the fragment",
"and the hook's user-facing warning say the same thing now."
],
"_note_cannot_see_every_body": [
"--body-file, --editor, `-F <file>` and an interpolated $BODY all put the",
"text where a literal scan cannot reach. The hook reports those as an",
"UNREADABLE body rather than as a missing marker, so its warning never",
"asserts more than it observed. That partial visibility is the second",
"reason it cannot deny: a block built on a check that sees a fraction of",
"its population would refuse compliant commands.",
"",
"skills/ard/SKILL.md's per-round summary is exactly that shape -- posted",
"via --body-file on every round of every PR -- so it states the marker",
"requirement in its own text rather than relying on this guard.",
"",
"REGISTERED TWICE, under Bash and under mcp__github__.*, because",
"hooks.json matches by TOOL NAME: the MCP tool list inside the script is",
"unreachable from a Bash-only entry however complete it is. A remote/web",
"session has no `gh` at all, so a Bash-only registration would be silent",
"in exactly the population the MCP branch was written for."
],
"_note_segmentation_is_quote_aware": [
"Segments are split on shell separators OUTSIDE quotes. A plain",
"re.split(r'[;&|\\n]+', ...) looked adequate and was not: the marker sits",
"on its own line at the END of a body, so splitting on every newline cuts",
"the marker off the very command it discloses, and every correctly",
"disclosed multi-line comment -- the normal shape -- warned. Caught by the",
"test suite before this hook was ever registered.",
"",
"Judging PER SEGMENT rather than per call is what stops one disclosed body",
"vouching for an undisclosed sibling in a batched round, which",
"shared/workflow/efficient-pr-babysitting.md actively encourages."
]
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/flag-uncounted-comment-claims.py\"",
"timeout": 10,
"script": "flag-uncounted-comment-claims.py",
"why": "ai-config#2377's sparta file-list incident (2026-08-26): a forge comment posted an enumerated file list recalled from memory rather than derived, and it was wrong. Warns, never blocks, when a `gh pr comment`/`gh issue comment`/`gh api .../comments` body about to post asserts an unverified count (no `grep -c`/`wc -l`-shaped discharge nearby) or a hand-typed enumerated list of hyphenated identifiers with no deriving command beside it in the body or elsewhere in the same Bash call -- `remind-brief-premises.py`'s cardinality/enumeration heuristic extended past Agent/Task/SendMessage briefs to forge-comment bodies, since that hook's own PATH clause is anchored to this corpus and a comment can be about any repo."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/flag-unmeasured-timestamp.py\"",
"timeout": 10,
"script": "flag-unmeasured-timestamp.py",
"why": "AGENTS.md 'Timestamp recaps in local time', forge-comment surface (ai-config#2900, #2903; measured 2026-09-01: claim comments stamped 12:15/12:40/12:58 PT off one 12:02 PDT reading, the next real reading 12:21 PDT). Warns, never blocks, when a `gh pr comment`/`gh issue comment`/`gh pr review`/`gh api .../comments` body about to post states a Pacific clock time (the Stop sibling's `RX_CLAIM` shape: HH:MM, optional seconds, optional AM/PM, then PDT, PST, or PT) and no clock read appears in the transcript since the current turn began -- or, when the harness's injected reading is in this turn, the stamp runs ahead of its value. The chat-recap half is `no-unmeasured-clock-claim.py` at Stop, whose `scan()`, `RX_CLAIM`, and context exemptions this hook imports so the two agree on what a turn, a clock read, and a stamp are; a comment body never reaches a Stop hook, which is the gap this fills. A post whose body the hook cannot read (a `--body-file` written by a heredoc in the same call, `--body-file -`) gets a cannot-read note rather than silence, after require-agent-disclosure.py's third verdict. Warns because a quoted or relayed time (a CI timestamp, a reviewer's own stamp) is legitimate and not distinguishable by the body alone."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-unmeasured-capability-claim.py\"",
"timeout": 10,
"script": "warn-unmeasured-capability-claim.py",
"why": "CLAUDE.md 'Don't take anyone's word for it' and shared/workflow/verify-the-right-artifact.md, applied to the one surface where an unmeasured claim becomes expensive (ai-config#3707, #3739; measured 2026-09-17). Warns, never blocks, when a forge write about to post carries an ABSOLUTE claim that a capability is absent -- 'is unavailable', 'is not possible', 'unbuildable', 'there is no way to', 'no X can Y' -- within 400 characters of a tooling noun (harness, guard, dispatch, transcript, agent... each pluralizable). Surfaces are derived from the siblings that already parse them: require-agent-disclosure.py's MCP post tools plus the issue/PR write tools, and flag-uncited-rebuttal.py's gh comment shapes plus gh pr review, gh issue|pr create|edit and glab issue|mr note. A negative-capability claim names no artifact, so it cannot be checked by opening the thing it is about, and so gets inferred from an adjacent observation and published as established. The two measured cases: 'foreground dispatch is unavailable' (it runs synchronously in 16.3s, though not while a sibling agent is in flight) and 'the provenance chain is unbuildable' (the linkage was on a record the author had not read) -- both posted to GitHub within an hour, both retracted in public. Requiring both factors narrows the field rather than separating system claims from ordinary prose (measured at 6a870ecc: 88 of 2010 non-overlapping 2000-character chunks of this repo's shared/ fire, 4.38%), which is why it warns rather than blocks: an exhaustively measured claim is lexically identical and is the valuable one."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/flag-unread-commit-citation.py\"",
"timeout": 10,
"script": "flag-unread-commit-citation.py",
"why": "ai-config#3471's SHA half: a case entry cited two commit SHAs with a narrative reconstructed from `git log --oneline` alone, and got both backwards -- neither patch was actually opened. Warns, never blocks, when a `gh pr comment`/`gh issue comment`/`gh pr review`/`gh api .../comments` body about to post cites a commit SHA (a word-bounded 7-40 char hex run containing a hex letter, outside a fenced/indented evidence block, not a `Reviewed-Commit:`/`HEAD=` trailer or a position-report phrasing like \"pushed at\"/\"squash,\", and -- for a 7-char token -- carrying a nearby cue) and no command reading that commit (`git show`/`git diff`/`git cat-file`/`git log -p`/`gh api .../commits/<sha>`/`gh api .../pulls/N/commits`/`mcp__github__get_commit`) appears in the transcript since the current turn began. A `git log --oneline` that merely lists the SHA does not discharge it -- that is the exact failure this hook exists to catch. Reuses flag-unmeasured-timestamp.py's comment-post detection and no-unmeasured-clock-claim.py's scan() for the turn boundary."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-new-line-breaks-on-push.py\"",
"timeout": 15,
"script": "warn-new-line-breaks-on-push.py",
"why": "memories/mistake-patterns.md Pattern 25, ai-config#2590 (2026-08-29): warns, never blocks, before a `git push` carrying newly-added Markdown lines that violate semantic line breaks against the default base branch (e.g. origin/main)."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/warn-stale-review-diff-base.py\"",
"timeout": 10,
"script": "warn-stale-review-diff-base.py",
"why": "verify-the-right-artifact 'A comparison's base is an artifact too' -- a bare local branch as a diff's base widens the range when it is behind, and narrows it when it is ahead of or diverged from its remote in commits the head branch also carries, so a review runs on already-merged work or silently skips part of the change; this names the base and the remote-tracking form.",
"_note_warn_only": [
"Reminder only: emits hookSpecificOutput.additionalContext and never a",
"decision. The hook cannot tell a review diff from an ordinary local",
"comparison, and a bare local base is correct for plenty of those, so a",
"block would refuse correct commands on a heuristic.",
"No fetch-based discharge on purpose: keep-checkouts-fresh mandates a",
"session-start fetch, so keying on one would silence this in exactly the",
"sessions that follow the corpus.",
"The Agent|Task|SendMessage matcher is there because the measured failure",
"was a brief handed to a subagent, which cannot check a premise about the",
"author's own environment."
],
"_note_deliberate_under_approximation": [
"The Bash matcher requires the git invocation to sit at a command",
"position, so a range merely quoted inside another command's argument",
"is inert -- including one inside a backtick code span, or after the",
"words `then` or `do` used in ordinary English.",
"That deliberately UNDER-approximates: a real backtick substitution,",
"`bash -c \"...\"`, and any wrapper word outside",
"sudo/env/time/nohup/xargs/command are missed. A missed reminder costs a",
"review round; one fired on quoted prose trains everyone to ignore it.",
"Agent|Task|SendMessage briefs are prose with no command structure, so",
"they use an unanchored pattern instead."
]
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/flag-positional-figure-in-commit-message.py\"",
"timeout": 10,
"script": "flag-positional-figure-in-commit-message.py",
"why": "shared/writing/timestamp-volatile-claims.md, commit-message surface. Warns, never blocks, when a `git commit` message about to be written states a POSITIONAL figure about text -- \"13 lines above\", \"39 lines below\", \"77 lines earlier\", \"~130 lines later\". A commit message is permanent history, so such a figure is asserted once and re-derived by nobody: true when typed, false as soon as anything above it changes, and never contradicted by a failing check. Measured on this repository's own history (2026-09-03, roughly 2400 commits): 14 occurrences across 13 commit messages, every one decoration locating a passage, with no legitimate code-move description among them -- e.g. 4e1dea144, 593d25ccf, fcb4ee10d, f2f706fa1, 60edf4c1e. The warning says to DELETE the number rather than correct it, since naming the target beats counting to it and a recounted figure is a fresher instance of the same defect.",
"_note_scope_is_deliberately_narrow": [
"A bare dimensional count with no positional word is NOT matched.",
"Measured over the same roughly 2400 commits, `\\d+ (characters|chars|words)`",
"alone matches 53, overwhelmingly legitimate measured facts -- a",
"skill-listing context budget, GitHub's 65536-character comment cap, a",
"line length against the style guide. (3 of the 53 also carry a",
"positional figure, so they fire on that arm anyway.) Warning on the",
"rest is the noise that costs a warn-only hook its credibility, so a",
"dimensional figure fires only alongside above/below/earlier/later.",
"Diffstats (`3 files changed`), version numbers, issue and PR numbers,",
"SHAs, dates and clock times are all out of scope for the same reason.",
"",
"A `\\d+-to-\\d+ range` arm was written and then DROPPED after measuring",
"it. Its only match in the whole history was 0709c1a28's \"The 60-to-80",
"range is human guidance\", which states what a style guide asks,",
"locates no passage, and loses its meaning if the number is deleted --",
"a misfire, not a hit. Zero measured true positives against one",
"measured false positive is a losing trade for a guard whose only",
"capital is that a fire means something. Two tests pin that this shape",
"must stay silent.",
"",
"`commit(?![\\w-])`, not `commit\\b`, per no-unshipped-commit.py: a word",
"boundary sits happily between `commit` and `-`, so `\\b` matches",
"`git commit-tree` and `git commit-graph write`, neither of which",
"writes a commit message at all."
],
"_note_fails_silent": [
"Every parse failure -- unbalanced quotes, an unreadable or stdin `-F`",
"target, an unrecognised payload shape -- returns with no output. A",
"commit is the worst thing for a hook to break, and a missed warning",
"costs one stale figure in one commit message. An unreadable `-F` also",
"abandons the whole segment rather than judging the `-m` fraction it",
"can see, so the warning never asserts more than it observed.",
"",
"That guarantee once had an exception, recorded here because the shape is",
"worth keeping: a copied `_GIT_FLAGS` regex backtracked catastrophically",
"on a command line carrying many flag-shaped tokens, so such a command",
"stalled this hook until its 10s timeout rather than returning silently.",
"ai-config#3172 fixed that and moved the patterns to",
"`scripts/lib/git_cmd.py`; this hook imports `COMMIT` from there rather",
"than copying it, so the exception no longer applies."
]
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/guard-slide-major-tag.py\"",
"timeout": 15,
"script": "guard-slide-major-tag.py",
"why": "Denies `gh workflow run slide-major-tag.yml` when git diff tag..origin/<default> adds a job-level permission to a reusable workflow (workflow_call in on:). A called workflow cannot request permissions its caller does not grant, so sliding the tag breaks every un-updated consumer with startup_failure (Morrison-Lab/gha#830 breaking ucdavis/bcs#966; same class as gha#685). Clearable with ALLOW_BREAKING_SLIDE=1. Tracked as #3303."
},
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/flag-unattributable-reviewer-request.py\"",
"timeout": 10,
"script": "flag-unattributable-reviewer-request.py",