claude-code-orchestrator-kit 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/.claude/agents/database/workers/api-builder.md +155 -0
  2. package/.claude/agents/database/workers/database-architect.md +193 -0
  3. package/.claude/agents/database/workers/supabase-auditor.md +1070 -0
  4. package/.claude/agents/development/workers/code-reviewer.md +968 -0
  5. package/.claude/agents/development/workers/cost-calculator-specialist.md +683 -0
  6. package/.claude/agents/development/workers/llm-service-specialist.md +999 -0
  7. package/.claude/agents/development/workers/skill-builder-v2.md +480 -0
  8. package/.claude/agents/development/workers/typescript-types-specialist.md +649 -0
  9. package/.claude/agents/development/workers/utility-builder.md +582 -0
  10. package/.claude/agents/documentation/workers/technical-writer.md +152 -0
  11. package/.claude/agents/frontend/workers/fullstack-nextjs-specialist.md +206 -0
  12. package/.claude/agents/frontend/workers/visual-effects-creator.md +159 -0
  13. package/.claude/agents/health/orchestrators/bug-orchestrator.md +1045 -0
  14. package/.claude/agents/health/orchestrators/dead-code-orchestrator.md +1045 -0
  15. package/.claude/agents/health/orchestrators/dependency-orchestrator.md +1045 -0
  16. package/.claude/agents/health/orchestrators/security-orchestrator.md +1045 -0
  17. package/.claude/agents/health/workers/bug-fixer.md +525 -0
  18. package/.claude/agents/health/workers/bug-hunter.md +649 -0
  19. package/.claude/agents/health/workers/dead-code-hunter.md +446 -0
  20. package/.claude/agents/health/workers/dead-code-remover.md +437 -0
  21. package/.claude/agents/health/workers/dependency-auditor.md +379 -0
  22. package/.claude/agents/health/workers/dependency-updater.md +436 -0
  23. package/.claude/agents/health/workers/security-scanner.md +700 -0
  24. package/.claude/agents/health/workers/vulnerability-fixer.md +524 -0
  25. package/.claude/agents/infrastructure/workers/infrastructure-specialist.md +156 -0
  26. package/.claude/agents/infrastructure/workers/orchestration-logic-specialist.md +1260 -0
  27. package/.claude/agents/infrastructure/workers/qdrant-specialist.md +503 -0
  28. package/.claude/agents/infrastructure/workers/quality-validator-specialist.md +984 -0
  29. package/.claude/agents/meta/workers/meta-agent-v3.md +503 -0
  30. package/.claude/agents/research/workers/problem-investigator.md +507 -0
  31. package/.claude/agents/research/workers/research-specialist.md +423 -0
  32. package/.claude/agents/testing/workers/accessibility-tester.md +813 -0
  33. package/.claude/agents/testing/workers/integration-tester.md +188 -0
  34. package/.claude/agents/testing/workers/mobile-fixes-implementer.md +252 -0
  35. package/.claude/agents/testing/workers/mobile-responsiveness-tester.md +180 -0
  36. package/.claude/agents/testing/workers/performance-optimizer.md +262 -0
  37. package/.claude/agents/testing/workers/test-writer.md +800 -0
  38. package/.claude/commands/health-bugs.md +297 -0
  39. package/.claude/commands/health-cleanup.md +297 -0
  40. package/.claude/commands/health-deps.md +297 -0
  41. package/.claude/commands/health-metrics.md +747 -0
  42. package/.claude/commands/health-security.md +297 -0
  43. package/.claude/commands/push.md +21 -0
  44. package/.claude/commands/speckit.analyze.md +184 -0
  45. package/.claude/commands/speckit.checklist.md +294 -0
  46. package/.claude/commands/speckit.clarify.md +178 -0
  47. package/.claude/commands/speckit.constitution.md +78 -0
  48. package/.claude/commands/speckit.implement.md +182 -0
  49. package/.claude/commands/speckit.plan.md +87 -0
  50. package/.claude/commands/speckit.specify.md +250 -0
  51. package/.claude/commands/speckit.tasks.md +137 -0
  52. package/.claude/commands/translate-doc.md +95 -0
  53. package/.claude/commands/worktree-cleanup.md +382 -0
  54. package/.claude/commands/worktree-create.md +287 -0
  55. package/.claude/commands/worktree-list.md +239 -0
  56. package/.claude/commands/worktree-remove.md +339 -0
  57. package/.claude/schemas/base-plan.schema.json +82 -0
  58. package/.claude/schemas/bug-plan.schema.json +71 -0
  59. package/.claude/schemas/dead-code-plan.schema.json +71 -0
  60. package/.claude/schemas/dependency-plan.schema.json +74 -0
  61. package/.claude/schemas/security-plan.schema.json +71 -0
  62. package/.claude/scripts/gates/check-bundle-size.sh +47 -0
  63. package/.claude/scripts/gates/check-coverage.sh +67 -0
  64. package/.claude/scripts/gates/check-security.sh +46 -0
  65. package/.claude/scripts/release.sh +740 -0
  66. package/.claude/settings.local.json +21 -0
  67. package/.claude/settings.local.json.example +20 -0
  68. package/.claude/skills/calculate-priority-score/SKILL.md +229 -0
  69. package/.claude/skills/calculate-priority-score/scoring-matrix.json +83 -0
  70. package/.claude/skills/extract-version/SKILL.md +228 -0
  71. package/.claude/skills/format-commit-message/SKILL.md +189 -0
  72. package/.claude/skills/format-commit-message/template.md +64 -0
  73. package/.claude/skills/format-markdown-table/SKILL.md +202 -0
  74. package/.claude/skills/format-markdown-table/examples.md +84 -0
  75. package/.claude/skills/format-todo-list/SKILL.md +222 -0
  76. package/.claude/skills/format-todo-list/template.json +30 -0
  77. package/.claude/skills/generate-changelog/SKILL.md +258 -0
  78. package/.claude/skills/generate-changelog/commit-mapping.json +47 -0
  79. package/.claude/skills/generate-report-header/SKILL.md +228 -0
  80. package/.claude/skills/generate-report-header/template.md +66 -0
  81. package/.claude/skills/parse-error-logs/SKILL.md +286 -0
  82. package/.claude/skills/parse-error-logs/patterns.json +26 -0
  83. package/.claude/skills/parse-git-status/SKILL.md +164 -0
  84. package/.claude/skills/parse-package-json/SKILL.md +151 -0
  85. package/.claude/skills/parse-package-json/schema.json +43 -0
  86. package/.claude/skills/render-template/SKILL.md +245 -0
  87. package/.claude/skills/rollback-changes/SKILL.md +582 -0
  88. package/.claude/skills/rollback-changes/changes-log-schema.json +101 -0
  89. package/.claude/skills/run-quality-gate/SKILL.md +404 -0
  90. package/.claude/skills/run-quality-gate/gate-mappings.json +97 -0
  91. package/.claude/skills/validate-plan-file/SKILL.md +327 -0
  92. package/.claude/skills/validate-plan-file/schema.json +35 -0
  93. package/.claude/skills/validate-report-file/SKILL.md +256 -0
  94. package/.claude/skills/validate-report-file/schema.json +67 -0
  95. package/.env.example +49 -0
  96. package/.github/BRANCH_PROTECTION.md +137 -0
  97. package/.github/workflows/build.yml +70 -0
  98. package/.github/workflows/claude-code-review.yml +255 -0
  99. package/.github/workflows/claude.yml +79 -0
  100. package/.github/workflows/deploy-staging.yml +90 -0
  101. package/.github/workflows/test.yml +104 -0
  102. package/.gitignore +116 -0
  103. package/CLAUDE.md +137 -0
  104. package/LICENSE +72 -0
  105. package/README.md +1098 -0
  106. package/docs/ARCHITECTURE.md +746 -0
  107. package/docs/Agents Ecosystem/AGENT-ORCHESTRATION.md +568 -0
  108. package/docs/Agents Ecosystem/AI-AGENT-ECOSYSTEM-README.md +658 -0
  109. package/docs/Agents Ecosystem/ARCHITECTURE.md +606 -0
  110. package/docs/Agents Ecosystem/QUALITY-GATES-SPECIFICATION.md +1315 -0
  111. package/docs/Agents Ecosystem/REPORT-TEMPLATE-STANDARD.md +1324 -0
  112. package/docs/Agents Ecosystem/spec-kit-comprehensive-updates.md +478 -0
  113. package/docs/FAQ.md +572 -0
  114. package/docs/MIGRATION-GUIDE.md +542 -0
  115. package/docs/PERFORMANCE-OPTIMIZATION.md +494 -0
  116. package/docs/ROADMAP.md +439 -0
  117. package/docs/TUTORIAL-CUSTOM-AGENTS.md +2041 -0
  118. package/docs/USE-CASES.md +706 -0
  119. package/index.js +96 -0
  120. package/mcp/.mcp.base.json +21 -0
  121. package/mcp/.mcp.frontend.json +29 -0
  122. package/mcp/.mcp.full.json +67 -0
  123. package/mcp/.mcp.local.example.json +7 -0
  124. package/mcp/.mcp.local.json +7 -0
  125. package/mcp/.mcp.n8n.json +45 -0
  126. package/mcp/.mcp.supabase-full.json +35 -0
  127. package/mcp/.mcp.supabase-only.json +28 -0
  128. package/package.json +78 -0
  129. package/postinstall.js +71 -0
  130. package/switch-mcp.sh +101 -0
@@ -0,0 +1,1315 @@
1
+ # Quality Gates Specification
2
+
3
+ **Date Created**: 2025-10-16
4
+ **Phase**: 2 - Task 2.4
5
+ **Status**: Complete
6
+ **Context**: Master Agent Ecosystem Refactoring
7
+
8
+ ---
9
+
10
+ ## Executive Summary
11
+
12
+ This document defines **Quality Gates** for all orchestrated workflows in our Claude Code project. Quality Gates are validation checkpoints that ensure work meets quality standards before proceeding to the next phase.
13
+
14
+ **Key Principle**: Block progression on critical failures, warn on non-critical issues.
15
+
16
+ **Source**: Research from vanzan01/claude-code-sub-agent-collective
17
+
18
+ ---
19
+
20
+ ## Table of Contents
21
+
22
+ 1. [What Are Quality Gates?](#what-are-quality-gates)
23
+ 2. [Gate Types](#gate-types)
24
+ 3. [Domain-Specific Gates](#domain-specific-gates)
25
+ 4. [Implementation Pattern](#implementation-pattern)
26
+ 5. [Thresholds and Metrics](#thresholds-and-metrics)
27
+ 6. [Failure Handling](#failure-handling)
28
+ 7. [Override Mechanisms](#override-mechanisms)
29
+
30
+ ---
31
+
32
+ ## What Are Quality Gates?
33
+
34
+ ### Definition
35
+
36
+ A **Quality Gate** is a validation checkpoint between workflow phases that:
37
+ - Verifies phase completion
38
+ - Checks quality metrics against thresholds
39
+ - Blocks progression if critical criteria fail
40
+ - Warns if non-critical criteria fail
41
+ - Provides clear pass/fail status
42
+
43
+ ### Purpose
44
+
45
+ Quality Gates ensure:
46
+ 1. **Quality**: Work meets minimum standards before progressing
47
+ 2. **Safety**: Critical failures are caught early
48
+ 3. **Visibility**: Users see validation results explicitly
49
+ 4. **Control**: Users can override with explicit confirmation
50
+
51
+ ### Gate Structure
52
+
53
+ Every Quality Gate has:
54
+
55
+ ```yaml
56
+ gate_name:
57
+ phase: N
58
+ description: "What this gate validates"
59
+
60
+ blocking_criteria:
61
+ - criterion: "Specific check"
62
+ command: "Command to verify"
63
+ threshold: "Pass threshold"
64
+ failure_action: "What to do if fails"
65
+
66
+ non_blocking_criteria:
67
+ - criterion: "Best practice check"
68
+ command: "Command to verify"
69
+ warning: "Warning message if fails"
70
+
71
+ on_failure:
72
+ - "Step 1 for recovery"
73
+ - "Step 2 for recovery"
74
+ - "User override option"
75
+ ```
76
+
77
+ ---
78
+
79
+ ## Gate Types
80
+
81
+ ### Type 1: Blocking Gates
82
+
83
+ **Characteristics**:
84
+ - ⛔ STOPS workflow progression if criteria fail
85
+ - Used for critical quality standards
86
+ - Requires user intervention (fix or skip)
87
+ - Logged with high severity
88
+
89
+ **Examples**:
90
+ - Type check failures
91
+ - Build failures
92
+ - Critical test failures
93
+ - Critical security vulnerabilities
94
+ - RLS policies missing
95
+
96
+ **User Experience**:
97
+ ```
98
+ ⛔ Quality Gate BLOCKED: Phase 2 Validation
99
+
100
+ ❌ Type Check: FAILED
101
+ - 5 type errors in src/components/
102
+ - See output above for details
103
+
104
+ ❌ Build: FAILED
105
+ - Compilation error in src/utils/version.ts
106
+
107
+ Action Required:
108
+ 1. Fix the errors listed above
109
+ 2. Re-run the orchestrator to retry
110
+
111
+ Or: Type "skip" to proceed anyway (not recommended)
112
+ ```
113
+
114
+ ### Type 2: Non-Blocking Gates
115
+
116
+ **Characteristics**:
117
+ - ⚠️ WARNS but allows progression
118
+ - Used for best practices and recommendations
119
+ - Logged in summary report
120
+ - User can address later
121
+
122
+ **Examples**:
123
+ - Performance benchmarks below target
124
+ - Code coverage below 80%
125
+ - Non-critical security issues
126
+ - Documentation incomplete
127
+ - Code style violations
128
+
129
+ **User Experience**:
130
+ ```
131
+ ⚠️ Quality Gate Warning: Phase 2 Validation
132
+
133
+ ✅ Type Check: PASSED
134
+ ✅ Build: PASSED
135
+ ⚠️ Code Coverage: 72% (target: 80%)
136
+ ⚠️ Performance: Response time 350ms (target: 200ms)
137
+
138
+ Workflow will continue, but please address warnings:
139
+ - Increase test coverage to 80%
140
+ - Optimize response time to meet target
141
+ ```
142
+
143
+ ---
144
+
145
+ ## Domain-Specific Gates
146
+
147
+ ### Bugs Domain
148
+
149
+ #### Gate 1: Detection Complete
150
+
151
+ **Phase**: After bug-hunter execution
152
+
153
+ **Blocking Criteria**:
154
+ ```yaml
155
+ - criterion: "Report file exists"
156
+ command: "test -f bug-hunting-report.md"
157
+ threshold: "File exists"
158
+ failure_action: "Report bug-hunter failure, ask to retry"
159
+
160
+ - criterion: "Report is well-formed"
161
+ command: "grep -q '## Executive Summary' bug-hunting-report.md"
162
+ threshold: "Contains required sections"
163
+ failure_action: "Report format error, ask bug-hunter to regenerate"
164
+
165
+ - criterion: "Validation status is PASSED"
166
+ command: "grep -q 'Validation.*PASSED' bug-hunting-report.md"
167
+ threshold: "PASSED status present"
168
+ failure_action: "Bug detection validation failed, review report"
169
+ ```
170
+
171
+ **Non-Blocking Criteria**:
172
+ ```yaml
173
+ - criterion: "High-priority bugs documented"
174
+ warning: "No high-priority bugs found - verify thoroughness"
175
+
176
+ - criterion: "Bug patterns identified"
177
+ warning: "No patterns identified - consider deeper analysis"
178
+ ```
179
+
180
+ **Pass Threshold**: All blocking criteria met
181
+
182
+ **On Failure**:
183
+ 1. ⛔ STOP - Do not proceed to Phase 2 (Bug Fixing)
184
+ 2. Report which criteria failed with details
185
+ 3. Show error messages from commands
186
+ 4. Ask user: "Fix issues and retry bug-hunter? (y/N)"
187
+ 5. If "N": Exit workflow with error summary
188
+
189
+ ---
190
+
191
+ #### Gate 2: Fixes Applied
192
+
193
+ **Phase**: After bug-fixer execution
194
+
195
+ **Blocking Criteria**:
196
+ ```yaml
197
+ - criterion: "Type check passes"
198
+ command: "pnpm type-check"
199
+ threshold: "Exit code 0, no errors"
200
+ failure_action: "Fixes introduced new type errors"
201
+
202
+ - criterion: "Build succeeds"
203
+ command: "pnpm build"
204
+ threshold: "Exit code 0, no errors"
205
+ failure_action: "Fixes broke the build"
206
+
207
+ - criterion: "Fixes report exists"
208
+ command: "test -f bug-fixing-report.md"
209
+ threshold: "File exists"
210
+ failure_action: "Bug-fixer didn't generate report"
211
+
212
+ - criterion: "Critical bugs fixed"
213
+ command: "grep -q 'Critical.*Fixed' bug-fixing-report.md"
214
+ threshold: "All critical bugs addressed"
215
+ failure_action: "Critical bugs remain unfixed"
216
+ ```
217
+
218
+ **Non-Blocking Criteria**:
219
+ ```yaml
220
+ - criterion: "Tests pass"
221
+ command: "pnpm test"
222
+ warning: "Some tests failing - review test failures"
223
+
224
+ - criterion: "Linting passes"
225
+ command: "pnpm lint"
226
+ warning: "Linting issues remain"
227
+ ```
228
+
229
+ **Pass Threshold**: All blocking criteria met
230
+
231
+ **On Failure**:
232
+ 1. ⛔ STOP - Do not proceed to Phase 3 (Verification)
233
+ 2. Report which criteria failed
234
+ 3. Show command output
235
+ 4. Ask user: "Rollback changes and retry? (y/N)"
236
+ 5. If "N": Ask "Skip validation and continue? (not recommended)"
237
+
238
+ ---
239
+
240
+ #### Gate 3: Verification
241
+
242
+ **Phase**: After bug-hunter verification scan
243
+
244
+ **Blocking Criteria**:
245
+ ```yaml
246
+ - criterion: "Zero critical bugs remain"
247
+ command: "grep -q 'Critical.*0' bug-hunting-report.md"
248
+ threshold: "0 critical bugs"
249
+ failure_action: "Critical bugs still present after fixes"
250
+
251
+ - criterion: "Type check still passes"
252
+ command: "pnpm type-check"
253
+ threshold: "Exit code 0"
254
+ failure_action: "Type check regressed"
255
+
256
+ - criterion: "Build still succeeds"
257
+ command: "pnpm build"
258
+ threshold: "Exit code 0"
259
+ failure_action: "Build regressed"
260
+ ```
261
+
262
+ **Non-Blocking Criteria**:
263
+ ```yaml
264
+ - criterion: "Zero high-priority bugs remain"
265
+ warning: "High-priority bugs still present"
266
+
267
+ - criterion: "No new bugs introduced"
268
+ warning: "New bugs detected by verification scan"
269
+ ```
270
+
271
+ **Pass Threshold**: All blocking criteria met
272
+
273
+ ---
274
+
275
+ ### Security Domain
276
+
277
+ #### Gate 1: Audit Complete
278
+
279
+ **Phase**: After security-scanner execution
280
+
281
+ **Blocking Criteria**:
282
+ ```yaml
283
+ - criterion: "Report file exists"
284
+ command: "test -f security-audit-report.md"
285
+ threshold: "File exists"
286
+ failure_action: "Security scanner didn't complete"
287
+
288
+ - criterion: "Report is well-formed"
289
+ command: "grep -q '## Executive Summary' security-audit-report.md"
290
+ threshold: "Contains required sections"
291
+ failure_action: "Report format error"
292
+
293
+ - criterion: "Vulnerabilities categorized"
294
+ command: "grep -E '(Critical|High|Medium|Low)' security-audit-report.md"
295
+ threshold: "Categories present"
296
+ failure_action: "Vulnerabilities not properly categorized"
297
+
298
+ - criterion: "Validation status is PASSED"
299
+ command: "grep -q 'Validation.*PASSED' security-audit-report.md"
300
+ threshold: "PASSED status present"
301
+ failure_action: "Security scan validation failed"
302
+ ```
303
+
304
+ **Non-Blocking Criteria**:
305
+ ```yaml
306
+ - criterion: "Zero critical vulnerabilities"
307
+ warning: "Critical vulnerabilities found - immediate attention required"
308
+
309
+ - criterion: "RLS policies reviewed"
310
+ warning: "RLS policy review incomplete"
311
+ ```
312
+
313
+ **Pass Threshold**: All blocking criteria met
314
+
315
+ ---
316
+
317
+ #### Gate 2: Critical Fixes Applied
318
+
319
+ **Phase**: After vulnerability-fixer execution (critical only)
320
+
321
+ **Blocking Criteria**:
322
+ ```yaml
323
+ - criterion: "RLS policies added/fixed"
324
+ command: "grep -q 'RLS.*Fixed' security-fixing-report.md"
325
+ threshold: "RLS issues addressed"
326
+ failure_action: "RLS policies not fixed"
327
+
328
+ - criterion: "Authentication fixed"
329
+ command: "grep -q 'Authentication.*Fixed' security-fixing-report.md"
330
+ threshold: "Auth issues addressed"
331
+ failure_action: "Authentication vulnerabilities remain"
332
+
333
+ - criterion: "Credentials secured"
334
+ command: "! grep -r 'password.*=.*[\"']' src/ --exclude-dir=node_modules"
335
+ threshold: "No hardcoded credentials"
336
+ failure_action: "Hardcoded credentials still present"
337
+
338
+ - criterion: "Type check passes"
339
+ command: "pnpm type-check"
340
+ threshold: "Exit code 0"
341
+ failure_action: "Security fixes broke type check"
342
+
343
+ - criterion: "Build succeeds"
344
+ command: "pnpm build"
345
+ threshold: "Exit code 0"
346
+ failure_action: "Security fixes broke build"
347
+ ```
348
+
349
+ **Non-Blocking Criteria**:
350
+ ```yaml
351
+ - criterion: "npm audit clean"
352
+ command: "npm audit --audit-level=critical"
353
+ warning: "Critical npm vulnerabilities remain"
354
+
355
+ - criterion: "Input validation added"
356
+ warning: "Input validation improvements incomplete"
357
+ ```
358
+
359
+ **Pass Threshold**: All blocking criteria met
360
+
361
+ ---
362
+
363
+ #### Gate 3: Verification
364
+
365
+ **Phase**: After security-scanner verification scan
366
+
367
+ **Blocking Criteria**:
368
+ ```yaml
369
+ - criterion: "Zero critical vulnerabilities"
370
+ command: "grep -q 'Critical.*0' security-audit-report.md"
371
+ threshold: "0 critical vulnerabilities"
372
+ failure_action: "Critical vulnerabilities still present"
373
+
374
+ - criterion: "No new vulnerabilities introduced"
375
+ command: "Compare previous vs current vulnerability count"
376
+ threshold: "Count not increased"
377
+ failure_action: "Fixes introduced new vulnerabilities"
378
+ ```
379
+
380
+ **Non-Blocking Criteria**:
381
+ ```yaml
382
+ - criterion: "High-priority vulnerabilities reduced"
383
+ warning: "High-priority vulnerabilities still present"
384
+ ```
385
+
386
+ **Pass Threshold**: All blocking criteria met
387
+
388
+ ---
389
+
390
+ ### Dead-Code Domain
391
+
392
+ #### Gate 1: Detection Complete
393
+
394
+ **Phase**: After dead-code-hunter execution
395
+
396
+ **Blocking Criteria**:
397
+ ```yaml
398
+ - criterion: "Report file exists"
399
+ command: "test -f dead-code-report.md"
400
+ threshold: "File exists"
401
+ failure_action: "Dead-code hunter didn't complete"
402
+
403
+ - criterion: "Report is well-formed"
404
+ command: "grep -q '## Executive Summary' dead-code-report.md"
405
+ threshold: "Contains required sections"
406
+ failure_action: "Report format error"
407
+
408
+ - criterion: "Dead code categorized"
409
+ command: "grep -E '(Unused|Unreachable|Commented)' dead-code-report.md"
410
+ threshold: "Categories present"
411
+ failure_action: "Dead code not properly categorized"
412
+ ```
413
+
414
+ **Non-Blocking Criteria**:
415
+ ```yaml
416
+ - criterion: "Dead code detected"
417
+ warning: "No dead code found - verify scan was thorough"
418
+ ```
419
+
420
+ **Pass Threshold**: All blocking criteria met
421
+
422
+ ---
423
+
424
+ #### Gate 2: Cleanup Applied
425
+
426
+ **Phase**: After dead-code-remover execution
427
+
428
+ **Blocking Criteria**:
429
+ ```yaml
430
+ - criterion: "Build succeeds"
431
+ command: "pnpm build"
432
+ threshold: "Exit code 0"
433
+ failure_action: "Dead code removal broke build"
434
+
435
+ - criterion: "Type check passes"
436
+ command: "pnpm type-check"
437
+ threshold: "Exit code 0"
438
+ failure_action: "Dead code removal broke type check"
439
+
440
+ - criterion: "Cleanup report exists"
441
+ command: "test -f dead-code-cleanup-report.md"
442
+ threshold: "File exists"
443
+ failure_action: "Dead-code remover didn't generate report"
444
+
445
+ - criterion: "Files removed documented"
446
+ command: "grep -q 'Files Removed' dead-code-cleanup-report.md"
447
+ threshold: "Removal stats present"
448
+ failure_action: "Cleanup stats missing"
449
+ ```
450
+
451
+ **Non-Blocking Criteria**:
452
+ ```yaml
453
+ - criterion: "Tests still pass"
454
+ command: "pnpm test"
455
+ warning: "Some tests failing after cleanup"
456
+
457
+ - criterion: "No new dead code"
458
+ warning: "Cleanup introduced new dead code"
459
+ ```
460
+
461
+ **Pass Threshold**: All blocking criteria met
462
+
463
+ ---
464
+
465
+ #### Gate 3: Verification
466
+
467
+ **Phase**: After dead-code-hunter verification scan
468
+
469
+ **Blocking Criteria**:
470
+ ```yaml
471
+ - criterion: "Build still succeeds"
472
+ command: "pnpm build"
473
+ threshold: "Exit code 0"
474
+ failure_action: "Build regressed"
475
+
476
+ - criterion: "No new dead code detected"
477
+ command: "Compare previous vs current dead code count"
478
+ threshold: "Count not increased"
479
+ failure_action: "Cleanup incomplete or introduced new dead code"
480
+ ```
481
+
482
+ **Pass Threshold**: All blocking criteria met
483
+
484
+ ---
485
+
486
+ ### Dependencies Domain
487
+
488
+ #### Gate 1: Audit Complete
489
+
490
+ **Phase**: After dependency-auditor execution
491
+
492
+ **Blocking Criteria**:
493
+ ```yaml
494
+ - criterion: "Report file exists"
495
+ command: "test -f dependency-audit-report.md"
496
+ threshold: "File exists"
497
+ failure_action: "Dependency auditor didn't complete"
498
+
499
+ - criterion: "Report is well-formed"
500
+ command: "grep -q '## Executive Summary' dependency-audit-report.md"
501
+ threshold: "Contains required sections"
502
+ failure_action: "Report format error"
503
+
504
+ - criterion: "Dependencies categorized"
505
+ command: "grep -E '(Outdated|Vulnerable|Unused)' dependency-audit-report.md"
506
+ threshold: "Categories present"
507
+ failure_action: "Dependencies not properly categorized"
508
+ ```
509
+
510
+ **Non-Blocking Criteria**:
511
+ ```yaml
512
+ - criterion: "Zero critical CVEs"
513
+ warning: "Critical CVEs found - immediate update required"
514
+
515
+ - criterion: "Dependencies reasonably current"
516
+ warning: "Many outdated dependencies - consider updates"
517
+ ```
518
+
519
+ **Pass Threshold**: All blocking criteria met
520
+
521
+ ---
522
+
523
+ #### Gate 2: Updates Applied
524
+
525
+ **Phase**: After dependency-updater execution (critical only)
526
+
527
+ **Blocking Criteria**:
528
+ ```yaml
529
+ - criterion: "Critical CVEs patched"
530
+ command: "npm audit --audit-level=critical"
531
+ threshold: "Exit code 0 or <5 critical"
532
+ failure_action: "Critical CVEs still present"
533
+
534
+ - criterion: "package.json updated"
535
+ command: "git diff --exit-code package.json"
536
+ threshold: "File modified (exit code 1)"
537
+ failure_action: "No updates applied to package.json"
538
+
539
+ - criterion: "Dependencies installed"
540
+ command: "test -d node_modules"
541
+ threshold: "Directory exists"
542
+ failure_action: "npm install not run"
543
+
544
+ - criterion: "Build succeeds"
545
+ command: "pnpm build"
546
+ threshold: "Exit code 0"
547
+ failure_action: "Updates broke build"
548
+
549
+ - criterion: "Type check passes"
550
+ command: "pnpm type-check"
551
+ threshold: "Exit code 0"
552
+ failure_action: "Updates broke type check"
553
+ ```
554
+
555
+ **Non-Blocking Criteria**:
556
+ ```yaml
557
+ - criterion: "Tests pass"
558
+ command: "pnpm test"
559
+ warning: "Some tests failing after updates"
560
+
561
+ - criterion: "No breaking changes"
562
+ warning: "Major version updates may have breaking changes"
563
+ ```
564
+
565
+ **Pass Threshold**: All blocking criteria met
566
+
567
+ ---
568
+
569
+ #### Gate 3: Verification
570
+
571
+ **Phase**: After dependency-auditor verification scan
572
+
573
+ **Blocking Criteria**:
574
+ ```yaml
575
+ - criterion: "npm audit clean (critical)"
576
+ command: "npm audit --audit-level=critical"
577
+ threshold: "<5 critical CVEs"
578
+ failure_action: "Critical CVEs remain"
579
+
580
+ - criterion: "Build still succeeds"
581
+ command: "pnpm build"
582
+ threshold: "Exit code 0"
583
+ failure_action: "Build regressed"
584
+ ```
585
+
586
+ **Non-Blocking Criteria**:
587
+ ```yaml
588
+ - criterion: "All CVEs addressed"
589
+ command: "npm audit"
590
+ warning: "Some non-critical CVEs remain"
591
+ ```
592
+
593
+ **Pass Threshold**: All blocking criteria met
594
+
595
+ ---
596
+
597
+ ## Implementation Pattern
598
+
599
+ ### Orchestrator Integration
600
+
601
+ Quality Gates are implemented in orchestrator prompts:
602
+
603
+ ```markdown
604
+ ## Phase 2: Quality Gate - {Phase Name}
605
+
606
+ ### Blocking Validation
607
+
608
+ Run the following checks (exit if any fail):
609
+
610
+ 1. **Check 1: {Criterion}**
611
+ ```bash
612
+ {command}
613
+ ```
614
+ Expected: {threshold}
615
+ If fails: ⛔ STOP - {failure_action}
616
+
617
+ 2. **Check 2: {Criterion}**
618
+ ```bash
619
+ {command}
620
+ ```
621
+ Expected: {threshold}
622
+ If fails: ⛔ STOP - {failure_action}
623
+
624
+ ### Non-Blocking Validation
625
+
626
+ Run the following checks (warn if any fail):
627
+
628
+ 1. **Check 1: {Criterion}**
629
+ ```bash
630
+ {command}
631
+ ```
632
+ Expected: {threshold}
633
+ If fails: ⚠️ WARNING - {warning}
634
+
635
+ ### Gate Result
636
+
637
+ If ALL blocking criteria pass:
638
+ ✅ Quality Gate PASSED - Proceeding to Phase {N+1}
639
+ Update TodoWrite: Mark Phase {N} complete
640
+
641
+ If ANY blocking criterion fails:
642
+ ⛔ Quality Gate BLOCKED - Workflow stopped
643
+ Update TodoWrite: Mark Phase {N} failed
644
+ Report to user:
645
+ "Quality Gate blocked on Phase {N}.
646
+
647
+ Failed criteria:
648
+ - {criterion1}: {details}
649
+ - {criterion2}: {details}
650
+
651
+ Actions:
652
+ 1. Fix the issues listed above
653
+ 2. Re-run orchestrator to retry
654
+
655
+ Or: Type 'skip' to bypass validation (not recommended)"
656
+
657
+ If non-blocking criteria fail:
658
+ Add warnings to summary report
659
+ Continue to next phase
660
+ ```
661
+
662
+ ---
663
+
664
+ ## Thresholds and Metrics
665
+
666
+ ### Numeric Thresholds
667
+
668
+ | Domain | Metric | Blocking Threshold | Non-Blocking Target |
669
+ |--------|--------|-------------------|---------------------|
670
+ | **Bugs** | Critical bugs | 0 | 0 |
671
+ | **Bugs** | High-priority bugs | N/A | 0 |
672
+ | **Bugs** | Type errors | 0 | 0 |
673
+ | **Security** | Critical CVEs | <5 | 0 |
674
+ | **Security** | High CVEs | N/A | <10 |
675
+ | **Security** | Missing RLS policies | 0 | 0 |
676
+ | **Dependencies** | Critical CVEs | <5 | 0 |
677
+ | **Dependencies** | Outdated (major) | N/A | <3 |
678
+ | **Code Quality** | Build success | 100% | 100% |
679
+ | **Code Quality** | Type check success | 100% | 100% |
680
+ | **Code Quality** | Test pass rate | N/A | >90% |
681
+ | **Code Quality** | Code coverage | N/A | >80% |
682
+
683
+ ### Threshold Philosophy
684
+
685
+ **Blocking Thresholds**:
686
+ - Set at level where failure causes immediate problems
687
+ - Type errors, build failures → Always blocking
688
+ - Critical security issues → Always blocking
689
+ - Critical bugs → Always blocking
690
+
691
+ **Non-Blocking Targets**:
692
+ - Set at aspirational level
693
+ - Best practices, code quality → Non-blocking
694
+ - Performance, coverage → Non-blocking
695
+ - User can address over time
696
+
697
+ ---
698
+
699
+ ## Failure Handling
700
+
701
+ ### Failure Response Flow
702
+
703
+ ```
704
+ 1. Quality Gate runs validation checks
705
+
706
+ 2. Check fails
707
+
708
+ 3. Capture failure details:
709
+ - Which criterion failed
710
+ - Command output
711
+ - Expected vs actual
712
+
713
+ 4. Determine severity:
714
+ - Blocking → STOP workflow
715
+ - Non-blocking → Log warning, continue
716
+
717
+ 5. Report to user:
718
+ - Show failure details
719
+ - Provide corrective actions
720
+ - Offer override option (blocking only)
721
+
722
+ 6. Wait for user decision:
723
+ - Fix: Exit workflow, user fixes, reruns
724
+ - Skip: Add warning to summary, continue
725
+ - Abort: Exit workflow with error
726
+ ```
727
+
728
+ ### Error Message Template
729
+
730
+ **Blocking Failure**:
731
+ ```
732
+ ⛔ QUALITY GATE BLOCKED: Phase {N} - {Gate Name}
733
+
734
+ Failed Criteria:
735
+
736
+ ❌ {Criterion 1}
737
+ Command: {command}
738
+ Expected: {threshold}
739
+ Actual: {actual_output}
740
+ Details: {error_message}
741
+
742
+ ❌ {Criterion 2}
743
+ Command: {command}
744
+ Expected: {threshold}
745
+ Actual: {actual_output}
746
+ Details: {error_message}
747
+
748
+ Corrective Actions:
749
+ 1. {Action 1}
750
+ 2. {Action 2}
751
+ 3. Re-run orchestrator after fixes
752
+
753
+ Override:
754
+ Type "skip" to bypass validation (NOT RECOMMENDED - may cause issues)
755
+ ```
756
+
757
+ **Non-Blocking Warning**:
758
+ ```
759
+ ⚠️ QUALITY GATE WARNING: Phase {N} - {Gate Name}
760
+
761
+ Warning Criteria:
762
+
763
+ ⚠️ {Criterion 1}
764
+ Command: {command}
765
+ Expected: {target}
766
+ Actual: {actual_output}
767
+ Recommendation: {recommendation}
768
+
769
+ ⚠️ {Criterion 2}
770
+ Command: {command}
771
+ Expected: {target}
772
+ Actual: {actual_output}
773
+ Recommendation: {recommendation}
774
+
775
+ Workflow will continue. Please address warnings in future iterations.
776
+ ```
777
+
778
+ ---
779
+
780
+ ## Override Mechanisms
781
+
782
+ ### When to Allow Override
783
+
784
+ **Blocking Gates CAN be overridden when**:
785
+ - User explicitly requests "skip"
786
+ - User accepts responsibility for potential issues
787
+ - Situation is time-sensitive or urgent
788
+ - User has expert knowledge of why it's safe
789
+
790
+ **Blocking Gates CANNOT be overridden when**:
791
+ - Security critical (e.g., RLS policies, authentication)
792
+ - Data safety critical (e.g., destructive operations)
793
+ - System stability critical (e.g., build must succeed for deploy)
794
+
795
+ ### Override Process
796
+
797
+ 1. **User Requests Override**:
798
+ ```
799
+ User: "skip validation"
800
+ ```
801
+
802
+ 2. **Orchestrator Confirms**:
803
+ ```
804
+ ⚠️ WARNING: Skipping Quality Gate
805
+
806
+ You are bypassing blocking validation:
807
+ - {Criterion 1}: FAILED
808
+ - {Criterion 2}: FAILED
809
+
810
+ This may cause:
811
+ - {Risk 1}
812
+ - {Risk 2}
813
+
814
+ Are you sure? Type "confirm skip" to proceed.
815
+ ```
816
+
817
+ 3. **User Confirms**:
818
+ ```
819
+ User: "confirm skip"
820
+ ```
821
+
822
+ 4. **Orchestrator Logs and Continues**:
823
+ ```
824
+ ⚠️ Quality Gate OVERRIDDEN by user
825
+
826
+ Adding to summary report:
827
+ - Phase {N} validation was SKIPPED
828
+ - Risks: {risks}
829
+ - User accepted responsibility
830
+
831
+ Proceeding to Phase {N+1}...
832
+ ```
833
+
834
+ ### Override Logging
835
+
836
+ All overrides are logged in:
837
+ 1. **TodoWrite**: Warning marker on phase
838
+ 2. **Summary Report**: Dedicated "Overrides" section
839
+ 3. **Console Output**: Clear warning banner
840
+
841
+ **Summary Report Section**:
842
+ ```markdown
843
+ ## ⚠️ Quality Gate Overrides
844
+
845
+ ### Phase 2: Bug Fixing Validation (SKIPPED)
846
+
847
+ **Failed Criteria**:
848
+ - Type check: 3 errors
849
+ - Build: 1 error
850
+
851
+ **Risks Accepted**:
852
+ - May introduce runtime errors
853
+ - May break downstream code
854
+
855
+ **User Decision**: Accepted override on 2025-10-16 14:30:00
856
+ ```
857
+
858
+ ---
859
+
860
+ ## Testing Quality Gates
861
+
862
+ ### Unit Testing (Per Gate)
863
+
864
+ Test each gate criterion individually:
865
+
866
+ ```bash
867
+ # Test blocking criterion
868
+ {command}
869
+ if [ $? -ne 0 ]; then
870
+ echo "✅ Gate correctly blocks on failure"
871
+ else
872
+ echo "❌ Gate should block but didn't"
873
+ fi
874
+
875
+ # Test non-blocking criterion
876
+ {command}
877
+ if [ $? -ne 0 ]; then
878
+ echo "✅ Gate correctly warns on failure"
879
+ # Verify workflow continues
880
+ else
881
+ echo "✅ Gate passes"
882
+ fi
883
+ ```
884
+
885
+ ### Integration Testing (With Orchestrators)
886
+
887
+ Test gates within orchestrator workflows:
888
+
889
+ ```bash
890
+ # Create failing condition
891
+ echo "Introduce type error in src/test.ts"
892
+
893
+ # Run orchestrator
894
+ /health bugs
895
+
896
+ # Expected: Gate blocks at Phase 2
897
+ # Expected: Error message shows type error details
898
+ # Expected: Offers fix/skip options
899
+
900
+ # Fix the error
901
+ "Fix type error"
902
+
903
+ # Re-run orchestrator
904
+ /health bugs
905
+
906
+ # Expected: Gate passes
907
+ # Expected: Workflow continues to Phase 3
908
+ ```
909
+
910
+ ### Validation Checklist
911
+
912
+ For each Quality Gate:
913
+ - [ ] Blocking criteria defined
914
+ - [ ] Non-blocking criteria defined
915
+ - [ ] Thresholds are testable
916
+ - [ ] Commands are correct
917
+ - [ ] Failure actions are clear
918
+ - [ ] Override mechanism works
919
+ - [ ] Logging captures details
920
+ - [ ] Integration tested with orchestrator
921
+
922
+ ---
923
+
924
+ ## Maintenance
925
+
926
+ ### Updating Thresholds
927
+
928
+ **When to Update**:
929
+ - Project quality improves → Raise thresholds
930
+ - Thresholds too strict → Lower thresholds
931
+ - New tools available → Add criteria
932
+ - Old tools deprecated → Remove criteria
933
+
934
+ **Process**:
935
+ 1. Propose threshold change in issue/PR
936
+ 2. Document rationale
937
+ 3. Update this specification
938
+ 4. Update affected orchestrators
939
+ 5. Test with realistic scenarios
940
+ 6. Announce change to team
941
+
942
+ ### Adding New Gates
943
+
944
+ **When to Add**:
945
+ - New domain orchestrators added
946
+ - New phases added to existing orchestrators
947
+ - New validation tools become available
948
+
949
+ **Process**:
950
+ 1. Define gate following template
951
+ 2. Identify blocking vs non-blocking criteria
952
+ 3. Set thresholds based on team standards
953
+ 4. Document in this specification
954
+ 5. Implement in orchestrator
955
+ 6. Test thoroughly
956
+
957
+ ---
958
+
959
+ **Document Status**: Complete - Ready for Phase 4 Implementation
960
+ **Next Phase**: Phase 3 - Implementation Planning
961
+
962
+ ---
963
+
964
+ ## Custom Quality Gates
965
+
966
+ **Added**: 2025-10-18 (Phase 4 - Task 4.3)
967
+
968
+ Custom quality gates allow projects to add domain-specific validation beyond the standard gates (type-check, build, tests, lint).
969
+
970
+ ### Using Custom Gates
971
+
972
+ Use the **run-quality-gate** Skill with `gate="custom"`:
973
+
974
+ ```markdown
975
+ Use run-quality-gate Skill:
976
+ - gate: "custom"
977
+ - custom_command: "your-command-here"
978
+ - blocking: true|false
979
+ ```
980
+
981
+ ### Common Custom Gates
982
+
983
+ #### 1. Bundle Size Check
984
+
985
+ **Purpose**: Ensure production bundle stays within size limits
986
+
987
+ **Configuration**:
988
+ ```json
989
+ {
990
+ "gate": "custom",
991
+ "custom_command": "npm run check-bundle-size",
992
+ "blocking": false
993
+ }
994
+ ```
995
+
996
+ **Example Script** (package.json):
997
+ ```json
998
+ {
999
+ "scripts": {
1000
+ "check-bundle-size": "bundlewatch --config .bundlewatch.json"
1001
+ }
1002
+ }
1003
+ ```
1004
+
1005
+ **.bundlewatch.json**:
1006
+ ```json
1007
+ {
1008
+ "files": [
1009
+ {
1010
+ "path": "dist/bundle.js",
1011
+ "maxSize": "500kb"
1012
+ }
1013
+ ]
1014
+ }
1015
+ ```
1016
+
1017
+ **Interpretation**:
1018
+ - ✅ Pass: Bundle size < 500KB
1019
+ - ⛔ Fail (non-blocking): Bundle size > 500KB, warn user
1020
+ - Action: Review bundle contents, remove unused imports
1021
+
1022
+ ---
1023
+
1024
+ #### 2. Performance Benchmark (Lighthouse CI)
1025
+
1026
+ **Purpose**: Validate performance metrics for critical pages
1027
+
1028
+ **Configuration**:
1029
+ ```json
1030
+ {
1031
+ "gate": "custom",
1032
+ "custom_command": "npm run lighthouse-ci",
1033
+ "blocking": false
1034
+ }
1035
+ ```
1036
+
1037
+ **Example Script** (package.json):
1038
+ ```json
1039
+ {
1040
+ "scripts": {
1041
+ "lighthouse-ci": "lhci autorun --config=lighthouserc.json"
1042
+ }
1043
+ }
1044
+ ```
1045
+
1046
+ **lighthouserc.json**:
1047
+ ```json
1048
+ {
1049
+ "ci": {
1050
+ "collect": {
1051
+ "url": ["http://localhost:3000/"],
1052
+ "numberOfRuns": 3
1053
+ },
1054
+ "assert": {
1055
+ "assertions": {
1056
+ "categories:performance": ["error", {"minScore": 0.9}],
1057
+ "categories:accessibility": ["warn", {"minScore": 0.9}]
1058
+ }
1059
+ }
1060
+ }
1061
+ }
1062
+ ```
1063
+
1064
+ **Interpretation**:
1065
+ - ✅ Pass: Performance score > 90, Accessibility > 90
1066
+ - ⚠️ Warn: Accessibility < 90 (non-blocking)
1067
+ - ⛔ Fail: Performance < 90 (non-blocking, but should investigate)
1068
+
1069
+ ---
1070
+
1071
+ #### 3. Security Scan (npm audit)
1072
+
1073
+ **Purpose**: Check for high/critical vulnerabilities in dependencies
1074
+
1075
+ **Configuration**:
1076
+ ```json
1077
+ {
1078
+ "gate": "custom",
1079
+ "custom_command": "npm audit --audit-level=high",
1080
+ "blocking": true
1081
+ }
1082
+ ```
1083
+
1084
+ **Interpretation**:
1085
+ - ✅ Pass: No high/critical vulnerabilities
1086
+ - ⛔ Fail (blocking): High/critical vulnerabilities found, MUST fix before merging
1087
+
1088
+ ---
1089
+
1090
+ #### 4. Code Coverage
1091
+
1092
+ **Purpose**: Ensure test coverage meets minimum threshold
1093
+
1094
+ **Configuration**:
1095
+ ```json
1096
+ {
1097
+ "gate": "custom",
1098
+ "custom_command": "npm run test:coverage -- --coverage-threshold=80",
1099
+ "blocking": false
1100
+ }
1101
+ ```
1102
+
1103
+ **Example Script** (package.json):
1104
+ ```json
1105
+ {
1106
+ "scripts": {
1107
+ "test:coverage": "jest --coverage"
1108
+ }
1109
+ }
1110
+ ```
1111
+
1112
+ **jest.config.js**:
1113
+ ```javascript
1114
+ module.exports = {
1115
+ coverageThresholds: {
1116
+ global: {
1117
+ branches: 80,
1118
+ functions: 80,
1119
+ lines: 80,
1120
+ statements: 80
1121
+ }
1122
+ }
1123
+ }
1124
+ ```
1125
+
1126
+ **Interpretation**:
1127
+ - ✅ Pass: Coverage > 80% for all metrics
1128
+ - ⚠️ Warn: Coverage < 80% (non-blocking, but should improve)
1129
+
1130
+ ---
1131
+
1132
+ #### 5. API Contract Validation
1133
+
1134
+ **Purpose**: Ensure API responses match OpenAPI/GraphQL schema
1135
+
1136
+ **Configuration**:
1137
+ ```json
1138
+ {
1139
+ "gate": "custom",
1140
+ "custom_command": "npm run validate-api-contracts",
1141
+ "blocking": true
1142
+ }
1143
+ ```
1144
+
1145
+ **Example Script**:
1146
+ ```bash
1147
+ #!/bin/bash
1148
+ # validate-api-contracts.sh
1149
+
1150
+ # Start test server
1151
+ npm run start:test &
1152
+ SERVER_PID=$!
1153
+
1154
+ # Wait for server
1155
+ sleep 5
1156
+
1157
+ # Run validation
1158
+ npx @openapitools/openapi-generator-cli validate -i openapi.yaml
1159
+
1160
+ EXIT_CODE=$?
1161
+
1162
+ # Cleanup
1163
+ kill $SERVER_PID
1164
+
1165
+ exit $EXIT_CODE
1166
+ ```
1167
+
1168
+ **Interpretation**:
1169
+ - ✅ Pass: API responses match schema
1170
+ - ⛔ Fail (blocking): Schema mismatch, fix before merging
1171
+
1172
+ ---
1173
+
1174
+ #### 6. Accessibility Audit (axe-core)
1175
+
1176
+ **Purpose**: Check for accessibility violations
1177
+
1178
+ **Configuration**:
1179
+ ```json
1180
+ {
1181
+ "gate": "custom",
1182
+ "custom_command": "npm run test:a11y",
1183
+ "blocking": false
1184
+ }
1185
+ ```
1186
+
1187
+ **Example Script** (package.json):
1188
+ ```json
1189
+ {
1190
+ "scripts": {
1191
+ "test:a11y": "jest --testMatch='**/*.a11y.test.ts'"
1192
+ }
1193
+ }
1194
+ ```
1195
+
1196
+ **Example Test** (Home.a11y.test.ts):
1197
+ ```typescript
1198
+ import { axe, toHaveNoViolations } from 'jest-axe'
1199
+ import { render } from '@testing-library/react'
1200
+ import Home from './Home'
1201
+
1202
+ expect.extend(toHaveNoViolations)
1203
+
1204
+ test('Home page should have no accessibility violations', async () => {
1205
+ const { container } = render(<Home />)
1206
+ const results = await axe(container)
1207
+ expect(results).toHaveNoViolations()
1208
+ })
1209
+ ```
1210
+
1211
+ **Interpretation**:
1212
+ - ✅ Pass: No accessibility violations
1213
+ - ⚠️ Warn: Violations found (non-blocking, should fix)
1214
+
1215
+ ---
1216
+
1217
+ ### Creating Custom Gate Scripts
1218
+
1219
+ **Location**: `.claude/scripts/gates/{gate-name}.sh`
1220
+
1221
+ **Template**:
1222
+ ```bash
1223
+ #!/bin/bash
1224
+ # .claude/scripts/gates/{gate-name}.sh
1225
+
1226
+ set -e
1227
+
1228
+ echo "Running {gate-name} validation..."
1229
+
1230
+ # Your validation logic here
1231
+ # Example: Check file exists
1232
+ if [ ! -f "required-file.txt" ]; then
1233
+ echo "Error: required-file.txt not found"
1234
+ exit 1
1235
+ fi
1236
+
1237
+ # Example: Run command and check output
1238
+ OUTPUT=$(your-command 2>&1)
1239
+ if echo "$OUTPUT" | grep -q "ERROR"; then
1240
+ echo "Validation failed: $OUTPUT"
1241
+ exit 1
1242
+ fi
1243
+
1244
+ echo "✅ {gate-name} validation passed"
1245
+ exit 0
1246
+ ```
1247
+
1248
+ **Usage in Orchestrator**:
1249
+ ```markdown
1250
+ Use run-quality-gate Skill:
1251
+ - gate: "custom"
1252
+ - custom_command: "bash .claude/scripts/gates/my-gate.sh"
1253
+ - blocking: true
1254
+ ```
1255
+
1256
+ ---
1257
+
1258
+ ### Custom Gate Best Practices
1259
+
1260
+ 1. **Make Scripts Idempotent**: Scripts should produce same result when run multiple times
1261
+ 2. **Fast Execution**: Custom gates should complete in < 5 minutes
1262
+ 3. **Clear Output**: Print clear success/failure messages
1263
+ 4. **Exit Codes**: Use 0 for success, non-zero for failure
1264
+ 5. **Dependencies**: Document required tools in gate script comments
1265
+ 6. **Thresholds**: Make thresholds configurable via environment variables
1266
+
1267
+ **Example with Configurable Threshold**:
1268
+ ```bash
1269
+ #!/bin/bash
1270
+ BUNDLE_SIZE_LIMIT=${BUNDLE_SIZE_LIMIT:-500000} # Default 500KB
1271
+
1272
+ ACTUAL_SIZE=$(wc -c < dist/bundle.js)
1273
+
1274
+ if [ "$ACTUAL_SIZE" -gt "$BUNDLE_SIZE_LIMIT" ]; then
1275
+ echo "Bundle size ($ACTUAL_SIZE bytes) exceeds limit ($BUNDLE_SIZE_LIMIT bytes)"
1276
+ exit 1
1277
+ fi
1278
+
1279
+ echo "✅ Bundle size OK: $ACTUAL_SIZE bytes (limit: $BUNDLE_SIZE_LIMIT bytes)"
1280
+ exit 0
1281
+ ```
1282
+
1283
+ ---
1284
+
1285
+ ### Integration with Orchestrators
1286
+
1287
+ Orchestrators can use custom gates in their quality gate phases:
1288
+
1289
+ **Example** (bug-orchestrator):
1290
+ ```markdown
1291
+ ## Phase 4: Quality Gate - Custom Validations
1292
+
1293
+ Use run-quality-gate Skill with these custom gates:
1294
+
1295
+ 1. Bundle size check (non-blocking):
1296
+ - gate: "custom"
1297
+ - custom_command: "npm run check-bundle-size"
1298
+ - blocking: false
1299
+
1300
+ 2. Security audit (blocking):
1301
+ - gate: "custom"
1302
+ - custom_command: "npm audit --audit-level=high"
1303
+ - blocking: true
1304
+
1305
+ If any blocking gate fails:
1306
+ - STOP workflow
1307
+ - Report failure to user
1308
+ - Provide fix instructions
1309
+ - Ask: "Fix issues or skip validation?"
1310
+ ```
1311
+
1312
+ ---
1313
+
1314
+ **Custom Gates Status**: Documented and Ready for Use
1315
+ **Next Steps**: Teams can add project-specific custom gates as needed