@jwdobeutechsolutions/dobeutech-claude-code-custom 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.
- package/CLAUDE.md +174 -0
- package/CONTRIBUTING.md +191 -0
- package/README.md +345 -0
- package/agents/accessibility-auditor.md +315 -0
- package/agents/api-designer.md +265 -0
- package/agents/architect.md +211 -0
- package/agents/build-error-resolver.md +532 -0
- package/agents/ci-cd-generator.md +318 -0
- package/agents/code-reviewer.md +104 -0
- package/agents/database-migrator.md +258 -0
- package/agents/deployment-manager.md +296 -0
- package/agents/doc-updater.md +452 -0
- package/agents/docker-specialist.md +293 -0
- package/agents/e2e-runner.md +708 -0
- package/agents/fullstack-architect.md +293 -0
- package/agents/infrastructure-engineer.md +297 -0
- package/agents/integration-tester.md +320 -0
- package/agents/performance-tester.md +243 -0
- package/agents/planner.md +119 -0
- package/agents/refactor-cleaner.md +306 -0
- package/agents/security-reviewer.md +545 -0
- package/agents/tdd-guide.md +280 -0
- package/agents/unit-test-generator.md +290 -0
- package/bin/claude-config.js +290 -0
- package/commands/api-design.md +55 -0
- package/commands/audit-accessibility.md +37 -0
- package/commands/audit-performance.md +38 -0
- package/commands/audit-security.md +43 -0
- package/commands/build-fix.md +29 -0
- package/commands/changelog.md +31 -0
- package/commands/code-review.md +40 -0
- package/commands/deploy.md +51 -0
- package/commands/docs-api.md +41 -0
- package/commands/e2e.md +363 -0
- package/commands/plan.md +113 -0
- package/commands/refactor-clean.md +28 -0
- package/commands/tdd.md +326 -0
- package/commands/test-coverage.md +27 -0
- package/commands/update-codemaps.md +17 -0
- package/commands/update-docs.md +31 -0
- package/hooks/hooks.json +121 -0
- package/mcp-configs/mcp-servers.json +163 -0
- package/package.json +53 -0
- package/rules/agents.md +49 -0
- package/rules/coding-style.md +70 -0
- package/rules/git-workflow.md +45 -0
- package/rules/hooks.md +46 -0
- package/rules/patterns.md +55 -0
- package/rules/performance.md +47 -0
- package/rules/security.md +36 -0
- package/rules/testing.md +30 -0
- package/scripts/install.js +254 -0
- package/skills/backend-patterns.md +582 -0
- package/skills/clickhouse-io.md +429 -0
- package/skills/coding-standards.md +520 -0
- package/skills/frontend-patterns.md +631 -0
- package/skills/project-guidelines-example.md +345 -0
- package/skills/security-review/SKILL.md +494 -0
- package/skills/tdd-workflow/SKILL.md +409 -0
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tdd-workflow
|
|
3
|
+
description: Use this skill when writing new features, fixing bugs, or refactoring code. Enforces test-driven development with 80%+ coverage including unit, integration, and E2E tests.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Test-Driven Development Workflow
|
|
7
|
+
|
|
8
|
+
This skill ensures all code development follows TDD principles with comprehensive test coverage.
|
|
9
|
+
|
|
10
|
+
## When to Activate
|
|
11
|
+
|
|
12
|
+
- Writing new features or functionality
|
|
13
|
+
- Fixing bugs or issues
|
|
14
|
+
- Refactoring existing code
|
|
15
|
+
- Adding API endpoints
|
|
16
|
+
- Creating new components
|
|
17
|
+
|
|
18
|
+
## Core Principles
|
|
19
|
+
|
|
20
|
+
### 1. Tests BEFORE Code
|
|
21
|
+
ALWAYS write tests first, then implement code to make tests pass.
|
|
22
|
+
|
|
23
|
+
### 2. Coverage Requirements
|
|
24
|
+
- Minimum 80% coverage (unit + integration + E2E)
|
|
25
|
+
- All edge cases covered
|
|
26
|
+
- Error scenarios tested
|
|
27
|
+
- Boundary conditions verified
|
|
28
|
+
|
|
29
|
+
### 3. Test Types
|
|
30
|
+
|
|
31
|
+
#### Unit Tests
|
|
32
|
+
- Individual functions and utilities
|
|
33
|
+
- Component logic
|
|
34
|
+
- Pure functions
|
|
35
|
+
- Helpers and utilities
|
|
36
|
+
|
|
37
|
+
#### Integration Tests
|
|
38
|
+
- API endpoints
|
|
39
|
+
- Database operations
|
|
40
|
+
- Service interactions
|
|
41
|
+
- External API calls
|
|
42
|
+
|
|
43
|
+
#### E2E Tests (Playwright)
|
|
44
|
+
- Critical user flows
|
|
45
|
+
- Complete workflows
|
|
46
|
+
- Browser automation
|
|
47
|
+
- UI interactions
|
|
48
|
+
|
|
49
|
+
## TDD Workflow Steps
|
|
50
|
+
|
|
51
|
+
### Step 1: Write User Journeys
|
|
52
|
+
```
|
|
53
|
+
As a [role], I want to [action], so that [benefit]
|
|
54
|
+
|
|
55
|
+
Example:
|
|
56
|
+
As a user, I want to search for markets semantically,
|
|
57
|
+
so that I can find relevant markets even without exact keywords.
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Step 2: Generate Test Cases
|
|
61
|
+
For each user journey, create comprehensive test cases:
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
describe('Semantic Search', () => {
|
|
65
|
+
it('returns relevant markets for query', async () => {
|
|
66
|
+
// Test implementation
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('handles empty query gracefully', async () => {
|
|
70
|
+
// Test edge case
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it('falls back to substring search when Redis unavailable', async () => {
|
|
74
|
+
// Test fallback behavior
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('sorts results by similarity score', async () => {
|
|
78
|
+
// Test sorting logic
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Step 3: Run Tests (They Should Fail)
|
|
84
|
+
```bash
|
|
85
|
+
npm test
|
|
86
|
+
# Tests should fail - we haven't implemented yet
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Step 4: Implement Code
|
|
90
|
+
Write minimal code to make tests pass:
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
// Implementation guided by tests
|
|
94
|
+
export async function searchMarkets(query: string) {
|
|
95
|
+
// Implementation here
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Step 5: Run Tests Again
|
|
100
|
+
```bash
|
|
101
|
+
npm test
|
|
102
|
+
# Tests should now pass
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Step 6: Refactor
|
|
106
|
+
Improve code quality while keeping tests green:
|
|
107
|
+
- Remove duplication
|
|
108
|
+
- Improve naming
|
|
109
|
+
- Optimize performance
|
|
110
|
+
- Enhance readability
|
|
111
|
+
|
|
112
|
+
### Step 7: Verify Coverage
|
|
113
|
+
```bash
|
|
114
|
+
npm run test:coverage
|
|
115
|
+
# Verify 80%+ coverage achieved
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Testing Patterns
|
|
119
|
+
|
|
120
|
+
### Unit Test Pattern (Jest/Vitest)
|
|
121
|
+
```typescript
|
|
122
|
+
import { render, screen, fireEvent } from '@testing-library/react'
|
|
123
|
+
import { Button } from './Button'
|
|
124
|
+
|
|
125
|
+
describe('Button Component', () => {
|
|
126
|
+
it('renders with correct text', () => {
|
|
127
|
+
render(<Button>Click me</Button>)
|
|
128
|
+
expect(screen.getByText('Click me')).toBeInTheDocument()
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
it('calls onClick when clicked', () => {
|
|
132
|
+
const handleClick = jest.fn()
|
|
133
|
+
render(<Button onClick={handleClick}>Click</Button>)
|
|
134
|
+
|
|
135
|
+
fireEvent.click(screen.getByRole('button'))
|
|
136
|
+
|
|
137
|
+
expect(handleClick).toHaveBeenCalledTimes(1)
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
it('is disabled when disabled prop is true', () => {
|
|
141
|
+
render(<Button disabled>Click</Button>)
|
|
142
|
+
expect(screen.getByRole('button')).toBeDisabled()
|
|
143
|
+
})
|
|
144
|
+
})
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### API Integration Test Pattern
|
|
148
|
+
```typescript
|
|
149
|
+
import { NextRequest } from 'next/server'
|
|
150
|
+
import { GET } from './route'
|
|
151
|
+
|
|
152
|
+
describe('GET /api/markets', () => {
|
|
153
|
+
it('returns markets successfully', async () => {
|
|
154
|
+
const request = new NextRequest('http://localhost/api/markets')
|
|
155
|
+
const response = await GET(request)
|
|
156
|
+
const data = await response.json()
|
|
157
|
+
|
|
158
|
+
expect(response.status).toBe(200)
|
|
159
|
+
expect(data.success).toBe(true)
|
|
160
|
+
expect(Array.isArray(data.data)).toBe(true)
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
it('validates query parameters', async () => {
|
|
164
|
+
const request = new NextRequest('http://localhost/api/markets?limit=invalid')
|
|
165
|
+
const response = await GET(request)
|
|
166
|
+
|
|
167
|
+
expect(response.status).toBe(400)
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
it('handles database errors gracefully', async () => {
|
|
171
|
+
// Mock database failure
|
|
172
|
+
const request = new NextRequest('http://localhost/api/markets')
|
|
173
|
+
// Test error handling
|
|
174
|
+
})
|
|
175
|
+
})
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### E2E Test Pattern (Playwright)
|
|
179
|
+
```typescript
|
|
180
|
+
import { test, expect } from '@playwright/test'
|
|
181
|
+
|
|
182
|
+
test('user can search and filter markets', async ({ page }) => {
|
|
183
|
+
// Navigate to markets page
|
|
184
|
+
await page.goto('/')
|
|
185
|
+
await page.click('a[href="/markets"]')
|
|
186
|
+
|
|
187
|
+
// Verify page loaded
|
|
188
|
+
await expect(page.locator('h1')).toContainText('Markets')
|
|
189
|
+
|
|
190
|
+
// Search for markets
|
|
191
|
+
await page.fill('input[placeholder="Search markets"]', 'election')
|
|
192
|
+
|
|
193
|
+
// Wait for debounce and results
|
|
194
|
+
await page.waitForTimeout(600)
|
|
195
|
+
|
|
196
|
+
// Verify search results displayed
|
|
197
|
+
const results = page.locator('[data-testid="market-card"]')
|
|
198
|
+
await expect(results).toHaveCount(5, { timeout: 5000 })
|
|
199
|
+
|
|
200
|
+
// Verify results contain search term
|
|
201
|
+
const firstResult = results.first()
|
|
202
|
+
await expect(firstResult).toContainText('election', { ignoreCase: true })
|
|
203
|
+
|
|
204
|
+
// Filter by status
|
|
205
|
+
await page.click('button:has-text("Active")')
|
|
206
|
+
|
|
207
|
+
// Verify filtered results
|
|
208
|
+
await expect(results).toHaveCount(3)
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
test('user can create a new market', async ({ page }) => {
|
|
212
|
+
// Login first
|
|
213
|
+
await page.goto('/creator-dashboard')
|
|
214
|
+
|
|
215
|
+
// Fill market creation form
|
|
216
|
+
await page.fill('input[name="name"]', 'Test Market')
|
|
217
|
+
await page.fill('textarea[name="description"]', 'Test description')
|
|
218
|
+
await page.fill('input[name="endDate"]', '2025-12-31')
|
|
219
|
+
|
|
220
|
+
// Submit form
|
|
221
|
+
await page.click('button[type="submit"]')
|
|
222
|
+
|
|
223
|
+
// Verify success message
|
|
224
|
+
await expect(page.locator('text=Market created successfully')).toBeVisible()
|
|
225
|
+
|
|
226
|
+
// Verify redirect to market page
|
|
227
|
+
await expect(page).toHaveURL(/\/markets\/test-market/)
|
|
228
|
+
})
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## Test File Organization
|
|
232
|
+
|
|
233
|
+
```
|
|
234
|
+
src/
|
|
235
|
+
├── components/
|
|
236
|
+
│ ├── Button/
|
|
237
|
+
│ │ ├── Button.tsx
|
|
238
|
+
│ │ ├── Button.test.tsx # Unit tests
|
|
239
|
+
│ │ └── Button.stories.tsx # Storybook
|
|
240
|
+
│ └── MarketCard/
|
|
241
|
+
│ ├── MarketCard.tsx
|
|
242
|
+
│ └── MarketCard.test.tsx
|
|
243
|
+
├── app/
|
|
244
|
+
│ └── api/
|
|
245
|
+
│ └── markets/
|
|
246
|
+
│ ├── route.ts
|
|
247
|
+
│ └── route.test.ts # Integration tests
|
|
248
|
+
└── e2e/
|
|
249
|
+
├── markets.spec.ts # E2E tests
|
|
250
|
+
├── trading.spec.ts
|
|
251
|
+
└── auth.spec.ts
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Mocking External Services
|
|
255
|
+
|
|
256
|
+
### Supabase Mock
|
|
257
|
+
```typescript
|
|
258
|
+
jest.mock('@/lib/supabase', () => ({
|
|
259
|
+
supabase: {
|
|
260
|
+
from: jest.fn(() => ({
|
|
261
|
+
select: jest.fn(() => ({
|
|
262
|
+
eq: jest.fn(() => Promise.resolve({
|
|
263
|
+
data: [{ id: 1, name: 'Test Market' }],
|
|
264
|
+
error: null
|
|
265
|
+
}))
|
|
266
|
+
}))
|
|
267
|
+
}))
|
|
268
|
+
}
|
|
269
|
+
}))
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Redis Mock
|
|
273
|
+
```typescript
|
|
274
|
+
jest.mock('@/lib/redis', () => ({
|
|
275
|
+
searchMarketsByVector: jest.fn(() => Promise.resolve([
|
|
276
|
+
{ slug: 'test-market', similarity_score: 0.95 }
|
|
277
|
+
])),
|
|
278
|
+
checkRedisHealth: jest.fn(() => Promise.resolve({ connected: true }))
|
|
279
|
+
}))
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### OpenAI Mock
|
|
283
|
+
```typescript
|
|
284
|
+
jest.mock('@/lib/openai', () => ({
|
|
285
|
+
generateEmbedding: jest.fn(() => Promise.resolve(
|
|
286
|
+
new Array(1536).fill(0.1) // Mock 1536-dim embedding
|
|
287
|
+
))
|
|
288
|
+
}))
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## Test Coverage Verification
|
|
292
|
+
|
|
293
|
+
### Run Coverage Report
|
|
294
|
+
```bash
|
|
295
|
+
npm run test:coverage
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Coverage Thresholds
|
|
299
|
+
```json
|
|
300
|
+
{
|
|
301
|
+
"jest": {
|
|
302
|
+
"coverageThresholds": {
|
|
303
|
+
"global": {
|
|
304
|
+
"branches": 80,
|
|
305
|
+
"functions": 80,
|
|
306
|
+
"lines": 80,
|
|
307
|
+
"statements": 80
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
## Common Testing Mistakes to Avoid
|
|
315
|
+
|
|
316
|
+
### ❌ WRONG: Testing Implementation Details
|
|
317
|
+
```typescript
|
|
318
|
+
// Don't test internal state
|
|
319
|
+
expect(component.state.count).toBe(5)
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### ✅ CORRECT: Test User-Visible Behavior
|
|
323
|
+
```typescript
|
|
324
|
+
// Test what users see
|
|
325
|
+
expect(screen.getByText('Count: 5')).toBeInTheDocument()
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### ❌ WRONG: Brittle Selectors
|
|
329
|
+
```typescript
|
|
330
|
+
// Breaks easily
|
|
331
|
+
await page.click('.css-class-xyz')
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### ✅ CORRECT: Semantic Selectors
|
|
335
|
+
```typescript
|
|
336
|
+
// Resilient to changes
|
|
337
|
+
await page.click('button:has-text("Submit")')
|
|
338
|
+
await page.click('[data-testid="submit-button"]')
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
### ❌ WRONG: No Test Isolation
|
|
342
|
+
```typescript
|
|
343
|
+
// Tests depend on each other
|
|
344
|
+
test('creates user', () => { /* ... */ })
|
|
345
|
+
test('updates same user', () => { /* depends on previous test */ })
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### ✅ CORRECT: Independent Tests
|
|
349
|
+
```typescript
|
|
350
|
+
// Each test sets up its own data
|
|
351
|
+
test('creates user', () => {
|
|
352
|
+
const user = createTestUser()
|
|
353
|
+
// Test logic
|
|
354
|
+
})
|
|
355
|
+
|
|
356
|
+
test('updates user', () => {
|
|
357
|
+
const user = createTestUser()
|
|
358
|
+
// Update logic
|
|
359
|
+
})
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
## Continuous Testing
|
|
363
|
+
|
|
364
|
+
### Watch Mode During Development
|
|
365
|
+
```bash
|
|
366
|
+
npm test -- --watch
|
|
367
|
+
# Tests run automatically on file changes
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### Pre-Commit Hook
|
|
371
|
+
```bash
|
|
372
|
+
# Runs before every commit
|
|
373
|
+
npm test && npm run lint
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### CI/CD Integration
|
|
377
|
+
```yaml
|
|
378
|
+
# GitHub Actions
|
|
379
|
+
- name: Run Tests
|
|
380
|
+
run: npm test -- --coverage
|
|
381
|
+
- name: Upload Coverage
|
|
382
|
+
uses: codecov/codecov-action@v3
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
## Best Practices
|
|
386
|
+
|
|
387
|
+
1. **Write Tests First** - Always TDD
|
|
388
|
+
2. **One Assert Per Test** - Focus on single behavior
|
|
389
|
+
3. **Descriptive Test Names** - Explain what's tested
|
|
390
|
+
4. **Arrange-Act-Assert** - Clear test structure
|
|
391
|
+
5. **Mock External Dependencies** - Isolate unit tests
|
|
392
|
+
6. **Test Edge Cases** - Null, undefined, empty, large
|
|
393
|
+
7. **Test Error Paths** - Not just happy paths
|
|
394
|
+
8. **Keep Tests Fast** - Unit tests < 50ms each
|
|
395
|
+
9. **Clean Up After Tests** - No side effects
|
|
396
|
+
10. **Review Coverage Reports** - Identify gaps
|
|
397
|
+
|
|
398
|
+
## Success Metrics
|
|
399
|
+
|
|
400
|
+
- 80%+ code coverage achieved
|
|
401
|
+
- All tests passing (green)
|
|
402
|
+
- No skipped or disabled tests
|
|
403
|
+
- Fast test execution (< 30s for unit tests)
|
|
404
|
+
- E2E tests cover critical user flows
|
|
405
|
+
- Tests catch bugs before production
|
|
406
|
+
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
**Remember**: Tests are not optional. They are the safety net that enables confident refactoring, rapid development, and production reliability.
|