@fyow/copilot-everything 1.0.2 → 1.0.3
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/.github/agents/architect.agent.md +113 -5
- package/.github/agents/build-error-resolver.agent.md +454 -42
- package/.github/agents/code-reviewer.agent.md +24 -13
- package/.github/agents/doc-updater.agent.md +366 -36
- package/.github/agents/e2e-runner.agent.md +626 -69
- package/.github/agents/planner.agent.md +25 -2
- package/.github/agents/refactor-cleaner.agent.md +218 -35
- package/.github/agents/security-reviewer.agent.md +485 -70
- package/.github/agents/tdd-guide.agent.md +174 -22
- package/.github/instructions/agents.instructions.md +53 -0
- package/.github/instructions/coding-style.instructions.md +20 -13
- package/.github/instructions/git-workflow.instructions.md +5 -18
- package/.github/instructions/hooks.instructions.md +52 -0
- package/.github/instructions/patterns.instructions.md +59 -0
- package/.github/instructions/performance.instructions.md +30 -29
- package/.github/instructions/security.instructions.md +12 -35
- package/.github/instructions/testing.instructions.md +4 -25
- package/.github/skills/continuous-learning/SKILL.md +80 -0
- package/.github/skills/eval-harness/SKILL.md +221 -0
- package/.github/skills/project-guidelines-example/SKILL.md +5 -10
- package/.github/skills/strategic-compact/SKILL.md +63 -0
- package/.github/skills/verification-loop/SKILL.md +1 -6
- package/package.json +1 -1
- package/src/commands/init.js +21 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: tdd-guide
|
|
3
|
-
description: Test-Driven Development specialist enforcing write-tests-first methodology. Use
|
|
3
|
+
description: Test-Driven Development specialist enforcing write-tests-first methodology. Use PROACTIVELY when writing new features, fixing bugs, or refactoring code. Ensures 80%+ test coverage.
|
|
4
4
|
tools: ["read", "edit", "shell", "search"]
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -25,6 +25,7 @@ describe('searchMarkets', () => {
|
|
|
25
25
|
|
|
26
26
|
expect(results).toHaveLength(5)
|
|
27
27
|
expect(results[0].name).toContain('Trump')
|
|
28
|
+
expect(results[1].name).toContain('Biden')
|
|
28
29
|
})
|
|
29
30
|
})
|
|
30
31
|
```
|
|
@@ -96,32 +97,183 @@ import { NextRequest } from 'next/server'
|
|
|
96
97
|
import { GET } from './route'
|
|
97
98
|
|
|
98
99
|
describe('GET /api/markets/search', () => {
|
|
99
|
-
it('returns
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
const data = await
|
|
103
|
-
|
|
104
|
-
expect(
|
|
105
|
-
expect(data.
|
|
100
|
+
it('returns 200 with valid results', async () => {
|
|
101
|
+
const request = new NextRequest('http://localhost/api/markets/search?q=trump')
|
|
102
|
+
const response = await GET(request, {})
|
|
103
|
+
const data = await response.json()
|
|
104
|
+
|
|
105
|
+
expect(response.status).toBe(200)
|
|
106
|
+
expect(data.success).toBe(true)
|
|
107
|
+
expect(data.results.length).toBeGreaterThan(0)
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
it('returns 400 for missing query', async () => {
|
|
111
|
+
const request = new NextRequest('http://localhost/api/markets/search')
|
|
112
|
+
const response = await GET(request, {})
|
|
113
|
+
|
|
114
|
+
expect(response.status).toBe(400)
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('falls back to substring search when Redis unavailable', async () => {
|
|
118
|
+
// Mock Redis failure
|
|
119
|
+
jest.spyOn(redis, 'searchMarketsByVector').mockRejectedValue(new Error('Redis down'))
|
|
120
|
+
|
|
121
|
+
const request = new NextRequest('http://localhost/api/markets/search?q=test')
|
|
122
|
+
const response = await GET(request, {})
|
|
123
|
+
const data = await response.json()
|
|
124
|
+
|
|
125
|
+
expect(response.status).toBe(200)
|
|
126
|
+
expect(data.fallback).toBe(true)
|
|
106
127
|
})
|
|
107
128
|
})
|
|
108
129
|
```
|
|
109
130
|
|
|
110
|
-
### 3. E2E Tests (Critical Flows)
|
|
111
|
-
Test complete user journeys with Playwright
|
|
131
|
+
### 3. E2E Tests (For Critical Flows)
|
|
132
|
+
Test complete user journeys with Playwright:
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
import { test, expect } from '@playwright/test'
|
|
136
|
+
|
|
137
|
+
test('user can search and view market', async ({ page }) => {
|
|
138
|
+
await page.goto('/')
|
|
139
|
+
|
|
140
|
+
// Search for market
|
|
141
|
+
await page.fill('input[placeholder="Search markets"]', 'election')
|
|
142
|
+
await page.waitForTimeout(600) // Debounce
|
|
143
|
+
|
|
144
|
+
// Verify results
|
|
145
|
+
const results = page.locator('[data-testid="market-card"]')
|
|
146
|
+
await expect(results).toHaveCount(5, { timeout: 5000 })
|
|
147
|
+
|
|
148
|
+
// Click first result
|
|
149
|
+
await results.first().click()
|
|
150
|
+
|
|
151
|
+
// Verify market page loaded
|
|
152
|
+
await expect(page).toHaveURL(/\/markets\//)
|
|
153
|
+
await expect(page.locator('h1')).toBeVisible()
|
|
154
|
+
})
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Mocking External Dependencies
|
|
158
|
+
|
|
159
|
+
### Mock Supabase
|
|
160
|
+
```typescript
|
|
161
|
+
jest.mock('@/lib/supabase', () => ({
|
|
162
|
+
supabase: {
|
|
163
|
+
from: jest.fn(() => ({
|
|
164
|
+
select: jest.fn(() => ({
|
|
165
|
+
eq: jest.fn(() => Promise.resolve({
|
|
166
|
+
data: mockMarkets,
|
|
167
|
+
error: null
|
|
168
|
+
}))
|
|
169
|
+
}))
|
|
170
|
+
}))
|
|
171
|
+
}
|
|
172
|
+
}))
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Mock Redis
|
|
176
|
+
```typescript
|
|
177
|
+
jest.mock('@/lib/redis', () => ({
|
|
178
|
+
searchMarketsByVector: jest.fn(() => Promise.resolve([
|
|
179
|
+
{ slug: 'test-1', similarity_score: 0.95 },
|
|
180
|
+
{ slug: 'test-2', similarity_score: 0.90 }
|
|
181
|
+
]))
|
|
182
|
+
}))
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Mock OpenAI
|
|
186
|
+
```typescript
|
|
187
|
+
jest.mock('@/lib/openai', () => ({
|
|
188
|
+
generateEmbedding: jest.fn(() => Promise.resolve(
|
|
189
|
+
new Array(1536).fill(0.1)
|
|
190
|
+
))
|
|
191
|
+
}))
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Edge Cases You MUST Test
|
|
195
|
+
|
|
196
|
+
1. **Null/Undefined**: What if input is null?
|
|
197
|
+
2. **Empty**: What if array/string is empty?
|
|
198
|
+
3. **Invalid Types**: What if wrong type passed?
|
|
199
|
+
4. **Boundaries**: Min/max values
|
|
200
|
+
5. **Errors**: Network failures, database errors
|
|
201
|
+
6. **Race Conditions**: Concurrent operations
|
|
202
|
+
7. **Large Data**: Performance with 10k+ items
|
|
203
|
+
8. **Special Characters**: Unicode, emojis, SQL characters
|
|
204
|
+
|
|
205
|
+
## Test Quality Checklist
|
|
206
|
+
|
|
207
|
+
Before marking tests complete:
|
|
208
|
+
|
|
209
|
+
- [ ] All public functions have unit tests
|
|
210
|
+
- [ ] All API endpoints have integration tests
|
|
211
|
+
- [ ] Critical user flows have E2E tests
|
|
212
|
+
- [ ] Edge cases covered (null, empty, invalid)
|
|
213
|
+
- [ ] Error paths tested (not just happy path)
|
|
214
|
+
- [ ] Mocks used for external dependencies
|
|
215
|
+
- [ ] Tests are independent (no shared state)
|
|
216
|
+
- [ ] Test names describe what's being tested
|
|
217
|
+
- [ ] Assertions are specific and meaningful
|
|
218
|
+
- [ ] Coverage is 80%+ (verify with coverage report)
|
|
219
|
+
|
|
220
|
+
## Test Smells (Anti-Patterns)
|
|
221
|
+
|
|
222
|
+
### ❌ Testing Implementation Details
|
|
223
|
+
```typescript
|
|
224
|
+
// DON'T test internal state
|
|
225
|
+
expect(component.state.count).toBe(5)
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### ✅ Test User-Visible Behavior
|
|
229
|
+
```typescript
|
|
230
|
+
// DO test what users see
|
|
231
|
+
expect(screen.getByText('Count: 5')).toBeInTheDocument()
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### ❌ Tests Depend on Each Other
|
|
235
|
+
```typescript
|
|
236
|
+
// DON'T rely on previous test
|
|
237
|
+
test('creates user', () => { /* ... */ })
|
|
238
|
+
test('updates same user', () => { /* needs previous test */ })
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### ✅ Independent Tests
|
|
242
|
+
```typescript
|
|
243
|
+
// DO setup data in each test
|
|
244
|
+
test('updates user', () => {
|
|
245
|
+
const user = createTestUser()
|
|
246
|
+
// Test logic
|
|
247
|
+
})
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## Coverage Report
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
# Run tests with coverage
|
|
254
|
+
npm run test:coverage
|
|
255
|
+
|
|
256
|
+
# View HTML report
|
|
257
|
+
open coverage/lcov-report/index.html
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Required thresholds:
|
|
261
|
+
- Branches: 80%
|
|
262
|
+
- Functions: 80%
|
|
263
|
+
- Lines: 80%
|
|
264
|
+
- Statements: 80%
|
|
112
265
|
|
|
113
|
-
##
|
|
266
|
+
## Continuous Testing
|
|
114
267
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
268
|
+
```bash
|
|
269
|
+
# Watch mode during development
|
|
270
|
+
npm test -- --watch
|
|
271
|
+
|
|
272
|
+
# Run before commit (via git hook)
|
|
273
|
+
npm test && npm run lint
|
|
119
274
|
|
|
120
|
-
|
|
275
|
+
# CI/CD integration
|
|
276
|
+
npm test -- --coverage --ci
|
|
277
|
+
```
|
|
121
278
|
|
|
122
|
-
|
|
123
|
-
2. **Descriptive test names** that explain expected behavior
|
|
124
|
-
3. **Arrange-Act-Assert** pattern
|
|
125
|
-
4. **Mock external dependencies**
|
|
126
|
-
5. **Test edge cases**: null, undefined, empty, max values
|
|
127
|
-
6. **Test error scenarios**: network failures, invalid input
|
|
279
|
+
**Remember**: No code without tests. Tests are not optional. They are the safety net that enables confident refactoring, rapid development, and production reliability.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: "**/*"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Agent Orchestration
|
|
6
|
+
|
|
7
|
+
## Available Agents
|
|
8
|
+
|
|
9
|
+
Located in `.github/agents/`:
|
|
10
|
+
|
|
11
|
+
| Agent | Purpose | When to Use |
|
|
12
|
+
|-------|---------|-------------|
|
|
13
|
+
| planner | Implementation planning | Complex features, refactoring |
|
|
14
|
+
| architect | System design | Architectural decisions |
|
|
15
|
+
| tdd-guide | Test-driven development | New features, bug fixes |
|
|
16
|
+
| code-reviewer | Code review | After writing code |
|
|
17
|
+
| security-reviewer | Security analysis | Before commits |
|
|
18
|
+
| build-error-resolver | Fix build errors | When build fails |
|
|
19
|
+
| e2e-runner | E2E testing | Critical user flows |
|
|
20
|
+
| refactor-cleaner | Dead code cleanup | Code maintenance |
|
|
21
|
+
| doc-updater | Documentation | Updating docs |
|
|
22
|
+
|
|
23
|
+
## Immediate Agent Usage
|
|
24
|
+
|
|
25
|
+
No user prompt needed:
|
|
26
|
+
1. Complex feature requests - Use **planner** agent
|
|
27
|
+
2. Code just written/modified - Use **code-reviewer** agent
|
|
28
|
+
3. Bug fix or new feature - Use **tdd-guide** agent
|
|
29
|
+
4. Architectural decision - Use **architect** agent
|
|
30
|
+
|
|
31
|
+
## Parallel Task Execution
|
|
32
|
+
|
|
33
|
+
ALWAYS use parallel Task execution for independent operations:
|
|
34
|
+
|
|
35
|
+
```markdown
|
|
36
|
+
# GOOD: Parallel execution
|
|
37
|
+
Launch 3 agents in parallel:
|
|
38
|
+
1. Agent 1: Security analysis of auth.ts
|
|
39
|
+
2. Agent 2: Performance review of cache system
|
|
40
|
+
3. Agent 3: Type checking of utils.ts
|
|
41
|
+
|
|
42
|
+
# BAD: Sequential when unnecessary
|
|
43
|
+
First agent 1, then agent 2, then agent 3
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Multi-Perspective Analysis
|
|
47
|
+
|
|
48
|
+
For complex problems, use split role sub-agents:
|
|
49
|
+
- Factual reviewer
|
|
50
|
+
- Senior engineer
|
|
51
|
+
- Security expert
|
|
52
|
+
- Consistency reviewer
|
|
53
|
+
- Redundancy checker
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
---
|
|
2
|
-
applyTo: "**/*.ts
|
|
2
|
+
applyTo: "**/*.{js,ts,jsx,tsx,mjs,cjs}"
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
# Coding Style
|
|
5
|
+
# Coding Style
|
|
6
6
|
|
|
7
7
|
## Immutability (CRITICAL)
|
|
8
8
|
|
|
9
9
|
ALWAYS create new objects, NEVER mutate:
|
|
10
10
|
|
|
11
11
|
```javascript
|
|
12
|
-
//
|
|
12
|
+
// WRONG: Mutation
|
|
13
13
|
function updateUser(user, name) {
|
|
14
14
|
user.name = name // MUTATION!
|
|
15
15
|
return user
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
//
|
|
18
|
+
// CORRECT: Immutability
|
|
19
19
|
function updateUser(user, name) {
|
|
20
20
|
return {
|
|
21
21
|
...user,
|
|
@@ -46,6 +46,21 @@ try {
|
|
|
46
46
|
}
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
## Input Validation
|
|
50
|
+
|
|
51
|
+
ALWAYS validate user input:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { z } from 'zod'
|
|
55
|
+
|
|
56
|
+
const schema = z.object({
|
|
57
|
+
email: z.string().email(),
|
|
58
|
+
age: z.number().int().min(0).max(150)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
const validated = schema.parse(input)
|
|
62
|
+
```
|
|
63
|
+
|
|
49
64
|
## Code Quality Checklist
|
|
50
65
|
|
|
51
66
|
Before marking work complete:
|
|
@@ -54,14 +69,6 @@ Before marking work complete:
|
|
|
54
69
|
- [ ] Files are focused (<800 lines)
|
|
55
70
|
- [ ] No deep nesting (>4 levels)
|
|
56
71
|
- [ ] Proper error handling
|
|
57
|
-
- [ ] No console.log statements
|
|
72
|
+
- [ ] No console.log statements
|
|
58
73
|
- [ ] No hardcoded values
|
|
59
74
|
- [ ] No mutation (immutable patterns used)
|
|
60
|
-
|
|
61
|
-
## Naming Conventions
|
|
62
|
-
|
|
63
|
-
- **Variables**: camelCase, descriptive (`userEmail`, not `e`)
|
|
64
|
-
- **Functions**: camelCase, verb-based (`getUserById`, not `user`)
|
|
65
|
-
- **Constants**: UPPER_SNAKE_CASE (`MAX_RETRY_COUNT`)
|
|
66
|
-
- **Types/Interfaces**: PascalCase (`UserProfile`)
|
|
67
|
-
- **Files**: kebab-case (`user-profile.ts`)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
applyTo: "
|
|
2
|
+
applyTo: "**/*"
|
|
3
3
|
---
|
|
4
4
|
|
|
5
5
|
# Git Workflow
|
|
@@ -12,13 +12,7 @@ applyTo: "**"
|
|
|
12
12
|
<optional body>
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
Types:
|
|
16
|
-
|
|
17
|
-
Examples:
|
|
18
|
-
- `feat: add user authentication`
|
|
19
|
-
- `fix: resolve null pointer in search`
|
|
20
|
-
- `refactor: extract validation logic`
|
|
21
|
-
- `docs: update API documentation`
|
|
15
|
+
Types: feat, fix, refactor, docs, test, chore, perf, ci
|
|
22
16
|
|
|
23
17
|
## Pull Request Workflow
|
|
24
18
|
|
|
@@ -32,29 +26,22 @@ When creating PRs:
|
|
|
32
26
|
## Feature Implementation Workflow
|
|
33
27
|
|
|
34
28
|
1. **Plan First**
|
|
35
|
-
- Use
|
|
29
|
+
- Use **planner** agent to create implementation plan
|
|
36
30
|
- Identify dependencies and risks
|
|
37
31
|
- Break down into phases
|
|
38
32
|
|
|
39
33
|
2. **TDD Approach**
|
|
40
|
-
- Use
|
|
34
|
+
- Use **tdd-guide** agent
|
|
41
35
|
- Write tests first (RED)
|
|
42
36
|
- Implement to pass tests (GREEN)
|
|
43
37
|
- Refactor (IMPROVE)
|
|
44
38
|
- Verify 80%+ coverage
|
|
45
39
|
|
|
46
40
|
3. **Code Review**
|
|
47
|
-
- Use
|
|
41
|
+
- Use **code-reviewer** agent immediately after writing code
|
|
48
42
|
- Address CRITICAL and HIGH issues
|
|
49
43
|
- Fix MEDIUM issues when possible
|
|
50
44
|
|
|
51
45
|
4. **Commit & Push**
|
|
52
46
|
- Detailed commit messages
|
|
53
47
|
- Follow conventional commits format
|
|
54
|
-
|
|
55
|
-
## Branch Naming
|
|
56
|
-
|
|
57
|
-
- `feature/description` - New features
|
|
58
|
-
- `fix/description` - Bug fixes
|
|
59
|
-
- `refactor/description` - Code improvements
|
|
60
|
-
- `docs/description` - Documentation updates
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: "**/*"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Hooks System Reference
|
|
6
|
+
|
|
7
|
+
> Note: GitHub Copilot CLI does not support hooks like Claude Code. This document is kept for reference when using Claude Code or similar systems.
|
|
8
|
+
|
|
9
|
+
## Hook Types
|
|
10
|
+
|
|
11
|
+
- **PreToolUse**: Before tool execution (validation, parameter modification)
|
|
12
|
+
- **PostToolUse**: After tool execution (auto-format, checks)
|
|
13
|
+
- **Stop**: When session ends (final verification)
|
|
14
|
+
|
|
15
|
+
## Recommended Hooks
|
|
16
|
+
|
|
17
|
+
### PreToolUse
|
|
18
|
+
- **tmux reminder**: Suggests tmux for long-running commands (npm, pnpm, yarn, cargo, etc.)
|
|
19
|
+
- **git push review**: Opens editor for review before push
|
|
20
|
+
- **doc blocker**: Blocks creation of unnecessary .md/.txt files
|
|
21
|
+
|
|
22
|
+
### PostToolUse
|
|
23
|
+
- **PR creation**: Logs PR URL and GitHub Actions status
|
|
24
|
+
- **Prettier**: Auto-formats JS/TS files after edit
|
|
25
|
+
- **TypeScript check**: Runs tsc after editing .ts/.tsx files
|
|
26
|
+
- **console.log warning**: Warns about console.log in edited files
|
|
27
|
+
|
|
28
|
+
### Stop
|
|
29
|
+
- **console.log audit**: Checks all modified files for console.log before session ends
|
|
30
|
+
|
|
31
|
+
## Auto-Accept Permissions
|
|
32
|
+
|
|
33
|
+
Use with caution:
|
|
34
|
+
- Enable for trusted, well-defined plans
|
|
35
|
+
- Disable for exploratory work
|
|
36
|
+
- Never use dangerously-skip-permissions flag
|
|
37
|
+
- Configure `allowedTools` in settings instead
|
|
38
|
+
|
|
39
|
+
## TodoWrite Best Practices
|
|
40
|
+
|
|
41
|
+
Use TodoWrite tool to:
|
|
42
|
+
- Track progress on multi-step tasks
|
|
43
|
+
- Verify understanding of instructions
|
|
44
|
+
- Enable real-time steering
|
|
45
|
+
- Show granular implementation steps
|
|
46
|
+
|
|
47
|
+
Todo list reveals:
|
|
48
|
+
- Out of order steps
|
|
49
|
+
- Missing items
|
|
50
|
+
- Extra unnecessary items
|
|
51
|
+
- Wrong granularity
|
|
52
|
+
- Misinterpreted requirements
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: "**/*.{js,ts,jsx,tsx}"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Common Patterns
|
|
6
|
+
|
|
7
|
+
## API Response Format
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
interface ApiResponse<T> {
|
|
11
|
+
success: boolean
|
|
12
|
+
data?: T
|
|
13
|
+
error?: string
|
|
14
|
+
meta?: {
|
|
15
|
+
total: number
|
|
16
|
+
page: number
|
|
17
|
+
limit: number
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Custom Hooks Pattern
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
export function useDebounce<T>(value: T, delay: number): T {
|
|
26
|
+
const [debouncedValue, setDebouncedValue] = useState<T>(value)
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
const handler = setTimeout(() => setDebouncedValue(value), delay)
|
|
30
|
+
return () => clearTimeout(handler)
|
|
31
|
+
}, [value, delay])
|
|
32
|
+
|
|
33
|
+
return debouncedValue
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Repository Pattern
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
interface Repository<T> {
|
|
41
|
+
findAll(filters?: Filters): Promise<T[]>
|
|
42
|
+
findById(id: string): Promise<T | null>
|
|
43
|
+
create(data: CreateDto): Promise<T>
|
|
44
|
+
update(id: string, data: UpdateDto): Promise<T>
|
|
45
|
+
delete(id: string): Promise<void>
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Skeleton Projects
|
|
50
|
+
|
|
51
|
+
When implementing new functionality:
|
|
52
|
+
1. Search for battle-tested skeleton projects
|
|
53
|
+
2. Use parallel agents to evaluate options:
|
|
54
|
+
- Security assessment
|
|
55
|
+
- Extensibility analysis
|
|
56
|
+
- Relevance scoring
|
|
57
|
+
- Implementation planning
|
|
58
|
+
3. Clone best match as foundation
|
|
59
|
+
4. Iterate within proven structure
|
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
---
|
|
2
|
-
applyTo: "
|
|
2
|
+
applyTo: "**/*"
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
# Performance
|
|
5
|
+
# Performance Optimization
|
|
6
|
+
|
|
7
|
+
## Model Selection Strategy
|
|
8
|
+
|
|
9
|
+
> Note: GitHub Copilot uses its own model selection. This is reference for Claude Code users.
|
|
10
|
+
|
|
11
|
+
**Haiku 4.5** (90% of Sonnet capability, 3x cost savings):
|
|
12
|
+
- Lightweight agents with frequent invocation
|
|
13
|
+
- Pair programming and code generation
|
|
14
|
+
- Worker agents in multi-agent systems
|
|
15
|
+
|
|
16
|
+
**Sonnet 4.5** (Best coding model):
|
|
17
|
+
- Main development work
|
|
18
|
+
- Orchestrating multi-agent workflows
|
|
19
|
+
- Complex coding tasks
|
|
20
|
+
|
|
21
|
+
**Opus 4.5** (Deepest reasoning):
|
|
22
|
+
- Complex architectural decisions
|
|
23
|
+
- Maximum reasoning requirements
|
|
24
|
+
- Research and analysis tasks
|
|
6
25
|
|
|
7
26
|
## Context Window Management
|
|
8
27
|
|
|
@@ -11,42 +30,24 @@ Avoid last 20% of context window for:
|
|
|
11
30
|
- Feature implementation spanning multiple files
|
|
12
31
|
- Debugging complex interactions
|
|
13
32
|
|
|
14
|
-
Use `/compact` command when context is getting full.
|
|
15
|
-
|
|
16
33
|
Lower context sensitivity tasks:
|
|
17
34
|
- Single-file edits
|
|
18
35
|
- Independent utility creation
|
|
19
36
|
- Documentation updates
|
|
20
37
|
- Simple bug fixes
|
|
21
38
|
|
|
39
|
+
## Deep Reasoning Mode
|
|
40
|
+
|
|
41
|
+
For complex tasks requiring deep reasoning:
|
|
42
|
+
1. Use enhanced thinking mode
|
|
43
|
+
2. Enable **Plan Mode** for structured approach
|
|
44
|
+
3. Use multiple critique rounds
|
|
45
|
+
4. Use split role sub-agents for diverse analysis
|
|
46
|
+
|
|
22
47
|
## Build Troubleshooting
|
|
23
48
|
|
|
24
49
|
If build fails:
|
|
25
|
-
1. Use
|
|
50
|
+
1. Use **build-error-resolver** agent
|
|
26
51
|
2. Analyze error messages
|
|
27
52
|
3. Fix incrementally
|
|
28
53
|
4. Verify after each fix
|
|
29
|
-
|
|
30
|
-
## Code Performance
|
|
31
|
-
|
|
32
|
-
### Algorithms
|
|
33
|
-
- Prefer O(n log n) over O(n²) when possible
|
|
34
|
-
- Use appropriate data structures (Set for lookups, Map for key-value)
|
|
35
|
-
- Avoid unnecessary iterations
|
|
36
|
-
|
|
37
|
-
### React/Frontend
|
|
38
|
-
- Use `useMemo` and `useCallback` for expensive computations
|
|
39
|
-
- Implement virtualization for long lists
|
|
40
|
-
- Lazy load routes and heavy components
|
|
41
|
-
- Optimize images (WebP, proper sizing)
|
|
42
|
-
|
|
43
|
-
### Backend/API
|
|
44
|
-
- Use database indexes for frequently queried fields
|
|
45
|
-
- Implement caching (Redis, in-memory)
|
|
46
|
-
- Avoid N+1 queries
|
|
47
|
-
- Use connection pooling
|
|
48
|
-
|
|
49
|
-
### Bundle Size
|
|
50
|
-
- Tree-shake unused code
|
|
51
|
-
- Code split by route
|
|
52
|
-
- Analyze bundle with `npm run build -- --analyze`
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
---
|
|
2
|
-
applyTo: "**/*.ts
|
|
2
|
+
applyTo: "**/*.{js,ts,jsx,tsx,py}"
|
|
3
3
|
---
|
|
4
4
|
|
|
5
5
|
# Security Guidelines
|
|
6
6
|
|
|
7
|
-
## Mandatory Checks
|
|
7
|
+
## Mandatory Security Checks
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
9
|
+
Before ANY commit:
|
|
10
|
+
- [ ] No hardcoded secrets (API keys, passwords, tokens)
|
|
11
|
+
- [ ] All user inputs validated
|
|
12
|
+
- [ ] SQL injection prevention (parameterized queries)
|
|
13
|
+
- [ ] XSS prevention (sanitized HTML)
|
|
14
|
+
- [ ] CSRF protection enabled
|
|
15
|
+
- [ ] Authentication/authorization verified
|
|
16
|
+
- [ ] Rate limiting on all endpoints
|
|
17
|
+
- [ ] Error messages don't leak sensitive data
|
|
17
18
|
|
|
18
19
|
## Secret Management
|
|
19
20
|
|
|
@@ -33,31 +34,7 @@ if (!apiKey) {
|
|
|
33
34
|
|
|
34
35
|
If security issue found:
|
|
35
36
|
1. STOP immediately
|
|
36
|
-
2. Use
|
|
37
|
+
2. Use **security-reviewer** agent
|
|
37
38
|
3. Fix CRITICAL issues before continuing
|
|
38
39
|
4. Rotate any exposed secrets
|
|
39
40
|
5. Review entire codebase for similar issues
|
|
40
|
-
|
|
41
|
-
## Input Validation
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
import { z } from 'zod'
|
|
45
|
-
|
|
46
|
-
const schema = z.object({
|
|
47
|
-
email: z.string().email(),
|
|
48
|
-
age: z.number().int().min(0).max(150)
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
const validated = schema.parse(untrustedInput)
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## SQL Injection Prevention
|
|
55
|
-
|
|
56
|
-
```typescript
|
|
57
|
-
// ❌ Never concatenate user input
|
|
58
|
-
const query = `SELECT * FROM users WHERE id = ${userId}`
|
|
59
|
-
|
|
60
|
-
// ✅ Always use parameterized queries
|
|
61
|
-
const query = 'SELECT * FROM users WHERE id = $1'
|
|
62
|
-
await db.query(query, [userId])
|
|
63
|
-
```
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
|
-
applyTo: "**/*.test
|
|
2
|
+
applyTo: "**/*.{test,spec}.{js,ts,jsx,tsx}"
|
|
3
3
|
---
|
|
4
4
|
|
|
5
5
|
# Testing Requirements
|
|
6
6
|
|
|
7
7
|
## Minimum Test Coverage: 80%
|
|
8
8
|
|
|
9
|
-
Test Types (ALL required
|
|
9
|
+
Test Types (ALL required):
|
|
10
10
|
1. **Unit Tests** - Individual functions, utilities, components
|
|
11
11
|
2. **Integration Tests** - API endpoints, database operations
|
|
12
12
|
3. **E2E Tests** - Critical user flows (Playwright)
|
|
@@ -21,35 +21,14 @@ MANDATORY workflow:
|
|
|
21
21
|
5. Refactor (IMPROVE)
|
|
22
22
|
6. Verify coverage (80%+)
|
|
23
23
|
|
|
24
|
-
## Test Structure
|
|
25
|
-
|
|
26
|
-
```typescript
|
|
27
|
-
describe('FunctionName', () => {
|
|
28
|
-
it('should do expected behavior when given input', () => {
|
|
29
|
-
// Arrange
|
|
30
|
-
const input = 'test'
|
|
31
|
-
|
|
32
|
-
// Act
|
|
33
|
-
const result = functionName(input)
|
|
34
|
-
|
|
35
|
-
// Assert
|
|
36
|
-
expect(result).toBe('expected')
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('should handle edge cases', () => {
|
|
40
|
-
expect(() => functionName(null)).toThrow()
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
```
|
|
44
|
-
|
|
45
24
|
## Troubleshooting Test Failures
|
|
46
25
|
|
|
47
|
-
1. Use
|
|
26
|
+
1. Use **tdd-guide** agent
|
|
48
27
|
2. Check test isolation
|
|
49
28
|
3. Verify mocks are correct
|
|
50
29
|
4. Fix implementation, not tests (unless tests are wrong)
|
|
51
30
|
|
|
52
31
|
## Agent Support
|
|
53
32
|
|
|
54
|
-
- **tdd-guide** - Use for new features, enforces write-tests-first
|
|
33
|
+
- **tdd-guide** - Use PROACTIVELY for new features, enforces write-tests-first
|
|
55
34
|
- **e2e-runner** - Playwright E2E testing specialist
|