-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrules.json
More file actions
2910 lines (2910 loc) · 97.4 KB
/
Copy pathrules.json
File metadata and controls
2910 lines (2910 loc) · 97.4 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
[
{
"id": "ssh-db-mutation",
"description": "Block gcloud compute ssh with inline DB or Moodle config commands",
"applies_to": [
"Bash"
],
"match": [
{
"field": "command",
"pattern": "gcloud[[:space:]]+compute[[:space:]]+ssh.*--command.*(php[[:space:]]+-r|set_config|mdl_|scorm_|mysql[[:space:]]+-|mysqldump|\\$DB->)"
}
],
"action": "block",
"bypass_marker": "ssh-db-rule",
"memory_ref": "feedback_scripts_not_db.md",
"message": "BLOCKED: gcloud compute ssh + inline DB/Moodle command detected.\n\nUse a versioned script in scripts/ instead. If none fits, write+commit\none first. Bypass: add \"// hook-bypass: ssh-db-rule\" to the command.\n",
"tests": [
{
"name": "blocks-ssh-php-r",
"input": {
"tool_input": {
"command": "gcloud compute ssh acme-vm --command=\"docker exec moodle php -r 'var_dump(1);'\""
}
},
"expected_exit": 2
},
{
"name": "blocks-ssh-set-config",
"input": {
"tool_input": {
"command": "gcloud compute ssh acme-vm --command=\"set_config('foo', 'bar', 'moodlecourse')\""
}
},
"expected_exit": 2
},
{
"name": "blocks-ssh-mysql-shell",
"input": {
"tool_input": {
"command": "gcloud compute ssh acme-vm --command=\"mysql -u root -e 'SELECT 1'\""
}
},
"expected_exit": 2
},
{
"name": "allows-regular-ssh",
"input": {
"tool_input": {
"command": "gcloud compute ssh acme-vm --command=\"ls /var/log\""
}
},
"expected_exit": 0
},
{
"name": "allows-bypass-marker",
"input": {
"tool_input": {
"command": "gcloud compute ssh acme-vm --command=\"php -r 'echo 1;'\" # hook-bypass: ssh-db-rule"
}
},
"expected_exit": 0
}
]
},
{
"id": "gcloud-missing-project",
"description": "Warn when gcloud command is missing --project= flag",
"applies_to": [
"Bash"
],
"match": [
{
"field": "command",
"pattern": "^[[:space:]]*gcloud([[:space:]]+--[a-zA-Z0-9_-]+(=[^[:space:]]+)?)*[[:space:]]+(compute|sql|run|iam|secrets|projects|storage|functions|builds|artifacts|container|auth)[[:space:]]",
"not_pattern": "--project[= ]|gcloud([[:space:]]+--[a-zA-Z0-9_-]+(=[^[:space:]]+)?)*[[:space:]]+(version|help|info|config)[[:space:]]"
}
],
"action": "warn",
"bypass_marker": null,
"memory_ref": "feedback_gcloud_explicit_flags.md",
"references": [],
"message": "WARNING: gcloud command without explicit --project= flag.\n\nActive config drift can cause cross-project mistakes. Pass --project=<id>\non every gcloud command (and --account= for multi-account setups).\n",
"tests": [
{
"name": "warns-on-compute-without-project",
"input": {
"tool_input": {
"command": "gcloud compute instances list"
}
},
"expected_exit": 0,
"expected_stderr_contains": "gcloud-missing-project"
},
{
"name": "allows-with-project",
"input": {
"tool_input": {
"command": "gcloud compute instances list --project=acme-dev"
}
},
"expected_exit": 0
},
{
"name": "allows-version-subcommand",
"input": {
"tool_input": {
"command": "gcloud version"
}
},
"expected_exit": 0
},
{
"name": "warns-with-global-flags-before-subcommand",
"input": {
"tool_input": {
"command": "gcloud --verbosity=debug compute instances list"
}
},
"expected_exit": 0,
"expected_stderr_contains": "gcloud-missing-project"
}
]
},
{
"id": "prod-ops-no-approval",
"description": "Block production operations without explicit user acknowledgement",
"applies_to": [
"Bash"
],
"match": [
{
"field": "command",
"pattern": "--project=([a-z0-9-]+-prod\\b|production\\b)|--env=prod\\b|\\bENV=prod\\b|--target=prod\\b"
}
],
"action": "block",
"bypass_marker": "prod-ops",
"memory_ref": "feedback_never_touch_prod_without_approval.md",
"references": [],
"message": "BLOCKED: production operation detected.\n\nProduction changes require explicit user approval. Once confirmed, add\n\"// hook-bypass: prod-ops\" to the command to acknowledge.\n",
"tests": [
{
"name": "blocks-prod-project-flag",
"input": {
"tool_input": {
"command": "gcloud --project=acme-prod compute instances list"
}
},
"expected_exit": 2
},
{
"name": "blocks-env-prod",
"input": {
"tool_input": {
"command": "ENV=prod npm run deploy"
}
},
"expected_exit": 2
},
{
"name": "allows-staging",
"input": {
"tool_input": {
"command": "gcloud --project=acme-dev compute instances list"
}
},
"expected_exit": 0
},
{
"name": "allows-bypass",
"input": {
"tool_input": {
"command": "gcloud --project=acme-prod compute instances list # hook-bypass: prod-ops"
}
},
"expected_exit": 0
}
]
},
{
"id": "destructive-db-ops",
"description": "Block destructive DB operations even with --local",
"applies_to": [
"Bash"
],
"match": [
{
"field": "command",
"pattern": "supabase[[:space:]]+db[[:space:]]+(reset|push|repair)\\b|psql[^|]*\\b(DROP[[:space:]]+(TABLE|DATABASE|SCHEMA)|TRUNCATE|DELETE[[:space:]]+FROM)\\b"
}
],
"action": "block",
"bypass_marker": "db-destructive",
"memory_ref": "feedback_db_ops_explicit_permission.md",
"references": [],
"message": "BLOCKED: destructive DB operation.\n\nEven with --local, ask explicit user permission first. Once confirmed,\nadd \"// hook-bypass: db-destructive\" to the command.\n",
"tests": [
{
"name": "blocks-supabase-reset",
"input": {
"tool_input": {
"command": "supabase db reset --local"
}
},
"expected_exit": 2
},
{
"name": "blocks-psql-drop-table",
"input": {
"tool_input": {
"command": "psql -c \"DROP TABLE users\""
}
},
"expected_exit": 2
},
{
"name": "blocks-psql-truncate",
"input": {
"tool_input": {
"command": "psql -c \"TRUNCATE users\""
}
},
"expected_exit": 2
},
{
"name": "allows-supabase-status",
"input": {
"tool_input": {
"command": "supabase status"
}
},
"expected_exit": 0
},
{
"name": "allows-bypass",
"input": {
"tool_input": {
"command": "supabase db reset --local # hook-bypass: db-destructive"
}
},
"expected_exit": 0
}
]
},
{
"id": "manual-edge-fn-deploy",
"description": "Block manual Edge Function deploy (CI-only)",
"applies_to": [
"Bash"
],
"match": [
{
"field": "command",
"pattern": "supabase[[:space:]]+functions[[:space:]]+deploy\\b"
}
],
"action": "block",
"bypass_marker": "edge-fn-manual",
"memory_ref": "feedback_edge_functions_via_ci.md",
"references": [],
"message": "BLOCKED: manual Edge Function deploy.\n\nDeploy via CI workflow (push to develop for staging, main for prod).\nBypass: add \"// hook-bypass: edge-fn-manual\" if a hotfix justifies it.\n",
"tests": [
{
"name": "blocks-functions-deploy",
"input": {
"tool_input": {
"command": "supabase functions deploy my-function"
}
},
"expected_exit": 2
},
{
"name": "allows-functions-list",
"input": {
"tool_input": {
"command": "supabase functions list"
}
},
"expected_exit": 0
},
{
"name": "allows-bypass",
"input": {
"tool_input": {
"command": "supabase functions deploy my-function # hook-bypass: edge-fn-manual"
}
},
"expected_exit": 0
}
]
},
{
"id": "minified-build-output",
"description": "Block writing minified content to build/ directories",
"applies_to": [
"Edit",
"Write",
"MultiEdit"
],
"match": [
{
"field": "file_path",
"pattern": "amd/build/.*\\.min\\.js$|dist/.*\\.min\\.(js|css)$"
},
{
"field": "content",
"pattern": "(var [a-z]=function|;function [a-z]\\(\\)|^[a-zA-Z0-9_$]+=function\\([a-zA-Z0-9_$,]*\\)\\{)"
}
],
"action": "block",
"bypass_marker": "minified-build",
"memory_ref": "feedback_no_minified_build.md",
"references": [],
"message": "BLOCKED: minified content being written to build/.\n\nBuild artifacts must stay human-readable. Replace with a readable copy\nof src/. Bypass: \"// hook-bypass: minified-build\" inside the content.\n",
"tests": [
{
"name": "blocks-minified-amd-build",
"input": {
"tool_input": {
"file_path": "plugins/foo/amd/build/main.min.js",
"content": "var a=function(b){return b};var c=function(){};"
}
},
"expected_exit": 2
},
{
"name": "allows-readable-amd-build",
"input": {
"tool_input": {
"file_path": "plugins/foo/amd/build/main.min.js",
"content": "define(['jquery'], function($) {\n 'use strict';\n return {\n init: function() { console.log('hello'); }\n };\n});\n"
}
},
"expected_exit": 0
},
{
"name": "allows-non-build-paths",
"input": {
"tool_input": {
"file_path": "src/utils/helper.js",
"content": "var a=function(b){return b};"
}
},
"expected_exit": 0
}
]
},
{
"id": "secrets-hardcoded",
"description": "Block hardcoded credential patterns being written to source files",
"applies_to": [
"Edit",
"Write",
"MultiEdit"
],
"match": [
{
"field": "content",
"pattern": "(password|secret|api_key|apikey|token|access_key|private_key)[\"\\']?[[:space:]]*[:=][[:space:]]*[\"\\']?[A-Za-z0-9_!@#$%^&*+/=-]{12,}",
"flags": "i"
},
{
"field": "file_path",
"not_pattern": "\\.env\\.example|\\.(test|spec)\\.|README|\\.md$|fixtures/|mocks?/"
}
],
"action": "block",
"bypass_marker": "secret-leak",
"memory_ref": "feedback_never_leak_secrets.md",
"references": [],
"message": "POTENTIAL SECRET LEAK: hardcoded credential pattern detected.\n\nUse Secret Manager / .env / local memory for real values. If this is a\nplaceholder or test fixture, prefix with \"EXAMPLE_\" / \"CHANGEME_\", move\nto .env.example, or add \"// hook-bypass: secret-leak\" near the line.\n",
"tests": [
{
"name": "blocks-hardcoded-password-in-src",
"input": {
"tool_input": {
"file_path": "src/config.ts",
"content": "const password = \"supersecret123ABC!\""
}
},
"expected_exit": 2
},
{
"name": "blocks-hardcoded-api-key",
"input": {
"tool_input": {
"file_path": "src/lib/api.ts",
"content": "const api_key: \"sk_live_abc123def456ghi789\""
}
},
"expected_exit": 2
},
{
"name": "allows-env-example",
"input": {
"tool_input": {
"file_path": ".env.example",
"content": "PASSWORD=changeme_supersecret_placeholder"
}
},
"expected_exit": 0
},
{
"name": "allows-bypass",
"input": {
"tool_input": {
"file_path": "src/config.ts",
"content": "const password = \"supersecret123ABC!\" // hook-bypass: secret-leak"
}
},
"expected_exit": 0
},
{
"name": "allows-test-file",
"input": {
"tool_input": {
"file_path": "src/auth.test.ts",
"content": "const password = \"supersecret123ABC!\""
}
},
"expected_exit": 0
}
]
},
{
"id": "slack-unicode-bullets",
"description": "Warn on Unicode bullets in Slack messages (use - instead)",
"applies_to": [
"Slack"
],
"match": [
{
"field": "text",
"pattern": "[•◦▪▫]"
}
],
"action": "warn",
"bypass_marker": null,
"memory_ref": "feedback_slack_no_unicode_bullets.md",
"references": [],
"message": "Slack style: Unicode bullets (•◦▪▫) detected. Use \"-\" instead.\n",
"tests": [
{
"name": "warns-on-bullet",
"input": {
"tool_input": {
"text": "Hola • mundo"
}
},
"expected_exit": 0,
"expected_stderr_contains": "slack-unicode-bullets"
},
{
"name": "allows-dash-bullet",
"input": {
"tool_input": {
"text": "Hola - mundo"
}
},
"expected_exit": 0
}
]
},
{
"id": "slack-tables-no-codeblock",
"description": "Warn when a markdown table separator row appears in Slack text",
"applies_to": [
"Slack"
],
"match": [
{
"field": "text",
"pattern": "^\\|[-:|[:space:]]+\\|[[:space:]]*$"
}
],
"action": "warn",
"bypass_marker": null,
"memory_ref": "feedback_slack_tables.md",
"message": "Slack style: markdown table syntax detected.\nSlack mrkdwn does not render bare pipe-tables — wrap the table in\ntriple-backtick fences for it to display correctly.\n",
"tests": [
{
"name": "warns-on-bare-table",
"input": {
"tool_input": {
"text": "Resultados:\n| col1 | col2 | col3 |\n| ---- | ---- | ---- |\n| a | b | c |\n"
}
},
"expected_exit": 0,
"expected_stderr_contains": "slack-tables-no-codeblock"
},
{
"name": "allows-message-with-stray-pipes",
"input": {
"tool_input": {
"text": "Just a paragraph with | a stray pipe | character — no table here.\n"
}
},
"expected_exit": 0
}
]
},
{
"id": "slack-spanish-tildes",
"description": "Warn when common Spanish words appear without tildes",
"applies_to": [
"Slack"
],
"match": [
{
"field": "text",
"pattern": "\\b(migracion|verificacion|analisis|patron|tambien|configuracion|implementacion|version|integracion|notificacion|aplicacion|comunicacion)\\b",
"flags": "i"
}
],
"action": "warn",
"bypass_marker": null,
"memory_ref": "feedback_spanish_accents.md",
"references": [],
"message": "Slack style: Spanish word without tilde detected. Always write with accents\n(migración, verificación, análisis, patrón, también, configuración, ...).\n",
"tests": [
{
"name": "warns-on-tildeless-migracion",
"input": {
"tool_input": {
"text": "La migracion fue exitosa"
}
},
"expected_exit": 0,
"expected_stderr_contains": "slack-spanish-tildes"
},
{
"name": "allows-with-tilde",
"input": {
"tool_input": {
"text": "La migración fue exitosa"
}
},
"expected_exit": 0
}
]
},
{
"id": "ds-arbitrary-breakpoint",
"description": "Block arbitrary Tailwind breakpoints (min-[Xpx]) in TSX/JSX/TS source — use sm:/md:/lg:/xl:/2xl: preset breakpoints",
"applies_to": [
"Edit",
"Write",
"MultiEdit"
],
"match": [
{
"field": "file_path",
"pattern": "\\.(tsx|jsx|ts|js)$"
},
{
"field": "content",
"pattern": "min-\\[[0-9]+px\\]"
}
],
"action": "block",
"bypass_marker": "ds-arbitrary-breakpoint",
"memory_ref": "feedback_design_system_no_arbitrary_breakpoints.md",
"message": "BLOCKED: arbitrary Tailwind breakpoint detected (min-[Xpx]).\n\nUse Tailwind's preset breakpoints instead: sm: (640px), md: (768px),\nlg: (1024px), xl: (1280px), 2xl: (1536px). Arbitrary values fragment\nthe responsive design language and break consistency across the app.\n\nIf a non-preset breakpoint is genuinely required, add\n\"// hook-bypass: ds-arbitrary-breakpoint\" to the line and justify\nin the PR description.\n",
"tests": [
{
"name": "blocks-min-1200px-in-tsx",
"input": {
"tool_input": {
"file_path": "src/components/foo.tsx",
"content": "<div className=\"min-[1200px]:flex\">x</div>"
}
},
"expected_exit": 2
},
{
"name": "blocks-min-768-arbitrary",
"input": {
"tool_input": {
"file_path": "src/pages/Bar.tsx",
"content": "<div className=\"min-[768px]:block\">y</div>"
}
},
"expected_exit": 2
},
{
"name": "allows-preset-md",
"input": {
"tool_input": {
"file_path": "src/components/foo.tsx",
"content": "<div className=\"md:flex\">x</div>"
}
},
"expected_exit": 0
},
{
"name": "allows-non-tsx-files",
"input": {
"tool_input": {
"file_path": "docs/example.md",
"content": "Use min-[1200px] for ..."
}
},
"expected_exit": 0
},
{
"name": "allows-bypass-marker",
"input": {
"tool_input": {
"file_path": "src/components/foo.tsx",
"content": "<div className=\"min-[1380px]:hidden\">x</div> // hook-bypass: ds-arbitrary-breakpoint"
}
},
"expected_exit": 0
}
]
},
{
"id": "ds-deep-ui-import",
"description": "Block deep imports from @/components/ui/<file> — always import from the barrel @/components/ui",
"applies_to": [
"Edit",
"Write",
"MultiEdit"
],
"match": [
{
"field": "file_path",
"pattern": "\\.(tsx|jsx|ts)$"
},
{
"field": "content",
"pattern": "from[[:space:]]+[\"']@/components/ui/[a-zA-Z][a-zA-Z0-9_-]+[\"']"
}
],
"action": "block",
"bypass_marker": "ds-deep-ui-import",
"memory_ref": "feedback_design_system_barrel_imports.md",
"message": "BLOCKED: deep import from @/components/ui/<file> detected.\n\nAlways import Design System components from the barrel:\n import { Button, Card, TextInput } from \"@/components/ui\"\n\nDeep imports like @/components/ui/button bypass the barrel-controlled\nsurface and make refactors brittle. The barrel is the public API.\n",
"tests": [
{
"name": "blocks-deep-button-import",
"input": {
"tool_input": {
"file_path": "src/pages/Foo.tsx",
"content": "import { Button } from \"@/components/ui/button\""
}
},
"expected_exit": 2
},
{
"name": "blocks-deep-textinput-import",
"input": {
"tool_input": {
"file_path": "src/components/Bar.tsx",
"content": "import { TextInput } from '@/components/ui/text-input'"
}
},
"expected_exit": 2
},
{
"name": "allows-barrel-import",
"input": {
"tool_input": {
"file_path": "src/pages/Foo.tsx",
"content": "import { Button, Card } from \"@/components/ui\""
}
},
"expected_exit": 0
},
{
"name": "allows-non-ds-import",
"input": {
"tool_input": {
"file_path": "src/pages/Foo.tsx",
"content": "import { foo } from \"@/lib/utils\""
}
},
"expected_exit": 0
},
{
"name": "allows-bypass-marker",
"input": {
"tool_input": {
"file_path": "src/pages/Foo.tsx",
"content": "import { Button } from \"@/components/ui/button\" // hook-bypass: ds-deep-ui-import"
}
},
"expected_exit": 0
}
]
},
{
"id": "ds-arbitrary-fixed-width-in-ds-component",
"description": "Block arbitrary fixed widths (w-[Xpx]) inside DS components — they must be flexible (w-full + max-w)",
"applies_to": [
"Edit",
"Write",
"MultiEdit"
],
"match": [
{
"field": "file_path",
"pattern": "(^|/)src/components/ui/"
},
{
"field": "content",
"pattern": "(^|[^a-zA-Z-])w-\\[[0-9]+px\\]"
}
],
"action": "block",
"bypass_marker": "ds-arbitrary-fixed-width",
"memory_ref": "feedback_design_system_no_fixed_pixel_widths.md",
"message": "BLOCKED: arbitrary fixed pixel width in a DS component.\n\nDS components live under src/components/ui/ and must be flexible.\nUse w-full + max-w-[Xpx] instead of w-[Xpx], so the component\nadapts to its container.\n\nApplication-level usage (outside src/components/ui/) is exempt —\nthis rule only fires when editing the DS components themselves.\n",
"tests": [
{
"name": "blocks-w-pixel-in-ui-button",
"input": {
"tool_input": {
"file_path": "src/components/ui/button.tsx",
"content": "<button className=\"w-[120px]\">x</button>"
}
},
"expected_exit": 2
},
{
"name": "blocks-w-pixel-in-ui-card",
"input": {
"tool_input": {
"file_path": "src/components/ui/card.tsx",
"content": "<div className=\"w-[300px] p-4\">y</div>"
}
},
"expected_exit": 2
},
{
"name": "blocks-w-pixel-in-ui-button-absolute-path",
"input": {
"tool_input": {
"file_path": "/home/user/repo/src/components/ui/button.tsx",
"content": "<button className=\"w-[120px]\">x</button>"
}
},
"expected_exit": 2
},
{
"name": "allows-w-pixel-outside-ds",
"input": {
"tool_input": {
"file_path": "src/pages/Settings.tsx",
"content": "<div className=\"w-[300px]\">page-specific</div>"
}
},
"expected_exit": 0
},
{
"name": "allows-w-full-max-w",
"input": {
"tool_input": {
"file_path": "src/components/ui/button.tsx",
"content": "<button className=\"w-full max-w-[200px]\">x</button>"
}
},
"expected_exit": 0
},
{
"name": "allows-bypass-marker",
"input": {
"tool_input": {
"file_path": "src/components/ui/special.tsx",
"content": "<div className=\"w-[42px]\">px-perfect-icon</div> // hook-bypass: ds-arbitrary-fixed-width"
}
},
"expected_exit": 0
}
]
},
{
"id": "ds-raw-hex-color-in-source",
"description": "Warn on raw hex color literals in TSX/TS source — colors must come from Tailwind tokens (dojo-primary-*, etc.)",
"applies_to": [
"Edit",
"Write",
"MultiEdit"
],
"match": [
{
"field": "file_path",
"pattern": "\\.(tsx|jsx|ts|js)$",
"not_pattern": "(tailwind\\.config|theme/|design-system/|design-tokens|\\.test\\.|\\.stories\\.)"
},
{
"field": "content",
"pattern": "#[0-9a-fA-F]{6}\\b"
}
],
"action": "warn",
"bypass_marker": "ds-raw-hex-color",
"memory_ref": "feedback_design_system_token_only_colors.md",
"message": "WARNING: raw hex color literal found in source.\n\nUse a Tailwind token instead (e.g., bg-dojo-primary-lilac, text-dojo-foreground).\nThe token system is the single source of truth for color and theming.\n\nExempt paths (NOT flagged): tailwind.config.*, theme/, design-system/,\ndesign-tokens, .test.*, .stories.*. Use the bypass marker if a hex is\ngenuinely required outside those paths (e.g. embedding a brand color\nin a logo SVG that the design system doesn't yet expose).\n",
"tests": [
{
"name": "warns-on-raw-hex-in-tsx",
"input": {
"tool_input": {
"file_path": "src/components/foo.tsx",
"content": "<div style={{ color: \"#FF7151\" }}>x</div>"
}
},
"expected_exit": 0,
"expected_stderr_contains": "ds-raw-hex-color-in-source"
},
{
"name": "warns-on-raw-hex-in-ts",
"input": {
"tool_input": {
"file_path": "src/lib/util.ts",
"content": "const PRIMARY = \"#C980FC\""
}
},
"expected_exit": 0,
"expected_stderr_contains": "ds-raw-hex-color-in-source"
},
{
"name": "allows-tailwind-config",
"input": {
"tool_input": {
"file_path": "tailwind.config.ts",
"content": "lilac: \"#C980FC\""
}
},
"expected_exit": 0
},
{
"name": "allows-theme-file",
"input": {
"tool_input": {
"file_path": "src/theme/tokens.ts",
"content": "export const PRIMARY = \"#C980FC\""
}
},
"expected_exit": 0
},
{
"name": "allows-test-file",
"input": {
"tool_input": {
"file_path": "src/components/foo.test.tsx",
"content": "expect(color).toBe(\"#FF7151\")"
}
},
"expected_exit": 0
},
{
"name": "allows-design-system-folder",
"input": {
"tool_input": {
"file_path": "src/design-system/tokens.ts",
"content": "export const PRIMARY = \"#C980FC\""
}
},
"expected_exit": 0
},
{
"name": "allows-design-tokens-file",
"input": {
"tool_input": {
"file_path": "src/lib/design-tokens.ts",
"content": "export const LILAC = \"#C980FC\""
}
},
"expected_exit": 0
},
{
"name": "allows-bypass-marker",
"input": {
"tool_input": {
"file_path": "src/components/Logo.tsx",
"content": "<svg fill=\"#FF7151\" /> // hook-bypass: ds-raw-hex-color"
}
},
"expected_exit": 0
}
]
},
{
"id": "schema-sql-outside-migrations",
"description": "Block schema-changing SQL (ALTER/CREATE/DROP/GRANT/REVOKE/CREATE POLICY) in .sql files outside supabase/migrations/",
"applies_to": [
"Edit",
"Write",
"MultiEdit"
],
"match": [
{
"field": "file_path",
"pattern": "\\.sql$",
"not_pattern": "(supabase/migrations/|supabase/tests/|supabase/seed)"
},
{
"field": "content",
"pattern": "\\b(ALTER TABLE|CREATE TABLE|DROP TABLE|CREATE POLICY|DROP POLICY|GRANT |REVOKE |CREATE FUNCTION|DROP FUNCTION|CREATE TYPE|ALTER TYPE)\\b",
"flags": "i"
}
],
"action": "block",
"bypass_marker": "schema-sql-outside-migrations",
"memory_ref": "feedback_scripts_not_db.md",
"message": "BLOCKED: schema-changing SQL in a file outside supabase/migrations/.\n\nEvery schema mutation (ALTER/CREATE/DROP/GRANT/POLICY) MUST live in a\ntimestamped migration file, never in ad-hoc scripts or runtime queries.\n\nCreate a new file:\n supabase/migrations/$(date -u +%Y%m%d%H%M%S)_<slug>.sql\n\nLegitimate exceptions (use the bypass marker):\n- Schema docs / examples in READMEs — should not be executable SQL\n- Test fixtures under supabase/tests/ — already exempt via not_pattern\n",
"tests": [
{
"name": "blocks-create-table-in-script",
"input": {
"tool_input": {
"file_path": "scripts/setup.sql",
"content": "CREATE TABLE foo (id int primary key);"
}
},
"expected_exit": 2
},
{
"name": "blocks-grant-in-edge-function",
"input": {
"tool_input": {
"file_path": "supabase/functions/foo/migrate.sql",
"content": "GRANT SELECT ON foo TO authenticated;"
}
},
"expected_exit": 2
},
{
"name": "blocks-alter-table-in-readme-example",
"input": {
"tool_input": {
"file_path": "docs/example.sql",
"content": "ALTER TABLE foo ADD COLUMN bar text;"
}
},
"expected_exit": 2
},
{
"name": "allows-schema-in-migrations-folder",
"input": {
"tool_input": {
"file_path": "supabase/migrations/20260509000000_foo.sql",
"content": "CREATE TABLE foo (id int primary key);"
}
},
"expected_exit": 0
},
{
"name": "allows-schema-in-tests-folder",
"input": {
"tool_input": {
"file_path": "supabase/tests/foo_test.sql",
"content": "CREATE TABLE temp_test_t (id int);"
}
},
"expected_exit": 0
},
{
"name": "allows-non-schema-sql-anywhere",
"input": {
"tool_input": {
"file_path": "scripts/query.sql",
"content": "SELECT * FROM foo;"
}
},
"expected_exit": 0
},
{
"name": "allows-bypass-marker",
"input": {
"tool_input": {
"file_path": "scripts/oneshot.sql",
"content": "-- # hook-bypass: schema-sql-outside-migrations\nCREATE TABLE foo (id int primary key);\n"
}
},
"expected_exit": 0
}
]
},
{
"id": "warn-psql-against-supabase-remote",
"description": "Warn when psql / pg_dump / pg_restore is executed directly against a *.supabase.co host (drift risk vs versioned migrations)",
"applies_to": [
"Bash"
],
"match": [
{
"field": "command",
"pattern": "\\b(psql|pg_dump|pg_restore|pg_dumpall)\\b.*\\.supabase\\.co",
"flags": "i"
}
],
"action": "warn",
"bypass_marker": "psql-supabase-remote",
"memory_ref": "feedback_scripts_not_db.md",
"message": "WARNING: direct psql / pg_dump / pg_restore execution against a Supabase\nremote host.\n\nSQL Editor / direct-Postgres-CLI workflows create drift between the\nversioned migrations directory and other devs' local databases.\n\nCorrect workflow:\n 1. Add a migration in supabase/migrations/<timestamp>_<slug>.sql\n 2. Test locally: supabase db reset --local\n 3. Push to develop — CI applies the migration to staging automatically\n 4. For production: follow the create-release SOP\n\nUse the bypass marker only for legitimate hotfixes where the PR cycle\nis too slow.\n",
"tests": [