@champpaba/claude-agent-kit 1.6.0 → 1.7.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 (72) hide show
  1. package/.claude/CHANGELOG-v1.1.1.md +259 -259
  2. package/.claude/CLAUDE.md +21 -6
  3. package/.claude/agents/01-integration.md +1 -1
  4. package/.claude/agents/02-uxui-frontend.md +1 -1
  5. package/.claude/agents/03-test-debug.md +1 -1
  6. package/.claude/agents/04-frontend.md +1 -1
  7. package/.claude/agents/05-backend.md +1 -1
  8. package/.claude/agents/06-database.md +1 -1
  9. package/.claude/commands/agentsetup.md +1464 -1464
  10. package/.claude/commands/cdev.md +3 -4
  11. package/.claude/commands/csetup.md +82 -3
  12. package/.claude/commands/cstatus.md +60 -60
  13. package/.claude/commands/cview.md +364 -364
  14. package/.claude/commands/psetup.md +101 -101
  15. package/.claude/contexts/design/accessibility.md +611 -611
  16. package/.claude/contexts/design/layout.md +400 -400
  17. package/.claude/contexts/design/responsive.md +551 -551
  18. package/.claude/contexts/design/shadows.md +522 -522
  19. package/.claude/contexts/design/typography.md +465 -465
  20. package/.claude/contexts/domain/README.md +164 -164
  21. package/.claude/contexts/patterns/agent-coordination.md +388 -388
  22. package/.claude/contexts/patterns/agent-discovery.md +182 -182
  23. package/.claude/contexts/patterns/change-workflow.md +538 -538
  24. package/.claude/contexts/patterns/code-standards.md +515 -515
  25. package/.claude/contexts/patterns/development-principles.md +513 -513
  26. package/.claude/contexts/patterns/error-handling.md +478 -478
  27. package/.claude/contexts/patterns/error-recovery.md +365 -365
  28. package/.claude/contexts/patterns/logging.md +424 -424
  29. package/.claude/contexts/patterns/task-breakdown.md +452 -452
  30. package/.claude/contexts/patterns/task-classification.md +523 -523
  31. package/.claude/contexts/patterns/tdd-classification.md +516 -516
  32. package/.claude/contexts/patterns/testing.md +413 -413
  33. package/.claude/contexts/patterns/validation-framework.md +776 -776
  34. package/.claude/lib/agent-executor.md +450 -1
  35. package/.claude/lib/agent-router.md +572 -572
  36. package/.claude/lib/detailed-guides/agent-system.md +11 -9
  37. package/.claude/lib/detailed-guides/incremental-testing.md +460 -0
  38. package/.claude/lib/flags-updater.md +469 -469
  39. package/.claude/lib/task-analyzer.md +398 -2
  40. package/.claude/lib/tdd-classifier.md +345 -345
  41. package/.claude/lib/validation-gates.md +484 -484
  42. package/.claude/settings.local.json +42 -42
  43. package/.claude/templates/context-template.md +45 -45
  44. package/.claude/templates/flags-template.json +42 -42
  45. package/.claude/templates/phase-templates.json +173 -124
  46. package/.claude/templates/phases-sections/accessibility-test.md +17 -17
  47. package/.claude/templates/phases-sections/api-design.md +37 -37
  48. package/.claude/templates/phases-sections/backend-tests.md +16 -16
  49. package/.claude/templates/phases-sections/backend.md +37 -37
  50. package/.claude/templates/phases-sections/business-logic-validation.md +16 -16
  51. package/.claude/templates/phases-sections/component-tests.md +17 -17
  52. package/.claude/templates/phases-sections/contract-backend.md +16 -16
  53. package/.claude/templates/phases-sections/contract-frontend.md +16 -16
  54. package/.claude/templates/phases-sections/database.md +35 -35
  55. package/.claude/templates/phases-sections/documentation.md +17 -17
  56. package/.claude/templates/phases-sections/e2e-tests.md +16 -16
  57. package/.claude/templates/phases-sections/fix-implementation.md +17 -17
  58. package/.claude/templates/phases-sections/frontend-integration.md +18 -18
  59. package/.claude/templates/phases-sections/frontend-mockup.md +123 -123
  60. package/.claude/templates/phases-sections/manual-flow-test.md +15 -15
  61. package/.claude/templates/phases-sections/manual-ux-test.md +16 -16
  62. package/.claude/templates/phases-sections/refactor-implementation.md +17 -17
  63. package/.claude/templates/phases-sections/refactor.md +16 -16
  64. package/.claude/templates/phases-sections/regression-tests.md +15 -15
  65. package/.claude/templates/phases-sections/report.md +16 -16
  66. package/.claude/templates/phases-sections/responsive-test.md +16 -16
  67. package/.claude/templates/phases-sections/script-implementation.md +43 -43
  68. package/.claude/templates/phases-sections/test-coverage.md +16 -16
  69. package/.claude/templates/phases-sections/user-approval.md +14 -14
  70. package/LICENSE +21 -21
  71. package/README.md +171 -35
  72. package/package.json +1 -1
@@ -1,6 +1,7 @@
1
1
  # Agent Executor with Retry & Escalation
2
2
 
3
3
  > **Robust agent execution with automatic retry and error recovery**
4
+ > **Version:** 1.4.0 (Incremental Testing Integration)
4
5
 
5
6
  ---
6
7
 
@@ -79,7 +80,7 @@ auto_proceed = userApprovalGranted() // Check if user approved workflow
79
80
  while (attempt <= max_retries):
80
81
 
81
82
  1. Invoke agent:
82
- Task(agent=agentType, model='haiku', prompt=buildPrompt(auto_proceed))
83
+ Task(agent=agentType, model='opus', prompt=buildPrompt(auto_proceed))
83
84
 
84
85
  2. Handle agent questions (NEW!):
85
86
  If agent asks "Should I proceed?" or "Continue?":
@@ -315,3 +316,451 @@ Manual mode → NO (user wants control)
315
316
  ---
316
317
 
317
318
  This retry & escalation framework makes agent execution **robust and reliable**.
319
+
320
+ ---
321
+
322
+ ---
323
+
324
+ # šŸ”„ Incremental Testing Execution (v1.4.0)
325
+
326
+ > **NEW:** Milestone-based execution with round-based retry and Main Claude intervention
327
+
328
+ ---
329
+
330
+ ## šŸ“‹ Execution Mode Detection
331
+
332
+ Before executing a phase, check the `testingStrategy` field:
333
+
334
+ ```typescript
335
+ if (phase.testingStrategy?.type === 'incremental' && phase.testingStrategy.milestones) {
336
+ // Incremental mode: Execute milestone by milestone
337
+ return await executeIncrementalPhase(phase, changeId)
338
+ } else {
339
+ // Standard mode: Single agent execution (existing logic above)
340
+ return await executeStandardPhase(phase, changeId)
341
+ }
342
+ ```
343
+
344
+ ---
345
+
346
+ ## šŸŽÆ Incremental Execution Flow
347
+
348
+ ### Overview
349
+
350
+ ```
351
+ Phase Start (e.g., "Google Maps API Integration")
352
+ ↓
353
+ Milestone 1: Core implementation (1 record)
354
+ → Round 1: Attempt 1 → FAIL
355
+ → Round 1: Attempt 2 → FAIL
356
+ → Main Claude: Give hints
357
+ → Round 2: Attempt 1 → PASS āœ…
358
+ ↓
359
+ Milestone 2: Parameterized query (10 records)
360
+ → Round 1: Attempt 1 → PASS āœ…
361
+ ↓
362
+ Milestone 3: Error handling
363
+ → Round 1: Attempt 1 → FAIL
364
+ → Round 1: Attempt 2 → FAIL
365
+ → Main Claude: Ask human (complex issue) → PAUSE šŸ›‘
366
+ ↓
367
+ Human resolves issue
368
+ ↓
369
+ Resume: Milestone 3
370
+ → Round 2: Attempt 1 → PASS āœ…
371
+ ↓
372
+ Milestone 4: Scale + performance
373
+ → Round 1: Attempt 1 → PASS āœ…
374
+ ↓
375
+ Phase Complete āœ…
376
+ ```
377
+
378
+ ---
379
+
380
+ ## šŸ”„ Round-based Retry Logic
381
+
382
+ ### Per-Milestone Retry
383
+
384
+ - **Quota per round:** 2 attempts
385
+ - **Between rounds:** Main Claude intervention (reset quota)
386
+ - **No global limit:** Unlimited rounds (user/Main Claude decides when to stop)
387
+
388
+ ```typescript
389
+ async function executeMilestone(milestone: Milestone, phase: Phase): Promise<MilestoneResult> {
390
+ let round = 1
391
+ let passed = false
392
+ const history = []
393
+
394
+ while (!passed) {
395
+ console.log(`\nšŸ“ Round ${round}`)
396
+
397
+ // Execute 2 attempts in this round
398
+ for (let attempt = 1; attempt <= 2; attempt++) {
399
+ console.log(`\n Attempt ${attempt}/2:`)
400
+
401
+ // Build prompt (include previous failures + hints if available)
402
+ const prompt = buildMilestonePrompt(milestone, round, attempt, history)
403
+
404
+ // Execute agent
405
+ const result = await executeAgent(phase.agent, prompt)
406
+
407
+ // Validate exit criteria
408
+ const validation = validateExitCriteria(result.output, milestone.exitCriteria)
409
+
410
+ // Store in history
411
+ history.push({ round, attempt, validation, output: result.output })
412
+
413
+ if (validation.allPassed) {
414
+ // SUCCESS!
415
+ console.log(`\n āœ… PASSED`)
416
+ passed = true
417
+ return { status: 'passed', history }
418
+ } else {
419
+ // FAILED
420
+ console.log(`\n āŒ FAILED (${validation.failures.length} criteria not met)`)
421
+
422
+ if (attempt === 2) {
423
+ // Both attempts failed → Escalate to Main Claude
424
+ console.log(`\n āš ļø Round ${round} exhausted`)
425
+ break // Exit attempt loop
426
+ } else {
427
+ console.log(`\n šŸ”„ Retrying...`)
428
+ }
429
+ }
430
+ }
431
+
432
+ // If we're here, round failed → Main Claude intervention
433
+ if (!passed) {
434
+ const decision = await mainClaudeIntervention(milestone, history)
435
+
436
+ if (decision.action === 'give_hints') {
437
+ // Continue to next round with hints
438
+ console.log(`\nšŸ’” Main Claude Guidance:`)
439
+ decision.hints.forEach(h => console.log(` - ${h}`))
440
+ history.push({ type: 'hints', round: round + 1, hints: decision.hints })
441
+ round++
442
+ } else if (decision.action === 'ask_human') {
443
+ // Pause and wait for human
444
+ console.log(`\nšŸ›‘ Human intervention required`)
445
+ return { status: 'paused', reason: decision.reason, history }
446
+ }
447
+ }
448
+ }
449
+ }
450
+ ```
451
+
452
+ ---
453
+
454
+ ## šŸ¤– Main Claude Intervention
455
+
456
+ ### Decision Logic
457
+
458
+ ```typescript
459
+ async function mainClaudeIntervention(milestone: Milestone, history: ExecutionHistory): Promise<Decision> {
460
+ // Analyze failure patterns
461
+ const analysis = analyzeFailures(history)
462
+
463
+ console.log(`\nšŸ¤” Main Claude analyzing failures...`)
464
+ console.log(` Error pattern: ${analysis.pattern}`)
465
+ console.log(` Complexity: ${analysis.complexity}`)
466
+ console.log(` Confidence: ${analysis.confidence}`)
467
+
468
+ // Decision matrix
469
+ if (analysis.pattern === 'same_error' && analysis.complexity === 'SIMPLE') {
470
+ // Same error 2x + simple issue → Give hints
471
+ return {
472
+ action: 'give_hints',
473
+ hints: generateHints(analysis, milestone)
474
+ }
475
+ }
476
+
477
+ if (analysis.pattern === 'different_errors' || analysis.complexity === 'COMPLEX') {
478
+ // Non-deterministic or complex → Ask human
479
+ return {
480
+ action: 'ask_human',
481
+ reason: 'Complex or intermittent failures detected',
482
+ report: generateHumanReport(milestone, history, analysis)
483
+ }
484
+ }
485
+
486
+ // Too many rounds without progress → Ask human
487
+ if (history.filter(h => h.type === 'hints').length >= 2) {
488
+ return {
489
+ action: 'ask_human',
490
+ reason: 'No progress after 2 rounds of guidance',
491
+ report: generateHumanReport(milestone, history, analysis)
492
+ }
493
+ }
494
+
495
+ // Default: Give hints
496
+ return {
497
+ action: 'give_hints',
498
+ hints: generateHints(analysis, milestone)
499
+ }
500
+ }
501
+ ```
502
+
503
+ ### Failure Analysis
504
+
505
+ ```typescript
506
+ function analyzeFailures(history: ExecutionHistory): Analysis {
507
+ const failures = history.filter(h => h.validation && !h.validation.allPassed)
508
+
509
+ // Extract unique error messages
510
+ const errorMessages = failures.flatMap(f =>
511
+ f.validation.failures.map(fail => fail.criterion + ':' + fail.explanation)
512
+ )
513
+ const uniqueErrors = [...new Set(errorMessages)]
514
+
515
+ // Detect pattern
516
+ let pattern: 'same_error' | 'different_errors' | 'intermittent'
517
+ if (uniqueErrors.length === 1) {
518
+ pattern = 'same_error'
519
+ } else if (uniqueErrors.length === failures.length) {
520
+ pattern = 'different_errors'
521
+ } else {
522
+ pattern = 'intermittent'
523
+ }
524
+
525
+ // Assess complexity
526
+ const complexity = uniqueErrors.some(e =>
527
+ e.includes('timeout') ||
528
+ e.includes('intermittent') ||
529
+ e.includes('non-deterministic')
530
+ ) ? 'COMPLEX' : 'SIMPLE'
531
+
532
+ // Confidence in root cause
533
+ const confidence = (pattern === 'same_error' && complexity === 'SIMPLE') ? 'HIGH' : 'LOW'
534
+
535
+ return { pattern, complexity, confidence, uniqueErrors }
536
+ }
537
+ ```
538
+
539
+ ### Hint Generation
540
+
541
+ ```typescript
542
+ function generateHints(analysis: Analysis, milestone: Milestone): string[] {
543
+ const hints = []
544
+
545
+ // Pattern-based hints
546
+ if (analysis.uniqueErrors.some(e => e.includes('401') || e.includes('auth'))) {
547
+ hints.push('Check if API_KEY environment variable is set correctly')
548
+ hints.push('Verify API key is valid (not expired/revoked)')
549
+ hints.push('Ensure API key has permissions for this endpoint')
550
+ }
551
+
552
+ if (analysis.uniqueErrors.some(e => e.includes('timeout'))) {
553
+ hints.push('Increase timeout threshold (may be too aggressive)')
554
+ hints.push('Check network connectivity to API endpoint')
555
+ hints.push('Verify API endpoint URL is correct')
556
+ }
557
+
558
+ if (analysis.uniqueErrors.some(e => e.includes('structure') || e.includes('schema'))) {
559
+ hints.push('Compare actual response structure with expected schema')
560
+ hints.push('Check if API version changed (response format may differ)')
561
+ hints.push('Add console.log() to inspect actual response')
562
+ }
563
+
564
+ // Generic debugging hints
565
+ hints.push('Review exit criteria - ensure they match current implementation')
566
+ hints.push('Add detailed logging to identify exact failure point')
567
+
568
+ return hints
569
+ }
570
+ ```
571
+
572
+ ---
573
+
574
+ ## āœ… Exit Criteria Validation
575
+
576
+ ### Agent Output Format
577
+
578
+ Agent MUST respond in this format:
579
+
580
+ ```markdown
581
+ ## Milestone ${id} Results
582
+
583
+ **Implementation Summary:**
584
+ [What was implemented]
585
+
586
+ **Test Results:**
587
+ - [ ] Response status = 200 - PASS - Got status 200
588
+ - [ ] Data structure valid - PASS - Schema matches
589
+ - [ ] Response time < 500ms - FAIL - Got 612ms (too slow)
590
+ - [ ] API authentication works - PASS - No 401 errors
591
+
592
+ **Issues Found (if any):**
593
+ - Response time exceeds threshold (612ms vs 500ms)
594
+
595
+ **Conclusion:**
596
+ FAIL → Need to optimize query performance
597
+ ```
598
+
599
+ ### Parsing Logic
600
+
601
+ ```typescript
602
+ function validateExitCriteria(agentOutput: string, criteria: string[]): Validation {
603
+ const results = []
604
+
605
+ for (const criterion of criteria) {
606
+ // Match pattern: "- [ ] {criterion} - PASS/FAIL - explanation"
607
+ const regex = new RegExp(
608
+ `\\[(.?)\\]\\s*${escapeRegex(criterion)}\\s*-\\s*(PASS|FAIL)\\s*-\\s*(.+)`,
609
+ 'i'
610
+ )
611
+ const match = agentOutput.match(regex)
612
+
613
+ if (match) {
614
+ const [, checkbox, status, explanation] = match
615
+ results.push({
616
+ criterion,
617
+ passed: status.toUpperCase() === 'PASS',
618
+ explanation: explanation.trim()
619
+ })
620
+ } else {
621
+ // Not found → FAIL (agent didn't report)
622
+ results.push({
623
+ criterion,
624
+ passed: false,
625
+ explanation: 'Agent did not report on this criterion'
626
+ })
627
+ }
628
+ }
629
+
630
+ return {
631
+ allPassed: results.every(r => r.passed),
632
+ passedCount: results.filter(r => r.passed).length,
633
+ totalCount: results.length,
634
+ results,
635
+ failures: results.filter(r => !r.passed)
636
+ }
637
+ }
638
+ ```
639
+
640
+ ---
641
+
642
+ ## šŸ›‘ Human Intervention Report
643
+
644
+ ### Report Format
645
+
646
+ ```markdown
647
+ šŸ›‘ Human Intervention Required
648
+
649
+ **Phase:** ${phase.name}
650
+ **Milestone:** ${milestone.id}/${totalMilestones} - ${milestone.name}
651
+ **Total Attempts:** ${totalAttempts} across ${rounds} rounds
652
+ **Status:** AWAITING RESOLUTION
653
+
654
+ ---
655
+
656
+ ## Failure Summary
657
+
658
+ ### Round 1
659
+ **Attempt 1:**
660
+ - āŒ Response status = 200 → Got 401 (Unauthorized)
661
+ - āŒ API authentication works → Invalid API key
662
+
663
+ **Attempt 2:**
664
+ - āŒ Response status = 200 → Got 401 (Unauthorized)
665
+ - āŒ API authentication works → Invalid API key
666
+
667
+ ### Round 2 (after hints: "Check API_KEY env variable")
668
+ **Attempt 1:**
669
+ - āŒ Response status = 200 → Got 500 (Internal Server Error)
670
+ - āŒ Data structure valid → Unexpected error format
671
+
672
+ **Attempt 2:**
673
+ - āŒ Response status = 200 → Got 503 (Service Unavailable)
674
+ - āœ… API authentication works → Auth passed this time
675
+
676
+ ---
677
+
678
+ ## Analysis
679
+
680
+ **Error Pattern:** Different errors each attempt (intermittent)
681
+ **Complexity:** HIGH (non-deterministic behavior)
682
+ **Root Cause Hypothesis:** API instability or network issues
683
+ **Confidence:** LOW
684
+
685
+ **Possible Causes:**
686
+ 1. Google Maps API experiencing outage/degradation
687
+ 2. Rate limiting kicking in intermittently
688
+ 3. Network connectivity issues
689
+ 4. API key quota exhausted
690
+
691
+ ---
692
+
693
+ ## Recommendations
694
+
695
+ 1. Check Google Cloud Console → API quota usage
696
+ 2. Test API directly (curl/Postman) outside codebase
697
+ 3. Review recent Google Maps API status
698
+ 4. Consider adding retry logic with exponential backoff
699
+ 5. Verify API key permissions and billing status
700
+
701
+ ---
702
+
703
+ ## Next Steps
704
+
705
+ Please investigate and provide guidance:
706
+ - Should we continue with current approach?
707
+ - Or pause and fix infrastructure/config first?
708
+ - Or change strategy (e.g., use different API)?
709
+
710
+ Reply with your decision.
711
+ ```
712
+
713
+ ---
714
+
715
+ ## šŸ“Š Complete Example Flow
716
+
717
+ ```typescript
718
+ // In /cdev command
719
+
720
+ async function executePhase(phase: Phase, changeId: string) {
721
+ // Check testing strategy
722
+ if (phase.testingStrategy?.type === 'incremental') {
723
+ console.log(`\nšŸ”„ INCREMENTAL MODE`)
724
+ console.log(` Milestones: ${phase.testingStrategy.milestones.length}`)
725
+
726
+ // Execute each milestone
727
+ for (const milestone of phase.testingStrategy.milestones) {
728
+ console.log(`\n━━━ Milestone ${milestone.id} ━━━`)
729
+
730
+ const result = await executeMilestone(milestone, phase)
731
+
732
+ if (result.status === 'passed') {
733
+ console.log(`āœ… Milestone ${milestone.id} complete`)
734
+ updateFlags(changeId, {
735
+ [`phase_${phase.id}_milestone_${milestone.id}`]: 'completed'
736
+ })
737
+ } else if (result.status === 'paused') {
738
+ console.log(`šŸ›‘ Execution paused`)
739
+ console.log(result.reason)
740
+ return { status: 'paused', phase, milestone }
741
+ }
742
+ }
743
+
744
+ console.log(`\nāœ… Phase complete: All milestones passed`)
745
+ return { status: 'completed', phase }
746
+
747
+ } else {
748
+ // Standard execution (existing logic)
749
+ return await executeStandardPhase(phase, changeId)
750
+ }
751
+ }
752
+ ```
753
+
754
+ ---
755
+
756
+ ## šŸŽÆ Benefits of Incremental Testing
757
+
758
+ āœ… **Early bug detection** - Catch issues at milestone 1 (1 record) vs milestone 4 (1000 records)
759
+ āœ… **Easier debugging** - Small scope = faster to identify root cause
760
+ āœ… **Progressive confidence** - Each milestone proves the next will likely work
761
+ āœ… **Intelligent recovery** - Main Claude provides hints instead of blind retry
762
+ āœ… **Human-in-the-loop** - Escalate complex issues that agents can't solve
763
+
764
+ ---
765
+
766
+ **This incremental execution framework transforms high-risk tasks into manageable, validated steps! šŸš€**