@champpaba/claude-agent-kit 1.1.1 → 1.4.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.
@@ -173,66 +173,21 @@ Report steps 1-4 BEFORE coding.
173
173
 
174
174
  ## Context Loading Strategy
175
175
 
176
- ### Step 0: Read Tech Stack & Package Manager (CRITICAL!)
176
+ **→ See:** `.claude/lib/context-loading-protocol.md` for complete protocol
177
177
 
178
- **BEFORE doing anything, read tech-stack.md:**
178
+ **Agent-Specific Additions (frontend):**
179
179
 
180
- ```bash
181
- # Check if tech-stack.md exists
182
- .claude/contexts/domain/{project-name}/tech-stack.md
183
- ```
184
-
185
- **Extract:**
186
- 1. **Framework** (Next.js, FastAPI, Vue, etc.)
187
- 2. **Package Manager** (pnpm, npm, bun, uv, poetry, pip)
188
- 3. **Dependencies** (specific to this agent's role)
189
-
190
- **Action:**
191
- - Store framework → Use for Context7 search
192
- - Store package manager → **USE THIS for all install/run commands**
193
-
194
- **CRITICAL:** Never use `npm`, `pip`, or any other package manager without checking tech-stack.md first!
180
+ ### State Management Libraries (Context7)
181
+ **Topic:** "hooks, state, mutations, queries, caching"
182
+ **Tokens:** 2000
195
183
 
196
- ### Step 1: Load Universal Patterns (Always)
197
- - @.claude/contexts/patterns/testing.md
198
- - @.claude/contexts/patterns/logging.md
199
- - @.claude/contexts/patterns/error-handling.md
184
+ **Additional Patterns:**
200
185
  - @.claude/contexts/patterns/state-management.md
201
- - @.claude/contexts/patterns/task-classification.md
202
-
203
- ### Step 2: Detect Tech Stack & Load Docs (Context7)
204
-
205
- **IF Next.js:**
206
- ```
207
- mcp__context7__get-library-docs("/vercel/next.js", {
208
- topic: "app router, server components, server actions, data fetching",
209
- tokens: 3000
210
- })
211
- ```
212
-
213
- **IF React + TanStack Query:**
214
- ```
215
- mcp__context7__get-library-docs("/tanstack/query", {
216
- topic: "useQuery, useMutation, query invalidation",
217
- tokens: 2000
218
- })
219
- ```
220
-
221
- **IF Vue:**
222
- ```
223
- mcp__context7__get-library-docs("/vuejs/vue", {
224
- topic: "composition api, reactive, computed, watch",
225
- tokens: 3000
226
- })
227
- ```
228
186
 
229
- **IF Zustand:**
230
- ```
231
- mcp__context7__get-library-docs("/pmndrs/zustand", {
232
- topic: "create store, persist, middleware",
233
- tokens: 2000
234
- })
235
- ```
187
+ **Quick Reference:**
188
+ - 📦 Package Manager: Read from `tech-stack.md` (see protocol)
189
+ - 🔍 Patterns: error-handling.md, logging.md, testing.md (universal)
190
+ - 🎨 State: TanStack Query, Zustand, Redux (from Context7)
236
191
 
237
192
  ## TDD Decision Logic
238
193
 
@@ -256,316 +211,28 @@ mcp__context7__get-library-docs("/pmndrs/zustand", {
256
211
 
257
212
  ---
258
213
 
259
- ## TDD Workflow: Red-Green-Refactor
214
+ ## TDD Workflow
260
215
 
261
- **Use when:** `tdd_required: true`
216
+ **→ See:** `.claude/lib/tdd-workflow.md` for complete Red-Green-Refactor cycle
262
217
 
263
- **Common scenarios:**
264
- - External API integrations (payment, analytics, etc.)
265
- - Business logic functions (discount calculations, etc.)
218
+ **When to use:**
219
+ - If `tdd_required: true` Use TDD (Red-Green-Refactor)
220
+ - If `tdd_required: false` → Use Test-Alongside (implementation first)
221
+
222
+ **Common TDD scenarios for frontend:**
223
+ - External API integrations (payment, analytics)
224
+ - Business logic (discount calculations, transformations)
266
225
  - Complex form validation
267
226
  - Data transformations
268
227
 
269
- ### Step 1: RED Phase - Write Test First
270
-
271
- **Important:** Test MUST be written BEFORE any implementation code.
272
-
273
- **Example: Stripe Payment Integration**
274
-
275
- ```typescript
276
- // __tests__/lib/payment.test.ts (WRITE THIS FIRST!)
277
- import { describe, it, expect, vi, beforeEach } from 'vitest'
278
- import { processPayment } from '@/lib/payment'
279
- import Stripe from 'stripe'
280
-
281
- // Mock Stripe
282
- vi.mock('stripe', () => ({
283
- default: vi.fn().mockImplementation(() => ({
284
- charges: {
285
- create: vi.fn()
286
- }
287
- }))
288
- }))
289
-
290
- describe('processPayment', () => {
291
- beforeEach(() => {
292
- vi.clearAllMocks()
293
- })
294
-
295
- it('should process payment and return transaction ID', async () => {
296
- /**
297
- * Test successful payment flow.
298
- *
299
- * This test MUST FAIL initially (function doesn't exist).
300
- */
301
- const mockCharge = {
302
- id: 'ch_test123',
303
- status: 'succeeded',
304
- amount: 10000
305
- }
306
-
307
- const stripeMock = new Stripe('test_key')
308
- vi.mocked(stripeMock.charges.create).mockResolvedValue(mockCharge as any)
309
-
310
- const result = await processPayment({
311
- amount: 100,
312
- currency: 'USD',
313
- cardToken: 'tok_visa'
314
- })
315
-
316
- expect(result.success).toBe(true)
317
- expect(result.transactionId).toBe('ch_test123')
318
- expect(stripeMock.charges.create).toHaveBeenCalledWith({
319
- amount: 10000,
320
- currency: 'USD',
321
- source: 'tok_visa'
322
- })
323
- })
324
-
325
- it('should handle payment failure', async () => {
326
- /**
327
- * Test error handling for declined payment.
328
- */
329
- const stripeMock = new Stripe('test_key')
330
- vi.mocked(stripeMock.charges.create).mockRejectedValue(
331
- new Error('Card declined')
332
- )
333
-
334
- const result = await processPayment({
335
- amount: 100,
336
- currency: 'USD',
337
- cardToken: 'tok_chargeDeclined'
338
- })
339
-
340
- expect(result.success).toBe(false)
341
- expect(result.error).toContain('declined')
342
- })
343
-
344
- it('should validate payment amount', async () => {
345
- /**
346
- * Test validation for invalid amounts.
347
- */
348
- await expect(
349
- processPayment({
350
- amount: -10,
351
- currency: 'USD',
352
- cardToken: 'tok_visa'
353
- })
354
- ).rejects.toThrow('Amount must be positive')
355
- })
356
- })
228
+ **Quick Reference (TDD):**
357
229
  ```
358
-
359
- **Run tests:**
360
- ```bash
361
- pnpm test -- payment.test.ts --run
362
-
363
- # Expected output:
364
- # ❌ FAILED - Cannot find module '@/lib/payment'
365
- # ✅ This is CORRECT! Test should fail in RED phase.
230
+ 1. 🔴 RED: Write test first → verify it FAILS
231
+ 2. 🟢 GREEN: Minimal code → make tests PASS
232
+ 3. 🔵 REFACTOR: Add quality → tests still PASS
366
233
  ```
367
234
 
368
- **Log RED phase:**
369
- ```json
370
- {
371
- "event": "tdd_red_phase",
372
- "task": "Integrate Stripe payment",
373
- "test_file": "__tests__/lib/payment.test.ts",
374
- "tests_written": 3,
375
- "status": "fail",
376
- "expected": "Tests should fail - module doesn't exist yet"
377
- }
378
- ```
379
-
380
- ---
381
-
382
- ### Step 2: GREEN Phase - Minimal Implementation
383
-
384
- **Goal:** Write just enough code to make tests pass.
385
-
386
- ```typescript
387
- // lib/payment.ts (NOW create implementation)
388
- export interface PaymentData {
389
- amount: number
390
- currency: string
391
- cardToken: string
392
- }
393
-
394
- export interface PaymentResult {
395
- success: boolean
396
- transactionId?: string
397
- error?: string
398
- }
399
-
400
- export async function processPayment(data: PaymentData): Promise<PaymentResult> {
401
- /**
402
- * Minimal implementation - just make tests pass.
403
- * Will refactor with real Stripe integration later.
404
- */
405
-
406
- // Validation (to pass validation test)
407
- if (data.amount <= 0) {
408
- throw new Error('Amount must be positive')
409
- }
410
-
411
- // Simulate payment processing
412
- try {
413
- // Hardcoded success for now
414
- if (data.cardToken === 'tok_chargeDeclined') {
415
- return {
416
- success: false,
417
- error: 'Card declined'
418
- }
419
- }
420
-
421
- return {
422
- success: true,
423
- transactionId: 'ch_test123'
424
- }
425
- } catch (error) {
426
- return {
427
- success: false,
428
- error: error instanceof Error ? error.message : 'Unknown error'
429
- }
430
- }
431
- }
432
- ```
433
-
434
- **Run tests:**
435
- ```bash
436
- pnpm test -- payment.test.ts --run
437
-
438
- # Expected output:
439
- # ✅ PASSED should process payment and return transaction ID
440
- # ✅ PASSED should handle payment failure
441
- # ✅ PASSED should validate payment amount
442
- ```
443
-
444
- **Log GREEN phase:**
445
- ```json
446
- {
447
- "event": "tdd_green_phase",
448
- "task": "Integrate Stripe payment",
449
- "tests_passed": 3,
450
- "implementation": "lib/payment.ts",
451
- "status": "pass",
452
- "note": "Minimal implementation complete, refactor needed"
453
- }
454
- ```
455
-
456
- ---
457
-
458
- ### Step 3: REFACTOR Phase - Add Real Logic
459
-
460
- **Goal:** Integrate real Stripe SDK while keeping tests green.
461
-
462
- ```typescript
463
- // lib/payment.ts (Refactor with real Stripe integration)
464
- import Stripe from 'stripe'
465
- import { logger } from '@/lib/logger'
466
-
467
- export interface PaymentData {
468
- amount: number
469
- currency: string
470
- cardToken: string
471
- metadata?: Record<string, string>
472
- }
473
-
474
- export interface PaymentResult {
475
- success: boolean
476
- transactionId?: string
477
- error?: string
478
- }
479
-
480
- const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, {
481
- apiVersion: '2023-10-16'
482
- })
483
-
484
- export async function processPayment(data: PaymentData): Promise<PaymentResult> {
485
- /**
486
- * Process payment using Stripe API.
487
- *
488
- * @throws Error if amount is invalid
489
- */
490
-
491
- // Validation
492
- if (data.amount <= 0) {
493
- logger.error('payment_validation_error', {
494
- amount: data.amount,
495
- reason: 'negative_amount'
496
- })
497
- throw new Error('Amount must be positive')
498
- }
499
-
500
- logger.info('payment_processing_start', {
501
- amount: data.amount,
502
- currency: data.currency
503
- })
504
-
505
- try {
506
- // Create charge with Stripe
507
- const charge = await stripe.charges.create({
508
- amount: Math.round(data.amount * 100), // Convert to cents
509
- currency: data.currency.toLowerCase(),
510
- source: data.cardToken,
511
- metadata: data.metadata
512
- })
513
-
514
- logger.info('payment_success', {
515
- transaction_id: charge.id,
516
- amount: data.amount,
517
- status: charge.status
518
- })
519
-
520
- return {
521
- success: true,
522
- transactionId: charge.id
523
- }
524
-
525
- } catch (error) {
526
- const errorMessage = error instanceof Error ? error.message : 'Unknown error'
527
-
528
- logger.error('payment_failure', {
529
- error: errorMessage,
530
- amount: data.amount,
531
- currency: data.currency
532
- })
533
-
534
- return {
535
- success: false,
536
- error: errorMessage
537
- }
538
- }
539
- }
540
- ```
541
-
542
- **Run tests again:**
543
- ```bash
544
- pnpm test -- payment.test.ts --run
545
-
546
- # Expected output:
547
- # ✅ PASSED should process payment and return transaction ID (still passing!)
548
- # ✅ PASSED should handle payment failure (still passing!)
549
- # ✅ PASSED should validate payment amount (still passing!)
550
- ```
551
-
552
- **Log REFACTOR phase:**
553
- ```json
554
- {
555
- "event": "tdd_refactor_phase",
556
- "task": "Integrate Stripe payment",
557
- "tests_passing": 3,
558
- "improvements": [
559
- "Added real Stripe SDK integration",
560
- "Added amount conversion to cents",
561
- "Added structured logging (start, success, failure)",
562
- "Added error handling with detailed messages",
563
- "Added metadata support",
564
- "Added JSDoc documentation"
565
- ],
566
- "status": "complete"
567
- }
568
- ```
235
+ **Examples:** See `lib/tdd-workflow.md` → TypeScript/Next.js, JavaScript/React
569
236
 
570
237
  ---
571
238
 
@@ -871,145 +538,50 @@ test('failed login shows error message', async () => {
871
538
 
872
539
  ---
873
540
 
874
- ## Handoff to Next Agent (Optional but Recommended)
875
-
876
- **When completing a task, provide context for the next agent:**
541
+ ## Handoff to Next Agent
877
542
 
878
- ### Template:
543
+ **→ See:** `.claude/lib/handoff-protocol.md` for complete templates
879
544
 
880
- ```markdown
881
- ## ✅ Task Complete: [Task Name]
545
+ **Common Handoff Paths (frontend agent):**
882
546
 
883
- **Agent:** frontend
547
+ ### frontend → test-debug
548
+ **Purpose:** Hand off API-integrated components for testing
884
549
 
885
- **What I Did:**
886
- - {summary-of-work-done}
887
- - {key-changes-made}
888
- - {files-created-or-modified}
550
+ **What to include:**
551
+ - API endpoints connected (with request/response formats)
552
+ - State management implementation (Zustand/Redux stores)
553
+ - Error handling patterns used
554
+ - Test scenarios to cover (success, failure, edge cases)
555
+ - Protected routes or auth flows
556
+ - Files modified/created
889
557
 
890
- **For Next Agent:**
558
+ **Template:** See `lib/handoff-protocol.md` → "frontend → test-debug"
891
559
 
892
- {agent-specific-handoff-info}
893
-
894
- **Important Notes:**
895
- - {any-gotchas-or-warnings}
896
- - {configuration-needed}
897
- - {things-to-watch-out-for}
898
- ```
899
-
900
- ### Example Handoff (Frontend → Test-Debug):
901
-
902
- ```markdown
903
- ## ✅ Task Complete: Connect login form to API
904
-
905
- **Agent:** frontend
906
-
907
- **What I Did:**
908
- - Replaced mock data with real API calls to POST /api/auth/login
909
- - Added Zustand store for auth state (token + user)
910
- - Implemented login/logout actions
911
- - Added token persistence (localStorage)
912
- - Added error handling for API failures
913
-
914
- **For Next Agent (Test-Debug):**
915
-
916
- **What to Test:**
917
-
918
- **1. Login Flow:**
919
- - [ ] Valid credentials → Success (200, token returned)
920
- - [ ] Invalid credentials → Error (401, error message shown)
921
- - [ ] Missing fields → Error (422, validation error shown)
922
- - [ ] Network error → Error message shown
923
- - [ ] Token stored in localStorage after success
924
- - [ ] User redirected to /dashboard after success
925
-
926
- **2. State Management:**
927
- - [ ] User object stored in Zustand after login
928
- - [ ] Token accessible from auth store
929
- - [ ] Logout clears token and user from store
930
- - [ ] Logout clears localStorage
931
-
932
- **3. Protected Routes:**
933
- - [ ] /dashboard requires authentication
934
- - [ ] Redirect to /login if not authenticated
935
- - [ ] Token sent in Authorization header for API calls
936
-
937
- **Test Files:**
938
- - tests/auth/login.test.tsx (component test)
939
- - tests/store/auth.test.ts (store test)
940
- - e2e/login.spec.ts (end-to-end test)
941
-
942
- **Important Notes:**
943
- - Token expires in 7 days (no auto-refresh yet - add later)
944
- - If 401 on any API call, logout and redirect to login
945
- - CORS already configured on backend (no issues expected)
946
-
947
- **Files Modified:**
948
- - components/LoginForm.tsx (added API call)
949
- - store/auth.ts (new Zustand store)
950
- - hooks/useAuth.ts (custom hook for auth state)
951
- - middleware/auth.ts (protected route middleware)
952
- ```
953
-
954
- ### Why This Helps:
955
- - ✅ Next agent doesn't need to read all your code
956
- - ✅ API contracts/interfaces are clear
957
- - ✅ Prevents miscommunication
958
- - ✅ Saves time (no need to reverse-engineer your work)
959
-
960
- **Note:** This handoff format is optional but highly recommended for multi-agent workflows.
560
+ ---
961
561
 
962
562
  ---
963
563
 
964
564
  ## Documentation Policy
965
565
 
966
- ### NEVER Create Documentation Files Unless Explicitly Requested
967
- - DO NOT create: README.md, IMPLEMENTATION_GUIDE.md, FRONTEND_DOCS.md, or any other .md documentation files
968
- - DO NOT create: Component documentation files, API integration guides, or state management docs
969
- - Exception: ONLY when user explicitly says "create documentation" or "write a README"
970
-
971
- ### ✅ Report Results as Verbose Text Output Instead
972
- - Return comprehensive text reports in your final message (not separate files)
973
- - Include all important details:
974
- - Components created/modified
975
- - API integrations completed
976
- - State management implementation
977
- - Test results and coverage
978
- - Next steps
979
- - Format: Use markdown in your response text, NOT separate .md files
980
-
981
- **Example:**
982
- ```
983
- ❌ BAD: Write FRONTEND_IMPLEMENTATION.md (500 lines)
984
- Write STATE_MANAGEMENT_GUIDE.md (300 lines)
566
+ **→ See:** `.claude/contexts/patterns/code-standards.md` for complete policy
985
567
 
986
- GOOD: Return detailed implementation summary in final message
987
- Include all details but as response, not files
988
- ```
568
+ **Quick Reference:**
569
+ - NEVER create documentation files unless explicitly requested
570
+ - ❌ NO README.md, IMPLEMENTATION_GUIDE.md, API_DOCS.md, etc.
571
+ - ✅ Return comprehensive text reports in your final message instead
572
+ - ✅ Exception: Only when user explicitly says "create documentation"
989
573
 
990
574
  ## Rules
991
575
 
992
576
  ### Package Manager (CRITICAL!)
993
- - ✅ **ALWAYS read tech-stack.md** before running ANY install/run commands
994
- - ✅ Use package manager specified in tech-stack.md
995
- - ✅ Never assume `npm`, `pip`, or any other package manager
996
- - ✅ For monorepos: use correct package manager for ecosystem
997
-
998
- **Example:**
999
- ```markdown
1000
- # tech-stack.md shows:
1001
- Package Manager: pnpm (JavaScript)
1002
577
 
1003
- CORRECT: pnpm install
1004
- ✅ CORRECT: pnpm add zustand
1005
- ❌ WRONG: npm install (ignored tech-stack.md!)
1006
- ❌ WRONG: bun add zustand (tech-stack says pnpm!)
1007
- ```
578
+ **→ See:** `.claude/lib/context-loading-protocol.md` → Level 0 (Package Manager Discovery)
1008
579
 
1009
- **If tech-stack.md doesn't exist:**
1010
- - Warn user to run `/agentsetup` first
1011
- - Ask user which package manager to use
1012
- - DO NOT proceed with hardcoded package manager
580
+ **Quick Reference:**
581
+ - ALWAYS read `tech-stack.md` before ANY install/run commands
582
+ - Use exact package manager from tech-stack.md (pnpm, npm, bun, uv, poetry, pip)
583
+ - NEVER assume or hardcode package manager
584
+ - ❌ If tech-stack.md missing → warn user to run `/agentsetup`
1013
585
 
1014
586
  ### TDD Compliance
1015
587
  - ✅ Check `tdd_required` flag from Orchestrator