@massu/core 0.5.0 → 0.6.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 (118) hide show
  1. package/README.md +40 -0
  2. package/agents/massu-architecture-reviewer.md +104 -0
  3. package/agents/massu-blast-radius-analyzer.md +84 -0
  4. package/agents/massu-competitive-scorer.md +126 -0
  5. package/agents/massu-help-sync.md +73 -0
  6. package/agents/massu-migration-writer.md +94 -0
  7. package/agents/massu-output-scorer.md +87 -0
  8. package/agents/massu-pattern-reviewer.md +84 -0
  9. package/agents/massu-plan-auditor.md +170 -0
  10. package/agents/massu-schema-sync-verifier.md +70 -0
  11. package/agents/massu-security-reviewer.md +98 -0
  12. package/agents/massu-ux-reviewer.md +106 -0
  13. package/commands/_shared-preamble.md +53 -23
  14. package/commands/_shared-references/auto-learning-protocol.md +71 -0
  15. package/commands/_shared-references/blast-radius-protocol.md +76 -0
  16. package/commands/_shared-references/security-pre-screen.md +64 -0
  17. package/commands/_shared-references/test-first-protocol.md +87 -0
  18. package/commands/_shared-references/verification-table.md +52 -0
  19. package/commands/massu-article-review.md +343 -0
  20. package/commands/massu-autoresearch/references/eval-runner.md +84 -0
  21. package/commands/massu-autoresearch/references/safety-rails.md +125 -0
  22. package/commands/massu-autoresearch/references/scoring-protocol.md +151 -0
  23. package/commands/massu-autoresearch.md +258 -0
  24. package/commands/massu-batch.md +44 -12
  25. package/commands/massu-bearings.md +42 -8
  26. package/commands/massu-checkpoint.md +588 -0
  27. package/commands/massu-ci-fix.md +2 -2
  28. package/commands/massu-command-health.md +132 -0
  29. package/commands/massu-command-improve.md +232 -0
  30. package/commands/massu-commit.md +205 -44
  31. package/commands/massu-create-plan.md +239 -57
  32. package/commands/massu-data/references/common-queries.md +79 -0
  33. package/commands/massu-data/references/table-guide.md +50 -0
  34. package/commands/massu-data.md +66 -0
  35. package/commands/massu-dead-code.md +29 -34
  36. package/commands/massu-debug/references/auto-learning.md +61 -0
  37. package/commands/massu-debug/references/codegraph-tracing.md +80 -0
  38. package/commands/massu-debug/references/common-shortcuts.md +98 -0
  39. package/commands/massu-debug/references/investigation-phases.md +294 -0
  40. package/commands/massu-debug/references/report-format.md +107 -0
  41. package/commands/massu-debug.md +105 -386
  42. package/commands/massu-docs.md +1 -1
  43. package/commands/massu-full-audit.md +61 -0
  44. package/commands/massu-gap-enhancement-analyzer.md +276 -16
  45. package/commands/massu-golden-path/references/approval-points.md +216 -0
  46. package/commands/massu-golden-path/references/competitive-mode.md +273 -0
  47. package/commands/massu-golden-path/references/error-handling.md +121 -0
  48. package/commands/massu-golden-path/references/phase-0-requirements.md +53 -0
  49. package/commands/massu-golden-path/references/phase-1-plan-creation.md +168 -0
  50. package/commands/massu-golden-path/references/phase-2-implementation.md +397 -0
  51. package/commands/massu-golden-path/references/phase-2.5-gap-analyzer.md +156 -0
  52. package/commands/massu-golden-path/references/phase-3-simplify.md +40 -0
  53. package/commands/massu-golden-path/references/phase-4-commit.md +94 -0
  54. package/commands/massu-golden-path/references/phase-5-push.md +116 -0
  55. package/commands/massu-golden-path/references/phase-5.5-production-verify.md +170 -0
  56. package/commands/massu-golden-path/references/phase-6-completion.md +113 -0
  57. package/commands/massu-golden-path/references/qa-evaluator-spec.md +137 -0
  58. package/commands/massu-golden-path/references/sprint-contract-protocol.md +117 -0
  59. package/commands/massu-golden-path/references/vr-visual-calibration.md +73 -0
  60. package/commands/massu-golden-path.md +114 -848
  61. package/commands/massu-guide.md +72 -69
  62. package/commands/massu-hooks.md +27 -12
  63. package/commands/massu-hotfix.md +221 -144
  64. package/commands/massu-incident.md +49 -20
  65. package/commands/massu-infra-audit.md +187 -0
  66. package/commands/massu-learning-audit.md +211 -0
  67. package/commands/massu-loop/references/auto-learning.md +49 -0
  68. package/commands/massu-loop/references/checkpoint-audit.md +40 -0
  69. package/commands/massu-loop/references/guardrails.md +17 -0
  70. package/commands/massu-loop/references/iteration-structure.md +115 -0
  71. package/commands/massu-loop/references/loop-controller.md +188 -0
  72. package/commands/massu-loop/references/plan-extraction.md +78 -0
  73. package/commands/massu-loop/references/vr-plan-spec.md +140 -0
  74. package/commands/massu-loop-playwright.md +9 -9
  75. package/commands/massu-loop.md +115 -670
  76. package/commands/massu-new-pattern.md +423 -0
  77. package/commands/massu-perf.md +422 -0
  78. package/commands/massu-plan-audit.md +1 -1
  79. package/commands/massu-plan.md +389 -122
  80. package/commands/massu-production-verify.md +433 -0
  81. package/commands/massu-push.md +62 -378
  82. package/commands/massu-recap.md +29 -3
  83. package/commands/massu-rollback.md +613 -0
  84. package/commands/massu-scaffold-hook.md +2 -4
  85. package/commands/massu-scaffold-page.md +2 -3
  86. package/commands/massu-scaffold-router.md +1 -2
  87. package/commands/massu-security.md +619 -0
  88. package/commands/massu-simplify.md +115 -85
  89. package/commands/massu-squirrels.md +2 -2
  90. package/commands/massu-tdd.md +38 -22
  91. package/commands/massu-test.md +3 -3
  92. package/commands/massu-type-mismatch-audit.md +469 -0
  93. package/commands/massu-ui-audit.md +587 -0
  94. package/commands/massu-verify-playwright.md +287 -32
  95. package/commands/massu-verify.md +150 -46
  96. package/dist/cli.js +146 -95
  97. package/package.json +6 -2
  98. package/patterns/build-patterns.md +302 -0
  99. package/patterns/component-patterns.md +246 -0
  100. package/patterns/display-patterns.md +185 -0
  101. package/patterns/form-patterns.md +890 -0
  102. package/patterns/integration-testing-checklist.md +445 -0
  103. package/patterns/security-patterns.md +219 -0
  104. package/patterns/testing-patterns.md +569 -0
  105. package/patterns/tool-routing.md +81 -0
  106. package/patterns/ui-patterns.md +371 -0
  107. package/protocols/plan-implementation.md +267 -0
  108. package/protocols/recovery.md +225 -0
  109. package/protocols/verification.md +404 -0
  110. package/reference/command-taxonomy.md +178 -0
  111. package/reference/cr-rules-reference.md +76 -0
  112. package/reference/hook-execution-order.md +148 -0
  113. package/reference/lessons-learned.md +175 -0
  114. package/reference/patterns-quickref.md +208 -0
  115. package/reference/standards.md +135 -0
  116. package/reference/subagents-reference.md +17 -0
  117. package/reference/vr-verification-reference.md +867 -0
  118. package/src/commands/install-commands.ts +149 -53
@@ -0,0 +1,178 @@
1
+ # Command Taxonomy
2
+
3
+ Categorization of all commands into the 9-type taxonomy from "Lessons from Building Claude Code: How We Use Skills."
4
+
5
+ ## Categories
6
+
7
+ | # | Category | Description |
8
+ |---|----------|-------------|
9
+ | 1 | Library & API Reference | Shared knowledge, patterns, specifications |
10
+ | 2 | Verification | Validation, testing, quality gates |
11
+ | 3 | Data Fetching & Analysis | Database queries, metrics, analytics |
12
+ | 4 | Business Process & Team Automation | Workflows, session management, orchestration |
13
+ | 5 | Code Scaffolding & Templates | File generation, boilerplate, format templates |
14
+ | 6 | Code Review | Quality analysis, simplification, auditing |
15
+ | 7 | Deployment | Push, release, hotfix, rollback |
16
+ | 8 | Investigation | Debugging, incident response, root cause analysis |
17
+ | 9 | Infrastructure Operations | Dependencies, hooks, dead code, configuration |
18
+
19
+ ---
20
+
21
+ ## Full Mapping
22
+
23
+ ### 1. Library & API Reference (2)
24
+
25
+ | Command | Purpose |
26
+ |---------|---------|
27
+ | `_shared-preamble` | Shared preamble injected into all commands |
28
+ | `massu-guide` | User onboarding and system documentation |
29
+
30
+ ### 2. Verification (6)
31
+
32
+ | Command | Purpose |
33
+ |---------|---------|
34
+ | `massu-verify` | Run verification requirements (VR-*) |
35
+ | `massu-checkpoint` | Mid-implementation checkpoint audit |
36
+ | `massu-loop-playwright` | Browser-based E2E verification loop |
37
+ | `massu-verify-playwright` | Single-page browser verification |
38
+ | `massu-test` | Run test suites |
39
+ | `massu-tdd` | Test-driven development workflow |
40
+
41
+ ### 3. Data Fetching & Analysis (3)
42
+
43
+ | Command | Purpose |
44
+ |---------|---------|
45
+ | `massu-parity` | Cross-environment schema parity check |
46
+ | `massu-gap-enhancement-analyzer` | Gap and enhancement analysis from reports |
47
+ | `massu-data` | Database analytics and query library |
48
+
49
+ ### 4. Business Process & Team Automation (6)
50
+
51
+ | Command | Purpose |
52
+ |---------|---------|
53
+ | `massu-golden-path` | Full autonomous plan-to-push pipeline |
54
+ | `massu-bearings` | Morning session orientation |
55
+ | `massu-recap` | End-of-session handoff |
56
+ | `massu-squirrels` | Park tangential ideas mid-task |
57
+ | `massu-create-plan` | Plan creation from requirements |
58
+ | `massu-plan` | Plan audit for gaps |
59
+
60
+ ### 5. Code Scaffolding & Templates (6)
61
+
62
+ | Command | Purpose |
63
+ |---------|---------|
64
+ | `format-supabase-migration` | SQL migration file template |
65
+ | `format-trpc-router` | tRPC router file template |
66
+ | `massu-scaffold-page` | New page scaffolding |
67
+ | `massu-scaffold-router` | New tRPC router scaffolding |
68
+ | `massu-scaffold-hook` | New hook scaffolding |
69
+ | `massu-scaffold-mcp` | New MCP integration scaffolding |
70
+
71
+ ### 6. Code Review (9)
72
+
73
+ | Command | Purpose |
74
+ |---------|---------|
75
+ | `massu-simplify` | Post-change multi-reviewer quality analysis |
76
+ | `massu-commit` | Pre-commit verification gates |
77
+ | `massu-article-review` | External article/post analysis |
78
+ | `massu-command-health` | Command quality dashboard |
79
+ | `massu-command-improve` | Improve a specific command |
80
+ | `massu-codebase-audit` | Full codebase quality audit |
81
+ | `massu-ui-audit` | UI/UX quality audit |
82
+ | `massu-feature-audit` | Feature completeness audit |
83
+ | `massu-extended-audit` | Extended multi-dimension audit |
84
+
85
+ ### 7. Deployment (4)
86
+
87
+ | Command | Purpose |
88
+ |---------|---------|
89
+ | `massu-push` | Push with pre-push verification |
90
+ | `massu-push-light` | Lightweight push (fewer checks) |
91
+ | `massu-hotfix` | Emergency production fix pipeline |
92
+ | `massu-rollback` | Deployment rollback |
93
+
94
+ ### 8. Investigation (2)
95
+
96
+ | Command | Purpose |
97
+ |---------|---------|
98
+ | `massu-debug` | Structured bug investigation with auto-learning |
99
+ | `massu-incident` | Incident documentation and response protocol |
100
+
101
+ ### 9. Infrastructure Operations (12)
102
+
103
+ | Command | Purpose |
104
+ |---------|---------|
105
+ | `massu-deps` | Dependency health audit |
106
+ | `massu-hooks` | Hook system inventory |
107
+ | `massu-dead-code` | Dead code detection and removal |
108
+ | `massu-ai-models` | AI model configuration audit |
109
+ | `massu-batch` | Parallel code-only migrations |
110
+ | `massu-config-audit` | Configuration consistency audit |
111
+ | `massu-db-audit` | Database health audit |
112
+ | `massu-db-branch` | Database branching operations |
113
+ | `massu-import-audit` | Import chain analysis |
114
+ | `massu-infra-audit` | Infrastructure audit |
115
+ | `massu-migrate` | Code migration assistant |
116
+ | `massu-session-optimization` | Session context optimization |
117
+
118
+ ### Cross-Cutting Orchestration (6)
119
+
120
+ | Command | Purpose |
121
+ |---------|---------|
122
+ | `massu-loop` | Plan implementation loop |
123
+ | `massu-new-feature` | New feature workflow |
124
+ | `massu-new-pattern` | New pattern documentation |
125
+ | `massu-rebuild` | Feature rebuild with parity |
126
+ | `massu-refactor` | Refactoring workflow |
127
+ | `massu-learning-audit` | Learning pipeline audit |
128
+
129
+ ### Specialized (9)
130
+
131
+ | Command | Purpose |
132
+ |---------|---------|
133
+ | `massu-api-contract` | API contract validation |
134
+ | `massu-docs` | Documentation generation |
135
+ | `massu-mobile-research` | Mobile platform research |
136
+ | `massu-perf` | Performance analysis |
137
+ | `massu-plan-audit` | Plan audit (subset of massu-plan) |
138
+ | `massu-security` | Security audit |
139
+ | `massu-type-mismatch-audit` | TypeScript type mismatch detection |
140
+ | `careful` | Session-scoped destructive command blocking |
141
+ | `freeze` | Session-scoped edit directory restriction |
142
+
143
+ ---
144
+
145
+ ## Coverage Analysis
146
+
147
+ | Category | Count | Coverage |
148
+ |----------|-------|----------|
149
+ | 1. Library & API Reference | 2 | Thin -- relies on pattern files in `patterns/` and `specs/` |
150
+ | 2. Verification | 6 | Strong |
151
+ | 3. Data Fetching & Analysis | 3 | Moderate |
152
+ | 4. Business Process | 6 | Strong |
153
+ | 5. Code Scaffolding | 6 | Strong |
154
+ | 6. Code Review | 9 | Very Strong |
155
+ | 7. Deployment | 4 | Strong |
156
+ | 8. Investigation | 2 | Adequate -- high quality per command |
157
+ | 9. Infrastructure Ops | 12 | Very Strong |
158
+
159
+ ### Coverage Gaps
160
+
161
+ 1. **Library & API Reference**: Relies on pattern files rather than dedicated commands. The `_shared-preamble` + `massu-guide` cover basics, but specific API reference skills could be useful as standalone lookups. **Recommendation**: Low priority -- pattern files serve this role well.
162
+
163
+ 2. **Data Fetching & Analysis**: Could benefit from a dedicated analytics/dashboard skill. **Recommendation**: Monitor usage of `massu-data` before expanding.
164
+
165
+ 3. **Investigation**: Only 2 commands but both are comprehensive folder-based skills. Quality over quantity. **Recommendation**: No action needed.
166
+
167
+ ---
168
+
169
+ ## Folder-Based Skills
170
+
171
+ Commands that have been migrated to folder-based structure for progressive disclosure:
172
+
173
+ | Command | Files | Scripts |
174
+ |---------|-------|---------|
175
+ | `massu-golden-path/` | Reference docs | -- |
176
+ | `massu-debug/` | Reference docs | Diagnostic scripts |
177
+ | `massu-loop/` | Reference docs | -- |
178
+ | `massu-data/` | Reference docs | SQL scripts |
@@ -0,0 +1,76 @@
1
+ # Canonical Rules (CR) — Full Reference
2
+
3
+ All CR rules with verification types and reference links.
4
+
5
+ | ID | Rule | Verification Type | Reference |
6
+ |----|------|-------------------|-----------|
7
+ | CR-1 | Never claim state without proof | VR-* | [protocols/verification.md](../protocols/verification.md) |
8
+ | CR-2 | Never assume database schema | VR-SCHEMA | [protocols/verification.md](../protocols/verification.md) |
9
+ | CR-3 | Never commit secrets | git status check | Incident records |
10
+ | CR-4 | Verify removals with negative grep | VR-NEGATIVE | [protocols/plan-implementation.md](../protocols/plan-implementation.md) |
11
+ | CR-5 | ALL secrets MUST use secure credential management | VR-SECRETS | [patterns/security-patterns.md](../patterns/security-patterns.md) |
12
+ | CR-6 | Read plan file, not memory | Plan file open | [protocols/plan-implementation.md](../protocols/plan-implementation.md) |
13
+ | CR-7 | Check ALL items in plan, not "most" | VR-COUNT | [protocols/plan-implementation.md](../protocols/plan-implementation.md) |
14
+ | CR-8 | Created components MUST be rendered | VR-RENDER | Incident records |
15
+ | CR-9 | Fix ALL issues encountered, whether from current changes or pre-existing | VR-FIX-ALL | Incident records |
16
+ | CR-10 | Plan document MUST have completion status | VR-PLAN-STATUS | [protocols/plan-implementation.md](../protocols/plan-implementation.md) |
17
+ | CR-11 | NEVER stop loop until 100% plan coverage | VR-PLAN-COVERAGE | Implementation loop protocol |
18
+ | CR-12 | After compaction, NEVER escalate beyond AUTHORIZED_COMMAND | VR-PROTOCOL | [protocols/recovery.md](../protocols/recovery.md) |
19
+ | CR-13 | Plan UI specs MUST match implementation | VR-PLAN-SPEC | [protocols/plan-implementation.md](../protocols/plan-implementation.md) |
20
+ | CR-14 | ALL solutions MUST be enterprise-grade | Design review | [protocols/verification.md](../protocols/verification.md) |
21
+ | CR-15 | Edge Runtime files MUST NOT import Node.js deps | VR-EDGE | [patterns/build-patterns.md](../patterns/build-patterns.md) |
22
+ | CR-16 | Native/heavy packages MUST be externalized | VR-EXTERN | [patterns/build-patterns.md](../patterns/build-patterns.md) |
23
+ | CR-17 | ALWAYS fix ALL issues encountered | VR-FIX | [protocols/verification.md](../protocols/verification.md) |
24
+ | CR-18 | Import chains MUST NOT pull heavy deps | VR-IMPORT | [patterns/build-patterns.md](../patterns/build-patterns.md) |
25
+ | CR-19 | Builds MUST have ZERO warnings | VR-LINT | [patterns/build-patterns.md](../patterns/build-patterns.md) |
26
+ | CR-20 | ALL tests MUST pass before claiming complete | VR-TEST | [protocols/verification.md](../protocols/verification.md) |
27
+ | CR-21 | Database configs MUST match code expectations | VR-DATA | [protocols/verification.md](../protocols/verification.md) |
28
+ | CR-22 | Backend procedures MUST be called from UI | VR-COUPLING | [protocols/verification.md](../protocols/verification.md) |
29
+ | CR-23 | ALL protocol commands MUST be followed exactly | VR-PROTOCOL | Incident records |
30
+ | CR-24 | Changing values requires codebase-wide blast radius analysis | VR-BLAST-RADIUS | Plan creation protocol |
31
+ | CR-25 | Before editing UI, verify file serves target URL | VR-ROUTE | Incident records |
32
+ | CR-26 | After table migrations, audit ALL stored procedures | VR-STORED-PROC | Incident records |
33
+ | CR-27 | Config map lookups MUST have fallback defaults for dynamic keys | VR-CONFIG-GUARD | Incident records |
34
+ | CR-28 | Rebuilds MUST audit old implementation for feature parity BEFORE deleting | VR-PARITY | Incident records |
35
+ | CR-29 | ALWAYS propose the most robust, enterprise-grade solution | VR-QUALITY | [protocols/verification.md](../protocols/verification.md) |
36
+ | CR-30 | ALL public tables MUST have RLS enabled | VR-RLS-AUDIT | Incident records |
37
+ | CR-31 | ALL fixes MUST be auto-learned: ingest to memory, record pattern, update scanner | VR-LEARNING | All command protocols |
38
+ | CR-32 | ALL database migrations MUST be applied to ALL environments | VR-SCHEMA-SYNC | Incident records |
39
+ | CR-33 | Stagnating loops MUST bail and replan, not grind | VR-PROTOCOL | Implementation loop protocol |
40
+ | CR-34 | ALL significant work MUST be persisted to memory BEFORE session ends | VR-MEMORY | [protocols/verification.md](../protocols/verification.md) |
41
+ | CR-35 | Propose approach before multi-file changes | VR-APPROACH | [protocols/verification.md](../protocols/verification.md) |
42
+ | CR-36 | ALL overlays MUST use Sheet, NEVER Dialog (except AlertDialog) | VR-UI | Incident records |
43
+ | CR-37 | ALL UI fixes MUST be browser-verified via Playwright before claiming done | VR-BROWSER | Incident records |
44
+ | CR-38 | Plan UI specs (CSS classes, structure, layout) MUST match implementation exactly | VR-SPEC-MATCH | [protocols/verification.md](../protocols/verification.md) |
45
+ | CR-39 | Data pipeline features MUST be triggered end-to-end with non-empty output verified | VR-PIPELINE | [protocols/verification.md](../protocols/verification.md) |
46
+ | CR-40 | After every debug fix, scanner MUST be updated with detection rule for the root cause pattern | VR-LEARNING | Incident records |
47
+ | CR-41 | After context compaction during implementation, re-read plan file from disk and rebuild item tracking before proceeding | VR-PLAN-COVERAGE | Incident records |
48
+ | CR-42 | ALL exported service functions MUST be wired to a consumer (tRPC router, API route, or cron). No half-built features. | VR-UNWIRED | Scanner enforcement |
49
+ | CR-43 | ALL data-writing features MUST be verified write->store->read->display end-to-end before claiming complete | VR-ROUNDTRIP | [reference/vr-verification-reference.md](vr-verification-reference.md) |
50
+
51
+ ---
52
+
53
+ ## Full Core Principles (22)
54
+
55
+ 1. **NO SHORTCUTS** - Quality over speed, always
56
+ 2. **COMPLETE VERIFICATION** - Proof, not claims
57
+ 3. **ZERO ASSUMPTIONS** - Query, don't guess
58
+ 4. **ALL ITEMS** - "Most of them" is not "all of them"
59
+ 5. **NEGATIVE VERIFICATION** - Removals need grep returning 0
60
+ 6. **SESSION STATE** - Record decisions and failures
61
+ 7. **PATTERN COMPLIANCE** - Read patterns, show proof
62
+ 8. **ENHANCEMENT PRINCIPLE** - If it would improve the system, add it NOW (no skipping, no workarounds)
63
+ 9. **ENTERPRISE-GRADE ONLY** - Every solution must be permanent, production-ready, error-free
64
+ 10. **NEVER SKIP** - Solve ALL problems as encountered, never postpone or use stopgaps
65
+ 11. **NEVER STOP EARLY** - Loop continues until 100% plan coverage, no exceptions, no early termination
66
+ 12. **SECRETS SECURED** - All secrets use secure credential management, never plain env vars
67
+ 13. **PROTOCOLS ARE MANDATORY** - Slash commands are execution instructions; reading is not following
68
+ 14. **BLAST RADIUS FIRST** - When changing any value, grep entire codebase before planning; documented sync patterns are necessary but not sufficient
69
+ 15. **CONTEXT HYGIENE** - Use subagents for exploration, /clear between unrelated tasks, update session state before compaction
70
+ 16. **FIX EVERYTHING ENCOUNTERED** - Every issue found during work MUST be fixed immediately, whether from current changes or pre-existing; "not in scope" is never valid
71
+ 17. **MIGRATIONS HIT ALL ENVIRONMENTS** - Every schema change MUST be applied to all environments in the same session; a migration applied to 1 database is incomplete
72
+ 18. **SIMPLEST CORRECT SOLUTION** - When fixing or building, choose the simplest approach that is correct and complete. CR-9 mandates fixing all issues; this principle mandates fixing them simply. If scope expands beyond the original task, flag it before expanding.
73
+ 19. **ELEGANCE CHECK** - For non-trivial changes, pause and ask: "Is there a more elegant way?" If a fix feels hacky, implement the elegant solution. Skip for simple, obvious fixes. Would a staff engineer approve this approach?
74
+ 20. **ONE TASK PER SUBAGENT** - Each spawned agent gets a single focused task. Parallel spawning is encouraged but each agent receives one isolated concern. Never combine unrelated tasks in one spawn.
75
+ 21. **MEMORY IS MANDATORY** - ALL significant decisions, fixes, patterns, errors, config changes, new tools, and architectural learnings MUST be persisted to memory files BEFORE the session ends or /clear. Knowledge lost to session end is unrecoverable.
76
+ 22. **PROPOSE FIRST** - For non-trivial tasks (>2 files, unfamiliar API, multiple valid approaches), propose approach in 2-3 bullets before implementing. Include which existing codebase patterns/utilities to use. Skip for simple fixes with obvious implementations.
@@ -0,0 +1,148 @@
1
+ # Hook Execution Order Reference
2
+
3
+ **Purpose**: Authoritative reference for hook execution ordering across all event types in `.claude/settings.json`.
4
+
5
+ **Scope**: Project hooks only (`.claude/settings.json`). User hooks (`~/.claude/settings.json`) run in a separate pipeline and are not covered here.
6
+
7
+ **Enforcement**: Run `scripts/hooks/validate-hook-order.sh` to verify ordering constraints. Exit 0 = valid.
8
+
9
+ ---
10
+
11
+ ## Ordering Principles
12
+
13
+ 1. **Security-critical hooks run first** -- secret filters, rate limiters, integrity checks
14
+ 2. **Blocking hooks before advisory** -- hooks that can reject/block run before informational ones
15
+ 3. **Data-writing hooks before data-reading hooks** -- producers before consumers
16
+ 4. **Observability hooks run last** -- trackers, advisors, and audit logs
17
+
18
+ ---
19
+
20
+ ## SessionStart (4 hooks)
21
+
22
+ Context initialization -> CR-12 enforcement -> advisories -> security scan.
23
+
24
+ | position: 1 | `session-start.js` | standard | Context initialization, memory injection |
25
+ |---|---|---|---|
26
+ | position: 2 | AUTHORIZED_COMMAND display | critical (inline) | CR-12 enforcement -- must display before any work |
27
+ | position: 3 | `surface-review-findings.sh` | advisory/strict | Surface findings from previous session's auto-review |
28
+ | position: 4 | `memory-integrity-check.sh` | critical (no gate) | Security scan of memory files for anti-patterns |
29
+
30
+ **Dependencies**:
31
+ - `session-start.js` MUST be position 1 -- writes DB state other hooks may read
32
+ - `memory-integrity-check.sh` runs last -- safety net that catches issues regardless of prior hooks
33
+
34
+ ---
35
+
36
+ ## PreToolUse (6 hooks)
37
+
38
+ Security blocking -> advisory warnings -> matcher-specific -> observability.
39
+
40
+ | position: 1 | `pattern-scanner.sh --quick` | standard | Bash(git push) -- block pushes with pattern violations |
41
+ |---|---|---|---|
42
+ | position: 2 | CR-24 blast radius advisory | standard | Edit -- warn on path/route changes |
43
+ | position: 3 | `validate-features.sh` | standard | Bash(git commit) -- validate feature registry before commit |
44
+ | position: 4 | CR-30 deletion sentinel | strict | Bash(rm) -- warn on src/ file deletions |
45
+ | position: 5 | `mcp-rate-limiter.sh` | critical | MCP tools -- rate-limit database queries |
46
+ | position: 6 | `command-invocation-tracker.sh` | standard | Skill -- observability, no blocking |
47
+
48
+ **Dependencies**:
49
+ - `pattern-scanner.sh` should run early -- gates bad pushes before other hooks fire
50
+ - `mcp-rate-limiter.sh` is matcher-specific (MCP only) -- position among Bash hooks is irrelevant
51
+ - `command-invocation-tracker.sh` MUST be last -- pure observability, no blocking
52
+
53
+ ---
54
+
55
+ ## PostToolUse (11 hooks)
56
+
57
+ Security scan -> immediate feedback -> context tracking -> incident capture -> memory sync -> observability.
58
+
59
+ | position: 1 | CI monitor | standard | Bash(git push) -- immediate push feedback |
60
+ |---|---|---|---|
61
+ | position: 2 | `output-secret-filter.sh` | critical | Bash\|Read\|mcp -- scan output for leaked secrets |
62
+ | position: 3 | `pattern-feedback.sh` | standard | Edit\|Write -- immediate pattern violation feedback |
63
+ | position: 4 | `post-edit-context.js` | strict | Edit\|Write -- detailed semantic analysis |
64
+ | position: 5 | `post-tool-use.js` | standard | Edit\|Write\|Bash -- structured context tracking |
65
+ | position: 6 | `auto-ingest-incident.sh` | strict | Edit\|Write -- auto-capture incident patterns |
66
+ | position: 7 | `memory-auto-ingest.sh` | standard | Write -- auto-sync memory files to codegraph SQLite DB |
67
+ | position: 8 | `validate-deliverables.sh` | strict | Bash\|Edit\|Write -- deliverable validation |
68
+ | position: 9 | `pattern-scanner.sh --single-file` | strict | Edit\|Write -- per-file pattern scan |
69
+ | position: 10 | `mcp-usage-tracker.sh` | strict | MCP tools -- append-only MCP audit log |
70
+ | position: 11 | `compaction-advisor.sh` | standard | Bash\|Edit\|Write\|Read\|Grep\|Glob -- context tracking, widest matcher |
71
+
72
+ **Dependencies**:
73
+ - `output-secret-filter.sh` MUST run before any feedback hooks -- security first
74
+ - `pattern-feedback.sh` before `post-tool-use.js` -- immediate feedback before tracking
75
+ - `memory-auto-ingest.sh` runs after incident capture -- memory sync is data-writing, before validation
76
+ - `compaction-advisor.sh` MUST be last -- widest matcher, just counts tool calls
77
+
78
+ ---
79
+
80
+ ## UserPromptSubmit (3 hooks)
81
+
82
+ Prompt tracking -> advisory reminders -> incident detection.
83
+
84
+ | position: 1 | `user-prompt.js` | standard | Prompt tracking and observation capture |
85
+ |---|---|---|---|
86
+ | position: 2 | CR-24 blast radius reminder | standard | Warn on plan commands that may change values |
87
+ | position: 3 | Incident detection | standard | Detect user frustration signals |
88
+
89
+ **Dependencies**:
90
+ - `user-prompt.js` MUST be first -- captures prompt before advisory hooks may modify context
91
+
92
+ ---
93
+
94
+ ## PreCompact (2 hooks)
95
+
96
+ Quick state capture -> full DB snapshot.
97
+
98
+ | position: 1 | Git status + session state | standard (inline) | Quick state capture to stdout |
99
+ |---|---|---|---|
100
+ | position: 2 | `pre-compact.js` | standard | Full session snapshot to memory DB |
101
+
102
+ **Dependencies**:
103
+ - Inline capture runs first (fast) -- provides immediate context
104
+ - `pre-compact.js` runs second -- more thorough but slower DB write
105
+
106
+ ---
107
+
108
+ ## Stop (7 hooks)
109
+
110
+ Session summary -> warnings -> memory extraction -> review -> validation.
111
+
112
+ | position: 1 | `session-end.js` | standard | Write session summary to memory DB |
113
+ |---|---|---|---|
114
+ | position: 2 | Uncommitted changes warning | standard (inline) | Alert user about unstaged work |
115
+ | position: 3 | `memory-auto-extract.sh` | standard | Auto-extract memories from DB observations |
116
+ | position: 4 | `auto-review-on-stop.sh` | strict | Automated code review of session changes |
117
+ | position: 5 | `surface-review-findings.sh` | strict | Display review findings to user |
118
+ | position: 6 | `validate-deliverables.sh` | strict | Final deliverable validation |
119
+ | position: 7 | `pattern-extractor.sh` | advisory | Extract new patterns from session |
120
+
121
+ **Dependencies**:
122
+ - `session-end.js` MUST be position 1 -- writes DB data that `memory-auto-extract.sh` reads
123
+ - `memory-auto-extract.sh` MUST come after `session-end.js` -- depends on DB observations
124
+ - `surface-review-findings.sh` MUST come after `auto-review-on-stop.sh` -- displays its output
125
+ - `pattern-extractor.sh` runs last -- advisory tier (skipped in minimal/standard profiles)
126
+
127
+ ---
128
+
129
+ ## Ordering Constraints (machine-readable)
130
+
131
+ These constraints are validated by `scripts/hooks/validate-hook-order.sh`:
132
+
133
+ ```
134
+ # Format: EVENT:HOOK_A must_precede HOOK_B [reason]
135
+ SessionStart:session-start.js must_precede memory-integrity-check.sh [writes DB state]
136
+ PostToolUse:output-secret-filter.sh must_precede pattern-feedback.sh [security before feedback]
137
+ PostToolUse:output-secret-filter.sh must_precede post-tool-use.js [security before tracking]
138
+ PostToolUse:pattern-feedback.sh must_precede compaction-advisor.sh [feedback before counting]
139
+ Stop:session-end.js must_precede memory-auto-extract.sh [DB write before memory extraction]
140
+ Stop:memory-auto-extract.sh must_precede auto-review-on-stop.sh [memory extraction before code review]
141
+ Stop:auto-review-on-stop.sh must_precede surface-review-findings.sh [generate before display]
142
+ Stop:session-end.js must_precede pattern-extractor.sh [DB write before pattern extraction]
143
+ PreCompact:git_status_inline must_precede pre-compact.js [fast capture before DB write]
144
+ ```
145
+
146
+ ---
147
+
148
+ *Validates against: `.claude/settings.json` hook arrays*
@@ -0,0 +1,175 @@
1
+ # Lessons Learned & Accountability
2
+
3
+ **Part of Prime Directive** | [Back to Main](../CLAUDE.md)
4
+
5
+ ---
6
+
7
+ ## Lessons from Past Failures
8
+
9
+ ### Incident: False "Production Ready" Claim
10
+
11
+ **What Happened:**
12
+ - Claimed "production ready" without running successful build
13
+ - Ignored build timeout instead of investigating
14
+ - Only ran partial checks (audit, lint) not complete verification
15
+ - Exposed OAuth credentials in documentation file
16
+ - Made 98 TypeScript errors to production branch
17
+
18
+ **Root Cause:**
19
+ - Prioritized speed over quality
20
+ - Made assumptions without verification
21
+ - Took shortcuts
22
+ - Over-confident claims without proof
23
+
24
+ **Consequences:**
25
+ - Lost user trust
26
+ - Created security vulnerability
27
+ - Wasted time with false confidence
28
+
29
+ **Lessons:**
30
+ 1. **Never skip verification steps**
31
+ 2. **Build timeout = blocker, not warning**
32
+ 3. **Scan ALL files for secrets**
33
+ 4. **Production ready requires proof, not assumptions**
34
+ 5. **Quality always trumps speed**
35
+
36
+ ---
37
+
38
+ ### Incident: Unverified Push to Production
39
+
40
+ **What Happened:**
41
+ - Pushed code without running full build verification
42
+ - Missed ESLint warnings that blocked deployments
43
+ - Did not trace client component import chains
44
+ - Caused PrismaClient browser environment error in production
45
+ - Application completely broken for all users
46
+
47
+ **Root Cause:**
48
+ - Did not run `npm run build` before pushing previous commit
49
+ - Assumed partial checks (type-check, prevention tests) were sufficient
50
+ - Did not analyze full import graph for client/server separation
51
+ - Did not test production build locally before deploying
52
+
53
+ **Consequences:**
54
+ - 4 consecutive deployment failures
55
+ - GitHub Actions tests failing
56
+ - Production application crashed (blank screen)
57
+ - Zero users could access application
58
+
59
+ **Lessons:**
60
+ 1. **ALWAYS run `npm run build` before pushing** - No exceptions
61
+ 2. **Trace client import chains** - Verify no server code imported
62
+ 3. **Test production build locally** - Run `npm run build && npm start`
63
+ 4. **ESLint warnings = deployment blockers** - Zero tolerance
64
+ 5. **Import chain analysis required** - Client components must not transitively import server code
65
+ 6. **Lazy-loading for external services** - Never instantiate at module load time
66
+
67
+ **Corrective Actions Taken:**
68
+ 1. Created build-patterns.md documenting client/server separation
69
+ 2. Established {domain}-types.ts + {domain}-service.ts pattern
70
+ 3. Implemented lazy-loading for external service clients
71
+ 4. Fixed all ESLint errors and warnings (zero tolerance)
72
+ 5. Verified production build succeeds before pushing
73
+
74
+ **Prevention Measures:**
75
+ 1. Pre-push checklist now includes full build verification
76
+ 2. Documentation updated with build separation patterns
77
+ 3. Verification workflow: TypeScript -> Build -> Prevention Tests -> Commit
78
+ 4. Import chain analysis for new client components
79
+
80
+ ---
81
+
82
+ ### Incident: Pattern Violations Despite Review
83
+
84
+ **What Happened:**
85
+ - Implemented feature with explicit pattern review instructions
86
+ - Read CLAUDE.md and all pattern documents BEFORE planning
87
+ - Updated the plan based on pattern learnings
88
+ - Read CLAUDE.md AGAIN before coding
89
+ - Despite all this, committed code with 7 `include:` violations
90
+ - Used single-bracket query keys
91
+ - Used deprecated toast patterns in multiple files
92
+
93
+ **Root Cause:**
94
+ - Reading patterns is NOT the same as following patterns
95
+ - No enforcement mechanism - only "read and understand"
96
+ - Pattern knowledge decayed during implementation
97
+ - Silent failures masked bugs (hybrid DB ignores `include:`, single brackets silently fail)
98
+ - No automated verification before commits
99
+
100
+ **Consequences:**
101
+ - Products missing relation data in UI
102
+ - Permission changes not reflecting until page refresh
103
+ - Inconsistent patterns across app
104
+ - Wasted significant time and resources on remediation
105
+
106
+ **Lessons:**
107
+ 1. **Reading documentation is not compliance** - Active verification required
108
+ 2. **Silent failures are the worst kind** - `include:` and single brackets fail silently
109
+ 3. **Verification must be automated** - Grep commands catch what review misses
110
+ 4. **Proof over claims** - "I followed the patterns" means nothing without grep results
111
+ 5. **Pattern compliance needs enforcement** - Not just documentation
112
+
113
+ **Corrective Actions Taken:**
114
+ 1. Added mandatory pre-implementation pattern compliance protocol
115
+ 2. Created written checklist requirement before coding
116
+ 3. Added grep-based verification requirement before commits
117
+ 4. Fixed all violations
118
+
119
+ **Prevention Measures:**
120
+ 1. Pre-commit grep audit now MANDATORY for pattern violations
121
+ 2. Pattern references required in implementation plans
122
+ 3. Grep results required as proof of compliance before commits
123
+ 4. **New Rule**: "grep shows zero violations" IS proof, "I read the patterns" IS NOT
124
+
125
+ ---
126
+
127
+ ## Error Response Protocol
128
+
129
+ When encountering errors:
130
+
131
+ 1. **STOP** - Do not proceed
132
+ 2. **INVESTIGATE** - Find root cause
133
+ 3. **FIX** - Implement proper solution (no workarounds)
134
+ 4. **VERIFY** - Confirm fix works
135
+ 5. **DOCUMENT** - Update documentation
136
+ 6. **PREVENT** - Add checks to prevent recurrence
137
+
138
+ **Never ignore, skip, or work around errors.**
139
+
140
+ ---
141
+
142
+ ## Build Timeout Protocol
143
+
144
+ If `npm run build` times out:
145
+
146
+ 1. **DO NOT** assume it's just slow
147
+ 2. **DO NOT** skip to other checks
148
+ 3. **DO** investigate why it's timing out
149
+ 4. **DO** increase timeout and run to completion
150
+ 5. **DO** treat timeout as a blocker
151
+ 6. **DO** fix the underlying issue
152
+
153
+ ---
154
+
155
+ ## Accountability
156
+
157
+ Commitments:
158
+
159
+ 1. **NO SHORTCUTS** - Ever
160
+ 2. **COMPLETE VERIFICATION** - Always
161
+ 3. **HONEST COMMUNICATION** - No exceptions
162
+ 4. **QUALITY OVER SPEED** - Without compromise
163
+ 5. **LEARN FROM MISTAKES** - And prevent recurrence
164
+
165
+ When standards are not met:
166
+ 1. **Admit the failure immediately**
167
+ 2. **Explain what went wrong**
168
+ 3. **Document the lesson learned**
169
+ 4. **Update processes to prevent recurrence**
170
+ 5. **Never make the same mistake twice**
171
+
172
+ ---
173
+
174
+ **Status**: PERMANENT RECORD
175
+ **Reference**: [Main CLAUDE.md](../CLAUDE.md)