claudify-agent 1.0.1 → 1.0.2
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/QUICK-REFERENCE.md +213 -213
- package/.claude/cost-dashboard.md +162 -162
- package/.claude/docs/COST-OPTIMIZATION.md +402 -403
- package/.claude/docs/MCP-INTEGRATION-GUIDE.md +348 -348
- package/.claude/docs/PLAN-MODE-OPTIMIZATION.md +835 -836
- package/.claude/hooks/auto-learning-review.ts +200 -195
- package/.claude/hooks/auto-lint-fix.ts +60 -104
- package/.claude/hooks/auto-security-review.ts +314 -354
- package/.claude/hooks/auto-validate.ts +249 -348
- package/.claude/hooks/lib/claude-hook.ts +168 -0
- package/.claude/hooks/plan-quality-tracker.ts +598 -719
- package/.claude/rules/anti-patterns.md +22 -22
- package/.claude/rules/context-tier-1.md +41 -41
- package/.claude/rules/context-tier-2.md +285 -285
- package/.claude/rules/general.md +25 -25
- package/.claude/rules/mcp-auto-use.md +46 -46
- package/.claude/rules/parallel-exploration-auto.md +30 -31
- package/.claude/rules/plan-mode-execution.md +289 -289
- package/.claude/rules/plan-mode-research.md +34 -34
- package/.claude/rules/plan-mode-structure.md +166 -166
- package/.claude/rules/plan-mode-validation.md +129 -130
- package/.claude/rules/security-critical.md +19 -19
- package/.claude/rules/tool-auto-selection.md +45 -45
- package/.claude/rules/tool-strategy.md +22 -22
- package/.claude/scripts/security-scan.js +1 -1
- package/.claude/security-dashboard.md +142 -142
- package/.claude/settings.json +50 -0
- package/.claude/skills/debug-optimizer/SKILL.md +420 -399
- package/.claude/skills/learning-loop/SKILL.md +313 -308
- package/.claude/skills/mcp-mastery/SKILL.md +218 -214
- package/.claude/skills/nextjs-guide/SKILL.md +687 -687
- package/.claude/skills/parallel-exploration/SKILL.md +197 -193
- package/.claude/skills/plan-mode-mastery/SKILL.md +268 -263
- package/.claude/skills/python-guide/SKILL.md +822 -822
- package/.claude/skills/react-guide/SKILL.md +762 -762
- package/.claude/skills/{security.md → security-guide/SKILL.md} +10 -0
- package/.claude/skills/solidity-guide/SKILL.md +5 -0
- package/.claude/skills/tool-selection/SKILL.md +433 -428
- package/.claude/skills/vite-guide/SKILL.md +445 -445
- package/CLAUDE.md +1 -0
- package/README.md +74 -35
- package/README.vi.md +106 -0
- package/bin/cli.js +13 -4
- package/package.json +9 -1
- package/.claude/skills/debug-optimizer.md +0 -12
- package/.claude/skills/nextjs.md +0 -13
- package/.claude/skills/react.md +0 -12
|
@@ -1,285 +1,285 @@
|
|
|
1
|
-
# Context Tier 2 (Task-Specific, Loaded On-Demand)
|
|
2
|
-
|
|
3
|
-
## Automatic Context Loading
|
|
4
|
-
|
|
5
|
-
**Purpose**: Task-specific context loaded based on keywords, file patterns, and task type.
|
|
6
|
-
|
|
7
|
-
**Loading Mechanism**: Automatic based on triggers below.
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Testing Context
|
|
12
|
-
|
|
13
|
-
**Triggers**:
|
|
14
|
-
- Keywords: "test", "spec", "testing", "__tests__", "vitest", "jest"
|
|
15
|
-
- File patterns: `**/__tests__/**`, `**/*.test.ts`, `**/*.spec.ts`
|
|
16
|
-
- Commands: `/test`, `/tdd`
|
|
17
|
-
|
|
18
|
-
**Loaded Context**:
|
|
19
|
-
```
|
|
20
|
-
## Testing Requirements
|
|
21
|
-
- Use Vitest for unit tests, Playwright for E2E
|
|
22
|
-
- Place tests in __tests__/ directory
|
|
23
|
-
- Name test files: [feature].test.ts
|
|
24
|
-
- Follow AAA pattern: Arrange, Act, Assert
|
|
25
|
-
- Minimum 80% coverage for new code
|
|
26
|
-
- Mock external APIs with MSW
|
|
27
|
-
- Include error boundary tests
|
|
28
|
-
|
|
29
|
-
## Test Commands
|
|
30
|
-
npm run test # Full suite
|
|
31
|
-
npm run test:unit # Unit tests only
|
|
32
|
-
npm run test:coverage # With coverage report
|
|
33
|
-
npm run test -- path/to # Specific file
|
|
34
|
-
|
|
35
|
-
## Test Examples
|
|
36
|
-
- Unit test: @__tests__/auth.test.ts
|
|
37
|
-
- Integration: @__tests__/api/users.test.ts
|
|
38
|
-
- E2E: @e2e/checkout.spec.ts
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## API Development Context
|
|
44
|
-
|
|
45
|
-
**Triggers**:
|
|
46
|
-
- Keywords: "API", "endpoint", "route", "REST", "GraphQL"
|
|
47
|
-
- File patterns: `**/app/api/**`, `**/routes/**`, `**/controllers/**`
|
|
48
|
-
- Commands: `/api`, `/endpoint`
|
|
49
|
-
|
|
50
|
-
**Loaded Context**:
|
|
51
|
-
```
|
|
52
|
-
## API Structure
|
|
53
|
-
- All routes in app/api/[resource]/route.ts
|
|
54
|
-
- Use Next.js App Router conventions
|
|
55
|
-
- Export GET, POST, PUT, DELETE handlers
|
|
56
|
-
|
|
57
|
-
## Authentication
|
|
58
|
-
- Validate JWT with @src/auth/validateToken.ts
|
|
59
|
-
- Extract user from token claims
|
|
60
|
-
- Return 401 for unauthorized, 403 for forbidden
|
|
61
|
-
|
|
62
|
-
## Validation
|
|
63
|
-
- Use Zod schemas for all input validation
|
|
64
|
-
- Return 400 with error details for invalid input
|
|
65
|
-
- Sanitize input before database queries
|
|
66
|
-
|
|
67
|
-
## Error Handling
|
|
68
|
-
```typescript
|
|
69
|
-
try {
|
|
70
|
-
// business logic
|
|
71
|
-
} catch (error) {
|
|
72
|
-
logger.error('API error', { error, userId });
|
|
73
|
-
return NextResponse.json(
|
|
74
|
-
{ error: 'Internal server error' },
|
|
75
|
-
{ status: 500 }
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## API Examples
|
|
81
|
-
- REST pattern: @app/api/users/route.ts
|
|
82
|
-
- Error handling: @app/api/orders/route.ts
|
|
83
|
-
- Validation: @src/validators/orderSchema.ts
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
---
|
|
87
|
-
|
|
88
|
-
## UI/Styling Context
|
|
89
|
-
|
|
90
|
-
**Triggers**:
|
|
91
|
-
- Keywords: "UI", "component", "styling", "CSS", "Tailwind", "frontend"
|
|
92
|
-
- File patterns: `**/components/**`, `**/app/**`, `**/pages/**`, `*.tsx`, `*.css`
|
|
93
|
-
- Commands: `/component`, `/ui`
|
|
94
|
-
|
|
95
|
-
**Loaded Context**:
|
|
96
|
-
```
|
|
97
|
-
## CSS Framework
|
|
98
|
-
- Use Tailwind CSS for all styling
|
|
99
|
-
- Follow utility-first approach
|
|
100
|
-
- Use clsx for conditional classes
|
|
101
|
-
|
|
102
|
-
## Component Structure
|
|
103
|
-
```tsx
|
|
104
|
-
interface Props {
|
|
105
|
-
variant?: 'primary' | 'secondary';
|
|
106
|
-
children: React.ReactNode;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export function Button({ variant = 'primary', children }: Props) {
|
|
110
|
-
return (
|
|
111
|
-
<button className={clsx(
|
|
112
|
-
'px-4 py-2 rounded font-medium',
|
|
113
|
-
variant === 'primary' ? 'bg-blue-600 text-white' : 'bg-gray-200'
|
|
114
|
-
)}>
|
|
115
|
-
{children}
|
|
116
|
-
</button>
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
## Responsive Design
|
|
122
|
-
- Mobile-first approach
|
|
123
|
-
- Use md:, lg:, xl: breakpoints
|
|
124
|
-
- Test on multiple screen sizes
|
|
125
|
-
|
|
126
|
-
## UI Examples
|
|
127
|
-
- Button: @components/Button.tsx
|
|
128
|
-
- Form: @components/forms/TextInput.tsx
|
|
129
|
-
- Layout: @components/Layout.tsx
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
---
|
|
133
|
-
|
|
134
|
-
## Performance Context
|
|
135
|
-
|
|
136
|
-
**Triggers**:
|
|
137
|
-
- Keywords: "performance", "optimize", "slow", "fast", "lighthouse", "audit"
|
|
138
|
-
- Commands: `/optimize`, `/performance`, `/audit`
|
|
139
|
-
|
|
140
|
-
**Loaded Context**:
|
|
141
|
-
```
|
|
142
|
-
## Performance Optimization
|
|
143
|
-
- Profile BEFORE optimizing (
|
|
144
|
-
- Use React.memo for expensive components
|
|
145
|
-
- Implement code splitting for large bundles
|
|
146
|
-
- Lazy load non-critical components
|
|
147
|
-
- Cache API responses with React Query or SWR
|
|
148
|
-
|
|
149
|
-
## Performance Metrics
|
|
150
|
-
- First Contentful Paint: <1.5s
|
|
151
|
-
- Time to Interactive: <3.5s
|
|
152
|
-
- Lighthouse Performance: >90
|
|
153
|
-
|
|
154
|
-
## Performance Examples
|
|
155
|
-
- Memoization: @components/ExpensiveList.tsx
|
|
156
|
-
- Code splitting: @app/dashboard/page.tsx
|
|
157
|
-
- Caching: @lib/react-query.ts
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
---
|
|
161
|
-
|
|
162
|
-
## Database Context
|
|
163
|
-
|
|
164
|
-
**Triggers**:
|
|
165
|
-
- Keywords: "database", "DB", "Prisma", "Drizzle", "migration", "schema", "query"
|
|
166
|
-
- File patterns: `**/prisma/**`, `**/models/**`, `**/db/**`, `*.prisma`
|
|
167
|
-
- Commands: `/db`, `/migration`, `/schema`
|
|
168
|
-
|
|
169
|
-
**Loaded Context**:
|
|
170
|
-
```
|
|
171
|
-
## Database ORM
|
|
172
|
-
- Use Prisma ORM for database operations
|
|
173
|
-
- Schema in prisma/schema.prisma
|
|
174
|
-
- Migrations required for schema changes
|
|
175
|
-
|
|
176
|
-
## Query Patterns
|
|
177
|
-
- Use transactions for multi-step operations
|
|
178
|
-
- Include related data with include/select
|
|
179
|
-
- Index frequently queried fields
|
|
180
|
-
|
|
181
|
-
## Database Examples
|
|
182
|
-
- Schema: @prisma/schema.prisma
|
|
183
|
-
- Query pattern: @src/db/queries/users.ts
|
|
184
|
-
- Migration: @prisma/migrations/[latest]
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
---
|
|
188
|
-
|
|
189
|
-
## Security Context
|
|
190
|
-
|
|
191
|
-
**Triggers**:
|
|
192
|
-
- Keywords: "security", "auth", "authentication", "authorization", "encrypt", "hash"
|
|
193
|
-
- File patterns: `**/auth/**`, `**/security/**`, `**/middleware/**`
|
|
194
|
-
- Commands: `/security`, `/auth`, `/review-security`
|
|
195
|
-
|
|
196
|
-
**Loaded Context**:
|
|
197
|
-
```
|
|
198
|
-
## Authentication
|
|
199
|
-
- JWT tokens with 15min expiration
|
|
200
|
-
- Refresh tokens with 7day expiration
|
|
201
|
-
- Store tokens in httpOnly cookies
|
|
202
|
-
- Validate tokens on all protected routes
|
|
203
|
-
|
|
204
|
-
## Password Security
|
|
205
|
-
- Hash passwords with bcrypt (cost: 12)
|
|
206
|
-
- Minimum 8 characters, mixed case, numbers
|
|
207
|
-
- Rate limit login attempts (5 per minute)
|
|
208
|
-
|
|
209
|
-
## Input Security
|
|
210
|
-
- Sanitize all user input
|
|
211
|
-
- Use parameterized queries (no SQL injection)
|
|
212
|
-
- Escape output to prevent XSS
|
|
213
|
-
|
|
214
|
-
## Security Examples
|
|
215
|
-
- Auth middleware: @src/middleware/auth.ts
|
|
216
|
-
- Password hashing: @src/lib/password.ts
|
|
217
|
-
- Input validation: @src/validators/userSchema.ts
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
---
|
|
221
|
-
|
|
222
|
-
## Deployment Context
|
|
223
|
-
|
|
224
|
-
**Triggers**:
|
|
225
|
-
- Keywords: "deploy", "production", "staging", "CI/CD", "build"
|
|
226
|
-
- Commands: `/deploy`, `/build`, `/ci`
|
|
227
|
-
|
|
228
|
-
**Loaded Context**:
|
|
229
|
-
```
|
|
230
|
-
## Build Process
|
|
231
|
-
- npm run build before deploying
|
|
232
|
-
- Check build output for errors
|
|
233
|
-
- Verify environment variables
|
|
234
|
-
|
|
235
|
-
## Deployment Pipeline
|
|
236
|
-
- Run tests in CI
|
|
237
|
-
- Run linter in CI
|
|
238
|
-
- Run typecheck in CI
|
|
239
|
-
- Deploy to staging first
|
|
240
|
-
- Manual approval for production
|
|
241
|
-
|
|
242
|
-
## Deployment Examples
|
|
243
|
-
- CI config: @.github/workflows/ci.yml
|
|
244
|
-
- Build script: @scripts/build.ts
|
|
245
|
-
- Deploy: @scripts/deploy.ts
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
---
|
|
249
|
-
|
|
250
|
-
## Automatic Context Pruning
|
|
251
|
-
|
|
252
|
-
**Rule**: To avoid over-specification (per ETH Zurich research):
|
|
253
|
-
|
|
254
|
-
```
|
|
255
|
-
1. Load ONLY relevant Tier 2 context based on triggers
|
|
256
|
-
2. DO NOT load multiple Tier 2 contexts unless task spans multiple areas
|
|
257
|
-
3. If task spans multiple areas, load summaries only
|
|
258
|
-
4. Agent discovers details via search tools (Grep,
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
**Example**:
|
|
262
|
-
```
|
|
263
|
-
Task: "Add API endpoint" → Load API context only
|
|
264
|
-
Task: "Add UI component" → Load UI context only
|
|
265
|
-
Task: "Add authenticated API" → Load API + Security context (summaries)
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
---
|
|
269
|
-
|
|
270
|
-
## Context Loading Decision Tree
|
|
271
|
-
|
|
272
|
-
```
|
|
273
|
-
Task involves testing? → Load Testing context
|
|
274
|
-
Task involves API? → Load API context
|
|
275
|
-
Task involves UI/components? → Load UI/Styling context
|
|
276
|
-
Task involves performance? → Load Performance context
|
|
277
|
-
Task involves database? → Load Database context
|
|
278
|
-
Task involves auth/security? → Load Security context
|
|
279
|
-
Task involves deployment? → Load Deployment context
|
|
280
|
-
Multiple areas? → Load summaries of each, agent discovers details
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
---
|
|
284
|
-
|
|
285
|
-
**Note**: These contexts load automatically based on task analysis. No manual intervention needed.
|
|
1
|
+
# Context Tier 2 (Task-Specific, Loaded On-Demand)
|
|
2
|
+
|
|
3
|
+
## Automatic Context Loading
|
|
4
|
+
|
|
5
|
+
**Purpose**: Task-specific context loaded based on keywords, file patterns, and task type.
|
|
6
|
+
|
|
7
|
+
**Loading Mechanism**: Automatic based on triggers below.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Testing Context
|
|
12
|
+
|
|
13
|
+
**Triggers**:
|
|
14
|
+
- Keywords: "test", "spec", "testing", "__tests__", "vitest", "jest"
|
|
15
|
+
- File patterns: `**/__tests__/**`, `**/*.test.ts`, `**/*.spec.ts`
|
|
16
|
+
- Commands: `/test`, `/tdd`
|
|
17
|
+
|
|
18
|
+
**Loaded Context**:
|
|
19
|
+
```
|
|
20
|
+
## Testing Requirements
|
|
21
|
+
- Use Vitest for unit tests, Playwright for E2E
|
|
22
|
+
- Place tests in __tests__/ directory
|
|
23
|
+
- Name test files: [feature].test.ts
|
|
24
|
+
- Follow AAA pattern: Arrange, Act, Assert
|
|
25
|
+
- Minimum 80% coverage for new code
|
|
26
|
+
- Mock external APIs with MSW
|
|
27
|
+
- Include error boundary tests
|
|
28
|
+
|
|
29
|
+
## Test Commands
|
|
30
|
+
npm run test # Full suite
|
|
31
|
+
npm run test:unit # Unit tests only
|
|
32
|
+
npm run test:coverage # With coverage report
|
|
33
|
+
npm run test -- path/to # Specific file
|
|
34
|
+
|
|
35
|
+
## Test Examples
|
|
36
|
+
- Unit test: @__tests__/auth.test.ts
|
|
37
|
+
- Integration: @__tests__/api/users.test.ts
|
|
38
|
+
- E2E: @e2e/checkout.spec.ts
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## API Development Context
|
|
44
|
+
|
|
45
|
+
**Triggers**:
|
|
46
|
+
- Keywords: "API", "endpoint", "route", "REST", "GraphQL"
|
|
47
|
+
- File patterns: `**/app/api/**`, `**/routes/**`, `**/controllers/**`
|
|
48
|
+
- Commands: `/api`, `/endpoint`
|
|
49
|
+
|
|
50
|
+
**Loaded Context**:
|
|
51
|
+
```
|
|
52
|
+
## API Structure
|
|
53
|
+
- All routes in app/api/[resource]/route.ts
|
|
54
|
+
- Use Next.js App Router conventions
|
|
55
|
+
- Export GET, POST, PUT, DELETE handlers
|
|
56
|
+
|
|
57
|
+
## Authentication
|
|
58
|
+
- Validate JWT with @src/auth/validateToken.ts
|
|
59
|
+
- Extract user from token claims
|
|
60
|
+
- Return 401 for unauthorized, 403 for forbidden
|
|
61
|
+
|
|
62
|
+
## Validation
|
|
63
|
+
- Use Zod schemas for all input validation
|
|
64
|
+
- Return 400 with error details for invalid input
|
|
65
|
+
- Sanitize input before database queries
|
|
66
|
+
|
|
67
|
+
## Error Handling
|
|
68
|
+
```typescript
|
|
69
|
+
try {
|
|
70
|
+
// business logic
|
|
71
|
+
} catch (error) {
|
|
72
|
+
logger.error('API error', { error, userId });
|
|
73
|
+
return NextResponse.json(
|
|
74
|
+
{ error: 'Internal server error' },
|
|
75
|
+
{ status: 500 }
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## API Examples
|
|
81
|
+
- REST pattern: @app/api/users/route.ts
|
|
82
|
+
- Error handling: @app/api/orders/route.ts
|
|
83
|
+
- Validation: @src/validators/orderSchema.ts
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## UI/Styling Context
|
|
89
|
+
|
|
90
|
+
**Triggers**:
|
|
91
|
+
- Keywords: "UI", "component", "styling", "CSS", "Tailwind", "frontend"
|
|
92
|
+
- File patterns: `**/components/**`, `**/app/**`, `**/pages/**`, `*.tsx`, `*.css`
|
|
93
|
+
- Commands: `/component`, `/ui`
|
|
94
|
+
|
|
95
|
+
**Loaded Context**:
|
|
96
|
+
```
|
|
97
|
+
## CSS Framework
|
|
98
|
+
- Use Tailwind CSS for all styling
|
|
99
|
+
- Follow utility-first approach
|
|
100
|
+
- Use clsx for conditional classes
|
|
101
|
+
|
|
102
|
+
## Component Structure
|
|
103
|
+
```tsx
|
|
104
|
+
interface Props {
|
|
105
|
+
variant?: 'primary' | 'secondary';
|
|
106
|
+
children: React.ReactNode;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function Button({ variant = 'primary', children }: Props) {
|
|
110
|
+
return (
|
|
111
|
+
<button className={clsx(
|
|
112
|
+
'px-4 py-2 rounded font-medium',
|
|
113
|
+
variant === 'primary' ? 'bg-blue-600 text-white' : 'bg-gray-200'
|
|
114
|
+
)}>
|
|
115
|
+
{children}
|
|
116
|
+
</button>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Responsive Design
|
|
122
|
+
- Mobile-first approach
|
|
123
|
+
- Use md:, lg:, xl: breakpoints
|
|
124
|
+
- Test on multiple screen sizes
|
|
125
|
+
|
|
126
|
+
## UI Examples
|
|
127
|
+
- Button: @components/Button.tsx
|
|
128
|
+
- Form: @components/forms/TextInput.tsx
|
|
129
|
+
- Layout: @components/Layout.tsx
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Performance Context
|
|
135
|
+
|
|
136
|
+
**Triggers**:
|
|
137
|
+
- Keywords: "performance", "optimize", "slow", "fast", "lighthouse", "audit"
|
|
138
|
+
- Commands: `/optimize`, `/performance`, `/audit`
|
|
139
|
+
|
|
140
|
+
**Loaded Context**:
|
|
141
|
+
```
|
|
142
|
+
## Performance Optimization
|
|
143
|
+
- Profile BEFORE optimizing (claude-in-chrome or chrome-devtools)
|
|
144
|
+
- Use React.memo for expensive components
|
|
145
|
+
- Implement code splitting for large bundles
|
|
146
|
+
- Lazy load non-critical components
|
|
147
|
+
- Cache API responses with React Query or SWR
|
|
148
|
+
|
|
149
|
+
## Performance Metrics
|
|
150
|
+
- First Contentful Paint: <1.5s
|
|
151
|
+
- Time to Interactive: <3.5s
|
|
152
|
+
- Lighthouse Performance: >90
|
|
153
|
+
|
|
154
|
+
## Performance Examples
|
|
155
|
+
- Memoization: @components/ExpensiveList.tsx
|
|
156
|
+
- Code splitting: @app/dashboard/page.tsx
|
|
157
|
+
- Caching: @lib/react-query.ts
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Database Context
|
|
163
|
+
|
|
164
|
+
**Triggers**:
|
|
165
|
+
- Keywords: "database", "DB", "Prisma", "Drizzle", "migration", "schema", "query"
|
|
166
|
+
- File patterns: `**/prisma/**`, `**/models/**`, `**/db/**`, `*.prisma`
|
|
167
|
+
- Commands: `/db`, `/migration`, `/schema`
|
|
168
|
+
|
|
169
|
+
**Loaded Context**:
|
|
170
|
+
```
|
|
171
|
+
## Database ORM
|
|
172
|
+
- Use Prisma ORM for database operations
|
|
173
|
+
- Schema in prisma/schema.prisma
|
|
174
|
+
- Migrations required for schema changes
|
|
175
|
+
|
|
176
|
+
## Query Patterns
|
|
177
|
+
- Use transactions for multi-step operations
|
|
178
|
+
- Include related data with include/select
|
|
179
|
+
- Index frequently queried fields
|
|
180
|
+
|
|
181
|
+
## Database Examples
|
|
182
|
+
- Schema: @prisma/schema.prisma
|
|
183
|
+
- Query pattern: @src/db/queries/users.ts
|
|
184
|
+
- Migration: @prisma/migrations/[latest]
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Security Context
|
|
190
|
+
|
|
191
|
+
**Triggers**:
|
|
192
|
+
- Keywords: "security", "auth", "authentication", "authorization", "encrypt", "hash"
|
|
193
|
+
- File patterns: `**/auth/**`, `**/security/**`, `**/middleware/**`
|
|
194
|
+
- Commands: `/security`, `/auth`, `/review-security`
|
|
195
|
+
|
|
196
|
+
**Loaded Context**:
|
|
197
|
+
```
|
|
198
|
+
## Authentication
|
|
199
|
+
- JWT tokens with 15min expiration
|
|
200
|
+
- Refresh tokens with 7day expiration
|
|
201
|
+
- Store tokens in httpOnly cookies
|
|
202
|
+
- Validate tokens on all protected routes
|
|
203
|
+
|
|
204
|
+
## Password Security
|
|
205
|
+
- Hash passwords with bcrypt (cost: 12)
|
|
206
|
+
- Minimum 8 characters, mixed case, numbers
|
|
207
|
+
- Rate limit login attempts (5 per minute)
|
|
208
|
+
|
|
209
|
+
## Input Security
|
|
210
|
+
- Sanitize all user input
|
|
211
|
+
- Use parameterized queries (no SQL injection)
|
|
212
|
+
- Escape output to prevent XSS
|
|
213
|
+
|
|
214
|
+
## Security Examples
|
|
215
|
+
- Auth middleware: @src/middleware/auth.ts
|
|
216
|
+
- Password hashing: @src/lib/password.ts
|
|
217
|
+
- Input validation: @src/validators/userSchema.ts
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Deployment Context
|
|
223
|
+
|
|
224
|
+
**Triggers**:
|
|
225
|
+
- Keywords: "deploy", "production", "staging", "CI/CD", "build"
|
|
226
|
+
- Commands: `/deploy`, `/build`, `/ci`
|
|
227
|
+
|
|
228
|
+
**Loaded Context**:
|
|
229
|
+
```
|
|
230
|
+
## Build Process
|
|
231
|
+
- npm run build before deploying
|
|
232
|
+
- Check build output for errors
|
|
233
|
+
- Verify environment variables
|
|
234
|
+
|
|
235
|
+
## Deployment Pipeline
|
|
236
|
+
- Run tests in CI
|
|
237
|
+
- Run linter in CI
|
|
238
|
+
- Run typecheck in CI
|
|
239
|
+
- Deploy to staging first
|
|
240
|
+
- Manual approval for production
|
|
241
|
+
|
|
242
|
+
## Deployment Examples
|
|
243
|
+
- CI config: @.github/workflows/ci.yml
|
|
244
|
+
- Build script: @scripts/build.ts
|
|
245
|
+
- Deploy: @scripts/deploy.ts
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Automatic Context Pruning
|
|
251
|
+
|
|
252
|
+
**Rule**: To avoid over-specification (per ETH Zurich research):
|
|
253
|
+
|
|
254
|
+
```
|
|
255
|
+
1. Load ONLY relevant Tier 2 context based on triggers
|
|
256
|
+
2. DO NOT load multiple Tier 2 contexts unless task spans multiple areas
|
|
257
|
+
3. If task spans multiple areas, load summaries only
|
|
258
|
+
4. Agent discovers details via search tools (Grep, Explore (quick))
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
**Example**:
|
|
262
|
+
```
|
|
263
|
+
Task: "Add API endpoint" → Load API context only
|
|
264
|
+
Task: "Add UI component" → Load UI context only
|
|
265
|
+
Task: "Add authenticated API" → Load API + Security context (summaries)
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Context Loading Decision Tree
|
|
271
|
+
|
|
272
|
+
```
|
|
273
|
+
Task involves testing? → Load Testing context
|
|
274
|
+
Task involves API? → Load API context
|
|
275
|
+
Task involves UI/components? → Load UI/Styling context
|
|
276
|
+
Task involves performance? → Load Performance context
|
|
277
|
+
Task involves database? → Load Database context
|
|
278
|
+
Task involves auth/security? → Load Security context
|
|
279
|
+
Task involves deployment? → Load Deployment context
|
|
280
|
+
Multiple areas? → Load summaries of each, agent discovers details
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
**Note**: These contexts load automatically based on task analysis. No manual intervention needed.
|
package/.claude/rules/general.md
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
# General Rules
|
|
2
|
-
|
|
3
|
-
## Essential Commands
|
|
4
|
-
- `npm run lint`: After substantive changes
|
|
5
|
-
- `npm run test`: Prefer single test files
|
|
6
|
-
- `npm run typecheck`: After TypeScript changes
|
|
7
|
-
|
|
8
|
-
## Critical Constraints
|
|
9
|
-
- Use ES modules (import/export)
|
|
10
|
-
- TypeScript strict mode, no `any`
|
|
11
|
-
- All user input validated with Zod
|
|
12
|
-
- Security: Never hardcode credentials (use env vars)
|
|
13
|
-
|
|
14
|
-
## Canonical Examples
|
|
15
|
-
- Component: `@components/Button.tsx`
|
|
16
|
-
- API route: `@app/api/users/route.ts`
|
|
17
|
-
- Test: `@__tests__/auth.test.ts`
|
|
18
|
-
|
|
19
|
-
## Pre-Commit Checklist
|
|
20
|
-
- [ ] Security review passed (auto-run)
|
|
21
|
-
- [ ] Lint clean (auto-fixed)
|
|
22
|
-
- [ ] Tests passing (auto-run)
|
|
23
|
-
- [ ] Cost within budget (check `.
|
|
24
|
-
|
|
25
|
-
**Note**: See @.
|
|
1
|
+
# General Rules
|
|
2
|
+
|
|
3
|
+
## Essential Commands
|
|
4
|
+
- `npm run lint`: After substantive changes
|
|
5
|
+
- `npm run test`: Prefer single test files
|
|
6
|
+
- `npm run typecheck`: After TypeScript changes
|
|
7
|
+
|
|
8
|
+
## Critical Constraints
|
|
9
|
+
- Use ES modules (import/export)
|
|
10
|
+
- TypeScript strict mode, no `any`
|
|
11
|
+
- All user input validated with Zod
|
|
12
|
+
- Security: Never hardcode credentials (use env vars)
|
|
13
|
+
|
|
14
|
+
## Canonical Examples
|
|
15
|
+
- Component: `@components/Button.tsx`
|
|
16
|
+
- API route: `@app/api/users/route.ts`
|
|
17
|
+
- Test: `@__tests__/auth.test.ts`
|
|
18
|
+
|
|
19
|
+
## Pre-Commit Checklist
|
|
20
|
+
- [ ] Security review passed (auto-run)
|
|
21
|
+
- [ ] Lint clean (auto-fixed)
|
|
22
|
+
- [ ] Tests passing (auto-run)
|
|
23
|
+
- [ ] Cost within budget (check `.claude/cost-dashboard.md`)
|
|
24
|
+
|
|
25
|
+
**Note**: See @.claude/rules/ for task-specific rules. Anti-patterns: @.claude/rules/anti-patterns.md
|