@champpaba/claude-agent-kit 1.0.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 (80) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +561 -0
  3. package/bin/cli.js +61 -0
  4. package/lib/init.js +52 -0
  5. package/lib/update.js +73 -0
  6. package/package.json +47 -0
  7. package/template/.claude/CHANGELOG-v1.1.1.md +259 -0
  8. package/template/.claude/CLAUDE.md +329 -0
  9. package/template/.claude/agents/01-integration.md +797 -0
  10. package/template/.claude/agents/02-uxui-frontend.md +899 -0
  11. package/template/.claude/agents/03-test-debug.md +759 -0
  12. package/template/.claude/agents/04-frontend.md +1099 -0
  13. package/template/.claude/agents/05-backend.md +1217 -0
  14. package/template/.claude/agents/06-database.md +969 -0
  15. package/template/.claude/commands/agentsetup.md +1464 -0
  16. package/template/.claude/commands/cdev.md +327 -0
  17. package/template/.claude/commands/csetup.md +447 -0
  18. package/template/.claude/commands/cstatus.md +60 -0
  19. package/template/.claude/commands/cview.md +364 -0
  20. package/template/.claude/commands/psetup.md +101 -0
  21. package/template/.claude/contexts/design/accessibility.md +611 -0
  22. package/template/.claude/contexts/design/box-thinking.md +553 -0
  23. package/template/.claude/contexts/design/color-theory.md +498 -0
  24. package/template/.claude/contexts/design/index.md +247 -0
  25. package/template/.claude/contexts/design/layout.md +400 -0
  26. package/template/.claude/contexts/design/responsive.md +551 -0
  27. package/template/.claude/contexts/design/shadows.md +522 -0
  28. package/template/.claude/contexts/design/spacing.md +428 -0
  29. package/template/.claude/contexts/design/typography.md +465 -0
  30. package/template/.claude/contexts/domain/README.md +164 -0
  31. package/template/.claude/contexts/patterns/agent-coordination.md +388 -0
  32. package/template/.claude/contexts/patterns/agent-discovery.md +182 -0
  33. package/template/.claude/contexts/patterns/change-workflow.md +538 -0
  34. package/template/.claude/contexts/patterns/code-standards.md +515 -0
  35. package/template/.claude/contexts/patterns/development-principles.md +513 -0
  36. package/template/.claude/contexts/patterns/error-handling.md +478 -0
  37. package/template/.claude/contexts/patterns/error-recovery.md +365 -0
  38. package/template/.claude/contexts/patterns/frontend-component-strategy.md +365 -0
  39. package/template/.claude/contexts/patterns/git-workflow.md +207 -0
  40. package/template/.claude/contexts/patterns/logging.md +424 -0
  41. package/template/.claude/contexts/patterns/task-breakdown.md +452 -0
  42. package/template/.claude/contexts/patterns/task-classification.md +523 -0
  43. package/template/.claude/contexts/patterns/tdd-classification.md +516 -0
  44. package/template/.claude/contexts/patterns/testing.md +413 -0
  45. package/template/.claude/contexts/patterns/ui-component-consistency.md +304 -0
  46. package/template/.claude/contexts/patterns/validation-framework.md +776 -0
  47. package/template/.claude/lib/README.md +39 -0
  48. package/template/.claude/lib/agent-executor.md +258 -0
  49. package/template/.claude/lib/agent-router.md +572 -0
  50. package/template/.claude/lib/flags-updater.md +469 -0
  51. package/template/.claude/lib/tdd-classifier.md +345 -0
  52. package/template/.claude/lib/validation-gates.md +484 -0
  53. package/template/.claude/settings.local.json +42 -0
  54. package/template/.claude/templates/context-template.md +45 -0
  55. package/template/.claude/templates/flags-template.json +42 -0
  56. package/template/.claude/templates/phase-templates.json +124 -0
  57. package/template/.claude/templates/phases-sections/accessibility-test.md +17 -0
  58. package/template/.claude/templates/phases-sections/api-design.md +37 -0
  59. package/template/.claude/templates/phases-sections/backend-tests.md +16 -0
  60. package/template/.claude/templates/phases-sections/backend.md +37 -0
  61. package/template/.claude/templates/phases-sections/business-logic-validation.md +16 -0
  62. package/template/.claude/templates/phases-sections/component-tests.md +17 -0
  63. package/template/.claude/templates/phases-sections/contract-backend.md +16 -0
  64. package/template/.claude/templates/phases-sections/contract-frontend.md +16 -0
  65. package/template/.claude/templates/phases-sections/database.md +35 -0
  66. package/template/.claude/templates/phases-sections/documentation.md +17 -0
  67. package/template/.claude/templates/phases-sections/e2e-tests.md +16 -0
  68. package/template/.claude/templates/phases-sections/fix-implementation.md +17 -0
  69. package/template/.claude/templates/phases-sections/frontend-integration.md +18 -0
  70. package/template/.claude/templates/phases-sections/frontend-mockup.md +123 -0
  71. package/template/.claude/templates/phases-sections/manual-flow-test.md +15 -0
  72. package/template/.claude/templates/phases-sections/manual-ux-test.md +16 -0
  73. package/template/.claude/templates/phases-sections/refactor-implementation.md +17 -0
  74. package/template/.claude/templates/phases-sections/refactor.md +16 -0
  75. package/template/.claude/templates/phases-sections/regression-tests.md +15 -0
  76. package/template/.claude/templates/phases-sections/report.md +16 -0
  77. package/template/.claude/templates/phases-sections/responsive-test.md +16 -0
  78. package/template/.claude/templates/phases-sections/script-implementation.md +43 -0
  79. package/template/.claude/templates/phases-sections/test-coverage.md +16 -0
  80. package/template/.claude/templates/phases-sections/user-approval.md +14 -0
@@ -0,0 +1,365 @@
1
+ # Error Recovery Pattern
2
+
3
+ > **Purpose:** Guide agents on how to handle errors, retry intelligently, and escalate when stuck.
4
+
5
+ ---
6
+
7
+ ## 🎯 Core Principle
8
+
9
+ **Don't get stuck. Retry smart, escalate fast.**
10
+
11
+ Agents should:
12
+ 1. ✅ Try to fix errors automatically (up to 3 attempts)
13
+ 2. ✅ Escalate to Main Claude when blocked
14
+ 3. ✅ Provide clear context for escalation
15
+
16
+ ---
17
+
18
+ ## 🔍 Step 1: Identify Error Type
19
+
20
+ When an agent encounters an error, first classify it:
21
+
22
+ ### ✅ Fixable Errors (Retry)
23
+ Errors that agent can fix automatically:
24
+ - **Missing import/dependency** → Add import, install package
25
+ - **Typo in code** → Fix typo
26
+ - **Validation error** → Add validation
27
+ - **Wrong HTTP method** → Fix method
28
+ - **Missing field** → Add field
29
+ - **Type mismatch** → Fix type
30
+
31
+ **Action:** Retry with fix (up to 3 attempts)
32
+
33
+ ---
34
+
35
+ ### 🚨 Blocking Errors (Escalate Immediately)
36
+ Errors that agent cannot fix alone:
37
+ - **Missing environment variable** (e.g., DATABASE_URL not set)
38
+ - **Service not running** (e.g., PostgreSQL not running)
39
+ - **Missing file/resource** (e.g., API spec doesn't exist)
40
+ - **Insufficient permissions** (e.g., can't write to directory)
41
+ - **Infrastructure issue** (e.g., network timeout)
42
+ - **Ambiguous requirements** (e.g., "should we use JWT or sessions?")
43
+
44
+ **Action:** Escalate immediately (don't waste time retrying)
45
+
46
+ ---
47
+
48
+ ### 🤔 Unclear Errors (Try Once, Then Escalate)
49
+ Errors where root cause is unclear:
50
+ - **Stack trace without clear message**
51
+ - **Unexpected behavior** (works locally, fails in test)
52
+ - **Third-party service error**
53
+ - **Complex dependency conflict**
54
+
55
+ **Action:**
56
+ 1. Try obvious fix once
57
+ 2. If still fails → Escalate with details
58
+
59
+ ---
60
+
61
+ ## 🔄 Step 2: Retry Logic
62
+
63
+ ### For Fixable Errors:
64
+
65
+ ```markdown
66
+ Attempt 1: Fix Obvious Issue
67
+ - Read error message carefully
68
+ - Apply most obvious fix
69
+ - Run test/command again
70
+
71
+ Attempt 2: Re-read Documentation
72
+ - Search Context7 for relevant docs
73
+ - Check if using correct pattern
74
+ - Apply fix based on docs
75
+ - Run test/command again
76
+
77
+ Attempt 3: Different Approach
78
+ - Try alternative solution
79
+ - Example: If fetch fails, try different HTTP library
80
+ - Example: If query slow, try different query structure
81
+ - Run test/command again
82
+
83
+ After 3 Attempts: STOP and Escalate
84
+ - Don't waste more time
85
+ - Escalate to Main Claude with full context
86
+ ```
87
+
88
+ ### Example (Backend Agent):
89
+
90
+ ```
91
+ Error: "Cannot find module 'fastapi'"
92
+
93
+ Attempt 1: Install missing package
94
+ → Run: uv pip install fastapi
95
+ → Test: Import works ✅ FIXED!
96
+
97
+ Error: "Validation error: email field required"
98
+
99
+ Attempt 1: Add email field to Pydantic model
100
+ → Test: Still fails ❌
101
+
102
+ Attempt 2: Check Context7 docs for Pydantic validation
103
+ → Fix: Email should be EmailStr, not str
104
+ → Test: Works ✅ FIXED!
105
+
106
+ Error: "Database connection refused"
107
+
108
+ → This is BLOCKING ERROR (database not running)
109
+ → Escalate immediately (don't retry)
110
+ ```
111
+
112
+ ---
113
+
114
+ ## 🚨 Step 3: Escalation Format
115
+
116
+ When escalating to Main Claude, provide this information:
117
+
118
+ ### Template:
119
+
120
+ ```markdown
121
+ 🚨 **Escalation Required**
122
+
123
+ **Agent:** {agent-name}
124
+ **Task:** {task-description}
125
+ **Attempts:** {number-of-attempts}
126
+ **Error Type:** {fixable/blocking/unclear}
127
+
128
+ **Error Message:**
129
+ ```
130
+ {full-error-message}
131
+ {stack-trace-if-available}
132
+ ```
133
+
134
+ **What I Tried:**
135
+ 1. {attempt-1-description} → {result}
136
+ 2. {attempt-2-description} → {result}
137
+ 3. {attempt-3-description} → {result}
138
+
139
+ **Current State:**
140
+ - Files modified: {list-of-files}
141
+ - Tests passing: {yes/no}
142
+ - Code compiling: {yes/no}
143
+
144
+ **Need Help With:**
145
+ - {specific-question-1}
146
+ - {specific-question-2}
147
+ - {specific-question-3}
148
+
149
+ **Suggested Next Steps:**
150
+ - {suggestion-1}
151
+ - {suggestion-2}
152
+ ```
153
+
154
+ ### Example Escalation:
155
+
156
+ ```markdown
157
+ 🚨 **Escalation Required**
158
+
159
+ **Agent:** backend
160
+ **Task:** Create POST /api/auth/login endpoint
161
+ **Attempts:** 3
162
+ **Error Type:** Unclear
163
+
164
+ **Error Message:**
165
+ ```
166
+ AssertionError: assert 200 == 401
167
+ Expected status code 200, got 401
168
+ Test: test_login_success
169
+ ```
170
+
171
+ **What I Tried:**
172
+ 1. Checked credentials in test → Correct (test@example.com / password123)
173
+ 2. Added debug logging to endpoint → Shows user found in database
174
+ 3. Checked password hashing → bcrypt.verify() returns True
175
+
176
+ **Current State:**
177
+ - Files modified: app/api/auth.py, tests/test_auth.py
178
+ - Tests passing: 2/3 (test_login_success fails)
179
+ - Code compiling: Yes
180
+
181
+ **Need Help With:**
182
+ - Why does endpoint return 401 even when credentials are correct?
183
+ - Is there middleware blocking the request?
184
+ - Should I check JWT token generation logic?
185
+
186
+ **Suggested Next Steps:**
187
+ - Review middleware configuration
188
+ - Check if CORS is blocking response
189
+ - Verify JWT secret is set in environment
190
+ ```
191
+
192
+ ---
193
+
194
+ ## 📊 Error Recovery Decision Tree
195
+
196
+ ```
197
+ ┌─────────────────┐
198
+ │ Error Occurs │
199
+ └────────┬────────┘
200
+
201
+
202
+ ┌─────────────────────────────────────┐
203
+ │ Is this a BLOCKING ERROR? │
204
+ │ (env var, service down, etc.) │
205
+ └─┬───────────────────────────────┬───┘
206
+ │ YES │ NO
207
+ ▼ ▼
208
+ ┌──────────────────┐ ┌──────────────────┐
209
+ │ Escalate │ │ Is error clear? │
210
+ │ Immediately │ └─┬────────────┬───┘
211
+ └──────────────────┘ │ YES │ NO
212
+ ▼ ▼
213
+ ┌──────────────┐ ┌──────────────┐
214
+ │ Fixable? │ │ Try once │
215
+ └─┬──────────┬─┘ └──────┬───────┘
216
+ │ YES │ NO │
217
+ ▼ ▼ ▼
218
+ ┌─────────┐ ┌──────┐ ┌──────┐
219
+ │ Retry │ │Escal.│ │Escal.│
220
+ │ (max 3) │ └──────┘ └──────┘
221
+ └─┬───────┘
222
+
223
+
224
+ ┌──────────────┐
225
+ │ Fixed after │
226
+ │ 3 attempts? │
227
+ └─┬──────────┬─┘
228
+ │ YES │ NO
229
+ ▼ ▼
230
+ ┌────────┐ ┌──────────┐
231
+ │Continue│ │ Escalate │
232
+ └────────┘ └──────────┘
233
+ ```
234
+
235
+ ---
236
+
237
+ ## 🎯 Agent-Specific Guidelines
238
+
239
+ ### Backend Agent
240
+ **Common Fixable Errors:**
241
+ - Missing imports → Add import
242
+ - Validation errors → Fix Pydantic/Zod schema
243
+ - Type errors → Fix type annotations
244
+
245
+ **Common Blocking Errors:**
246
+ - Database not running → Escalate
247
+ - Missing DATABASE_URL → Escalate
248
+ - Port already in use → Escalate (or suggest: kill process)
249
+
250
+ ---
251
+
252
+ ### Database Agent
253
+ **Common Fixable Errors:**
254
+ - Migration syntax error → Fix SQL/Prisma syntax
255
+ - Missing index → Add index
256
+ - Wrong data type → Fix type
257
+
258
+ **Common Blocking Errors:**
259
+ - Cannot connect to database → Escalate
260
+ - Destructive migration without confirmation → Escalate (ask user)
261
+ - Migration conflict (already applied) → Escalate
262
+
263
+ ---
264
+
265
+ ### Test-Debug Agent
266
+ **Common Fixable Errors:**
267
+ - Test assertion fails → Fix code to pass test
268
+ - Mock data incorrect → Fix mock
269
+ - Import error → Add import
270
+
271
+ **Common Blocking Errors:**
272
+ - Test framework not installed → Escalate (install needed)
273
+ - Test requires external service → Escalate (mock or skip)
274
+ - Test flaky (random pass/fail) → Escalate after 2 attempts
275
+
276
+ ---
277
+
278
+ ### Frontend Agent
279
+ **Common Fixable Errors:**
280
+ - API fetch fails → Fix API URL
281
+ - State update error → Fix state logic
282
+ - Type error → Fix TypeScript types
283
+
284
+ **Common Blocking Errors:**
285
+ - Backend API not running → Escalate
286
+ - CORS error → Escalate (backend config needed)
287
+ - Environment variable missing → Escalate
288
+
289
+ ---
290
+
291
+ ### UX-UI Frontend Agent
292
+ **Common Fixable Errors:**
293
+ - CSS syntax error → Fix syntax
294
+ - Component prop error → Fix props
295
+ - Missing dependency → Install package
296
+
297
+ **Common Blocking Errors:**
298
+ - Design spec unclear → Escalate (ask for clarification)
299
+ - Asset missing (logo, image) → Escalate (request asset)
300
+ - Conflicting design requirements → Escalate
301
+
302
+ ---
303
+
304
+ ### Integration Agent
305
+ **Common Fixable Errors:**
306
+ - Type mismatch in contract → Document mismatch
307
+ - Missing field → Document missing field
308
+
309
+ **Common Blocking Errors:**
310
+ - Frontend or Backend doesn't exist → Escalate (cannot validate)
311
+ - API spec file missing → Escalate (request spec)
312
+
313
+ ---
314
+
315
+ ## 📋 Logging Error Recovery
316
+
317
+ **Always log each attempt:**
318
+
319
+ ```json
320
+ {
321
+ "event": "error_recovery_attempt",
322
+ "agent": "backend",
323
+ "task": "Create POST /api/login",
324
+ "attempt": 1,
325
+ "error_type": "fixable",
326
+ "error_message": "Missing import: FastAPI",
327
+ "fix_applied": "Added: from fastapi import FastAPI",
328
+ "result": "success"
329
+ }
330
+ ```
331
+
332
+ ```json
333
+ {
334
+ "event": "error_recovery_escalation",
335
+ "agent": "backend",
336
+ "task": "Create POST /api/login",
337
+ "attempts": 3,
338
+ "error_type": "unclear",
339
+ "error_message": "Test fails with 401 despite correct credentials",
340
+ "escalation_reason": "Root cause unclear after 3 attempts",
341
+ "context_provided": true
342
+ }
343
+ ```
344
+
345
+ ---
346
+
347
+ ## ✅ Summary
348
+
349
+ ### DO:
350
+ - ✅ Classify error first (fixable/blocking/unclear)
351
+ - ✅ Retry up to 3 times for fixable errors
352
+ - ✅ Escalate immediately for blocking errors
353
+ - ✅ Provide full context when escalating
354
+ - ✅ Log all attempts and results
355
+
356
+ ### DON'T:
357
+ - ❌ Don't retry forever (max 3 attempts)
358
+ - ❌ Don't retry blocking errors (waste of time)
359
+ - ❌ Don't escalate without context (unhelpful)
360
+ - ❌ Don't guess randomly (read docs first)
361
+ - ❌ Don't skip logging (observability critical)
362
+
363
+ ---
364
+
365
+ **Remember:** Getting unstuck fast is more valuable than fixing everything yourself. Escalate when needed!