@chc880/everything-antigravity 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/LICENSE +21 -0
- package/README.md +54 -0
- package/assets/rules/common/coding-style.md +53 -0
- package/assets/rules/common/git-workflow.md +47 -0
- package/assets/rules/common/patterns.md +36 -0
- package/assets/rules/common/performance.md +21 -0
- package/assets/rules/common/security.md +34 -0
- package/assets/rules/common/testing.md +29 -0
- package/assets/rules/golang/coding-style.md +40 -0
- package/assets/rules/golang/patterns.md +44 -0
- package/assets/rules/golang/security.md +33 -0
- package/assets/rules/golang/testing.md +30 -0
- package/assets/rules/python/coding-style.md +52 -0
- package/assets/rules/python/patterns.md +39 -0
- package/assets/rules/python/security.md +30 -0
- package/assets/rules/python/testing.md +38 -0
- package/assets/rules/typescript/coding-style.md +44 -0
- package/assets/rules/typescript/patterns.md +50 -0
- package/assets/rules/typescript/security.md +27 -0
- package/assets/rules/typescript/testing.md +24 -0
- package/assets/skills/agent-guides/SKILL.md +40 -0
- package/assets/skills/agent-guides/references/architect.md +209 -0
- package/assets/skills/agent-guides/references/build-error-resolver.md +530 -0
- package/assets/skills/agent-guides/references/code-reviewer.md +102 -0
- package/assets/skills/agent-guides/references/database-reviewer.md +652 -0
- package/assets/skills/agent-guides/references/doc-updater.md +450 -0
- package/assets/skills/agent-guides/references/e2e-runner.md +795 -0
- package/assets/skills/agent-guides/references/go-build-resolver.md +366 -0
- package/assets/skills/agent-guides/references/go-reviewer.md +265 -0
- package/assets/skills/agent-guides/references/planner.md +117 -0
- package/assets/skills/agent-guides/references/python-reviewer.md +467 -0
- package/assets/skills/agent-guides/references/refactor-cleaner.md +304 -0
- package/assets/skills/agent-guides/references/security-reviewer.md +543 -0
- package/assets/skills/agent-guides/references/tdd-guide.md +278 -0
- package/assets/skills/backend-patterns/SKILL.md +587 -0
- package/assets/skills/clickhouse-io/SKILL.md +429 -0
- package/assets/skills/coding-standards/SKILL.md +520 -0
- package/assets/skills/cpp-testing/SKILL.md +322 -0
- package/assets/skills/django-patterns/SKILL.md +733 -0
- package/assets/skills/django-security/SKILL.md +592 -0
- package/assets/skills/django-tdd/SKILL.md +728 -0
- package/assets/skills/django-verification/SKILL.md +460 -0
- package/assets/skills/frontend-patterns/SKILL.md +631 -0
- package/assets/skills/golang-patterns/SKILL.md +673 -0
- package/assets/skills/golang-testing/SKILL.md +719 -0
- package/assets/skills/java-coding-standards/SKILL.md +138 -0
- package/assets/skills/jpa-patterns/SKILL.md +141 -0
- package/assets/skills/knowledge-management/SKILL.md +77 -0
- package/assets/skills/nutrient-document-processing/SKILL.md +165 -0
- package/assets/skills/postgres-patterns/SKILL.md +146 -0
- package/assets/skills/python-patterns/SKILL.md +749 -0
- package/assets/skills/python-testing/SKILL.md +815 -0
- package/assets/skills/security-hardening/SKILL.md +76 -0
- package/assets/skills/security-review/SKILL.md +494 -0
- package/assets/skills/security-review/cloud-infrastructure-security.md +361 -0
- package/assets/skills/springboot-patterns/SKILL.md +304 -0
- package/assets/skills/springboot-security/SKILL.md +119 -0
- package/assets/skills/springboot-tdd/SKILL.md +157 -0
- package/assets/skills/springboot-verification/SKILL.md +100 -0
- package/assets/skills/tdd-workflow/SKILL.md +409 -0
- package/assets/workflows/build-fix.md +50 -0
- package/assets/workflows/code-review.md +61 -0
- package/assets/workflows/e2e.md +65 -0
- package/assets/workflows/go-build.md +39 -0
- package/assets/workflows/go-review.md +44 -0
- package/assets/workflows/go-test.md +61 -0
- package/assets/workflows/plan.md +93 -0
- package/assets/workflows/python-review.md +95 -0
- package/assets/workflows/setup-pm.md +36 -0
- package/assets/workflows/tdd.md +75 -0
- package/assets/workflows/verify.md +81 -0
- package/bin/cli.js +69 -0
- package/lib/installer.js +301 -0
- package/package.json +34 -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.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Fix build errors, compiler warnings, and linter issues incrementally.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Build Fix
|
|
6
|
+
|
|
7
|
+
Diagnose and fix build errors incrementally.
|
|
8
|
+
|
|
9
|
+
## Workflow Steps
|
|
10
|
+
|
|
11
|
+
1. **Run Build** — Execute the project build command
|
|
12
|
+
2. **Analyze Errors** — Parse error messages carefully
|
|
13
|
+
3. **Fix Incrementally** — One error at a time (cascading errors may self-resolve)
|
|
14
|
+
4. **Verify** — Re-run build after each fix
|
|
15
|
+
5. **Repeat** — Until build succeeds
|
|
16
|
+
|
|
17
|
+
## Common Build Error Patterns
|
|
18
|
+
|
|
19
|
+
### TypeScript/JavaScript
|
|
20
|
+
```bash
|
|
21
|
+
npm run build # or npx tsc --noEmit
|
|
22
|
+
```
|
|
23
|
+
- Type errors → Fix type annotations
|
|
24
|
+
- Import errors → Fix paths or install missing dependencies
|
|
25
|
+
- ESLint errors → `npx eslint --fix .`
|
|
26
|
+
|
|
27
|
+
### Python
|
|
28
|
+
```bash
|
|
29
|
+
python -m py_compile src/*.py # or mypy src/
|
|
30
|
+
```
|
|
31
|
+
- Import errors → Fix module paths or install missing packages
|
|
32
|
+
- Type errors → Fix type annotations
|
|
33
|
+
- Syntax errors → Fix syntax
|
|
34
|
+
|
|
35
|
+
### Go
|
|
36
|
+
```bash
|
|
37
|
+
go build ./...
|
|
38
|
+
go vet ./...
|
|
39
|
+
```
|
|
40
|
+
- Compilation errors → Fix type mismatches, missing imports
|
|
41
|
+
- Vet warnings → Fix potential issues
|
|
42
|
+
- Lint issues → `golangci-lint run`
|
|
43
|
+
|
|
44
|
+
## Best Practices
|
|
45
|
+
|
|
46
|
+
1. Fix one error at a time — later errors may be caused by earlier ones
|
|
47
|
+
2. Read the full error message including file and line number
|
|
48
|
+
3. Check if the error is a real bug vs. a type system limitation
|
|
49
|
+
4. Run the build after each fix to verify
|
|
50
|
+
5. If stuck, try `npm ci` / `pip install -r requirements.txt` / `go mod tidy`
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Comprehensive code review for patterns, security, performance, and best practices. Generates severity-based report.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Code Review
|
|
6
|
+
|
|
7
|
+
Perform comprehensive code review with severity-based issue categorization.
|
|
8
|
+
|
|
9
|
+
## What This Command Does
|
|
10
|
+
|
|
11
|
+
1. **Identify Changed Files** — via `git diff` against base branch
|
|
12
|
+
2. **Review Code** — Check for patterns, security, performance issues
|
|
13
|
+
3. **Generate Report** — Categorize issues by severity
|
|
14
|
+
4. **Provide Verdict** — APPROVE, WARNING, or BLOCK
|
|
15
|
+
|
|
16
|
+
## Review Categories
|
|
17
|
+
|
|
18
|
+
### CRITICAL (Must Fix)
|
|
19
|
+
- Security vulnerabilities (SQL injection, XSS, etc.)
|
|
20
|
+
- Data loss potential
|
|
21
|
+
- Authentication/authorization bypass
|
|
22
|
+
- Hardcoded secrets
|
|
23
|
+
|
|
24
|
+
### HIGH (Should Fix)
|
|
25
|
+
- Missing error handling
|
|
26
|
+
- Performance issues (N+1 queries, memory leaks)
|
|
27
|
+
- Missing input validation
|
|
28
|
+
- Race conditions
|
|
29
|
+
|
|
30
|
+
### MEDIUM (Consider)
|
|
31
|
+
- Code style violations
|
|
32
|
+
- Missing documentation
|
|
33
|
+
- Suboptimal patterns
|
|
34
|
+
- Duplicate code
|
|
35
|
+
|
|
36
|
+
### LOW (Nice to Have)
|
|
37
|
+
- Minor naming improvements
|
|
38
|
+
- Additional test coverage
|
|
39
|
+
- Code comments
|
|
40
|
+
|
|
41
|
+
## Workflow Steps
|
|
42
|
+
|
|
43
|
+
1. Run `git diff [base-branch]...HEAD --name-only` to find changed files
|
|
44
|
+
2. Review each file for issues across all categories
|
|
45
|
+
3. Run available linters and formatters
|
|
46
|
+
4. Generate severity-based report
|
|
47
|
+
5. Provide overall verdict
|
|
48
|
+
|
|
49
|
+
## Approval Criteria
|
|
50
|
+
|
|
51
|
+
| Status | Condition |
|
|
52
|
+
|--------|-----------|
|
|
53
|
+
| ✅ Approve | No CRITICAL or HIGH issues |
|
|
54
|
+
| ⚠️ Warning | Only MEDIUM issues (merge with caution) |
|
|
55
|
+
| ❌ Block | CRITICAL or HIGH issues found |
|
|
56
|
+
|
|
57
|
+
## Integration with Other Workflows
|
|
58
|
+
|
|
59
|
+
- Use `/plan` before starting complex features
|
|
60
|
+
- Use `/tdd` for test-driven implementation
|
|
61
|
+
- Use `/build-fix` if build fails after review fixes
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Generate and run end-to-end tests with Playwright. Creates test journeys, captures screenshots/videos.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# E2E Testing
|
|
6
|
+
|
|
7
|
+
Generate and run end-to-end tests for critical user flows using Playwright.
|
|
8
|
+
|
|
9
|
+
## Workflow Steps
|
|
10
|
+
|
|
11
|
+
1. **Identify Critical Flows** — Determine the most important user journeys
|
|
12
|
+
2. **Write Test Specs** — Create Playwright test files
|
|
13
|
+
3. **Run Tests** — Execute tests with screenshots and traces
|
|
14
|
+
4. **Review Results** — Analyze test output and fix failures
|
|
15
|
+
|
|
16
|
+
## Setup
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Install Playwright
|
|
20
|
+
npm init playwright@latest
|
|
21
|
+
|
|
22
|
+
# Or add to existing project
|
|
23
|
+
npm install -D @playwright/test
|
|
24
|
+
npx playwright install
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Test Structure
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { test, expect } from '@playwright/test'
|
|
31
|
+
|
|
32
|
+
test.describe('User Authentication', () => {
|
|
33
|
+
test('can login successfully', async ({ page }) => {
|
|
34
|
+
await page.goto('/login')
|
|
35
|
+
await page.fill('[name="email"]', 'user@example.com')
|
|
36
|
+
await page.fill('[name="password"]', 'password')
|
|
37
|
+
await page.click('button[type="submit"]')
|
|
38
|
+
await expect(page).toHaveURL('/dashboard')
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Running Tests
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Run all tests
|
|
47
|
+
npx playwright test
|
|
48
|
+
|
|
49
|
+
# Run with UI
|
|
50
|
+
npx playwright test --ui
|
|
51
|
+
|
|
52
|
+
# Run specific file
|
|
53
|
+
npx playwright test tests/auth.spec.ts
|
|
54
|
+
|
|
55
|
+
# Run with trace
|
|
56
|
+
npx playwright test --trace on
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Best Practices
|
|
60
|
+
|
|
61
|
+
1. Use semantic selectors (`getByRole`, `getByText`) over CSS selectors
|
|
62
|
+
2. Add `data-testid` attributes for test-specific elements
|
|
63
|
+
3. Test critical user flows, not every UI detail
|
|
64
|
+
4. Use page objects for reusable interactions
|
|
65
|
+
5. Run tests in CI/CD pipeline
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Fix Go build errors, go vet warnings, and linter issues incrementally.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Go Build Fix
|
|
6
|
+
|
|
7
|
+
Fix Go build errors, vet warnings, and linter issues.
|
|
8
|
+
|
|
9
|
+
## Workflow Steps
|
|
10
|
+
|
|
11
|
+
1. Run `go build ./...` → fix compilation errors
|
|
12
|
+
2. Run `go vet ./...` → fix potential issues
|
|
13
|
+
3. Run `golangci-lint run` (if available) → fix lint issues
|
|
14
|
+
4. Repeat until clean
|
|
15
|
+
|
|
16
|
+
## Common Fixes
|
|
17
|
+
|
|
18
|
+
### Unused imports/variables
|
|
19
|
+
```go
|
|
20
|
+
// Remove unused imports or use blank identifier
|
|
21
|
+
import _ "unused/package"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Missing error handling
|
|
25
|
+
```go
|
|
26
|
+
// Wrong
|
|
27
|
+
result := doSomething()
|
|
28
|
+
|
|
29
|
+
// Right
|
|
30
|
+
result, err := doSomething()
|
|
31
|
+
if err != nil {
|
|
32
|
+
return fmt.Errorf("failed: %w", err)
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Type mismatches
|
|
37
|
+
- Check function signatures
|
|
38
|
+
- Use type assertions or conversions
|
|
39
|
+
- Verify interface implementations
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Comprehensive Go code review for idiomatic patterns, concurrency safety, error handling, and security.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Go Code Review
|
|
6
|
+
|
|
7
|
+
Comprehensive Go-specific code review.
|
|
8
|
+
|
|
9
|
+
## Review Checklist
|
|
10
|
+
|
|
11
|
+
### Idiomatic Go
|
|
12
|
+
- [ ] `gofmt` / `goimports` applied
|
|
13
|
+
- [ ] Small interfaces (1-3 methods)
|
|
14
|
+
- [ ] Accept interfaces, return structs
|
|
15
|
+
- [ ] Functional options for configuration
|
|
16
|
+
- [ ] Proper use of `context.Context`
|
|
17
|
+
|
|
18
|
+
### Concurrency Safety
|
|
19
|
+
- [ ] No data races (verify with `-race` flag)
|
|
20
|
+
- [ ] Proper channel usage and lifecycle
|
|
21
|
+
- [ ] `sync.Mutex` / `sync.RWMutex` where needed
|
|
22
|
+
- [ ] `sync.WaitGroup` for goroutine synchronization
|
|
23
|
+
- [ ] No goroutine leaks
|
|
24
|
+
|
|
25
|
+
### Error Handling
|
|
26
|
+
- [ ] All errors checked (no `_` for error returns)
|
|
27
|
+
- [ ] Errors wrapped with `fmt.Errorf("context: %w", err)`
|
|
28
|
+
- [ ] Custom error types where appropriate
|
|
29
|
+
- [ ] Sentinel errors for expected conditions
|
|
30
|
+
|
|
31
|
+
### Security
|
|
32
|
+
- [ ] No hardcoded secrets
|
|
33
|
+
- [ ] SQL injection prevention (parameterized queries)
|
|
34
|
+
- [ ] Input validation at boundaries
|
|
35
|
+
- [ ] Timeouts via `context.WithTimeout`
|
|
36
|
+
|
|
37
|
+
## Running Review
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
go vet ./...
|
|
41
|
+
golangci-lint run
|
|
42
|
+
go test -race ./...
|
|
43
|
+
gosec ./...
|
|
44
|
+
```
|