@champpaba/claude-agent-kit 2.0.0 → 2.1.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 (87) hide show
  1. package/.claude/CLAUDE.md +253 -31
  2. package/.claude/agents/01-integration.md +106 -552
  3. package/.claude/agents/02-uxui-frontend.md +188 -850
  4. package/.claude/agents/03-test-debug.md +152 -521
  5. package/.claude/agents/04-frontend.md +169 -549
  6. package/.claude/agents/05-backend.md +132 -661
  7. package/.claude/agents/06-database.md +149 -698
  8. package/.claude/agents/_shared/README.md +57 -0
  9. package/.claude/agents/_shared/agent-boundaries.md +64 -0
  10. package/.claude/agents/_shared/documentation-policy.md +47 -0
  11. package/.claude/agents/_shared/package-manager.md +59 -0
  12. package/.claude/agents/_shared/pre-work-checklist.md +57 -0
  13. package/.claude/commands/cdev.md +36 -61
  14. package/.claude/commands/csetup.md +90 -14
  15. package/.claude/commands/cstatus.md +153 -60
  16. package/.claude/commands/cview.md +364 -364
  17. package/.claude/commands/designsetup.md +1 -1
  18. package/.claude/commands/pageplan.md +53 -177
  19. package/.claude/commands/pstatus.md +431 -0
  20. package/.claude/contexts/design/accessibility.md +611 -611
  21. package/.claude/contexts/design/box-thinking.md +1 -1
  22. package/.claude/contexts/design/index.md +1 -1
  23. package/.claude/contexts/design/layout.md +400 -400
  24. package/.claude/contexts/design/responsive.md +551 -551
  25. package/.claude/contexts/design/shadows.md +522 -522
  26. package/.claude/contexts/design/typography.md +465 -465
  27. package/.claude/contexts/domain/README.md +164 -164
  28. package/.claude/contexts/patterns/agent-coordination.md +388 -388
  29. package/.claude/contexts/patterns/agent-discovery.md +2 -2
  30. package/.claude/contexts/patterns/animation-patterns.md +1 -1
  31. package/.claude/contexts/patterns/change-workflow.md +541 -538
  32. package/.claude/contexts/patterns/code-standards.md +10 -8
  33. package/.claude/contexts/patterns/development-principles.md +513 -513
  34. package/.claude/contexts/patterns/error-handling.md +478 -478
  35. package/.claude/contexts/patterns/error-recovery.md +365 -365
  36. package/.claude/contexts/patterns/frontend-component-strategy.md +1 -1
  37. package/.claude/contexts/patterns/logging.md +424 -424
  38. package/.claude/contexts/patterns/performance-optimization.md +1 -1
  39. package/.claude/contexts/patterns/task-breakdown.md +452 -452
  40. package/.claude/contexts/patterns/task-classification.md +523 -523
  41. package/.claude/contexts/patterns/tdd-classification.md +516 -516
  42. package/.claude/contexts/patterns/testing.md +413 -413
  43. package/.claude/contexts/patterns/ui-component-consistency.md +3 -3
  44. package/.claude/contexts/patterns/validation-framework.md +779 -776
  45. package/.claude/lib/README.md +4 -4
  46. package/.claude/lib/agent-executor.md +31 -40
  47. package/.claude/lib/agent-router.md +450 -572
  48. package/.claude/lib/context-loading-protocol.md +19 -36
  49. package/.claude/lib/detailed-guides/agent-system.md +43 -121
  50. package/.claude/lib/detailed-guides/taskmaster-analysis.md +1 -1
  51. package/.claude/lib/document-loader.md +22 -25
  52. package/.claude/lib/flags-updater.md +461 -469
  53. package/.claude/lib/tdd-classifier.md +345 -345
  54. package/.claude/lib/validation-gates.md +484 -484
  55. package/.claude/settings.local.json +42 -42
  56. package/.claude/templates/STYLE_GUIDE.template.md +1 -1
  57. package/.claude/templates/context-template.md +45 -45
  58. package/.claude/templates/design-context-template.md +1 -1
  59. package/.claude/templates/flags-template.json +42 -42
  60. package/.claude/templates/phases-sections/accessibility-test.md +17 -17
  61. package/.claude/templates/phases-sections/api-design.md +37 -37
  62. package/.claude/templates/phases-sections/backend-tests.md +16 -16
  63. package/.claude/templates/phases-sections/backend.md +37 -37
  64. package/.claude/templates/phases-sections/business-logic-validation.md +16 -16
  65. package/.claude/templates/phases-sections/component-tests.md +17 -17
  66. package/.claude/templates/phases-sections/contract-backend.md +16 -16
  67. package/.claude/templates/phases-sections/contract-frontend.md +16 -16
  68. package/.claude/templates/phases-sections/database.md +35 -35
  69. package/.claude/templates/phases-sections/e2e-tests.md +16 -16
  70. package/.claude/templates/phases-sections/fix-implementation.md +17 -17
  71. package/.claude/templates/phases-sections/frontend-integration.md +18 -18
  72. package/.claude/templates/phases-sections/frontend-mockup.md +126 -123
  73. package/.claude/templates/phases-sections/manual-flow-test.md +15 -15
  74. package/.claude/templates/phases-sections/manual-ux-test.md +16 -16
  75. package/.claude/templates/phases-sections/refactor-implementation.md +17 -17
  76. package/.claude/templates/phases-sections/refactor.md +16 -16
  77. package/.claude/templates/phases-sections/regression-tests.md +15 -15
  78. package/.claude/templates/phases-sections/responsive-test.md +16 -16
  79. package/.claude/templates/phases-sections/script-implementation.md +43 -43
  80. package/.claude/templates/phases-sections/test-coverage.md +16 -16
  81. package/.claude/templates/phases-sections/user-approval.md +14 -14
  82. package/LICENSE +21 -21
  83. package/PROJECT_STATUS.template.yml +105 -0
  84. package/README.md +103 -1115
  85. package/lib/init.js +30 -2
  86. package/package.json +3 -2
  87. package/.claude/CHANGELOG-v1.1.1.md +0 -259
@@ -1,776 +1,779 @@
1
- # Comprehensive Validation Framework
2
-
3
- > **Enforce ALL mandatory patterns across ALL agents**
4
-
5
- ---
6
-
7
- ## 🎯 Overview
8
-
9
- Every agent has MANDATORY pre-work steps. This framework ensures agents CANNOT skip required patterns.
10
-
11
- **Principles:**
12
- 1. **Report Before Code** - Agent must report completion BEFORE implementation
13
- 2. **Validation Gates** - Orchestrator validates BEFORE allowing next step
14
- 3. **Rejection with Guidance** - Clear feedback if validation fails
15
- 4. **Pattern-Specific** - Each agent has unique validation requirements
16
-
17
- ---
18
-
19
- ## 📋 Validation Checklists by Agent
20
-
21
- ### 1️⃣ **uxui-frontend Agent**
22
-
23
- **Required Pre-Work:**
24
-
25
- ```markdown
26
- ## Pre-Implementation Validation Report
27
-
28
- ### A. Design Foundation ✓
29
- - [x] Read: design/index.md
30
- - [x] Read: design/box-thinking.md
31
- - [x] Read: design/color-theory.md
32
- - [x] Read: design/spacing.md
33
- - [x] Read: design/shadows.md
34
- - [x] Read: patterns/ui-component-consistency.md
35
- - [x] Read: patterns/frontend-component-strategy.md
36
-
37
- **Summary:** Loaded design system, spacing scale (8/16/24/32/40/48px), color tokens, shadow patterns.
38
-
39
- ### B. Box Thinking Analysis ✓
40
- **Component:** [Landing Page]
41
-
42
- **Structure:**
43
- ```
44
- Landing Page
45
- ├─ Hero (container) - padding: 48px
46
- │ ├─ Headline (h1)
47
- │ ├─ Subtitle (p)
48
- │ └─ CTA Button
49
- └─ Features (container) - gap: 24px
50
- └─ FeatureCard x3 (grid)
51
- ├─ Icon
52
- ├─ Title
53
- └─ Description
54
- ```
55
-
56
- **Spacing Plan:**
57
- - Hero: padding-12 (48px)
58
- - Card gap: gap-6 (24px)
59
- - Card padding: padding-6 (24px)
60
-
61
- **Responsive:**
62
- - Mobile (<640px): Stack vertically
63
- - Tablet (640-1024px): 2-column grid
64
- - Desktop (>1024px): 3-column grid
65
-
66
- ### C. Component Search
67
- **Search Performed:**
68
- ```bash
69
- Glob: "**/*{Hero,Feature,Card,Button,Icon}*.{tsx,jsx}"
70
- Grep: "export.*function.*(Button|Card)"
71
- ```
72
-
73
- **Results:**
74
- - ✅ Found: components/ui/Button.tsx
75
- - ✅ Found: components/ui/Card.tsx
76
- - ❌ Not found: Hero, FeatureCard
77
-
78
- **Decision:**
79
- - **Reuse:** Button (variant="primary", size="lg")
80
- - **Reuse:** Card (for FeatureCard base)
81
- - **Create New:** HeroSection, FeatureCard (no alternatives exist)
82
-
83
- **Justification:** Hero and FeatureCard are domain-specific, cannot reuse generic components.
84
-
85
- ### D. Design Tokens Extracted ✓
86
- **Reference:** components/ui/Button.tsx
87
-
88
- ```typescript
89
- const DESIGN_TOKENS = {
90
- spacing: {
91
- padding: 'px-4 py-2', // Button default
92
- gap: 'gap-4' // Between elements
93
- },
94
- colors: {
95
- primary: 'bg-blue-600',
96
- primaryHover: 'hover:bg-blue-700',
97
- text: 'text-white',
98
- muted: 'text-foreground/70'
99
- },
100
- shadows: 'shadow-sm',
101
- radius: 'rounded-md',
102
- transitions: 'transition-colors duration-200'
103
- }
104
- ```
105
-
106
- **Consistency Check:**
107
- - ✅ All buttons use bg-blue-600/700
108
- - ✅ All rounded corners use rounded-md
109
- - ✅ All shadows use shadow-sm
110
- - ✅ Will follow these patterns
111
-
112
- ### E. Mock Data Strategy
113
- ```typescript
114
- const MOCK_DATA = {
115
- hero: {
116
- headline: "Welcome to Our Platform",
117
- subtitle: "Build amazing things",
118
- ctaText: "Get Started"
119
- },
120
- features: [
121
- { id: 1, title: "Fast", description: "Lightning speed", icon: "⚡" },
122
- { id: 2, title: "Secure", description: "Bank-level security", icon: "🔒" },
123
- { id: 3, title: "Scalable", description: "Grows with you", icon: "📈" }
124
- ]
125
- }
126
- // TODO: Replace with API call in Phase 3
127
- ```
128
-
129
- ### F. Ready to Implement
130
- ✅ All design contexts loaded
131
- ✅ Box thinking complete
132
- Existing components searched
133
- Design tokens extracted
134
- Mock data prepared
135
-
136
- **Proceeding with implementation...**
137
- ```
138
-
139
- **Validation Keywords:**
140
- - MUST contain: "Design Foundation ✓"
141
- - MUST contain: "Box Thinking Analysis ✓"
142
- - MUST contain: "Component Search ✓"
143
- - MUST contain: "Design Tokens Extracted ✓"
144
- - MUST contain: "Ready to Implement ✓"
145
-
146
- ---
147
-
148
- ### 2️⃣ **backend Agent**
149
-
150
- **Required Pre-Work:**
151
-
152
- ```markdown
153
- ## Pre-Implementation Validation Report
154
-
155
- ### A. Patterns Loaded ✓
156
- - [x] Read: patterns/error-handling.md
157
- - [x] Read: patterns/logging.md
158
- - [x] Read: patterns/testing.md
159
-
160
- ### B. Existing Endpoints Search ✓
161
- **Search Performed:**
162
- ```bash
163
- Grep: "router\\.(post|get|put|delete).*\\/api\\/auth"
164
- Grep: "@app\\.(post|get).*\\/api\\/auth"
165
- ```
166
-
167
- **Results:**
168
- - ❌ No existing /api/auth/login
169
- - ❌ No existing /api/auth/register
170
- - ✅ Can proceed with implementation
171
-
172
- ### C. TDD Workflow (if metadata: | TDD |) ✓
173
- **TDD Required:** YES (metadata flag detected)
174
-
175
- **Phase Plan:**
176
- 1. 🔴 RED: Write 7 tests FIRST
177
- - test_register_success
178
- - test_register_duplicate_email
179
- - test_register_invalid_email
180
- - test_register_weak_password
181
- - test_login_success
182
- - test_login_invalid_credentials
183
- - test_login_validation_error
184
-
185
- 2. ✅ GREEN: Minimal implementation
186
- - User model
187
- - Password hashing (bcrypt)
188
- - JWT generation
189
- - Registration endpoint
190
- - Login endpoint
191
-
192
- 3. 🔧 REFACTOR: Add production quality
193
- - Structured logging
194
- - Error handling
195
- - Type hints
196
- - Docstrings
197
-
198
- **Commitment:** Will follow RED-GREEN-REFACTOR strictly.
199
-
200
- ### D. Error Handling Pattern ✓
201
- **From:** patterns/error-handling.md
202
-
203
- ```python
204
- # Pattern to follow:
205
- try:
206
- # Business logic
207
- user = await create_user(...)
208
- logger.info("user_created", extra={"user_id": user.id})
209
- return {"id": user.id}
210
- except HTTPException:
211
- raise # Re-raise HTTP exceptions
212
- except Exception as e:
213
- logger.error("user_creation_error", extra={"error": str(e)})
214
- raise HTTPException(status_code=500, detail="Internal server error")
215
- ```
216
-
217
- ### E. Logging Pattern
218
- **From:** patterns/logging.md
219
-
220
- ```python
221
- # All significant events:
222
- logger.info("api_route_entry", extra={"route": "/api/auth/login"})
223
- logger.info("login_success", extra={"user_id": user.id})
224
- logger.warning("login_failed", extra={"email": email, "reason": "invalid_credentials"})
225
- logger.error("login_error", extra={"error": str(e)})
226
- ```
227
-
228
- ### F. Ready to Implement ✓
229
- ✅ Patterns loaded
230
- ✅ Existing endpoints searched
231
- TDD workflow planned
232
- Error handling pattern identified
233
- Logging pattern identified
234
-
235
- **Proceeding with TDD (RED phase first)...**
236
- ```
237
-
238
- **Validation Keywords:**
239
- - MUST contain: "Patterns Loaded ✓"
240
- - MUST contain: "Existing Endpoints Search ✓"
241
- - IF TDD: MUST contain: "TDD Workflow" + "RED-GREEN-REFACTOR"
242
- - MUST contain: "Error Handling Pattern ✓"
243
- - MUST contain: "Logging Pattern ✓"
244
- - MUST contain: "Ready to Implement "
245
-
246
- ---
247
-
248
- ### 3️⃣ **frontend Agent**
249
-
250
- **Required Pre-Work:**
251
-
252
- ```markdown
253
- ## Pre-Implementation Validation Report
254
-
255
- ### A. Patterns Loaded ✓
256
- - [x] Read: patterns/error-handling.md
257
- - [x] Read: patterns/logging.md
258
- - [x] Read: patterns/testing.md
259
-
260
- ### B. API Contract Review ✓
261
- **From:** integration agent / API spec
262
-
263
- **Endpoints to Connect:**
264
- - POST /api/auth/login
265
- - Request: { email: string, password: string }
266
- - Success (200): { token: string, user: { id, email } }
267
- - Error (401): { detail: "Invalid credentials" }
268
- - Error (422): { detail: [...validation errors] }
269
-
270
- **State Management Needed:**
271
- - Auth state (user, token, isLoading)
272
- - Form state (email, password, errors)
273
-
274
- ### C. State Management Strategy
275
- **Framework:** Zustand (from tech-stack.md)
276
-
277
- ```typescript
278
- // Create auth store
279
- import { create } from 'zustand'
280
-
281
- interface AuthState {
282
- user: User | null
283
- token: string | null
284
- isLoading: boolean
285
- login: (email: string, password: string) => Promise<void>
286
- logout: () => void
287
- }
288
-
289
- const useAuthStore = create<AuthState>((set) => ({
290
- user: null,
291
- token: null,
292
- isLoading: false,
293
- login: async (email, password) => {
294
- set({ isLoading: true })
295
- try {
296
- const response = await fetch('/api/auth/login', {
297
- method: 'POST',
298
- body: JSON.stringify({ email, password })
299
- })
300
- const data = await response.json()
301
- set({ user: data.user, token: data.token, isLoading: false })
302
- } catch (error) {
303
- set({ isLoading: false })
304
- throw error
305
- }
306
- },
307
- logout: () => set({ user: null, token: null })
308
- }))
309
- ```
310
-
311
- ### D. Error Handling Strategy ✓
312
- ```typescript
313
- // User-friendly error messages
314
- const handleError = (error: ApiError) => {
315
- if (error.status === 401) {
316
- toast.error("Invalid email or password")
317
- } else if (error.status === 422) {
318
- // Show validation errors
319
- error.detail.forEach(err => {
320
- setFieldError(err.loc[1], err.msg)
321
- })
322
- } else {
323
- toast.error("Something went wrong. Please try again.")
324
- }
325
-
326
- // Log for debugging (no sensitive data)
327
- logger.error("login_failed", { status: error.status })
328
- }
329
- ```
330
-
331
- ### E. Component Integration Plan ✓
332
- **Existing Component:** LoginForm (from uxui-frontend phase)
333
-
334
- **Changes Required:**
335
- 1. Replace mock onClick with real useAuthStore
336
- 2. Add loading state (disable button, show spinner)
337
- 3. Add error handling (toast notifications)
338
- 4. Add form validation (client-side)
339
- 5. Add redirect after success
340
-
341
- ### F. Ready to Implement
342
- Patterns loaded
343
- ✅ API contract reviewed
344
- State management strategy defined
345
- Error handling strategy defined
346
- Component integration plan ready
347
-
348
- **Proceeding with implementation...**
349
- ```
350
-
351
- **Validation Keywords:**
352
- - MUST contain: "Patterns Loaded ✓"
353
- - MUST contain: "API Contract Review ✓"
354
- - MUST contain: "State Management Strategy ✓"
355
- - MUST contain: "Error Handling Strategy ✓"
356
- - MUST contain: "Ready to Implement ✓"
357
-
358
- ---
359
-
360
- ### 4️⃣ **database Agent**
361
-
362
- **Required Pre-Work:**
363
-
364
- ```markdown
365
- ## Pre-Implementation Validation Report
366
-
367
- ### A. Patterns Loaded ✓
368
- - [x] Read: patterns/error-handling.md
369
- - [x] Read: patterns/logging.md
370
-
371
- ### B. Existing Schema Search ✓
372
- **Search Performed:**
373
- ```bash
374
- Glob: "**/*.prisma"
375
- Glob: "**/*models*.py"
376
- Grep: "class.*\\(Base\\)"
377
- Grep: "model User"
378
- ```
379
-
380
- **Results:**
381
- - ❌ No existing User model
382
- - ✅ Can proceed with schema design
383
-
384
- ### C. Schema Design Plan
385
- **Model:** User
386
-
387
- **Fields:**
388
- - id: string (UUID, primary key)
389
- - email: string (unique, indexed)
390
- - hashed_password: string (never exposed)
391
- - created_at: datetime (auto)
392
- - updated_at: datetime (auto)
393
-
394
- **Constraints:**
395
- - Unique: email
396
- - Index: email (for fast lookups)
397
-
398
- **Relationships:**
399
- - User Sessions (1:N) - for JWT token management
400
-
401
- ### D. Migration Strategy ✓
402
- **ORM:** Prisma (from tech-stack.md)
403
-
404
- ```bash
405
- # Generate migration
406
- pnpm prisma migrate dev --name add_user_model
407
-
408
- # This will create:
409
- # prisma/migrations/YYYYMMDD_add_user_model/migration.sql
410
- ```
411
-
412
- ### E. Query Functions Plan ✓
413
- ```typescript
414
- // Create user
415
- async function createUser(email: string, hashedPassword: string): Promise<User>
416
-
417
- // Find by email (for login)
418
- async function findUserByEmail(email: string): Promise<User | null>
419
-
420
- // Update password
421
- async function updatePassword(userId: string, newHashedPassword: string): Promise<void>
422
- ```
423
-
424
- ### F. Performance Considerations
425
- - ✅ Index on email (unique constraint also creates index)
426
- - ✅ Use select() to avoid exposing hashed_password
427
- - No N+1 queries (direct lookups)
428
-
429
- ### G. Ready to Implement
430
- Patterns loaded
431
- ✅ Existing schemas searched
432
- Schema design planned
433
- Migration strategy defined
434
- Query functions planned
435
- Performance considered
436
-
437
- **Proceeding with schema implementation...**
438
- ```
439
-
440
- **Validation Keywords:**
441
- - MUST contain: "Patterns Loaded ✓"
442
- - MUST contain: "Existing Schema Search ✓"
443
- - MUST contain: "Schema Design Plan ✓"
444
- - MUST contain: "Migration Strategy ✓"
445
- - MUST contain: "Ready to Implement ✓"
446
-
447
- ---
448
-
449
- ### 5️⃣ **test-debug Agent**
450
-
451
- **Required Pre-Work:**
452
-
453
- ```markdown
454
- ## Pre-Implementation Validation Report
455
-
456
- ### A. Patterns Loaded ✓
457
- - [x] Read: patterns/testing.md
458
- - [x] Read: patterns/error-handling.md
459
- - [x] Read: patterns/logging.md
460
-
461
- ### B. Test Scope Analysis ✓
462
- **Phase:** Component Tests / Backend Tests / E2E Tests
463
-
464
- **Components to Test:**
465
- - HeroSection
466
- - FeatureCard
467
- - LoginForm
468
-
469
- **Coverage Target:** 85% (from project standards)
470
-
471
- ### C. Test Strategy ✓
472
- **Framework:** Vitest (from tech-stack.md)
473
-
474
- **Test Types:**
475
- 1. **Unit Tests**
476
- - Component rendering
477
- - Props validation
478
- - Event handlers
479
- - State changes
480
-
481
- 2. **Integration Tests**
482
- - Component interactions
483
- - API mocking
484
- - State management
485
-
486
- ### D. Existing Test Patterns ✓
487
- **Search Performed:**
488
- ```bash
489
- Grep: "describe.*test.*it\\("
490
- Grep: "expect\\(.*\\)\\.toBe"
491
- ```
492
-
493
- **Pattern Found:**
494
- ```typescript
495
- // Existing pattern in __tests__/Button.test.tsx
496
- describe('Button', () => {
497
- it('renders with correct text', () => {
498
- render(<Button>Click me</Button>)
499
- expect(screen.getByText('Click me')).toBeInTheDocument()
500
- })
501
-
502
- it('calls onClick when clicked', () => {
503
- const handleClick = vi.fn()
504
- render(<Button onClick={handleClick}>Click</Button>)
505
- fireEvent.click(screen.getByText('Click'))
506
- expect(handleClick).toHaveBeenCalledTimes(1)
507
- })
508
- })
509
- ```
510
-
511
- **Will follow this pattern.**
512
-
513
- ### E. Debug Strategy (if tests fail) ✓
514
- **Max Iterations:** 3-4
515
- **Per Iteration:**
516
- 1. Read error messages carefully
517
- 2. Identify root cause
518
- 3. Fix code or test
519
- 4. Re-run
520
- 5. Log iteration results
521
-
522
- **If stuck after 4 iterations:**
523
- - Escalate to main Claude with:
524
- - Error messages
525
- - Code attempted
526
- - Suspected root cause
527
-
528
- ### F. Ready to Implement ✓
529
- Patterns loaded
530
- ✅ Test scope analyzed
531
- Test strategy defined
532
- Existing patterns identified
533
- Debug strategy prepared
534
-
535
- **Proceeding with test implementation...**
536
- ```
537
-
538
- **Validation Keywords:**
539
- - MUST contain: "Patterns Loaded ✓"
540
- - MUST contain: "Test Scope Analysis ✓"
541
- - MUST contain: "Test Strategy ✓"
542
- - MUST contain: "Existing Test Patterns ✓"
543
- - MUST contain: "Ready to Implement ✓"
544
-
545
- ---
546
-
547
- ### 6️⃣ **integration Agent**
548
-
549
- **Required Pre-Work:**
550
-
551
- ```markdown
552
- ## Pre-Implementation Validation Report
553
-
554
- ### A. Validation Type ✓
555
- **Phase:** API Design / Contract Validation / Business Logic
556
-
557
- **Tasks:**
558
- - [ ] Generate OpenAPI spec (if API Design)
559
- - [ ] Validate backend/frontend contracts (if Contract Validation)
560
- - [ ] Verify requirements (if Business Logic)
561
-
562
- ### B. Contract Sources ✓
563
- **Backend API Files:**
564
- ```bash
565
- Glob: "**/api/**/*.{py,ts,js}"
566
- Grep: "router\\.(post|get|put|delete)"
567
- Grep: "@app\\.(post|get)"
568
- ```
569
-
570
- **Frontend API Calls:**
571
- ```bash
572
- Grep: "fetch\\(.*\\/api\\/"
573
- Grep: "axios\\.(post|get)"
574
- ```
575
-
576
- ### C. Validation Checklist ✓
577
- **For Each Endpoint:**
578
- - [ ] Request schema matches
579
- - [ ] Response schema matches
580
- - [ ] Status codes match
581
- - [ ] Error responses match
582
- - [ ] Types compatible
583
-
584
- ### D. Business Requirements Check
585
- **From:** proposal.md
586
-
587
- **Requirements:**
588
- 1. User registration with email validation
589
- 2. User login with JWT
590
- 3. Secure password storage
591
-
592
- **Implementation Check:**
593
- - [x] Registration endpoint exists → POST /api/auth/register
594
- - [x] Login endpoint exists → POST /api/auth/login
595
- - [x] Email validation → Pydantic EmailStr
596
- - [x] JWT generationlib/jwt.py
597
- - [x] Password hashingbcrypt
598
-
599
- **Result:** All requirements met
600
-
601
- ### E. Ready to Validate ✓
602
- Validation type identified
603
- ✅ Contract sources located
604
- Validation checklist prepared
605
- Business requirements reviewed
606
-
607
- **Proceeding with validation...**
608
- ```
609
-
610
- **Validation Keywords:**
611
- - MUST contain: "Validation Type ✓"
612
- - MUST contain: "Contract Sources ✓" OR "Requirements Check ✓"
613
- - MUST contain: "Ready to Validate ✓"
614
-
615
- ---
616
-
617
- ## 🚨 Validation Enforcement Logic
618
-
619
- ### Orchestrator Validation Function
620
-
621
- ```typescript
622
- interface ValidationResult {
623
- passed: boolean
624
- missing: string[]
625
- report?: string
626
- }
627
-
628
- function validateAgentPreWork(
629
- agentType: string,
630
- agentResponse: string,
631
- phaseMetadata: string
632
- ): ValidationResult {
633
- const required: string[] = []
634
-
635
- // Common for all agents
636
- required.push("Pre-Implementation Validation Report")
637
- required.push("Ready to Implement ✓")
638
-
639
- // Agent-specific requirements
640
- switch (agentType) {
641
- case "uxui-frontend":
642
- required.push("Design Foundation ✓")
643
- required.push("Box Thinking Analysis ✓")
644
- required.push("Component Search ✓")
645
- required.push("Design Tokens Extracted ✓")
646
- break
647
-
648
- case "backend":
649
- required.push("Patterns Loaded ✓")
650
- required.push("Existing Endpoints Search ✓")
651
- required.push("Error Handling Pattern ✓")
652
- required.push("Logging Pattern ✓")
653
-
654
- // TDD specific
655
- if (phaseMetadata.includes("| TDD |")) {
656
- required.push("TDD Workflow")
657
- required.push("RED-GREEN-REFACTOR")
658
- }
659
- break
660
-
661
- case "frontend":
662
- required.push("Patterns Loaded ✓")
663
- required.push("API Contract Review ✓")
664
- required.push("State Management Strategy ✓")
665
- required.push("Error Handling Strategy ✓")
666
- break
667
-
668
- case "database":
669
- required.push("Patterns Loaded ✓")
670
- required.push("Existing Schema Search ✓")
671
- required.push("Schema Design Plan ✓")
672
- required.push("Migration Strategy ✓")
673
- break
674
-
675
- case "test-debug":
676
- required.push("Patterns Loaded ✓")
677
- required.push("Test Scope Analysis ✓")
678
- required.push("Test Strategy ✓")
679
- required.push("Existing Test Patterns ✓")
680
- break
681
-
682
- case "integration":
683
- required.push("Validation Type ✓")
684
- required.push("Ready to Validate ✓")
685
- break
686
- }
687
-
688
- // Check all requirements
689
- const missing = required.filter(req =>
690
- !agentResponse.includes(req)
691
- )
692
-
693
- return {
694
- passed: missing.length === 0,
695
- missing,
696
- report: missing.length === 0 ? agentResponse : undefined
697
- }
698
- }
699
- ```
700
-
701
- ### Rejection Message Template
702
-
703
- ```markdown
704
- **Validation Failed**
705
-
706
- Your response is missing required pre-work steps:
707
-
708
- {missing.map(item => `- ${item}`).join('\n')}
709
-
710
- **You MUST complete ALL mandatory steps before implementation.**
711
-
712
- Please provide a complete Pre-Implementation Validation Report covering:
713
-
714
- {agent-specific requirements}
715
-
716
- **Format:**
717
- ```markdown
718
- ## ✅ Pre-Implementation Validation Report
719
-
720
- ### A. {First Requirement} ✓
721
- [details]
722
-
723
- ### B. {Second Requirement} ✓
724
- [details]
725
-
726
- ...
727
-
728
- ### Ready to Implement ✓
729
- [confirmation]
730
- ```
731
-
732
- **Only after validation passes can you proceed with implementation.**
733
- ```
734
-
735
- ---
736
-
737
- ## 🔄 Updated Workflow
738
-
739
- ```
740
- User: /cdev CHANGE-001
741
-
742
- Main Claude: Read phases.md → Phase 1 (uxui-frontend)
743
-
744
- Main Claude: Build prompt with validation requirement
745
-
746
- Main Claude: Invoke agent
747
-
748
- Agent: Respond with Pre-Implementation Report
749
-
750
- Main Claude: Validate report
751
- ├─ Invalid Send rejection message → Wait for corrected report
752
- └─ ✅ Valid → Allow agent to proceed
753
-
754
- Agent: Implement with validated context
755
-
756
- Agent: Update flags.json
757
-
758
- Main Claude: Move to next phase
759
- ```
760
-
761
- ---
762
-
763
- ## 📊 Validation Coverage
764
-
765
- | Agent | Design | TDD | Reuse | Errors | Logging | Testing | State |
766
- |-------|--------|-----|-------|--------|---------|---------|-------|
767
- | **uxui-frontend** | ✅ | - | ✅ | - | - | - | - |
768
- | **backend** | - | | | | | - | - |
769
- | **frontend** | - | - | - | ✅ | ✅ | - | ✅ |
770
- | **database** | - | - | ✅ | | | - | - |
771
- | **test-debug** | - | - | ✅ | - | - | | - |
772
- | **integration** | - | - | - | - | - | - | - |
773
-
774
- ---
775
-
776
- **Every agent, every pattern, fully validated!** ✅
1
+ # Comprehensive Validation Framework
2
+
3
+ > **Validation patterns for agent pre-work**
4
+ > **Version:** 2.0.0 (Claude 4.5 Optimized)
5
+
6
+ ---
7
+
8
+ ## 🎯 Overview
9
+
10
+ Every agent has pre-work steps that ensure quality output.
11
+
12
+ WHY: Pre-work validation prevents inconsistent output (mismatched colors, missing error handling, duplicate components).
13
+
14
+ **Principles:**
15
+ 1. **Report Before Code** - Agent must report completion BEFORE implementation
16
+ 2. **Validation Gates** - Orchestrator validates BEFORE allowing next step
17
+ 3. **Rejection with Guidance** - Clear feedback if validation fails
18
+ 4. **Pattern-Specific** - Each agent has unique validation requirements
19
+
20
+ ---
21
+
22
+ ## 📋 Validation Checklists by Agent
23
+
24
+ ### 1️⃣ **uxui-frontend Agent**
25
+
26
+ **Required Pre-Work:**
27
+
28
+ ```markdown
29
+ ## ✅ Pre-Implementation Validation Report
30
+
31
+ ### A. Design Foundation ✓
32
+ - [x] Read: design/index.md
33
+ - [x] Read: design/box-thinking.md
34
+ - [x] Read: design/color-theory.md
35
+ - [x] Read: design/spacing.md
36
+ - [x] Read: design/shadows.md
37
+ - [x] Read: patterns/ui-component-consistency.md
38
+ - [x] Read: patterns/frontend-component-strategy.md
39
+
40
+ **Summary:** Loaded design system, spacing scale (8/16/24/32/40/48px), color tokens, shadow patterns.
41
+
42
+ ### B. Box Thinking Analysis ✓
43
+ **Component:** [Landing Page]
44
+
45
+ **Structure:**
46
+ ```
47
+ Landing Page
48
+ ├─ Hero (container) - padding: 48px
49
+ │ ├─ Headline (h1)
50
+ │ ├─ Subtitle (p)
51
+ │ └─ CTA Button
52
+ └─ Features (container) - gap: 24px
53
+ └─ FeatureCard x3 (grid)
54
+ ├─ Icon
55
+ ├─ Title
56
+ └─ Description
57
+ ```
58
+
59
+ **Spacing Plan:**
60
+ - Hero: padding-12 (48px)
61
+ - Card gap: gap-6 (24px)
62
+ - Card padding: padding-6 (24px)
63
+
64
+ **Responsive:**
65
+ - Mobile (<640px): Stack vertically
66
+ - Tablet (640-1024px): 2-column grid
67
+ - Desktop (>1024px): 3-column grid
68
+
69
+ ### C. Component Search ✓
70
+ **Search Performed:**
71
+ ```bash
72
+ Glob: "**/*{Hero,Feature,Card,Button,Icon}*.{tsx,jsx}"
73
+ Grep: "export.*function.*(Button|Card)"
74
+ ```
75
+
76
+ **Results:**
77
+ - ✅ Found: components/ui/Button.tsx
78
+ - ✅ Found: components/ui/Card.tsx
79
+ - Not found: Hero, FeatureCard
80
+
81
+ **Decision:**
82
+ - **Reuse:** Button (variant="primary", size="lg")
83
+ - **Reuse:** Card (for FeatureCard base)
84
+ - **Create New:** HeroSection, FeatureCard (no alternatives exist)
85
+
86
+ **Justification:** Hero and FeatureCard are domain-specific, cannot reuse generic components.
87
+
88
+ ### D. Design Tokens Extracted ✓
89
+ **Reference:** components/ui/Button.tsx
90
+
91
+ ```typescript
92
+ const DESIGN_TOKENS = {
93
+ spacing: {
94
+ padding: 'px-4 py-2', // Button default
95
+ gap: 'gap-4' // Between elements
96
+ },
97
+ colors: {
98
+ primary: 'bg-blue-600',
99
+ primaryHover: 'hover:bg-blue-700',
100
+ text: 'text-white',
101
+ muted: 'text-foreground/70'
102
+ },
103
+ shadows: 'shadow-sm',
104
+ radius: 'rounded-md',
105
+ transitions: 'transition-colors duration-200'
106
+ }
107
+ ```
108
+
109
+ **Consistency Check:**
110
+ - ✅ All buttons use bg-blue-600/700
111
+ - ✅ All rounded corners use rounded-md
112
+ - All shadows use shadow-sm
113
+ - ✅ Will follow these patterns
114
+
115
+ ### E. Mock Data Strategy ✓
116
+ ```typescript
117
+ const MOCK_DATA = {
118
+ hero: {
119
+ headline: "Welcome to Our Platform",
120
+ subtitle: "Build amazing things",
121
+ ctaText: "Get Started"
122
+ },
123
+ features: [
124
+ { id: 1, title: "Fast", description: "Lightning speed", icon: "⚡" },
125
+ { id: 2, title: "Secure", description: "Bank-level security", icon: "🔒" },
126
+ { id: 3, title: "Scalable", description: "Grows with you", icon: "📈" }
127
+ ]
128
+ }
129
+ // TODO: Replace with API call in Phase 3
130
+ ```
131
+
132
+ ### F. Ready to Implement ✓
133
+ All design contexts loaded
134
+ Box thinking complete
135
+ ✅ Existing components searched
136
+ Design tokens extracted
137
+ ✅ Mock data prepared
138
+
139
+ **Proceeding with implementation...**
140
+ ```
141
+
142
+ **Validation Keywords:**
143
+ - Contains: "Design Foundation ✓"
144
+ - Contains: "Box Thinking Analysis ✓"
145
+ - Contains: "Component Search ✓"
146
+ - Contains: "Design Tokens Extracted ✓"
147
+ - Contains: "Ready to Implement ✓"
148
+
149
+ ---
150
+
151
+ ### 2️⃣ **backend Agent**
152
+
153
+ **Required Pre-Work:**
154
+
155
+ ```markdown
156
+ ## ✅ Pre-Implementation Validation Report
157
+
158
+ ### A. Patterns Loaded ✓
159
+ - [x] Read: patterns/error-handling.md
160
+ - [x] Read: patterns/logging.md
161
+ - [x] Read: patterns/testing.md
162
+
163
+ ### B. Existing Endpoints Search ✓
164
+ **Search Performed:**
165
+ ```bash
166
+ Grep: "router\\.(post|get|put|delete).*\\/api\\/auth"
167
+ Grep: "@app\\.(post|get).*\\/api\\/auth"
168
+ ```
169
+
170
+ **Results:**
171
+ - ❌ No existing /api/auth/login
172
+ - No existing /api/auth/register
173
+ - Can proceed with implementation
174
+
175
+ ### C. TDD Workflow (if metadata: | TDD |) ✓
176
+ **TDD Required:** YES (metadata flag detected)
177
+
178
+ **Phase Plan:**
179
+ 1. 🔴 RED: Write 7 tests FIRST
180
+ - test_register_success
181
+ - test_register_duplicate_email
182
+ - test_register_invalid_email
183
+ - test_register_weak_password
184
+ - test_login_success
185
+ - test_login_invalid_credentials
186
+ - test_login_validation_error
187
+
188
+ 2. GREEN: Minimal implementation
189
+ - User model
190
+ - Password hashing (bcrypt)
191
+ - JWT generation
192
+ - Registration endpoint
193
+ - Login endpoint
194
+
195
+ 3. 🔧 REFACTOR: Add production quality
196
+ - Structured logging
197
+ - Error handling
198
+ - Type hints
199
+ - Docstrings
200
+
201
+ **Commitment:** Will follow RED-GREEN-REFACTOR strictly.
202
+
203
+ ### D. Error Handling Pattern ✓
204
+ **From:** patterns/error-handling.md
205
+
206
+ ```python
207
+ # Pattern to follow:
208
+ try:
209
+ # Business logic
210
+ user = await create_user(...)
211
+ logger.info("user_created", extra={"user_id": user.id})
212
+ return {"id": user.id}
213
+ except HTTPException:
214
+ raise # Re-raise HTTP exceptions
215
+ except Exception as e:
216
+ logger.error("user_creation_error", extra={"error": str(e)})
217
+ raise HTTPException(status_code=500, detail="Internal server error")
218
+ ```
219
+
220
+ ### E. Logging Pattern ✓
221
+ **From:** patterns/logging.md
222
+
223
+ ```python
224
+ # All significant events:
225
+ logger.info("api_route_entry", extra={"route": "/api/auth/login"})
226
+ logger.info("login_success", extra={"user_id": user.id})
227
+ logger.warning("login_failed", extra={"email": email, "reason": "invalid_credentials"})
228
+ logger.error("login_error", extra={"error": str(e)})
229
+ ```
230
+
231
+ ### F. Ready to Implement ✓
232
+ Patterns loaded
233
+ Existing endpoints searched
234
+ ✅ TDD workflow planned
235
+ Error handling pattern identified
236
+ ✅ Logging pattern identified
237
+
238
+ **Proceeding with TDD (RED phase first)...**
239
+ ```
240
+
241
+ **Validation Keywords:**
242
+ - Contains: "Patterns Loaded ✓"
243
+ - Contains: "Existing Endpoints Search ✓"
244
+ - IF TDD: Contains "TDD Workflow" + "RED-GREEN-REFACTOR"
245
+ - Contains: "Error Handling Pattern ✓"
246
+ - Contains: "Logging Pattern ✓"
247
+ - Contains: "Ready to Implement ✓"
248
+
249
+ ---
250
+
251
+ ### 3️⃣ **frontend Agent**
252
+
253
+ **Required Pre-Work:**
254
+
255
+ ```markdown
256
+ ## ✅ Pre-Implementation Validation Report
257
+
258
+ ### A. Patterns Loaded ✓
259
+ - [x] Read: patterns/error-handling.md
260
+ - [x] Read: patterns/logging.md
261
+ - [x] Read: patterns/testing.md
262
+
263
+ ### B. API Contract Review ✓
264
+ **From:** integration agent / API spec
265
+
266
+ **Endpoints to Connect:**
267
+ - POST /api/auth/login
268
+ - Request: { email: string, password: string }
269
+ - Success (200): { token: string, user: { id, email } }
270
+ - Error (401): { detail: "Invalid credentials" }
271
+ - Error (422): { detail: [...validation errors] }
272
+
273
+ **State Management Needed:**
274
+ - Auth state (user, token, isLoading)
275
+ - Form state (email, password, errors)
276
+
277
+ ### C. State Management Strategy ✓
278
+ **Framework:** Zustand (from tech-stack.md)
279
+
280
+ ```typescript
281
+ // Create auth store
282
+ import { create } from 'zustand'
283
+
284
+ interface AuthState {
285
+ user: User | null
286
+ token: string | null
287
+ isLoading: boolean
288
+ login: (email: string, password: string) => Promise<void>
289
+ logout: () => void
290
+ }
291
+
292
+ const useAuthStore = create<AuthState>((set) => ({
293
+ user: null,
294
+ token: null,
295
+ isLoading: false,
296
+ login: async (email, password) => {
297
+ set({ isLoading: true })
298
+ try {
299
+ const response = await fetch('/api/auth/login', {
300
+ method: 'POST',
301
+ body: JSON.stringify({ email, password })
302
+ })
303
+ const data = await response.json()
304
+ set({ user: data.user, token: data.token, isLoading: false })
305
+ } catch (error) {
306
+ set({ isLoading: false })
307
+ throw error
308
+ }
309
+ },
310
+ logout: () => set({ user: null, token: null })
311
+ }))
312
+ ```
313
+
314
+ ### D. Error Handling Strategy
315
+ ```typescript
316
+ // User-friendly error messages
317
+ const handleError = (error: ApiError) => {
318
+ if (error.status === 401) {
319
+ toast.error("Invalid email or password")
320
+ } else if (error.status === 422) {
321
+ // Show validation errors
322
+ error.detail.forEach(err => {
323
+ setFieldError(err.loc[1], err.msg)
324
+ })
325
+ } else {
326
+ toast.error("Something went wrong. Please try again.")
327
+ }
328
+
329
+ // Log for debugging (no sensitive data)
330
+ logger.error("login_failed", { status: error.status })
331
+ }
332
+ ```
333
+
334
+ ### E. Component Integration Plan ✓
335
+ **Existing Component:** LoginForm (from uxui-frontend phase)
336
+
337
+ **Changes Required:**
338
+ 1. Replace mock onClick with real useAuthStore
339
+ 2. Add loading state (disable button, show spinner)
340
+ 3. Add error handling (toast notifications)
341
+ 4. Add form validation (client-side)
342
+ 5. Add redirect after success
343
+
344
+ ### F. Ready to Implement ✓
345
+ Patterns loaded
346
+ API contract reviewed
347
+ ✅ State management strategy defined
348
+ Error handling strategy defined
349
+ ✅ Component integration plan ready
350
+
351
+ **Proceeding with implementation...**
352
+ ```
353
+
354
+ **Validation Keywords:**
355
+ - Contains: "Patterns Loaded ✓"
356
+ - Contains: "API Contract Review ✓"
357
+ - Contains: "State Management Strategy ✓"
358
+ - Contains: "Error Handling Strategy ✓"
359
+ - Contains: "Ready to Implement ✓"
360
+
361
+ ---
362
+
363
+ ### 4️⃣ **database Agent**
364
+
365
+ **Required Pre-Work:**
366
+
367
+ ```markdown
368
+ ## ✅ Pre-Implementation Validation Report
369
+
370
+ ### A. Patterns Loaded ✓
371
+ - [x] Read: patterns/error-handling.md
372
+ - [x] Read: patterns/logging.md
373
+
374
+ ### B. Existing Schema Search ✓
375
+ **Search Performed:**
376
+ ```bash
377
+ Glob: "**/*.prisma"
378
+ Glob: "**/*models*.py"
379
+ Grep: "class.*\\(Base\\)"
380
+ Grep: "model User"
381
+ ```
382
+
383
+ **Results:**
384
+ - No existing User model
385
+ - ✅ Can proceed with schema design
386
+
387
+ ### C. Schema Design Plan ✓
388
+ **Model:** User
389
+
390
+ **Fields:**
391
+ - id: string (UUID, primary key)
392
+ - email: string (unique, indexed)
393
+ - hashed_password: string (never exposed)
394
+ - created_at: datetime (auto)
395
+ - updated_at: datetime (auto)
396
+
397
+ **Constraints:**
398
+ - Unique: email
399
+ - Index: email (for fast lookups)
400
+
401
+ **Relationships:**
402
+ - User → Sessions (1:N) - for JWT token management
403
+
404
+ ### D. Migration Strategy ✓
405
+ **ORM:** Prisma (from tech-stack.md)
406
+
407
+ ```bash
408
+ # Generate migration
409
+ pnpm prisma migrate dev --name add_user_model
410
+
411
+ # This will create:
412
+ # prisma/migrations/YYYYMMDD_add_user_model/migration.sql
413
+ ```
414
+
415
+ ### E. Query Functions Plan
416
+ ```typescript
417
+ // Create user
418
+ async function createUser(email: string, hashedPassword: string): Promise<User>
419
+
420
+ // Find by email (for login)
421
+ async function findUserByEmail(email: string): Promise<User | null>
422
+
423
+ // Update password
424
+ async function updatePassword(userId: string, newHashedPassword: string): Promise<void>
425
+ ```
426
+
427
+ ### F. Performance Considerations
428
+ - ✅ Index on email (unique constraint also creates index)
429
+ - Use select() to avoid exposing hashed_password
430
+ - No N+1 queries (direct lookups)
431
+
432
+ ### G. Ready to Implement ✓
433
+ Patterns loaded
434
+ Existing schemas searched
435
+ Schema design planned
436
+ ✅ Migration strategy defined
437
+ Query functions planned
438
+ ✅ Performance considered
439
+
440
+ **Proceeding with schema implementation...**
441
+ ```
442
+
443
+ **Validation Keywords:**
444
+ - Contains: "Patterns Loaded ✓"
445
+ - Contains: "Existing Schema Search ✓"
446
+ - Contains: "Schema Design Plan ✓"
447
+ - Contains: "Migration Strategy ✓"
448
+ - Contains: "Ready to Implement ✓"
449
+
450
+ ---
451
+
452
+ ### 5️⃣ **test-debug Agent**
453
+
454
+ **Required Pre-Work:**
455
+
456
+ ```markdown
457
+ ## ✅ Pre-Implementation Validation Report
458
+
459
+ ### A. Patterns Loaded ✓
460
+ - [x] Read: patterns/testing.md
461
+ - [x] Read: patterns/error-handling.md
462
+ - [x] Read: patterns/logging.md
463
+
464
+ ### B. Test Scope Analysis ✓
465
+ **Phase:** Component Tests / Backend Tests / E2E Tests
466
+
467
+ **Components to Test:**
468
+ - HeroSection
469
+ - FeatureCard
470
+ - LoginForm
471
+
472
+ **Coverage Target:** 85% (from project standards)
473
+
474
+ ### C. Test Strategy ✓
475
+ **Framework:** Vitest (from tech-stack.md)
476
+
477
+ **Test Types:**
478
+ 1. **Unit Tests**
479
+ - Component rendering
480
+ - Props validation
481
+ - Event handlers
482
+ - State changes
483
+
484
+ 2. **Integration Tests**
485
+ - Component interactions
486
+ - API mocking
487
+ - State management
488
+
489
+ ### D. Existing Test Patterns ✓
490
+ **Search Performed:**
491
+ ```bash
492
+ Grep: "describe.*test.*it\\("
493
+ Grep: "expect\\(.*\\)\\.toBe"
494
+ ```
495
+
496
+ **Pattern Found:**
497
+ ```typescript
498
+ // Existing pattern in __tests__/Button.test.tsx
499
+ describe('Button', () => {
500
+ it('renders with correct text', () => {
501
+ render(<Button>Click me</Button>)
502
+ expect(screen.getByText('Click me')).toBeInTheDocument()
503
+ })
504
+
505
+ it('calls onClick when clicked', () => {
506
+ const handleClick = vi.fn()
507
+ render(<Button onClick={handleClick}>Click</Button>)
508
+ fireEvent.click(screen.getByText('Click'))
509
+ expect(handleClick).toHaveBeenCalledTimes(1)
510
+ })
511
+ })
512
+ ```
513
+
514
+ **Will follow this pattern.**
515
+
516
+ ### E. Debug Strategy (if tests fail) ✓
517
+ **Max Iterations:** 3-4
518
+ **Per Iteration:**
519
+ 1. Read error messages carefully
520
+ 2. Identify root cause
521
+ 3. Fix code or test
522
+ 4. Re-run
523
+ 5. Log iteration results
524
+
525
+ **If stuck after 4 iterations:**
526
+ - Escalate to main Claude with:
527
+ - Error messages
528
+ - Code attempted
529
+ - Suspected root cause
530
+
531
+ ### F. Ready to Implement ✓
532
+ Patterns loaded
533
+ Test scope analyzed
534
+ ✅ Test strategy defined
535
+ Existing patterns identified
536
+ ✅ Debug strategy prepared
537
+
538
+ **Proceeding with test implementation...**
539
+ ```
540
+
541
+ **Validation Keywords:**
542
+ - Contains: "Patterns Loaded ✓"
543
+ - Contains: "Test Scope Analysis ✓"
544
+ - Contains: "Test Strategy ✓"
545
+ - Contains: "Existing Test Patterns ✓"
546
+ - Contains: "Ready to Implement ✓"
547
+
548
+ ---
549
+
550
+ ### 6️⃣ **integration Agent**
551
+
552
+ **Required Pre-Work:**
553
+
554
+ ```markdown
555
+ ## Pre-Implementation Validation Report
556
+
557
+ ### A. Validation Type ✓
558
+ **Phase:** API Design / Contract Validation / Business Logic
559
+
560
+ **Tasks:**
561
+ - [ ] Generate OpenAPI spec (if API Design)
562
+ - [ ] Validate backend/frontend contracts (if Contract Validation)
563
+ - [ ] Verify requirements (if Business Logic)
564
+
565
+ ### B. Contract Sources ✓
566
+ **Backend API Files:**
567
+ ```bash
568
+ Glob: "**/api/**/*.{py,ts,js}"
569
+ Grep: "router\\.(post|get|put|delete)"
570
+ Grep: "@app\\.(post|get)"
571
+ ```
572
+
573
+ **Frontend API Calls:**
574
+ ```bash
575
+ Grep: "fetch\\(.*\\/api\\/"
576
+ Grep: "axios\\.(post|get)"
577
+ ```
578
+
579
+ ### C. Validation Checklist
580
+ **For Each Endpoint:**
581
+ - [ ] Request schema matches
582
+ - [ ] Response schema matches
583
+ - [ ] Status codes match
584
+ - [ ] Error responses match
585
+ - [ ] Types compatible
586
+
587
+ ### D. Business Requirements Check ✓
588
+ **From:** proposal.md
589
+
590
+ **Requirements:**
591
+ 1. User registration with email validation
592
+ 2. User login with JWT
593
+ 3. Secure password storage
594
+
595
+ **Implementation Check:**
596
+ - [x] Registration endpoint exists POST /api/auth/register
597
+ - [x] Login endpoint exists POST /api/auth/login
598
+ - [x] Email validation → Pydantic EmailStr
599
+ - [x] JWT generation → lib/jwt.py
600
+ - [x] Password hashing → bcrypt
601
+
602
+ **Result:** All requirements met ✓
603
+
604
+ ### E. Ready to Validate ✓
605
+ Validation type identified
606
+ ✅ Contract sources located
607
+ Validation checklist prepared
608
+ ✅ Business requirements reviewed
609
+
610
+ **Proceeding with validation...**
611
+ ```
612
+
613
+ **Validation Keywords:**
614
+ - Contains: "Validation Type ✓"
615
+ - Contains: "Contract Sources ✓" OR "Requirements Check ✓"
616
+ - Contains: "Ready to Validate ✓"
617
+
618
+ ---
619
+
620
+ ## ✅ Validation Enforcement Logic
621
+
622
+ ### Orchestrator Validation Function
623
+
624
+ ```typescript
625
+ interface ValidationResult {
626
+ passed: boolean
627
+ missing: string[]
628
+ report?: string
629
+ }
630
+
631
+ function validateAgentPreWork(
632
+ agentType: string,
633
+ agentResponse: string,
634
+ phaseMetadata: string
635
+ ): ValidationResult {
636
+ const required: string[] = []
637
+
638
+ // Common for all agents
639
+ required.push("Pre-Implementation Validation Report")
640
+ required.push("Ready to Implement ✓")
641
+
642
+ // Agent-specific requirements
643
+ switch (agentType) {
644
+ case "uxui-frontend":
645
+ required.push("Design Foundation ✓")
646
+ required.push("Box Thinking Analysis ✓")
647
+ required.push("Component Search ✓")
648
+ required.push("Design Tokens Extracted ✓")
649
+ break
650
+
651
+ case "backend":
652
+ required.push("Patterns Loaded ✓")
653
+ required.push("Existing Endpoints Search ✓")
654
+ required.push("Error Handling Pattern ✓")
655
+ required.push("Logging Pattern ")
656
+
657
+ // TDD specific
658
+ if (phaseMetadata.includes("| TDD |")) {
659
+ required.push("TDD Workflow")
660
+ required.push("RED-GREEN-REFACTOR")
661
+ }
662
+ break
663
+
664
+ case "frontend":
665
+ required.push("Patterns Loaded ✓")
666
+ required.push("API Contract Review ✓")
667
+ required.push("State Management Strategy ✓")
668
+ required.push("Error Handling Strategy ✓")
669
+ break
670
+
671
+ case "database":
672
+ required.push("Patterns Loaded ✓")
673
+ required.push("Existing Schema Search ✓")
674
+ required.push("Schema Design Plan ✓")
675
+ required.push("Migration Strategy ✓")
676
+ break
677
+
678
+ case "test-debug":
679
+ required.push("Patterns Loaded ✓")
680
+ required.push("Test Scope Analysis ✓")
681
+ required.push("Test Strategy ✓")
682
+ required.push("Existing Test Patterns ✓")
683
+ break
684
+
685
+ case "integration":
686
+ required.push("Validation Type ✓")
687
+ required.push("Ready to Validate ✓")
688
+ break
689
+ }
690
+
691
+ // Check all requirements
692
+ const missing = required.filter(req =>
693
+ !agentResponse.includes(req)
694
+ )
695
+
696
+ return {
697
+ passed: missing.length === 0,
698
+ missing,
699
+ report: missing.length === 0 ? agentResponse : undefined
700
+ }
701
+ }
702
+ ```
703
+
704
+ ### Rejection Message Template
705
+
706
+ ```markdown
707
+ ❌ **Validation Failed**
708
+
709
+ Your response is missing required pre-work steps:
710
+
711
+ {missing.map(item => `- ${item}`).join('\n')}
712
+
713
+ **Complete all pre-work steps before implementation for quality output.**
714
+
715
+ Please provide a complete Pre-Implementation Validation Report covering:
716
+
717
+ {agent-specific requirements}
718
+
719
+ **Format:**
720
+ ```markdown
721
+ ## ✅ Pre-Implementation Validation Report
722
+
723
+ ### A. {First Requirement} ✓
724
+ [details]
725
+
726
+ ### B. {Second Requirement} ✓
727
+ [details]
728
+
729
+ ...
730
+
731
+ ### Ready to Implement ✓
732
+ [confirmation]
733
+ ```
734
+
735
+ **Only after validation passes can you proceed with implementation.**
736
+ ```
737
+
738
+ ---
739
+
740
+ ## 🔄 Updated Workflow
741
+
742
+ ```
743
+ User: /cdev CHANGE-001
744
+
745
+ Main Claude: Read phases.md → Phase 1 (uxui-frontend)
746
+
747
+ Main Claude: Build prompt with validation requirement
748
+
749
+ Main Claude: Invoke agent
750
+
751
+ Agent: Respond with Pre-Implementation Report
752
+
753
+ Main Claude: Validate report
754
+ ├─ Invalid Send rejection message → Wait for corrected report
755
+ └─ ✅ Valid → Allow agent to proceed
756
+
757
+ Agent: Implement with validated context
758
+
759
+ Agent: Update flags.json
760
+
761
+ Main Claude: Move to next phase
762
+ ```
763
+
764
+ ---
765
+
766
+ ## 📊 Validation Coverage
767
+
768
+ | Agent | Design | TDD | Reuse | Errors | Logging | Testing | State |
769
+ |-------|--------|-----|-------|--------|---------|---------|-------|
770
+ | **uxui-frontend** | | - | ✅ | - | - | - | - |
771
+ | **backend** | - | | ✅ | | | - | - |
772
+ | **frontend** | - | - | - | | | - | |
773
+ | **database** | - | - | ✅ | ✅ | ✅ | - | - |
774
+ | **test-debug** | - | - | ✅ | - | - | ✅ | - |
775
+ | **integration** | - | - | - | - | - | - | - |
776
+
777
+ ---
778
+
779
+ **Every agent, every pattern, fully validated!** ✅