@champpaba/claude-agent-kit 2.7.0 → 2.8.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 (44) hide show
  1. package/.claude/CLAUDE.md +49 -0
  2. package/.claude/commands/csetup.md +364 -38
  3. package/.claude/commands/cview.md +364 -364
  4. package/.claude/contexts/design/accessibility.md +611 -611
  5. package/.claude/contexts/design/layout.md +400 -400
  6. package/.claude/contexts/design/responsive.md +551 -551
  7. package/.claude/contexts/design/shadows.md +522 -522
  8. package/.claude/contexts/design/typography.md +465 -465
  9. package/.claude/contexts/domain/README.md +164 -164
  10. package/.claude/contexts/patterns/agent-coordination.md +388 -388
  11. package/.claude/contexts/patterns/development-principles.md +513 -513
  12. package/.claude/contexts/patterns/error-handling.md +478 -478
  13. package/.claude/contexts/patterns/logging.md +424 -424
  14. package/.claude/contexts/patterns/tdd-classification.md +516 -516
  15. package/.claude/contexts/patterns/testing.md +413 -413
  16. package/.claude/lib/tdd-classifier.md +345 -345
  17. package/.claude/lib/validation-gates.md +484 -484
  18. package/.claude/settings.local.json +42 -42
  19. package/.claude/templates/context-template.md +45 -45
  20. package/.claude/templates/flags-template.json +42 -42
  21. package/.claude/templates/phases-sections/accessibility-test.md +17 -17
  22. package/.claude/templates/phases-sections/api-design.md +37 -37
  23. package/.claude/templates/phases-sections/backend-tests.md +16 -16
  24. package/.claude/templates/phases-sections/backend.md +37 -37
  25. package/.claude/templates/phases-sections/business-logic-validation.md +16 -16
  26. package/.claude/templates/phases-sections/component-tests.md +17 -17
  27. package/.claude/templates/phases-sections/contract-backend.md +16 -16
  28. package/.claude/templates/phases-sections/contract-frontend.md +16 -16
  29. package/.claude/templates/phases-sections/database.md +35 -35
  30. package/.claude/templates/phases-sections/e2e-tests.md +16 -16
  31. package/.claude/templates/phases-sections/fix-implementation.md +17 -17
  32. package/.claude/templates/phases-sections/frontend-integration.md +18 -18
  33. package/.claude/templates/phases-sections/manual-flow-test.md +15 -15
  34. package/.claude/templates/phases-sections/manual-ux-test.md +16 -16
  35. package/.claude/templates/phases-sections/refactor-implementation.md +17 -17
  36. package/.claude/templates/phases-sections/refactor.md +16 -16
  37. package/.claude/templates/phases-sections/regression-tests.md +15 -15
  38. package/.claude/templates/phases-sections/responsive-test.md +16 -16
  39. package/.claude/templates/phases-sections/script-implementation.md +43 -43
  40. package/.claude/templates/phases-sections/test-coverage.md +16 -16
  41. package/.claude/templates/phases-sections/user-approval.md +14 -14
  42. package/LICENSE +21 -21
  43. package/README.md +25 -0
  44. package/package.json +8 -4
@@ -1,516 +1,516 @@
1
- # Universal Task Classification
2
-
3
- ## Purpose
4
-
5
- Classify tasks to determine if Test-Driven Development (TDD) is required, regardless of task source (file, command, spec framework, etc.).
6
-
7
- ---
8
-
9
- ## Classification Output
10
-
11
- **Input:** Task description (string)
12
- **Output:** Classification object
13
-
14
- ```typescript
15
- {
16
- type: 'critical' | 'standard' | 'ui' | 'ui-complex' | 'config',
17
- tdd_required: boolean,
18
- workflow: 'red-green-refactor' | 'test-alongside',
19
- reason: string
20
- }
21
- ```
22
-
23
- ---
24
-
25
- ## Critical Code Patterns (TDD Required ✅)
26
-
27
- ### 1. API Mutations
28
- - POST, PUT, PATCH, DELETE methods
29
- - Any `/api/` endpoint that modifies data
30
- - GraphQL mutations
31
- - Webhook handlers, callbacks
32
-
33
- **Examples:**
34
- ```
35
- ✅ "Implement POST /api/auth/login"
36
- ✅ "Add PUT /api/users/:id/profile"
37
- ✅ "Create webhook handler for Stripe payments"
38
- ✅ "Delete endpoint for products"
39
- ```
40
-
41
- ### 2. Business Logic
42
- - Calculations, computations, algorithms
43
- - Validation rules, verification logic
44
- - Transformations, conversions, parsing
45
- - Domain-specific logic
46
-
47
- **Keywords:** calculate, compute, algorithm, validate, verify, check, transform, convert, parse
48
-
49
- **Business domains:** discount, pricing, payment, commission, fee, tax, shipping, score, rate, evaluate
50
-
51
- **Examples:**
52
- ```
53
- ✅ "Calculate shipping cost based on weight and distance"
54
- ✅ "Add discount calculation for VIP users"
55
- ✅ "Implement tax calculation logic"
56
- ✅ "Validate credit card numbers using Luhn algorithm"
57
- ✅ "Transform user data for export"
58
- ```
59
-
60
- ### 3. External Integrations
61
- - Third-party APIs, webhooks, callbacks
62
- - Payment gateways
63
- - Email/SMS services
64
- - Cloud storage providers
65
- - Analytics platforms
66
- - Authentication providers
67
-
68
- **Payment providers:** Stripe, PayPal, Square, Braintree, Adyen, Razorpay
69
- **Email services:** SendGrid, Mailgun, Postmark, AWS SES, Mailchimp
70
- **SMS providers:** Twilio, Vonage, MessageBird, AWS SNS
71
- **Storage:** S3, GCS, Azure Storage, Cloudinary, DigitalOcean Spaces
72
- **Analytics:** Google Analytics, Mixpanel, Amplitude, Segment
73
- **Auth:** Auth0, Firebase Auth, Cognito, Okta
74
-
75
- **Examples:**
76
- ```
77
- ✅ "Integrate Stripe payment processing"
78
- ✅ "Add SendGrid email notifications"
79
- ✅ "Implement Twilio SMS verification"
80
- ✅ "Connect to Google Analytics API"
81
- ✅ "Upload images to S3"
82
- ```
83
-
84
- ### 4. Data Transformations
85
- - Serialization, deserialization
86
- - ETL operations, data pipelines
87
- - Complex mapping, aggregations
88
- - Data normalization/denormalization
89
-
90
- **Keywords:** serialize, deserialize, transform, convert, parse, ETL, pipeline, aggregate, map, reduce, filter (complex), normalize, denormalize
91
-
92
- **Examples:**
93
- ```
94
- ✅ "Parse CSV and transform to JSON"
95
- ✅ "Aggregate user analytics data"
96
- ✅ "Serialize user data for API response"
97
- ✅ "ETL pipeline for data migration"
98
- ```
99
-
100
- ### 5. Security & Critical Operations
101
- - Authentication, authorization
102
- - Encryption, decryption, hashing, signing
103
- - Permissions, access control
104
- - Transactions, financial operations
105
- - Audit logging
106
-
107
- **Keywords:** auth, authenticate, authorize, JWT, OAuth, encrypt, decrypt, hash, sign, permission, access control, transaction, rollback, commit, audit
108
-
109
- **Examples:**
110
- ```
111
- ✅ "Implement JWT authentication"
112
- ✅ "Add password hashing with bcrypt"
113
- ✅ "Create payment transaction handler"
114
- ✅ "Implement role-based access control"
115
- ✅ "Add audit log for sensitive operations"
116
- ```
117
-
118
- ---
119
-
120
- ## Standard Code Patterns (Test-Alongside OK ⚠️)
121
-
122
- - Simple GET endpoints (read-only)
123
- - Basic list/show/display operations
124
- - Simple data fetching (no transformations)
125
- - Configuration, setup, initialization
126
-
127
- **Examples:**
128
- ```
129
- ⚠️ "Add GET /api/users endpoint"
130
- ⚠️ "Fetch user profile data"
131
- ⚠️ "Display product list"
132
- ⚠️ "Setup environment configuration"
133
- ```
134
-
135
- ---
136
-
137
- ## UI Code Patterns (Usually No TDD ❌)
138
-
139
- - Presentational components (Button, Card, Modal, etc.)
140
- - Styling, themes, CSS
141
- - Simple renders, displays
142
- - Layout components
143
-
144
- **Keywords:** component, button, card, modal, navbar, footer, style, CSS, theme, render, display, layout
145
-
146
- **Examples:**
147
- ```
148
- ❌ "Create Button component"
149
- ❌ "Add Card component with shadow"
150
- ❌ "Style navigation bar"
151
- ❌ "Update footer layout"
152
- ```
153
-
154
- ### Exception: Complex UI Logic (TDD Required ✅)
155
-
156
- **UI tasks that DO require TDD:**
157
- - Multi-step forms with validation
158
- - State machines (wizards, checkout flows)
159
- - Complex form validation logic
160
- - Accessibility features (keyboard navigation, screen reader support)
161
- - Dynamic form generation
162
-
163
- **Keywords:** multi-step, wizard, state machine, validation (complex), keyboard navigation, accessibility, ARIA, dynamic form
164
-
165
- **Examples:**
166
- ```
167
- ✅ "Implement multi-step checkout wizard with validation"
168
- ✅ "Add keyboard navigation for dropdown menu"
169
- ✅ "Create dynamic form with conditional fields"
170
- ✅ "Build wizard with state management"
171
- ```
172
-
173
- ---
174
-
175
- ## Pattern Matching Algorithm
176
-
177
- ```typescript
178
- const CRITICAL_PATTERNS = [
179
- // HTTP mutations
180
- /\b(post|put|patch|delete)\b.*\/api\//i,
181
-
182
- // Business logic
183
- /\b(calculate|compute|algorithm|validate|verify|check)\b/i,
184
- /\b(discount|pricing|payment|commission|fee|tax|shipping)\b/i,
185
- /\b(score|rate|evaluate|transform|convert|parse)\b/i,
186
-
187
- // External services (extensible)
188
- /\b(integrate|webhook|callback|third-party|external)\b/i,
189
-
190
- // Payment providers
191
- /\b(stripe|paypal|square|braintree|adyen|razorpay)\b/i,
192
-
193
- // Communication services
194
- /\b(sendgrid|mailgun|postmark|ses|mailchimp)\b/i,
195
- /\b(twilio|vonage|messagebird|sns)\b/i,
196
-
197
- // Storage providers
198
- /\b(s3|gcs|azure.*storage|cloudinary|digitalocean.*spaces)\b/i,
199
-
200
- // Analytics
201
- /\b(analytics|mixpanel|amplitude|segment)\b/i,
202
-
203
- // Auth providers
204
- /\b(auth0|firebase.*auth|cognito|okta)\b/i,
205
-
206
- // Data operations
207
- /\b(serialize|deserialize|etl|pipeline|aggregate)\b/i,
208
-
209
- // Security
210
- /\b(auth|jwt|oauth|encrypt|decrypt|hash|sign)\b/i,
211
- /\b(permission|access.*control|authorize)\b/i,
212
-
213
- // Transactions
214
- /\b(transaction|rollback|commit|audit)\b/i,
215
- ]
216
-
217
- function classifyTask(description: string): Classification {
218
- const text = description.toLowerCase()
219
-
220
- // Check critical patterns
221
- for (const pattern of CRITICAL_PATTERNS) {
222
- if (pattern.test(text)) {
223
- return {
224
- type: 'critical',
225
- tdd_required: true,
226
- workflow: 'red-green-refactor',
227
- reason: `Matched critical pattern: ${pattern.source}`
228
- }
229
- }
230
- }
231
-
232
- // Check simple GET (read-only)
233
- if (/^get\s+\/api\//i.test(text) && !/\b(complex|join|aggregate|transform)\b/i.test(text)) {
234
- return {
235
- type: 'standard',
236
- tdd_required: false,
237
- workflow: 'test-alongside',
238
- reason: 'Simple read-only operation'
239
- }
240
- }
241
-
242
- // Check UI
243
- if (/\b(component|button|card|modal|navbar|footer|style|theme|css|layout)\b/i.test(text)) {
244
- // Check for complex UI logic
245
- if (/\b(multi-step|wizard|state.*machine|keyboard.*navigation|accessibility|aria|dynamic.*form)\b/i.test(text)) {
246
- return {
247
- type: 'ui-complex',
248
- tdd_required: true,
249
- workflow: 'red-green-refactor',
250
- reason: 'Complex UI logic detected'
251
- }
252
- }
253
-
254
- return {
255
- type: 'ui',
256
- tdd_required: false,
257
- workflow: 'test-alongside',
258
- reason: 'Presentational UI component'
259
- }
260
- }
261
-
262
- // Check config/setup
263
- if (/\b(config|setup|init|install|env)\b/i.test(text)) {
264
- return {
265
- type: 'config',
266
- tdd_required: false,
267
- workflow: 'test-alongside',
268
- reason: 'Configuration task'
269
- }
270
- }
271
-
272
- // Default: standard
273
- return {
274
- type: 'standard',
275
- tdd_required: false,
276
- workflow: 'test-alongside',
277
- reason: 'Default classification (no critical patterns matched)'
278
- }
279
- }
280
- ```
281
-
282
- ---
283
-
284
- ## Classification Examples
285
-
286
- | Task Description | Type | TDD? | Reason |
287
- |-----------------|------|------|--------|
288
- | "Implement POST /api/auth/login" | critical | ✅ YES | API mutation + authentication |
289
- | "Add discount calculation for VIP users" | critical | ✅ YES | Business logic |
290
- | "Integrate Stripe webhook handler" | critical | ✅ YES | External integration + webhook |
291
- | "Parse CSV and transform to JSON" | critical | ✅ YES | Data transformation |
292
- | "Add JWT authentication middleware" | critical | ✅ YES | Security operation |
293
- | "Create multi-step checkout wizard" | ui-complex | ✅ YES | Complex UI state machine |
294
- | "Implement keyboard navigation" | ui-complex | ✅ YES | Accessibility feature |
295
- | "Create GET /api/users list" | standard | ⚠️ Optional | Simple read-only |
296
- | "Fetch user profile data" | standard | ⚠️ Optional | Simple fetch |
297
- | "Create Button component" | ui | ❌ No | Presentational UI |
298
- | "Style navigation bar" | ui | ❌ No | CSS/styling |
299
- | "Setup environment variables" | config | ❌ No | Configuration |
300
-
301
- ---
302
-
303
- ## Usage by Orchestrator
304
-
305
- ```markdown
306
- 1. Receive task (from any source: file, command, framework)
307
- 2. Extract task description
308
- 3. Run classification algorithm
309
- 4. Add classification metadata to task
310
- 5. Delegate to specialist agent with metadata
311
- ```
312
-
313
- **Example Orchestrator Code:**
314
- ```typescript
315
- // 1. Receive tasks
316
- const tasks = parseTasks(input)
317
-
318
- // 2. Classify each task
319
- for (const task of tasks) {
320
- const classification = classifyTask(task.description)
321
-
322
- task.type = classification.type
323
- task.tdd_required = classification.tdd_required
324
- task.workflow = classification.workflow
325
- task.reason = classification.reason
326
- }
327
-
328
- // 3. Delegate with metadata
329
- for (const task of tasks) {
330
- delegateToAgent(task.agent, {
331
- description: task.description,
332
- type: task.type,
333
- tdd_required: task.tdd_required,
334
- workflow: task.workflow,
335
- reason: task.reason
336
- })
337
- }
338
- ```
339
-
340
- ---
341
-
342
- ## Usage by Specialist Agents
343
-
344
- ```markdown
345
- 1. Receive task with classification metadata
346
- 2. Check `tdd_required` flag
347
- 3. If true → Red-Green-Refactor workflow
348
- 4. If false → Test-Alongside workflow
349
- ```
350
-
351
- **Example Agent Code:**
352
- ```typescript
353
- // Receive task from Orchestrator
354
- const task = receiveTask()
355
-
356
- if (task.tdd_required === true) {
357
- // TDD Workflow
358
- console.log(`⚠️ TDD Required: ${task.reason}`)
359
-
360
- // RED: Write test first
361
- writeTests()
362
- runTests() // Must FAIL
363
-
364
- // GREEN: Implement
365
- writeImplementation()
366
- runTests() // Must PASS
367
-
368
- // REFACTOR: Improve
369
- refactorCode()
370
- runTests() // Must STILL PASS
371
-
372
- } else {
373
- // Standard Workflow
374
- console.log(`ℹ️ Test-Alongside OK: ${task.reason}`)
375
-
376
- writeImplementation()
377
- writeTests()
378
- runTests()
379
- }
380
- ```
381
-
382
- ---
383
-
384
- ## Extending the Classification
385
-
386
- ### Adding New Service Providers
387
-
388
- **To support new payment provider (e.g., Payoneer):**
389
- ```typescript
390
- // Before
391
- /\b(stripe|paypal|square|braintree|adyen|razorpay)\b/i
392
-
393
- // After
394
- /\b(stripe|paypal|square|braintree|adyen|razorpay|payoneer)\b/i
395
- ```
396
-
397
- ### Adding New Critical Keywords
398
-
399
- **To add new business domain (e.g., inventory):**
400
- ```typescript
401
- // Add to business logic patterns
402
- /\b(discount|pricing|payment|commission|fee|tax|shipping|inventory|stock)\b/i
403
- ```
404
-
405
- ### Adding New Pattern Categories
406
-
407
- ```typescript
408
- // Example: Add AI/ML operations as critical
409
- const AI_ML_PATTERNS = [
410
- /\b(train.*model|inference|prediction|openai|anthropic)\b/i,
411
- ]
412
-
413
- CRITICAL_PATTERNS.push(...AI_ML_PATTERNS)
414
- ```
415
-
416
- ---
417
-
418
- ## Testing Classification
419
-
420
- ```typescript
421
- const testCases = [
422
- // Critical - API
423
- {
424
- input: "Implement POST /api/auth/login",
425
- expected: { type: 'critical', tdd_required: true }
426
- },
427
-
428
- // Critical - Business logic
429
- {
430
- input: "Add discount calculation for VIP members",
431
- expected: { type: 'critical', tdd_required: true }
432
- },
433
-
434
- // Critical - External integration
435
- {
436
- input: "Integrate Stripe payment processing",
437
- expected: { type: 'critical', tdd_required: true }
438
- },
439
-
440
- // Critical - Data transformation
441
- {
442
- input: "Parse XML and convert to JSON",
443
- expected: { type: 'critical', tdd_required: true }
444
- },
445
-
446
- // Standard
447
- {
448
- input: "Create GET /api/users endpoint",
449
- expected: { type: 'standard', tdd_required: false }
450
- },
451
-
452
- // UI - Presentational
453
- {
454
- input: "Add Button component",
455
- expected: { type: 'ui', tdd_required: false }
456
- },
457
-
458
- // UI - Complex
459
- {
460
- input: "Build multi-step checkout wizard",
461
- expected: { type: 'ui-complex', tdd_required: true }
462
- },
463
- ]
464
-
465
- // Run tests
466
- for (const test of testCases) {
467
- const result = classifyTask(test.input)
468
-
469
- console.assert(
470
- result.type === test.expected.type &&
471
- result.tdd_required === test.expected.tdd_required,
472
- `Failed: ${test.input}`
473
- )
474
- }
475
- ```
476
-
477
- ---
478
-
479
- ## Troubleshooting
480
-
481
- ### Task Classified Incorrectly
482
-
483
- **Problem:** Simple task marked as critical
484
- **Solution:** Check if task description contains critical keywords unintentionally
485
-
486
- **Example:**
487
- ```
488
- Task: "Display payment history"
489
- → Wrongly classified as critical (contains "payment")
490
- → Fix: Add context check "display" + "payment" → standard
491
- ```
492
-
493
- ### Missing Pattern
494
-
495
- **Problem:** Critical task not detected
496
- **Solution:** Add new pattern to CRITICAL_PATTERNS
497
-
498
- **Example:**
499
- ```
500
- Task: "Implement Razorpay integration"
501
- → Not detected (Razorpay not in list)
502
- → Fix: Add "razorpay" to payment providers pattern
503
- ```
504
-
505
- ---
506
-
507
- ## Summary
508
-
509
- **Key Principles:**
510
- 1. ✅ **Content-based:** Classification based on task description only
511
- 2. ✅ **Source-agnostic:** Works with any task source
512
- 3. ✅ **Extensible:** Easy to add new patterns
513
- 4. ✅ **Explicit:** Clear reason for each classification
514
- 5. ✅ **Conservative:** Default to standard if unclear
515
-
516
- **Remember:** When in doubt about classification, prefer `tdd_required: false` and let the specialist agent decide if TDD is needed.
1
+ # Universal Task Classification
2
+
3
+ ## Purpose
4
+
5
+ Classify tasks to determine if Test-Driven Development (TDD) is required, regardless of task source (file, command, spec framework, etc.).
6
+
7
+ ---
8
+
9
+ ## Classification Output
10
+
11
+ **Input:** Task description (string)
12
+ **Output:** Classification object
13
+
14
+ ```typescript
15
+ {
16
+ type: 'critical' | 'standard' | 'ui' | 'ui-complex' | 'config',
17
+ tdd_required: boolean,
18
+ workflow: 'red-green-refactor' | 'test-alongside',
19
+ reason: string
20
+ }
21
+ ```
22
+
23
+ ---
24
+
25
+ ## Critical Code Patterns (TDD Required ✅)
26
+
27
+ ### 1. API Mutations
28
+ - POST, PUT, PATCH, DELETE methods
29
+ - Any `/api/` endpoint that modifies data
30
+ - GraphQL mutations
31
+ - Webhook handlers, callbacks
32
+
33
+ **Examples:**
34
+ ```
35
+ ✅ "Implement POST /api/auth/login"
36
+ ✅ "Add PUT /api/users/:id/profile"
37
+ ✅ "Create webhook handler for Stripe payments"
38
+ ✅ "Delete endpoint for products"
39
+ ```
40
+
41
+ ### 2. Business Logic
42
+ - Calculations, computations, algorithms
43
+ - Validation rules, verification logic
44
+ - Transformations, conversions, parsing
45
+ - Domain-specific logic
46
+
47
+ **Keywords:** calculate, compute, algorithm, validate, verify, check, transform, convert, parse
48
+
49
+ **Business domains:** discount, pricing, payment, commission, fee, tax, shipping, score, rate, evaluate
50
+
51
+ **Examples:**
52
+ ```
53
+ ✅ "Calculate shipping cost based on weight and distance"
54
+ ✅ "Add discount calculation for VIP users"
55
+ ✅ "Implement tax calculation logic"
56
+ ✅ "Validate credit card numbers using Luhn algorithm"
57
+ ✅ "Transform user data for export"
58
+ ```
59
+
60
+ ### 3. External Integrations
61
+ - Third-party APIs, webhooks, callbacks
62
+ - Payment gateways
63
+ - Email/SMS services
64
+ - Cloud storage providers
65
+ - Analytics platforms
66
+ - Authentication providers
67
+
68
+ **Payment providers:** Stripe, PayPal, Square, Braintree, Adyen, Razorpay
69
+ **Email services:** SendGrid, Mailgun, Postmark, AWS SES, Mailchimp
70
+ **SMS providers:** Twilio, Vonage, MessageBird, AWS SNS
71
+ **Storage:** S3, GCS, Azure Storage, Cloudinary, DigitalOcean Spaces
72
+ **Analytics:** Google Analytics, Mixpanel, Amplitude, Segment
73
+ **Auth:** Auth0, Firebase Auth, Cognito, Okta
74
+
75
+ **Examples:**
76
+ ```
77
+ ✅ "Integrate Stripe payment processing"
78
+ ✅ "Add SendGrid email notifications"
79
+ ✅ "Implement Twilio SMS verification"
80
+ ✅ "Connect to Google Analytics API"
81
+ ✅ "Upload images to S3"
82
+ ```
83
+
84
+ ### 4. Data Transformations
85
+ - Serialization, deserialization
86
+ - ETL operations, data pipelines
87
+ - Complex mapping, aggregations
88
+ - Data normalization/denormalization
89
+
90
+ **Keywords:** serialize, deserialize, transform, convert, parse, ETL, pipeline, aggregate, map, reduce, filter (complex), normalize, denormalize
91
+
92
+ **Examples:**
93
+ ```
94
+ ✅ "Parse CSV and transform to JSON"
95
+ ✅ "Aggregate user analytics data"
96
+ ✅ "Serialize user data for API response"
97
+ ✅ "ETL pipeline for data migration"
98
+ ```
99
+
100
+ ### 5. Security & Critical Operations
101
+ - Authentication, authorization
102
+ - Encryption, decryption, hashing, signing
103
+ - Permissions, access control
104
+ - Transactions, financial operations
105
+ - Audit logging
106
+
107
+ **Keywords:** auth, authenticate, authorize, JWT, OAuth, encrypt, decrypt, hash, sign, permission, access control, transaction, rollback, commit, audit
108
+
109
+ **Examples:**
110
+ ```
111
+ ✅ "Implement JWT authentication"
112
+ ✅ "Add password hashing with bcrypt"
113
+ ✅ "Create payment transaction handler"
114
+ ✅ "Implement role-based access control"
115
+ ✅ "Add audit log for sensitive operations"
116
+ ```
117
+
118
+ ---
119
+
120
+ ## Standard Code Patterns (Test-Alongside OK ⚠️)
121
+
122
+ - Simple GET endpoints (read-only)
123
+ - Basic list/show/display operations
124
+ - Simple data fetching (no transformations)
125
+ - Configuration, setup, initialization
126
+
127
+ **Examples:**
128
+ ```
129
+ ⚠️ "Add GET /api/users endpoint"
130
+ ⚠️ "Fetch user profile data"
131
+ ⚠️ "Display product list"
132
+ ⚠️ "Setup environment configuration"
133
+ ```
134
+
135
+ ---
136
+
137
+ ## UI Code Patterns (Usually No TDD ❌)
138
+
139
+ - Presentational components (Button, Card, Modal, etc.)
140
+ - Styling, themes, CSS
141
+ - Simple renders, displays
142
+ - Layout components
143
+
144
+ **Keywords:** component, button, card, modal, navbar, footer, style, CSS, theme, render, display, layout
145
+
146
+ **Examples:**
147
+ ```
148
+ ❌ "Create Button component"
149
+ ❌ "Add Card component with shadow"
150
+ ❌ "Style navigation bar"
151
+ ❌ "Update footer layout"
152
+ ```
153
+
154
+ ### Exception: Complex UI Logic (TDD Required ✅)
155
+
156
+ **UI tasks that DO require TDD:**
157
+ - Multi-step forms with validation
158
+ - State machines (wizards, checkout flows)
159
+ - Complex form validation logic
160
+ - Accessibility features (keyboard navigation, screen reader support)
161
+ - Dynamic form generation
162
+
163
+ **Keywords:** multi-step, wizard, state machine, validation (complex), keyboard navigation, accessibility, ARIA, dynamic form
164
+
165
+ **Examples:**
166
+ ```
167
+ ✅ "Implement multi-step checkout wizard with validation"
168
+ ✅ "Add keyboard navigation for dropdown menu"
169
+ ✅ "Create dynamic form with conditional fields"
170
+ ✅ "Build wizard with state management"
171
+ ```
172
+
173
+ ---
174
+
175
+ ## Pattern Matching Algorithm
176
+
177
+ ```typescript
178
+ const CRITICAL_PATTERNS = [
179
+ // HTTP mutations
180
+ /\b(post|put|patch|delete)\b.*\/api\//i,
181
+
182
+ // Business logic
183
+ /\b(calculate|compute|algorithm|validate|verify|check)\b/i,
184
+ /\b(discount|pricing|payment|commission|fee|tax|shipping)\b/i,
185
+ /\b(score|rate|evaluate|transform|convert|parse)\b/i,
186
+
187
+ // External services (extensible)
188
+ /\b(integrate|webhook|callback|third-party|external)\b/i,
189
+
190
+ // Payment providers
191
+ /\b(stripe|paypal|square|braintree|adyen|razorpay)\b/i,
192
+
193
+ // Communication services
194
+ /\b(sendgrid|mailgun|postmark|ses|mailchimp)\b/i,
195
+ /\b(twilio|vonage|messagebird|sns)\b/i,
196
+
197
+ // Storage providers
198
+ /\b(s3|gcs|azure.*storage|cloudinary|digitalocean.*spaces)\b/i,
199
+
200
+ // Analytics
201
+ /\b(analytics|mixpanel|amplitude|segment)\b/i,
202
+
203
+ // Auth providers
204
+ /\b(auth0|firebase.*auth|cognito|okta)\b/i,
205
+
206
+ // Data operations
207
+ /\b(serialize|deserialize|etl|pipeline|aggregate)\b/i,
208
+
209
+ // Security
210
+ /\b(auth|jwt|oauth|encrypt|decrypt|hash|sign)\b/i,
211
+ /\b(permission|access.*control|authorize)\b/i,
212
+
213
+ // Transactions
214
+ /\b(transaction|rollback|commit|audit)\b/i,
215
+ ]
216
+
217
+ function classifyTask(description: string): Classification {
218
+ const text = description.toLowerCase()
219
+
220
+ // Check critical patterns
221
+ for (const pattern of CRITICAL_PATTERNS) {
222
+ if (pattern.test(text)) {
223
+ return {
224
+ type: 'critical',
225
+ tdd_required: true,
226
+ workflow: 'red-green-refactor',
227
+ reason: `Matched critical pattern: ${pattern.source}`
228
+ }
229
+ }
230
+ }
231
+
232
+ // Check simple GET (read-only)
233
+ if (/^get\s+\/api\//i.test(text) && !/\b(complex|join|aggregate|transform)\b/i.test(text)) {
234
+ return {
235
+ type: 'standard',
236
+ tdd_required: false,
237
+ workflow: 'test-alongside',
238
+ reason: 'Simple read-only operation'
239
+ }
240
+ }
241
+
242
+ // Check UI
243
+ if (/\b(component|button|card|modal|navbar|footer|style|theme|css|layout)\b/i.test(text)) {
244
+ // Check for complex UI logic
245
+ if (/\b(multi-step|wizard|state.*machine|keyboard.*navigation|accessibility|aria|dynamic.*form)\b/i.test(text)) {
246
+ return {
247
+ type: 'ui-complex',
248
+ tdd_required: true,
249
+ workflow: 'red-green-refactor',
250
+ reason: 'Complex UI logic detected'
251
+ }
252
+ }
253
+
254
+ return {
255
+ type: 'ui',
256
+ tdd_required: false,
257
+ workflow: 'test-alongside',
258
+ reason: 'Presentational UI component'
259
+ }
260
+ }
261
+
262
+ // Check config/setup
263
+ if (/\b(config|setup|init|install|env)\b/i.test(text)) {
264
+ return {
265
+ type: 'config',
266
+ tdd_required: false,
267
+ workflow: 'test-alongside',
268
+ reason: 'Configuration task'
269
+ }
270
+ }
271
+
272
+ // Default: standard
273
+ return {
274
+ type: 'standard',
275
+ tdd_required: false,
276
+ workflow: 'test-alongside',
277
+ reason: 'Default classification (no critical patterns matched)'
278
+ }
279
+ }
280
+ ```
281
+
282
+ ---
283
+
284
+ ## Classification Examples
285
+
286
+ | Task Description | Type | TDD? | Reason |
287
+ |-----------------|------|------|--------|
288
+ | "Implement POST /api/auth/login" | critical | ✅ YES | API mutation + authentication |
289
+ | "Add discount calculation for VIP users" | critical | ✅ YES | Business logic |
290
+ | "Integrate Stripe webhook handler" | critical | ✅ YES | External integration + webhook |
291
+ | "Parse CSV and transform to JSON" | critical | ✅ YES | Data transformation |
292
+ | "Add JWT authentication middleware" | critical | ✅ YES | Security operation |
293
+ | "Create multi-step checkout wizard" | ui-complex | ✅ YES | Complex UI state machine |
294
+ | "Implement keyboard navigation" | ui-complex | ✅ YES | Accessibility feature |
295
+ | "Create GET /api/users list" | standard | ⚠️ Optional | Simple read-only |
296
+ | "Fetch user profile data" | standard | ⚠️ Optional | Simple fetch |
297
+ | "Create Button component" | ui | ❌ No | Presentational UI |
298
+ | "Style navigation bar" | ui | ❌ No | CSS/styling |
299
+ | "Setup environment variables" | config | ❌ No | Configuration |
300
+
301
+ ---
302
+
303
+ ## Usage by Orchestrator
304
+
305
+ ```markdown
306
+ 1. Receive task (from any source: file, command, framework)
307
+ 2. Extract task description
308
+ 3. Run classification algorithm
309
+ 4. Add classification metadata to task
310
+ 5. Delegate to specialist agent with metadata
311
+ ```
312
+
313
+ **Example Orchestrator Code:**
314
+ ```typescript
315
+ // 1. Receive tasks
316
+ const tasks = parseTasks(input)
317
+
318
+ // 2. Classify each task
319
+ for (const task of tasks) {
320
+ const classification = classifyTask(task.description)
321
+
322
+ task.type = classification.type
323
+ task.tdd_required = classification.tdd_required
324
+ task.workflow = classification.workflow
325
+ task.reason = classification.reason
326
+ }
327
+
328
+ // 3. Delegate with metadata
329
+ for (const task of tasks) {
330
+ delegateToAgent(task.agent, {
331
+ description: task.description,
332
+ type: task.type,
333
+ tdd_required: task.tdd_required,
334
+ workflow: task.workflow,
335
+ reason: task.reason
336
+ })
337
+ }
338
+ ```
339
+
340
+ ---
341
+
342
+ ## Usage by Specialist Agents
343
+
344
+ ```markdown
345
+ 1. Receive task with classification metadata
346
+ 2. Check `tdd_required` flag
347
+ 3. If true → Red-Green-Refactor workflow
348
+ 4. If false → Test-Alongside workflow
349
+ ```
350
+
351
+ **Example Agent Code:**
352
+ ```typescript
353
+ // Receive task from Orchestrator
354
+ const task = receiveTask()
355
+
356
+ if (task.tdd_required === true) {
357
+ // TDD Workflow
358
+ console.log(`⚠️ TDD Required: ${task.reason}`)
359
+
360
+ // RED: Write test first
361
+ writeTests()
362
+ runTests() // Must FAIL
363
+
364
+ // GREEN: Implement
365
+ writeImplementation()
366
+ runTests() // Must PASS
367
+
368
+ // REFACTOR: Improve
369
+ refactorCode()
370
+ runTests() // Must STILL PASS
371
+
372
+ } else {
373
+ // Standard Workflow
374
+ console.log(`ℹ️ Test-Alongside OK: ${task.reason}`)
375
+
376
+ writeImplementation()
377
+ writeTests()
378
+ runTests()
379
+ }
380
+ ```
381
+
382
+ ---
383
+
384
+ ## Extending the Classification
385
+
386
+ ### Adding New Service Providers
387
+
388
+ **To support new payment provider (e.g., Payoneer):**
389
+ ```typescript
390
+ // Before
391
+ /\b(stripe|paypal|square|braintree|adyen|razorpay)\b/i
392
+
393
+ // After
394
+ /\b(stripe|paypal|square|braintree|adyen|razorpay|payoneer)\b/i
395
+ ```
396
+
397
+ ### Adding New Critical Keywords
398
+
399
+ **To add new business domain (e.g., inventory):**
400
+ ```typescript
401
+ // Add to business logic patterns
402
+ /\b(discount|pricing|payment|commission|fee|tax|shipping|inventory|stock)\b/i
403
+ ```
404
+
405
+ ### Adding New Pattern Categories
406
+
407
+ ```typescript
408
+ // Example: Add AI/ML operations as critical
409
+ const AI_ML_PATTERNS = [
410
+ /\b(train.*model|inference|prediction|openai|anthropic)\b/i,
411
+ ]
412
+
413
+ CRITICAL_PATTERNS.push(...AI_ML_PATTERNS)
414
+ ```
415
+
416
+ ---
417
+
418
+ ## Testing Classification
419
+
420
+ ```typescript
421
+ const testCases = [
422
+ // Critical - API
423
+ {
424
+ input: "Implement POST /api/auth/login",
425
+ expected: { type: 'critical', tdd_required: true }
426
+ },
427
+
428
+ // Critical - Business logic
429
+ {
430
+ input: "Add discount calculation for VIP members",
431
+ expected: { type: 'critical', tdd_required: true }
432
+ },
433
+
434
+ // Critical - External integration
435
+ {
436
+ input: "Integrate Stripe payment processing",
437
+ expected: { type: 'critical', tdd_required: true }
438
+ },
439
+
440
+ // Critical - Data transformation
441
+ {
442
+ input: "Parse XML and convert to JSON",
443
+ expected: { type: 'critical', tdd_required: true }
444
+ },
445
+
446
+ // Standard
447
+ {
448
+ input: "Create GET /api/users endpoint",
449
+ expected: { type: 'standard', tdd_required: false }
450
+ },
451
+
452
+ // UI - Presentational
453
+ {
454
+ input: "Add Button component",
455
+ expected: { type: 'ui', tdd_required: false }
456
+ },
457
+
458
+ // UI - Complex
459
+ {
460
+ input: "Build multi-step checkout wizard",
461
+ expected: { type: 'ui-complex', tdd_required: true }
462
+ },
463
+ ]
464
+
465
+ // Run tests
466
+ for (const test of testCases) {
467
+ const result = classifyTask(test.input)
468
+
469
+ console.assert(
470
+ result.type === test.expected.type &&
471
+ result.tdd_required === test.expected.tdd_required,
472
+ `Failed: ${test.input}`
473
+ )
474
+ }
475
+ ```
476
+
477
+ ---
478
+
479
+ ## Troubleshooting
480
+
481
+ ### Task Classified Incorrectly
482
+
483
+ **Problem:** Simple task marked as critical
484
+ **Solution:** Check if task description contains critical keywords unintentionally
485
+
486
+ **Example:**
487
+ ```
488
+ Task: "Display payment history"
489
+ → Wrongly classified as critical (contains "payment")
490
+ → Fix: Add context check "display" + "payment" → standard
491
+ ```
492
+
493
+ ### Missing Pattern
494
+
495
+ **Problem:** Critical task not detected
496
+ **Solution:** Add new pattern to CRITICAL_PATTERNS
497
+
498
+ **Example:**
499
+ ```
500
+ Task: "Implement Razorpay integration"
501
+ → Not detected (Razorpay not in list)
502
+ → Fix: Add "razorpay" to payment providers pattern
503
+ ```
504
+
505
+ ---
506
+
507
+ ## Summary
508
+
509
+ **Key Principles:**
510
+ 1. ✅ **Content-based:** Classification based on task description only
511
+ 2. ✅ **Source-agnostic:** Works with any task source
512
+ 3. ✅ **Extensible:** Easy to add new patterns
513
+ 4. ✅ **Explicit:** Clear reason for each classification
514
+ 5. ✅ **Conservative:** Default to standard if unclear
515
+
516
+ **Remember:** When in doubt about classification, prefer `tdd_required: false` and let the specialist agent decide if TDD is needed.