start-vibing 2.0.38 → 2.0.40

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "start-vibing",
3
- "version": "2.0.38",
3
+ "version": "2.0.40",
4
4
  "description": "Setup Claude Code agents, skills, and hooks in your project. Smart copy that preserves your custom domains and configurations.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,738 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * UserPromptSubmit Hook - TypeScript version (fallback when Python not available)
3
+ * UserPromptSubmit Hook
4
4
  *
5
- * This hook runs BEFORE Claude processes any user prompt and ENFORCES:
6
- * 1. MANDATORY detailed todo list creation from prompt
7
- * 2. MANDATORY research agent for new features
8
- * 3. STRICT workflow: audit -> branch -> implement -> document -> quality -> merge to main
9
- * 4. Separate UI for mobile/tablet/desktop (NOT just responsive)
10
- *
11
- * AGENT SYSTEM: 82 specialized agents in 14 categories
12
- * SKILL SYSTEM: 22 skills auto-loaded by agents
5
+ * Concise instructions injected before Claude processes each user prompt.
6
+ * Enforces: todo-list creation, sequential execution, commit rules, CLAUDE.md update.
13
7
  */
14
8
 
15
- import { existsSync, readFileSync } from 'fs';
16
- import { join } from 'path';
17
-
18
- const PROJECT_DIR = process.env['CLAUDE_PROJECT_DIR'] || process.cwd();
19
- const WORKFLOW_STATE_PATH = join(PROJECT_DIR, '.claude', 'workflow-state.json');
20
-
21
- const STRICT_WORKFLOW = `
22
- ┌─────────────────────────────────────────────────────────────────┐
23
- │ STRICT WORKFLOW (MANDATORY) │
24
- ├─────────────────────────────────────────────────────────────────┤
25
- │ 0. INIT TASK → Run commit-manager to REGISTER task start │
26
- │ 1. TODO LIST → Create DETAILED todo list from prompt │
27
- │ 2. RESEARCH → Run research agent for NEW features │
28
- │ 3. AUDIT → Check last audit docs OR run fresh audit │
29
- │ 4. BRANCH → Create feature/ | fix/ | refactor/ | test/ │
30
- │ 5. IMPLEMENT → Follow rules + analyzer approval │
31
- │ 6. DOCUMENT → Document ALL modified files (MANDATORY) │
32
- │ 7. UPDATE → Update CLAUDE.md with session changes │
33
- │ 8. QUALITY → typecheck + lint + test (Husky enforced) │
34
- │ 9. VALIDATE → RUN: npx tsx .claude/hooks/stop-validator.ts │
35
- │ 10. FINISH → Only after "ALL CHECKS PASSED" │
36
- └─────────────────────────────────────────────────────────────────┘
37
-
38
- ╔═════════════════════════════════════════════════════════════════╗
39
- ║ ⚠️ MANDATORY: RUN STOP VALIDATOR BEFORE COMPLETING ANY TASK ║
40
- ╠═════════════════════════════════════════════════════════════════╣
41
- ║ ║
42
- ║ COMMAND: npx tsx .claude/hooks/stop-validator.ts ║
43
- ║ ║
44
- ║ YOU MUST run this command manually BEFORE saying "task done". ║
45
- ║ Fix ALL issues one by one. Run validator again after EACH fix.║
46
- ║ Only complete task when output shows "ALL CHECKS PASSED". ║
47
- ║ ║
48
- ╚═════════════════════════════════════════════════════════════════╝
49
-
50
- ⚠️ STOP HOOK BLOCKS task completion if:
51
- - NOT on main branch (work must be merged to main first)
52
- - Git tree NOT clean (all changes must be committed)
53
- - CLAUDE.md NOT updated (must reflect session changes)
54
- - CLAUDE.md missing required sections (Last Change, Stack, etc.)
55
- - CLAUDE.md exceeds 40,000 characters (must compact)
56
- - Source files NOT documented (must run documenter agent)
57
- `;
58
-
59
- // ============================================================================
60
- // AGENT SYSTEM - 82 Specialized Agents in 14 Categories
61
- // ============================================================================
62
-
63
- interface AgentInfo {
64
- triggers: string[];
65
- when: string;
66
- skills: string[];
67
- can_veto?: boolean;
68
- mandatory_for?: string[];
69
- }
70
-
71
- interface CategoryInfo {
72
- description: string;
73
- agents: Record<string, AgentInfo>;
74
- }
75
-
76
- const AGENT_CATEGORIES: Record<string, CategoryInfo> = {
77
- '01-orchestration': {
78
- description: 'Workflow coordination and task management',
79
- agents: {
80
- orchestrator: {
81
- triggers: ['implement feature', 'build', 'create', 'full workflow', 'multi-step'],
82
- when: 'Task requires >2 agents or touches >3 files',
83
- skills: ['codebase-knowledge'],
84
- },
85
- 'task-decomposer': {
86
- triggers: ['complex task', 'break down', 'multiple steps'],
87
- when: 'Task has >3 steps or touches >3 files',
88
- skills: ['codebase-knowledge'],
89
- },
90
- 'workflow-router': {
91
- triggers: ['route', 'which agent', 'unclear'],
92
- when: 'At task start to route to correct agent',
93
- skills: ['codebase-knowledge'],
94
- },
95
- 'parallel-coordinator': {
96
- triggers: ['parallel', 'concurrent', 'simultaneous'],
97
- when: 'Multiple independent agents should run simultaneously',
98
- skills: ['codebase-knowledge'],
99
- },
100
- 'context-manager': {
101
- triggers: ['context', 'compress', 'long conversation'],
102
- when: 'Context grows large or between major phases',
103
- skills: ['codebase-knowledge'],
104
- },
105
- 'checkpoint-manager': {
106
- triggers: ['checkpoint', 'save state', 'backup'],
107
- when: 'BEFORE risky operations (git, deletions, refactors)',
108
- skills: ['codebase-knowledge'],
109
- },
110
- 'error-recovery': {
111
- triggers: ['failed', 'retry', 'timeout', 'unexpected error'],
112
- when: 'An agent fails or returns unexpected results',
113
- skills: ['codebase-knowledge', 'debugging-patterns'],
114
- },
115
- 'agent-selector': {
116
- triggers: ['select agent', 'best agent', 'which agent'],
117
- when: 'Multiple agents could handle a task',
118
- skills: ['codebase-knowledge'],
119
- },
120
- },
121
- },
122
- '02-typescript': {
123
- description: 'TypeScript strict mode, types, and module resolution',
124
- agents: {
125
- 'ts-strict-checker': {
126
- triggers: ['strict mode', 'null check', 'process.env'],
127
- when: 'AFTER editing any .ts file',
128
- skills: ['typescript-strict'],
129
- },
130
- 'ts-types-analyzer': {
131
- triggers: ['type error', 'inference', 'generic problem'],
132
- when: 'On type errors or typecheck fails',
133
- skills: ['typescript-strict'],
134
- },
135
- 'ts-generics-helper': {
136
- triggers: ['generic', 'type parameter', 'complex type'],
137
- when: 'Creating generic functions/types',
138
- skills: ['typescript-strict'],
139
- },
140
- 'ts-migration-helper': {
141
- triggers: ['migrate', 'convert to typescript', '.js'],
142
- when: 'Migrating JavaScript to TypeScript',
143
- skills: ['typescript-strict'],
144
- },
145
- 'type-definition-writer': {
146
- triggers: ['new model', 'new entity', 'interface needed'],
147
- when: 'BEFORE implementing new entities',
148
- skills: ['typescript-strict'],
149
- },
150
- 'import-alias-enforcer': {
151
- triggers: ['import', 'alias', '@types'],
152
- when: 'AFTER editing .ts files - enforces $types/*, @common, @db',
153
- skills: ['typescript-strict'],
154
- },
155
- 'esm-resolver': {
156
- triggers: ['module error', 'import error', 'cannot find module'],
157
- when: 'On module errors',
158
- skills: ['typescript-strict', 'bun-runtime'],
159
- },
160
- 'bun-runtime-expert': {
161
- triggers: ['bun', 'runtime', 'package management'],
162
- when: 'Using Bun runtime',
163
- skills: ['bun-runtime'],
164
- },
165
- 'zod-validator': {
166
- triggers: ['validation', 'zod', 'schema'],
167
- when: 'BEFORE commit when API routes exist',
168
- skills: ['zod-validation'],
169
- },
170
- 'zod-schema-designer': {
171
- triggers: ['new endpoint', 'form input', 'user input'],
172
- when: 'BEFORE implementing any API endpoint',
173
- skills: ['zod-validation', 'typescript-strict'],
174
- },
175
- },
176
- },
177
- '03-testing': {
178
- description: 'Unit tests (Vitest) and E2E tests (Playwright)',
179
- agents: {
180
- 'vitest-config': {
181
- triggers: ['test setup', 'vitest config', 'coverage config'],
182
- when: 'Setting up tests or coverage issues arise',
183
- skills: ['test-coverage'],
184
- },
185
- 'tester-unit': {
186
- triggers: ['unit test', 'function test', 'utility test'],
187
- when: 'AFTER implementing any function or utility',
188
- skills: ['test-coverage'],
189
- },
190
- 'tester-integration': {
191
- triggers: ['integration test', 'api test', 'service test'],
192
- when: 'AFTER implementing API endpoints or services',
193
- skills: ['test-coverage'],
194
- },
195
- 'test-data-generator': {
196
- triggers: ['mock data', 'test fixture', 'factory'],
197
- when: 'BEFORE writing tests that need data',
198
- skills: ['test-coverage'],
199
- },
200
- 'test-cleanup-manager': {
201
- triggers: ['flaky test', 'test isolation', 'state leakage'],
202
- when: 'Tests are flaky or share state',
203
- skills: ['test-coverage'],
204
- },
205
- 'playwright-e2e': {
206
- triggers: ['e2e test', 'user flow', 'end to end'],
207
- when: 'AFTER implementing any user-facing feature',
208
- skills: ['test-coverage', 'playwright-automation'],
209
- },
210
- 'playwright-fixtures': {
211
- triggers: ['fixture', 'shared setup', 'auth helper'],
212
- when: 'Creating E2E tests that need shared setup',
213
- skills: ['test-coverage', 'playwright-automation'],
214
- },
215
- 'playwright-page-objects': {
216
- triggers: ['page object', 'page model', 'page interaction'],
217
- when: 'Creating E2E tests for new pages',
218
- skills: ['test-coverage', 'playwright-automation'],
219
- },
220
- 'playwright-multi-viewport': {
221
- triggers: ['viewport', 'responsive test', 'mobile test'],
222
- when: 'AFTER any UI implementation - tests desktop/tablet/mobile',
223
- skills: ['test-coverage', 'playwright-automation'],
224
- },
225
- 'playwright-assertions': {
226
- triggers: ['assertion', 'expect', 'test validation'],
227
- when: 'Creating comprehensive test assertions',
228
- skills: ['test-coverage', 'playwright-automation'],
229
- },
230
- },
231
- },
232
- '04-docker': {
233
- description: 'Docker containerization and deployment',
234
- agents: {
235
- 'dockerfile-optimizer': {
236
- triggers: ['dockerfile', 'docker build', 'image size'],
237
- when: 'Creating or modifying Dockerfile',
238
- skills: ['docker-patterns'],
239
- },
240
- 'docker-multi-stage': {
241
- triggers: ['multi-stage', 'build optimization', 'production docker'],
242
- when: 'Dockerfile can benefit from multi-stage',
243
- skills: ['docker-patterns'],
244
- },
245
- 'docker-compose-designer': {
246
- triggers: ['docker-compose', 'multi-service', 'local dev'],
247
- when: 'Multi-service setup is needed',
248
- skills: ['docker-patterns'],
249
- },
250
- 'docker-env-manager': {
251
- triggers: ['docker env', 'secrets', 'env vars'],
252
- when: 'Docker uses environment variables',
253
- skills: ['docker-patterns'],
254
- },
255
- 'container-health': {
256
- triggers: ['health check', 'container monitoring', 'service health'],
257
- when: 'Creating Docker containers',
258
- skills: ['docker-patterns'],
259
- },
260
- 'deployment-validator': {
261
- triggers: ['deploy', 'pre-deploy', 'docker validation'],
262
- when: 'BEFORE deploying',
263
- skills: ['docker-patterns'],
264
- },
265
- },
266
- },
267
- '05-database': {
268
- description: 'MongoDB/Mongoose database operations',
269
- agents: {
270
- 'mongoose-schema-designer': {
271
- triggers: ['schema', 'model', 'collection'],
272
- when: 'BEFORE creating any database model',
273
- skills: ['mongoose-patterns'],
274
- },
275
- 'mongoose-index-optimizer': {
276
- triggers: ['index', 'slow query', 'query performance'],
277
- when: 'Database queries are slow',
278
- skills: ['mongoose-patterns'],
279
- },
280
- 'mongoose-aggregation': {
281
- triggers: ['aggregation', 'pipeline', 'reporting'],
282
- when: 'Complex data queries needed',
283
- skills: ['mongoose-patterns'],
284
- },
285
- 'mongodb-query-optimizer': {
286
- triggers: ['n+1', 'query optimizer', 'database performance'],
287
- when: 'Queries are slow',
288
- skills: ['mongoose-patterns'],
289
- },
290
- 'database-seeder': {
291
- triggers: ['seed', 'sample data', 'dev data'],
292
- when: 'Setting up development environment',
293
- skills: ['mongoose-patterns'],
294
- },
295
- 'data-migration': {
296
- triggers: ['migration', 'schema change', 'data transform'],
297
- when: 'Schema changes are needed',
298
- skills: ['mongoose-patterns'],
299
- },
300
- },
301
- },
302
- '06-security': {
303
- description: 'Security auditing and OWASP compliance (CAN VETO)',
304
- agents: {
305
- 'security-auditor': {
306
- triggers: ['security', 'audit', 'vulnerability'],
307
- when: 'BEFORE committing auth/user/API code',
308
- can_veto: true,
309
- skills: ['security-scan'],
310
- },
311
- 'owasp-checker': {
312
- triggers: ['owasp', 'top 10', 'security review'],
313
- when: 'BEFORE committing any API or security code',
314
- can_veto: true,
315
- skills: ['security-scan'],
316
- },
317
- 'input-sanitizer': {
318
- triggers: ['sanitize', 'user input', 'xss'],
319
- when: 'Handling user input',
320
- skills: ['security-scan', 'zod-validation'],
321
- },
322
- 'auth-session-validator': {
323
- triggers: ['auth', 'session', 'login', 'jwt'],
324
- when: 'Implementing auth or session code',
325
- skills: ['security-scan'],
326
- },
327
- 'permission-auditor': {
328
- triggers: ['permission', 'authorization', 'access control'],
329
- when: 'Implementing protected routes',
330
- skills: ['security-scan'],
331
- },
332
- 'sensitive-data-scanner': {
333
- triggers: ['sensitive', 'pii', 'data leak'],
334
- when: 'Implementing API responses or logging',
335
- skills: ['security-scan'],
336
- },
337
- },
338
- },
339
- '07-documentation': {
340
- description: 'Documentation and domain knowledge updates',
341
- agents: {
342
- documenter: {
343
- triggers: ['document', 'docs', 'explain code'],
344
- when: 'AFTER any code implementation completes',
345
- skills: ['docs-tracker', 'codebase-knowledge'],
346
- },
347
- 'domain-updater': {
348
- triggers: ['domain', 'learnings', 'session end'],
349
- when: 'BEFORE commit-manager at session end',
350
- skills: ['codebase-knowledge', 'docs-tracker'],
351
- },
352
- 'readme-generator': {
353
- triggers: ['readme', 'project docs', 'setup guide'],
354
- when: 'Project structure changes significantly',
355
- skills: ['docs-tracker'],
356
- },
357
- 'jsdoc-generator': {
358
- triggers: ['jsdoc', 'function docs', 'api docs'],
359
- when: 'Complex functions lack documentation',
360
- skills: ['docs-tracker', 'typescript-strict'],
361
- },
362
- 'changelog-manager': {
363
- triggers: ['changelog', 'release notes', 'version'],
364
- when: 'BEFORE committing any feature or fix',
365
- skills: ['docs-tracker', 'git-workflow'],
366
- },
367
- 'api-documenter': {
368
- triggers: ['api docs', 'swagger', 'openapi'],
369
- when: 'AFTER creating or modifying API endpoints',
370
- skills: ['docs-tracker'],
371
- },
372
- },
373
- },
374
- '08-git': {
375
- description: 'Git workflow and version control',
376
- agents: {
377
- 'branch-manager': {
378
- triggers: ['branch', 'feature branch', 'fix branch'],
379
- when: 'BEFORE making source changes on main branch',
380
- skills: ['git-workflow'],
381
- },
382
- 'commit-manager': {
383
- triggers: ['commit', 'push', 'finalize', 'merge'],
384
- when: 'FINAL AGENT when implementation is complete - commits and merges to main',
385
- skills: ['git-workflow', 'docs-tracker', 'codebase-knowledge'],
386
- },
387
- },
388
- },
389
- '09-quality': {
390
- description: 'Code quality and review',
391
- agents: {
392
- 'quality-checker': {
393
- triggers: ['quality', 'typecheck', 'lint', 'build'],
394
- when: 'BEFORE any commit',
395
- skills: ['quality-gate', 'codebase-knowledge'],
396
- },
397
- 'code-reviewer': {
398
- triggers: ['review', 'code review', 'code quality'],
399
- when: 'AFTER significant code is written',
400
- skills: ['quality-gate', 'codebase-knowledge'],
401
- },
402
- },
403
- },
404
- '10-research': {
405
- description: 'Web research and best practices (MANDATORY for new features)',
406
- agents: {
407
- 'research-web': {
408
- triggers: ['search', 'find info', 'look up'],
409
- when: 'BEFORE implementing any new feature or technology',
410
- mandatory_for: ['feature'],
411
- skills: ['research-cache'],
412
- },
413
- 'research-cache-manager': {
414
- triggers: ['cache', 'cached research', 'previous research'],
415
- when: 'BEFORE any web research',
416
- skills: ['research-cache'],
417
- },
418
- 'best-practices-finder': {
419
- triggers: ['best practice', 'recommended', 'how should'],
420
- when: 'BEFORE implementing any new pattern',
421
- skills: ['research-cache'],
422
- },
423
- 'pattern-researcher': {
424
- triggers: ['pattern', 'architecture', 'design decision'],
425
- when: 'Facing architectural decisions',
426
- skills: ['research-cache'],
427
- },
428
- 'competitor-analyzer': {
429
- triggers: ['competitor', 'similar app', 'how does'],
430
- when: 'Designing UI or features with existing market solutions',
431
- skills: ['research-cache'],
432
- },
433
- 'tech-evaluator': {
434
- triggers: ['compare', 'evaluate', 'which library'],
435
- when: 'Choosing between technologies',
436
- skills: ['research-cache'],
437
- },
438
- },
439
- },
440
- '11-ui-ux': {
441
- description: 'UI/UX - SEPARATE UIs for mobile/tablet/desktop (NOT just responsive)',
442
- agents: {
443
- 'ui-mobile': {
444
- triggers: ['mobile', 'touch', '375px'],
445
- when: 'Implementing any UI feature',
446
- skills: ['ui-ux-audit', 'react-patterns', 'tailwind-patterns', 'shadcn-ui'],
447
- },
448
- 'ui-tablet': {
449
- triggers: ['tablet', 'ipad', '768px'],
450
- when: 'Implementing any UI feature',
451
- skills: ['ui-ux-audit', 'react-patterns', 'tailwind-patterns', 'shadcn-ui'],
452
- },
453
- 'ui-desktop': {
454
- triggers: ['desktop', 'sidebar', '1280px'],
455
- when: 'Implementing any UI feature',
456
- skills: ['ui-ux-audit', 'react-patterns', 'tailwind-patterns', 'shadcn-ui'],
457
- },
458
- 'skeleton-generator': {
459
- triggers: ['skeleton', 'loading', 'placeholder'],
460
- when: 'AFTER creating any component that loads data',
461
- skills: ['react-patterns', 'tailwind-patterns'],
462
- },
463
- 'design-system-enforcer': {
464
- triggers: ['design system', 'consistency', 'component style'],
465
- when: 'AFTER creating UI components',
466
- skills: ['ui-ux-audit', 'shadcn-ui', 'tailwind-patterns'],
467
- },
468
- 'accessibility-auditor': {
469
- triggers: ['a11y', 'accessibility', 'wcag', 'screen reader'],
470
- when: 'AFTER any UI implementation',
471
- skills: ['ui-ux-audit'],
472
- },
473
- },
474
- },
475
- '12-performance': {
476
- description: 'Performance profiling and optimization',
477
- agents: {
478
- 'performance-profiler': {
479
- triggers: ['slow', 'performance', 'profile', 'bottleneck'],
480
- when: 'Application is slow',
481
- skills: ['performance-patterns'],
482
- },
483
- 'memory-leak-detector': {
484
- triggers: ['memory', 'leak', 'heap'],
485
- when: 'Memory issues are suspected',
486
- skills: ['performance-patterns'],
487
- },
488
- 'bundle-analyzer': {
489
- triggers: ['bundle', 'build size', 'lighthouse'],
490
- when: 'Build is large or slow',
491
- skills: ['performance-patterns'],
492
- },
493
- 'api-latency-analyzer': {
494
- triggers: ['api slow', 'response time', 'latency'],
495
- when: 'API endpoints are slow',
496
- skills: ['performance-patterns'],
497
- },
498
- 'query-optimizer': {
499
- triggers: ['slow query', 'n+1', 'database slow'],
500
- when: 'Database queries are slow',
501
- skills: ['performance-patterns', 'mongoose-patterns'],
502
- },
503
- 'render-optimizer': {
504
- triggers: ['re-render', 'react slow', 'component slow'],
505
- when: 'React components re-render excessively',
506
- skills: ['performance-patterns', 'react-patterns'],
507
- },
508
- },
509
- },
510
- '13-debugging': {
511
- description: 'Error analysis and debugging',
512
- agents: {
513
- debugger: {
514
- triggers: ['bug', 'error', 'not working', 'broken', 'fails'],
515
- when: 'Any bug or error occurs',
516
- skills: ['debugging-patterns'],
517
- },
518
- 'type-error-resolver': {
519
- triggers: ['ts error', 'type error', 'typecheck fails'],
520
- when: 'On TypeScript type errors',
521
- skills: ['debugging-patterns', 'typescript-strict'],
522
- },
523
- 'runtime-error-fixer': {
524
- triggers: ['crash', 'exception', 'runtime error'],
525
- when: 'On runtime crashes or exceptions',
526
- skills: ['debugging-patterns'],
527
- },
528
- 'network-debugger': {
529
- triggers: ['fetch error', 'api error', 'cors', 'network'],
530
- when: 'On network or API errors',
531
- skills: ['debugging-patterns'],
532
- },
533
- 'error-stack-analyzer': {
534
- triggers: ['stack trace', 'trace', 'call stack'],
535
- when: 'Error includes stack trace',
536
- skills: ['debugging-patterns'],
537
- },
538
- 'build-error-fixer': {
539
- triggers: ['build failed', 'compile error', 'bundler error'],
540
- when: 'Build fails',
541
- skills: ['debugging-patterns'],
542
- },
543
- },
544
- },
545
- '14-validation': {
546
- description: 'Final validation before commit (CAN VETO)',
547
- agents: {
548
- 'final-validator': {
549
- triggers: ['final check', 'validate', 'ready to commit'],
550
- when: 'BEFORE commit-manager - last check',
551
- can_veto: true,
552
- skills: ['final-check'],
553
- },
554
- },
555
- },
556
- };
557
-
558
- // ============================================================================
559
- // SKILL SYSTEM - 22 Skills Auto-loaded by Agents
560
- // ============================================================================
561
-
562
- const SKILLS: Record<string, string> = {
563
- 'bun-runtime': 'Bun runtime patterns, package management, scripts',
564
- 'codebase-knowledge': 'Project domain knowledge, file mapping, recent commits',
565
- 'debugging-patterns': 'Stack traces, runtime errors, build errors, network issues',
566
- 'docker-patterns': 'Containerization, multi-stage builds, Docker Compose, security',
567
- 'docs-tracker': 'Documentation maintenance, git diff detection, changelog',
568
- 'final-check': 'Final validation, tests pass, docs updated, security audited',
569
- 'git-workflow': 'Branch management, conventional commits, merge to main, hooks',
570
- 'mongoose-patterns': 'MongoDB schema design, queries, indexes, aggregations',
571
- 'nextjs-app-router': 'Next.js 15 App Router, Server/Client components, data fetching',
572
- 'performance-patterns': 'React optimization, bundle analysis, memory leaks, API latency',
573
- 'playwright-automation': 'E2E tests, browser automation, visual testing, API testing',
574
- 'quality-gate': 'Quality checks (typecheck, lint, test, build)',
575
- 'react-patterns': 'React 19 patterns, hooks, state management, performance',
576
- 'research-cache': 'Cached research findings, best practices by topic',
577
- 'security-scan': 'OWASP Top 10, user ID validation, sensitive data detection',
578
- 'shadcn-ui': 'shadcn/ui components, customization, theming, accessibility',
579
- 'tailwind-patterns': 'Tailwind CSS, responsive design, dark mode, animations',
580
- 'test-coverage': 'Playwright E2E, Vitest unit tests, coverage tracking',
581
- 'trpc-api': 'tRPC type-safe APIs, routers, procedures, middleware',
582
- 'typescript-strict': 'TypeScript strict mode, index access, null checks, generics',
583
- 'ui-ux-audit': 'UI/UX audits, competitor research, WCAG 2.1, responsiveness',
584
- 'zod-validation': 'Zod schemas, input validation, type inference, error handling',
585
- };
586
-
587
- const WORKFLOWS: Record<string, string[]> = {
588
- feature: [
589
- 'analyzer',
590
- 'research-web',
591
- 'ui-ux-reviewer',
592
- 'documenter',
593
- 'tester',
594
- 'security-auditor',
595
- 'quality-checker',
596
- 'final-validator',
597
- 'domain-updater',
598
- 'commit-manager',
599
- ],
600
- fix: [
601
- 'debugger',
602
- 'analyzer',
603
- 'tester',
604
- 'security-auditor',
605
- 'quality-checker',
606
- 'final-validator',
607
- 'domain-updater',
608
- 'commit-manager',
609
- ],
610
- refactor: [
611
- 'analyzer',
612
- 'code-reviewer',
613
- 'tester',
614
- 'quality-checker',
615
- 'final-validator',
616
- 'domain-updater',
617
- 'commit-manager',
618
- ],
619
- config: ['quality-checker', 'domain-updater', 'commit-manager'],
620
- };
621
-
622
- interface WorkflowState {
623
- currentTask?: {
624
- id?: string;
625
- type?: string;
626
- description?: string;
627
- agents?: Record<string, { executed?: boolean }>;
628
- approvedFiles?: string[];
629
- };
630
- }
631
-
632
- function loadWorkflowState(): WorkflowState | null {
633
- if (!existsSync(WORKFLOW_STATE_PATH)) return null;
634
- try {
635
- return JSON.parse(readFileSync(WORKFLOW_STATE_PATH, 'utf8'));
636
- } catch {
637
- return null;
638
- }
639
- }
640
-
641
- function detectTaskType(prompt: string): string {
642
- const promptLower = prompt.toLowerCase();
643
-
644
- if (
645
- ['bug', 'fix', 'error', 'broken', 'not working', 'issue', 'debug'].some((w) =>
646
- promptLower.includes(w)
647
- )
648
- ) {
649
- return 'fix';
650
- } else if (
651
- ['refactor', 'restructure', 'reorganize', 'clean up', 'improve'].some((w) =>
652
- promptLower.includes(w)
653
- )
654
- ) {
655
- return 'refactor';
656
- } else if (
657
- ['config', 'setting', 'env', 'package.json', 'tsconfig'].some((w) =>
658
- promptLower.includes(w)
659
- )
660
- ) {
661
- return 'config';
662
- }
663
- return 'feature';
664
- }
665
-
666
- function detectBestAgents(prompt: string): Array<[string, string, string]> {
667
- const promptLower = prompt.toLowerCase();
668
- const matches: Array<[string, string, string]> = [];
669
-
670
- for (const [category, info] of Object.entries(AGENT_CATEGORIES)) {
671
- for (const [agentName, agentInfo] of Object.entries(info.agents)) {
672
- for (const trigger of agentInfo.triggers) {
673
- if (promptLower.includes(trigger)) {
674
- matches.push([category, agentName, `Matched '${trigger}'`]);
675
- break;
676
- }
677
- }
678
- }
679
- }
680
-
681
- matches.sort((a, b) => a[0].localeCompare(b[0]));
682
-
683
- if (matches.length === 0) {
684
- return [
685
- ['01-orchestration', 'orchestrator', 'No specific trigger - orchestrator will analyze'],
686
- ];
687
- }
688
-
689
- return matches.slice(0, 3);
690
- }
691
-
692
- function formatAgentCategories(): string {
693
- const lines: string[] = [];
694
- for (const [category, info] of Object.entries(AGENT_CATEGORIES).sort()) {
695
- const agentCount = Object.keys(info.agents).length;
696
- const vetoAgents = Object.entries(info.agents)
697
- .filter(([, a]) => a.can_veto)
698
- .map(([n]) => n);
699
- const vetoStr = vetoAgents.length > 0 ? ` [VETO: ${vetoAgents.join(', ')}]` : '';
700
- lines.push(` ${category}: ${info.description} (${agentCount} agents)${vetoStr}`);
701
- }
702
- return lines.join('\n');
703
- }
704
-
705
- function formatSkills(): string {
706
- return Object.entries(SKILLS)
707
- .sort()
708
- .map(([name, desc]) => ` ${name}: ${desc}`)
709
- .join('\n');
710
- }
711
-
712
- function formatWorkflowStatus(state: WorkflowState | null): string {
713
- if (!state || !state.currentTask) {
714
- return 'STATUS: No active task. Start with orchestrator agent';
715
- }
716
-
717
- const task = state.currentTask;
718
- const agents = task.agents || {};
719
-
720
- const executed = Object.entries(agents)
721
- .filter(([, s]) => s.executed)
722
- .map(([n]) => n);
723
- const pending = Object.entries(agents)
724
- .filter(([, s]) => !s.executed)
725
- .map(([n]) => n);
726
-
727
- return `STATUS: Task active
728
- ID: ${task.id || 'unknown'}
729
- Type: ${task.type || 'unknown'}
730
- Description: ${task.description || 'unknown'}
731
- Executed: ${executed.length > 0 ? executed.join(', ') : 'none'}
732
- Pending: ${pending.length > 0 ? pending.join(', ') : 'none'}
733
- Approved files: ${(task.approvedFiles || []).length}`;
734
- }
735
-
736
9
  async function readStdinWithTimeout(timeoutMs: number): Promise<string> {
737
10
  return new Promise((resolve) => {
738
11
  const timeout = setTimeout(() => {
@@ -773,122 +46,32 @@ async function main(): Promise<void> {
773
46
  }
774
47
 
775
48
  const prompt = hookInput.user_prompt || hookInput.prompt || '';
776
- const state = loadWorkflowState();
777
- const taskType = prompt ? detectTaskType(prompt) : 'unknown';
778
- const bestAgents = prompt
779
- ? detectBestAgents(prompt)
780
- : [['01-orchestration', 'orchestrator', 'Default'] as [string, string, string]];
781
-
782
- const isNewFeature =
783
- taskType === 'feature' ||
784
- ['new', 'implement', 'create', 'add'].some((w) => prompt.toLowerCase().includes(w));
785
- const isUiTask = [
786
- 'ui',
787
- 'component',
788
- 'page',
789
- 'design',
790
- 'layout',
791
- 'mobile',
792
- 'desktop',
793
- 'tablet',
794
- ].some((w) => prompt.toLowerCase().includes(w));
795
- const isDebugTask = ['bug', 'error', 'broken', 'not working', 'debug', 'fix'].some((w) =>
796
- prompt.toLowerCase().includes(w)
797
- );
798
-
799
- const recommendedStr = bestAgents
800
- .map(([cat, agent, reason], i) => ` ${i + 1}. ${cat}/${agent} - ${reason}`)
801
- .join('\n');
802
-
803
- const claudeMdReminder = `
804
- ================================================================================
805
- CLAUDE.MD UPDATE REQUIREMENT (MANDATORY)
806
- ================================================================================
807
-
808
- Before completing ANY task, you MUST update CLAUDE.md at project root with:
809
-
810
- 1. "## Last Change" section (ONLY keep the latest, do NOT stack):
811
- **Branch:** your-branch-name
812
- **Date:** ${new Date().toISOString().split('T')[0]}
813
- **Summary:** What you implemented/fixed
814
-
815
- 2. Update "## Architecture" if structure changed
816
-
817
- 3. Add new rules/patterns learned to appropriate sections
818
-
819
- 4. SYNTHESIZE: If user mentioned preferences or corrections, add as rules
820
-
821
- CHARACTER LIMIT: 40,000 max. If exceeded, COMPACT the file (keep critical sections).
822
-
823
- STOP HOOK WILL BLOCK if CLAUDE.md is not properly updated!
824
- ================================================================================
825
- `;
826
-
827
- const output = `
828
- ================================================================================
829
- STRICT WORKFLOW ENFORCEMENT - UserPromptSubmit Hook
830
- ================================================================================
831
- ${STRICT_WORKFLOW}
832
- ${claudeMdReminder}
833
-
834
- ${isNewFeature ? '⚠️ NEW FEATURE DETECTED - RESEARCH AGENT IS MANDATORY!' : ''}
835
- ${isUiTask ? '⚠️ UI TASK DETECTED - SEPARATE UIs FOR MOBILE/TABLET/DESKTOP REQUIRED!' : ''}
836
- ${isDebugTask ? '🐛 DEBUG TASK DETECTED - Use debugger or type-error-resolver agents' : ''}
837
-
838
- ================================================================================
839
- STEP 1: CREATE DETAILED TODO LIST (MANDATORY)
840
- ================================================================================
841
-
842
- BEFORE doing anything, you MUST use TodoWrite to create a detailed todo list.
843
- Break down the user's prompt into specific, actionable items.
844
-
845
- ================================================================================
846
- AGENT SYSTEM: 82 Specialized Agents in 14 Categories
847
- ================================================================================
848
-
849
- CATEGORIES:
850
- ${formatAgentCategories()}
851
-
852
- TASK ANALYSIS:
853
- Detected type: ${taskType}
854
- Recommended agents:
855
- ${recommendedStr}
856
- Research required: ${isNewFeature ? 'YES (MANDATORY)' : 'Optional'}
857
- Separate UIs required: ${isUiTask ? 'YES (MANDATORY)' : 'N/A'}
858
- Workflow sequence: ${(WORKFLOWS[taskType] || WORKFLOWS['feature']).join(' -> ')}
859
-
860
- ${formatWorkflowStatus(state)}
861
-
862
- ================================================================================
863
- SKILL SYSTEM: 22 Skills Auto-loaded by Agents
864
- ================================================================================
865
-
866
- ${formatSkills()}
867
-
868
- Skills are auto-loaded when an agent starts. Agents don't inherit parent skills.
869
-
870
- ================================================================================
871
- AGENT INVOCATION (VIA TASK TOOL ONLY)
872
- ================================================================================
49
+ if (!prompt.trim()) {
50
+ console.log(JSON.stringify({ continue: true }));
51
+ process.exit(0);
52
+ }
873
53
 
874
- You MUST use the Task tool with subagent_type to invoke agents.
875
- DO NOT execute agent logic manually - INVOKE the agent properly.
54
+ const today = new Date().toISOString().split('T')[0];
876
55
 
877
- Example:
878
- Task(subagent_type="debugger", prompt="Fix the TypeError in user.ts")
879
- Task(subagent_type="playwright-e2e", prompt="Create E2E tests for login")
56
+ const systemMessage = `TASK WORKFLOW (English only):
880
57
 
881
- ================================================================================
882
- `;
58
+ 1. CREATE a detailed todo-list (TaskCreate) breaking down the user's request into subtopics/steps.
59
+ 2. WORK through each item sequentially — mark in_progress when starting, completed when done.
60
+ 3. COMMIT using conventional commits (feat/fix/refactor/docs/chore). Use the commit-manager agent for proper git workflow: branch → implement → commit → merge to main.
61
+ 4. UPDATE CLAUDE.md before finishing — this is the project's fast-recall memory across sessions:
62
+ a. "## Last Change" section (date: ${today}, branch, summary). Keep only the latest, never stack.
63
+ b. If you changed how the app works (new flows, changed workflows, new patterns): update the relevant CLAUDE.md sections (Architecture, Workflow, Rules, UI patterns, etc.) so the next session knows.
64
+ c. If you added new rules, gotchas, or forbidden patterns: add them to the appropriate section.
65
+ d. If you changed config, stack, or tooling: update the Stack/Configuration sections.
66
+ CLAUDE.md is the single source of truth for quick context. Anything not recorded here will be forgotten next session.
67
+ 5. RUN stop-validator before finishing: npx tsx .claude/hooks/stop-validator.ts`;
883
68
 
884
- const result = { continue: true, systemMessage: output };
885
- console.log(JSON.stringify(result));
69
+ console.log(JSON.stringify({ continue: true, systemMessage }));
886
70
  process.exit(0);
887
71
  }
888
72
 
889
73
  main().catch((err) => {
890
74
  console.error('Hook error:', err);
891
- const result = { continue: true, systemMessage: 'Hook error occurred, continuing...' };
892
- console.log(JSON.stringify(result));
75
+ console.log(JSON.stringify({ continue: true, systemMessage: 'Hook error, continuing...' }));
893
76
  process.exit(0);
894
77
  });
@@ -2,9 +2,9 @@
2
2
 
3
3
  ## Last Update
4
4
 
5
- - **Date:** 2026-01-06
6
- - **Commit:** 77e2263
7
- - **Session:** Fixed stop hook exit code from 2 to 0 for proper JSON processing
5
+ - **Date:** 2026-02-04
6
+ - **Commit:** pending
7
+ - **Session:** Simplified user-prompt-submit hook (895→73 lines) and enhanced CLAUDE.md update instructions to cover flows, rules, architecture — not just Last Change
8
8
 
9
9
  ## Files
10
10
 
@@ -36,8 +36,7 @@
36
36
  - `.claude/hooks/run-hook.cmd` - **NEW** Batch wrapper for Windows
37
37
  - `.claude/hooks/stop-validator.py` - Stop hook enforcement: branch protection + documentation check
38
38
  - `.claude/hooks/stop-validator.ts` - **NEW** TypeScript fallback version of stop-validator
39
- - `.claude/hooks/user-prompt-submit.py` - Agent selection guidance before prompt processing
40
- - `.claude/hooks/user-prompt-submit.ts` - **NEW** TypeScript fallback version of user-prompt-submit
39
+ - `.claude/hooks/user-prompt-submit.ts` - Concise 5-step workflow instructions (simplified from 895 to 73 lines)
41
40
  - `.claude/hooks/check-documentation.py` - Documentation verification hook
42
41
  - `.claude/hooks/SETUP.md` - Hook system documentation
43
42