@champpaba/claude-agent-kit 2.1.6 → 2.2.1
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/CLAUDE.md +73 -7
- package/.claude/agents/_shared/pre-work-checklist.md +83 -1
- package/.claude/commands/csetup.md +990 -134
- package/.claude/contexts/patterns/validation-framework.md +51 -1
- package/.claude/lib/agent-executor.md +149 -0
- package/.claude/lib/feature-best-practices.md +386 -0
- package/README.md +30 -1
- package/package.json +1 -1
|
@@ -228,12 +228,56 @@ logger.warning("login_failed", extra={"email": email, "reason": "invalid_credent
|
|
|
228
228
|
logger.error("login_error", extra={"error": str(e)})
|
|
229
229
|
```
|
|
230
230
|
|
|
231
|
-
### F.
|
|
231
|
+
### F. Library Feasibility Check ✓ (v2.2.0)
|
|
232
|
+
**From:** design.md + library documentation
|
|
233
|
+
|
|
234
|
+
**Spec Requirements:**
|
|
235
|
+
- JWT access token 15min expiry
|
|
236
|
+
- Refresh token with rotation
|
|
237
|
+
- Redis session storage
|
|
238
|
+
- Token revocation capability
|
|
239
|
+
|
|
240
|
+
**Library Capability Verification:**
|
|
241
|
+
- [x] JWT 15min → better-auth jwt plugin: YES ✅
|
|
242
|
+
- [x] Refresh token → better-auth: PARTIAL ⚠️ (session-based, not separate token)
|
|
243
|
+
- [ ] Token rotation → better-auth: NO ❌
|
|
244
|
+
- [ ] Redis storage → better-auth: NO ❌
|
|
245
|
+
|
|
246
|
+
**IF ALL SUPPORTED:**
|
|
247
|
+
```
|
|
248
|
+
✅ Library Feasibility Validated
|
|
249
|
+
All spec requirements are supported by chosen library.
|
|
250
|
+
Proceeding with implementation...
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**IF GAPS FOUND:**
|
|
254
|
+
```
|
|
255
|
+
⚠️ Library Capability Gap Detected
|
|
256
|
+
|
|
257
|
+
Library: better-auth
|
|
258
|
+
Requirement: Refresh token rotation
|
|
259
|
+
Support Status: NO
|
|
260
|
+
|
|
261
|
+
What library supports: Session-based auth with auto-refresh
|
|
262
|
+
What spec requires: Explicit refresh token rotation on each use
|
|
263
|
+
|
|
264
|
+
Options:
|
|
265
|
+
A) Change library → lucia-auth (supports custom session storage)
|
|
266
|
+
B) Change spec → Use session-based approach instead
|
|
267
|
+
C) Custom implementation → Build rotation on top of better-auth
|
|
268
|
+
|
|
269
|
+
My Recommendation: B (simplest, meets core security needs)
|
|
270
|
+
|
|
271
|
+
Awaiting decision before proceeding.
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### G. Ready to Implement ✓
|
|
232
275
|
✅ Patterns loaded
|
|
233
276
|
✅ Existing endpoints searched
|
|
234
277
|
✅ TDD workflow planned
|
|
235
278
|
✅ Error handling pattern identified
|
|
236
279
|
✅ Logging pattern identified
|
|
280
|
+
✅ Library feasibility validated
|
|
237
281
|
|
|
238
282
|
**Proceeding with TDD (RED phase first)...**
|
|
239
283
|
```
|
|
@@ -244,8 +288,14 @@ logger.error("login_error", extra={"error": str(e)})
|
|
|
244
288
|
- IF TDD: Contains "TDD Workflow" + "RED-GREEN-REFACTOR"
|
|
245
289
|
- Contains: "Error Handling Pattern ✓"
|
|
246
290
|
- Contains: "Logging Pattern ✓"
|
|
291
|
+
- Contains: "Library Feasibility" (either "Validated" or "Gap Detected")
|
|
247
292
|
- Contains: "Ready to Implement ✓"
|
|
248
293
|
|
|
294
|
+
**Spec Deviation Markers (triggers workflow pause):**
|
|
295
|
+
- "⚠️ Library Capability Gap"
|
|
296
|
+
- "Awaiting decision"
|
|
297
|
+
- "Support Status: NO"
|
|
298
|
+
|
|
249
299
|
---
|
|
250
300
|
|
|
251
301
|
### 3️⃣ **frontend Agent**
|
|
@@ -318,6 +318,155 @@ Please provide complete output including:
|
|
|
318
318
|
|
|
319
319
|
---
|
|
320
320
|
|
|
321
|
+
## 🔄 Spec Deviation Protocol (v2.2.0)
|
|
322
|
+
|
|
323
|
+
When an agent discovers that implementation cannot match spec exactly, this protocol ensures proper handling.
|
|
324
|
+
|
|
325
|
+
WHY: Silent spec drift creates technical debt and user confusion. Explicit decisions create documented trade-offs.
|
|
326
|
+
|
|
327
|
+
### Detection Triggers
|
|
328
|
+
|
|
329
|
+
Agent discovers:
|
|
330
|
+
- Library doesn't support a spec feature
|
|
331
|
+
- Technical constraint prevents exact implementation
|
|
332
|
+
- Better alternative exists than what spec describes
|
|
333
|
+
- Dependency conflict with existing code
|
|
334
|
+
|
|
335
|
+
### Required Actions
|
|
336
|
+
|
|
337
|
+
**Agent should NOT:**
|
|
338
|
+
- Implement alternative approach silently
|
|
339
|
+
- Change the approach without user knowledge
|
|
340
|
+
- Continue with "close enough" solution
|
|
341
|
+
- Assume user would prefer the simpler option
|
|
342
|
+
|
|
343
|
+
**Agent MUST:**
|
|
344
|
+
1. Document the gap clearly
|
|
345
|
+
2. Stop implementation immediately
|
|
346
|
+
3. Report to Main Claude with options
|
|
347
|
+
4. Wait for explicit decision
|
|
348
|
+
|
|
349
|
+
### Spec Deviation Report Format
|
|
350
|
+
|
|
351
|
+
```markdown
|
|
352
|
+
⚠️ Spec Deviation Required
|
|
353
|
+
|
|
354
|
+
**Phase:** {current phase}
|
|
355
|
+
**Agent:** {agent type}
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
**Spec Requirement:** (exact text from design.md)
|
|
360
|
+
{paste the exact requirement from design.md}
|
|
361
|
+
|
|
362
|
+
**Library/Technical Constraint:**
|
|
363
|
+
{what the library/system actually supports}
|
|
364
|
+
|
|
365
|
+
**Gap Analysis:**
|
|
366
|
+
{explain what cannot be implemented as specified}
|
|
367
|
+
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
**Options:**
|
|
371
|
+
|
|
372
|
+
A) **Change Approach** - Use what library supports
|
|
373
|
+
- Implementation: {alternative approach}
|
|
374
|
+
- Benefit: {what you gain}
|
|
375
|
+
- Trade-off: {what you lose vs spec}
|
|
376
|
+
|
|
377
|
+
B) **Change Library** - Switch to alternative
|
|
378
|
+
- Alternative: {library name}
|
|
379
|
+
- Benefit: Matches spec exactly
|
|
380
|
+
- Trade-off: {migration effort, learning curve}
|
|
381
|
+
|
|
382
|
+
C) **Custom Implementation** - Build on top of library
|
|
383
|
+
- Implementation: {what needs to be built}
|
|
384
|
+
- Benefit: Matches spec, uses existing library
|
|
385
|
+
- Trade-off: {maintenance burden, complexity}
|
|
386
|
+
|
|
387
|
+
---
|
|
388
|
+
|
|
389
|
+
**My Recommendation:** {A/B/C}
|
|
390
|
+
**Reasoning:** {why this option is best}
|
|
391
|
+
|
|
392
|
+
Awaiting decision before proceeding.
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### Main Claude Response Protocol
|
|
396
|
+
|
|
397
|
+
When receiving a spec deviation report:
|
|
398
|
+
|
|
399
|
+
1. **Pause workflow** - Do not auto-proceed to next phase
|
|
400
|
+
2. **Show report to user** - Present options clearly
|
|
401
|
+
3. **Get explicit decision** - User must choose A, B, or C
|
|
402
|
+
4. **Document decision** in design.md:
|
|
403
|
+
|
|
404
|
+
```markdown
|
|
405
|
+
### D{n}: {Decision Title}
|
|
406
|
+
|
|
407
|
+
**Context:** Agent found {library} doesn't support {feature}
|
|
408
|
+
**Decision:** Option {A/B/C} - {brief description}
|
|
409
|
+
**Reason:** {user's reasoning}
|
|
410
|
+
**Trade-off Accepted:** {what we're giving up}
|
|
411
|
+
**Date:** {date}
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
5. **Update spec if needed:**
|
|
415
|
+
- If Option A: Add "Library Capability Alignment" section to design.md
|
|
416
|
+
- If Option B: Update library references in design.md and tasks.md
|
|
417
|
+
- If Option C: Add "Custom Implementation Required" section
|
|
418
|
+
|
|
419
|
+
6. **Resume workflow** with clear, documented direction
|
|
420
|
+
|
|
421
|
+
### Spec Deviation Validation
|
|
422
|
+
|
|
423
|
+
**Check agent output for spec deviation markers:**
|
|
424
|
+
|
|
425
|
+
| Marker | Meaning |
|
|
426
|
+
|--------|---------|
|
|
427
|
+
| "⚠️ Spec Deviation" | Agent found gap, needs decision |
|
|
428
|
+
| "Library Capability Gap" | Library doesn't support requirement |
|
|
429
|
+
| "Awaiting decision" | Agent stopped, waiting for response |
|
|
430
|
+
|
|
431
|
+
**Main Claude should:**
|
|
432
|
+
- Pause workflow when seeing these markers
|
|
433
|
+
- Present options to user
|
|
434
|
+
- Record decision before resuming
|
|
435
|
+
|
|
436
|
+
### Example Flow
|
|
437
|
+
|
|
438
|
+
```
|
|
439
|
+
Agent: Backend implementing auth
|
|
440
|
+
↓
|
|
441
|
+
Agent: Reads design.md "JWT + Redis refresh + rotation"
|
|
442
|
+
↓
|
|
443
|
+
Agent: Checks better-auth capabilities
|
|
444
|
+
↓
|
|
445
|
+
Agent: Finds "rotation" not supported
|
|
446
|
+
↓
|
|
447
|
+
Agent: ⚠️ STOPS - Sends Spec Deviation Report
|
|
448
|
+
↓
|
|
449
|
+
Main Claude: Pauses workflow, shows user options
|
|
450
|
+
↓
|
|
451
|
+
User: Chooses Option B (change library to lucia-auth)
|
|
452
|
+
↓
|
|
453
|
+
Main Claude: Updates design.md with decision
|
|
454
|
+
↓
|
|
455
|
+
Main Claude: Resumes workflow with new library
|
|
456
|
+
↓
|
|
457
|
+
Agent: Implements with lucia-auth (supports rotation)
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
### Benefits of Spec Deviation Protocol
|
|
461
|
+
|
|
462
|
+
- **Prevents silent drift** - User knows about every deviation
|
|
463
|
+
- **Documented trade-offs** - All decisions recorded in design.md
|
|
464
|
+
- **Early detection** - Gaps found at pre-work, not during implementation
|
|
465
|
+
- **Clear options** - User can make informed choice
|
|
466
|
+
- **Audit trail** - Design decisions are traceable
|
|
467
|
+
|
|
468
|
+
---
|
|
469
|
+
|
|
321
470
|
## 🎯 Benefits
|
|
322
471
|
|
|
323
472
|
✅ **Auto-recovery** - Transient errors handled automatically
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
# Feature Best Practices Detection & Validation
|
|
2
|
+
|
|
3
|
+
> **Version:** 1.0.0
|
|
4
|
+
> **Purpose:** Detect features from spec and validate against industry standards
|
|
5
|
+
> **Used by:** `/csetup` Step 2.6
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
Before querying stack-level best practices (React, Next.js, etc.), we first need to:
|
|
12
|
+
1. Detect what features the change involves (Auth, Payment, etc.)
|
|
13
|
+
2. Query industry best practices for each feature
|
|
14
|
+
3. Compare spec against industry standards
|
|
15
|
+
4. Report gaps and get user decision
|
|
16
|
+
|
|
17
|
+
WHY: Stack best practices tell you "how to use React well", but Feature best practices tell you "what a good auth system needs". The feature layer is higher-level and informs whether your spec is complete.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Feature Detection
|
|
22
|
+
|
|
23
|
+
### Keyword Mapping
|
|
24
|
+
|
|
25
|
+
| Keywords in proposal/tasks/design | Feature Type | Security Tier |
|
|
26
|
+
|-----------------------------------|--------------|---------------|
|
|
27
|
+
| login, auth, register, password, session, jwt, token, oauth | Authentication | Tier 1 (Blocking) |
|
|
28
|
+
| payment, stripe, checkout, billing, subscription, invoice | Payment | Tier 1 (Blocking) |
|
|
29
|
+
| upload, file, image, s3, storage, attachment | File Upload | Tier 1 (Blocking) |
|
|
30
|
+
| admin, role, permission, rbac, acl, access control | Authorization | Tier 1 (Blocking) |
|
|
31
|
+
| api, endpoint, rest, graphql, webhook | API Design | Tier 2 (Warning) |
|
|
32
|
+
| realtime, websocket, notification, push, sse | Real-time | Tier 2 (Warning) |
|
|
33
|
+
| email, smtp, sendgrid, notification, mailer | Email/Notification | Tier 2 (Warning) |
|
|
34
|
+
| search, elasticsearch, algolia, filter, query | Search | Tier 2 (Warning) |
|
|
35
|
+
| cache, redis, memcached, cdn | Caching | Tier 2 (Warning) |
|
|
36
|
+
| crud, list, table, form, dashboard | CRUD/UI | Tier 3 (Info) |
|
|
37
|
+
| landing, hero, marketing, seo | Marketing Page | Tier 3 (Info) |
|
|
38
|
+
|
|
39
|
+
### Security Tiers
|
|
40
|
+
|
|
41
|
+
**Tier 1 (Blocking):** Security-critical features
|
|
42
|
+
- Validation against industry standard is required
|
|
43
|
+
- User must explicitly approve if skipping requirements
|
|
44
|
+
- Gaps are documented in design.md
|
|
45
|
+
|
|
46
|
+
**Tier 2 (Warning):** Important but not security-critical
|
|
47
|
+
- Show warning if gaps found
|
|
48
|
+
- Allow continue without blocking
|
|
49
|
+
- Log decision
|
|
50
|
+
|
|
51
|
+
**Tier 3 (Info):** Nice-to-have
|
|
52
|
+
- Suggest best practices
|
|
53
|
+
- No blocking or warning
|
|
54
|
+
- Optional to follow
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Industry Standard Queries
|
|
59
|
+
|
|
60
|
+
### Authentication
|
|
61
|
+
|
|
62
|
+
**Query Topics:**
|
|
63
|
+
```
|
|
64
|
+
- "JWT authentication best practices 2024"
|
|
65
|
+
- "refresh token rotation security"
|
|
66
|
+
- "session management security best practices"
|
|
67
|
+
- "OAuth 2.0 implementation best practices"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Expected Standards:**
|
|
71
|
+
|
|
72
|
+
| Requirement | Description | Priority |
|
|
73
|
+
|-------------|-------------|----------|
|
|
74
|
+
| Short-lived access token | JWT 15-60 minutes max | Required |
|
|
75
|
+
| Refresh token rotation | New refresh token on each use | Required |
|
|
76
|
+
| Secure token storage | httpOnly cookies, not localStorage | Required |
|
|
77
|
+
| Token revocation | Ability to invalidate tokens immediately | Required |
|
|
78
|
+
| Rate limiting | 5-10 attempts per minute on auth endpoints | Required |
|
|
79
|
+
| Account lockout | Lock after N failed attempts | Recommended |
|
|
80
|
+
| Password requirements | Min length, complexity | Required |
|
|
81
|
+
| Secure password storage | bcrypt/argon2, never plain text | Required |
|
|
82
|
+
| HTTPS only | All auth endpoints over TLS | Required |
|
|
83
|
+
| CSRF protection | For cookie-based auth | Required |
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
### Payment
|
|
88
|
+
|
|
89
|
+
**Query Topics:**
|
|
90
|
+
```
|
|
91
|
+
- "payment integration security best practices"
|
|
92
|
+
- "PCI DSS compliance requirements"
|
|
93
|
+
- "Stripe integration best practices"
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Expected Standards:**
|
|
97
|
+
|
|
98
|
+
| Requirement | Description | Priority |
|
|
99
|
+
|-------------|-------------|----------|
|
|
100
|
+
| No card data on server | Use Stripe Elements/Checkout | Required |
|
|
101
|
+
| Webhook signature verification | Validate Stripe webhook signatures | Required |
|
|
102
|
+
| Idempotency keys | Prevent duplicate charges | Required |
|
|
103
|
+
| Amount validation | Server-side price validation | Required |
|
|
104
|
+
| Audit logging | Log all payment events | Required |
|
|
105
|
+
| Error handling | Graceful failure, no sensitive data in errors | Required |
|
|
106
|
+
| Test mode separation | Clear separation of test/live keys | Required |
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
### File Upload
|
|
111
|
+
|
|
112
|
+
**Query Topics:**
|
|
113
|
+
```
|
|
114
|
+
- "file upload security best practices"
|
|
115
|
+
- "image upload validation security"
|
|
116
|
+
- "S3 presigned URL best practices"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Expected Standards:**
|
|
120
|
+
|
|
121
|
+
| Requirement | Description | Priority |
|
|
122
|
+
|-------------|-------------|----------|
|
|
123
|
+
| File type validation | Server-side MIME type check | Required |
|
|
124
|
+
| File size limits | Configurable max size | Required |
|
|
125
|
+
| Filename sanitization | Remove path traversal, special chars | Required |
|
|
126
|
+
| Virus scanning | For user-uploaded files | Recommended |
|
|
127
|
+
| Presigned URLs | For direct-to-S3 uploads | Recommended |
|
|
128
|
+
| Access control | Private by default, signed URLs for access | Required |
|
|
129
|
+
| Content-Disposition | Force download, prevent XSS | Required |
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
### Authorization (RBAC)
|
|
134
|
+
|
|
135
|
+
**Query Topics:**
|
|
136
|
+
```
|
|
137
|
+
- "role based access control best practices"
|
|
138
|
+
- "RBAC implementation patterns"
|
|
139
|
+
- "authorization security best practices"
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Expected Standards:**
|
|
143
|
+
|
|
144
|
+
| Requirement | Description | Priority |
|
|
145
|
+
|-------------|-------------|----------|
|
|
146
|
+
| Deny by default | No access unless explicitly granted | Required |
|
|
147
|
+
| Server-side checks | Never trust client-side only | Required |
|
|
148
|
+
| Principle of least privilege | Minimal permissions needed | Required |
|
|
149
|
+
| Role hierarchy | Clear inheritance if needed | Recommended |
|
|
150
|
+
| Audit logging | Log access decisions | Required |
|
|
151
|
+
| Separation of duties | Critical actions need multiple roles | Recommended |
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
### API Design
|
|
156
|
+
|
|
157
|
+
**Query Topics:**
|
|
158
|
+
```
|
|
159
|
+
- "REST API design best practices 2024"
|
|
160
|
+
- "API security best practices"
|
|
161
|
+
- "API rate limiting best practices"
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
**Expected Standards:**
|
|
165
|
+
|
|
166
|
+
| Requirement | Description | Priority |
|
|
167
|
+
|-------------|-------------|----------|
|
|
168
|
+
| Consistent naming | Resource-based URLs, proper HTTP methods | Required |
|
|
169
|
+
| Versioning | URL or header-based versioning | Recommended |
|
|
170
|
+
| Rate limiting | Per-user/IP rate limits | Required |
|
|
171
|
+
| Input validation | Validate all inputs server-side | Required |
|
|
172
|
+
| Error format | Consistent error response structure | Required |
|
|
173
|
+
| Pagination | For list endpoints | Required |
|
|
174
|
+
| CORS configuration | Proper origin restrictions | Required |
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Spec Comparison Logic
|
|
179
|
+
|
|
180
|
+
### Extracting Spec Requirements
|
|
181
|
+
|
|
182
|
+
From `design.md`, look for:
|
|
183
|
+
1. **Decision sections** (### D1, ### D2, etc.)
|
|
184
|
+
2. **Technical specs** (tables, bullet points)
|
|
185
|
+
3. **Architecture descriptions**
|
|
186
|
+
|
|
187
|
+
### Comparison Algorithm
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
interface SpecComparison {
|
|
191
|
+
feature: string
|
|
192
|
+
industryRequirements: Requirement[]
|
|
193
|
+
specRequirements: string[]
|
|
194
|
+
gaps: Gap[]
|
|
195
|
+
matches: Match[]
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
interface Gap {
|
|
199
|
+
requirement: string
|
|
200
|
+
priority: 'required' | 'recommended'
|
|
201
|
+
securityImpact: 'high' | 'medium' | 'low'
|
|
202
|
+
suggestion: string
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function compareSpecToIndustry(
|
|
206
|
+
featureType: string,
|
|
207
|
+
specContent: string,
|
|
208
|
+
industryStandards: Requirement[]
|
|
209
|
+
): SpecComparison {
|
|
210
|
+
const gaps = []
|
|
211
|
+
const matches = []
|
|
212
|
+
|
|
213
|
+
for (const standard of industryStandards) {
|
|
214
|
+
// Check if spec mentions this requirement
|
|
215
|
+
const mentioned = checkIfMentioned(specContent, standard.keywords)
|
|
216
|
+
|
|
217
|
+
if (mentioned) {
|
|
218
|
+
matches.push({ requirement: standard.name, specText: mentioned })
|
|
219
|
+
} else if (standard.priority === 'required') {
|
|
220
|
+
gaps.push({
|
|
221
|
+
requirement: standard.name,
|
|
222
|
+
priority: standard.priority,
|
|
223
|
+
securityImpact: standard.securityImpact,
|
|
224
|
+
suggestion: standard.suggestion
|
|
225
|
+
})
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return { feature: featureType, industryRequirements, specRequirements, gaps, matches }
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Gap Report Format
|
|
236
|
+
|
|
237
|
+
### For Tier 1 (Blocking) Features
|
|
238
|
+
|
|
239
|
+
```markdown
|
|
240
|
+
## Feature Best Practice Validation
|
|
241
|
+
|
|
242
|
+
### Feature: Authentication
|
|
243
|
+
**Security Tier:** 1 (Blocking)
|
|
244
|
+
|
|
245
|
+
### Spec vs Industry Standard
|
|
246
|
+
|
|
247
|
+
| Requirement | Industry Standard | Your Spec | Status |
|
|
248
|
+
|-------------|------------------|-----------|--------|
|
|
249
|
+
| Access token expiry | 15-60 min | 15 min | ✅ Match |
|
|
250
|
+
| Refresh token rotation | Required | Not specified | ❌ Gap |
|
|
251
|
+
| Token revocation | Required | Redis-based | ✅ Match |
|
|
252
|
+
| Rate limiting | 5-10/min | Not specified | ❌ Gap |
|
|
253
|
+
| Account lockout | Recommended | Not specified | ⚠️ Missing |
|
|
254
|
+
|
|
255
|
+
### Gaps Found: 2 Required, 1 Recommended
|
|
256
|
+
|
|
257
|
+
**Security Impact:** HIGH
|
|
258
|
+
|
|
259
|
+
⚠️ Your spec is missing security-critical requirements.
|
|
260
|
+
|
|
261
|
+
### Options:
|
|
262
|
+
|
|
263
|
+
**A) Update spec (Recommended)**
|
|
264
|
+
Add missing requirements to design.md:
|
|
265
|
+
- Refresh token rotation on each use
|
|
266
|
+
- Rate limiting: 5 attempts per minute
|
|
267
|
+
|
|
268
|
+
**B) Document conscious skip**
|
|
269
|
+
Record why these aren't needed for your use case.
|
|
270
|
+
(Requires justification for security review)
|
|
271
|
+
|
|
272
|
+
**C) Continue anyway**
|
|
273
|
+
Proceed without these requirements.
|
|
274
|
+
⚠️ Security risk - not recommended for production
|
|
275
|
+
|
|
276
|
+
Which option? [A/B/C]
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### For Tier 2 (Warning) Features
|
|
280
|
+
|
|
281
|
+
```markdown
|
|
282
|
+
## Feature Best Practice Validation
|
|
283
|
+
|
|
284
|
+
### Feature: API Design
|
|
285
|
+
**Security Tier:** 2 (Warning)
|
|
286
|
+
|
|
287
|
+
### Recommendations
|
|
288
|
+
|
|
289
|
+
Your spec could be improved with:
|
|
290
|
+
- [ ] API versioning strategy
|
|
291
|
+
- [ ] Pagination for list endpoints
|
|
292
|
+
- [ ] Consistent error format
|
|
293
|
+
|
|
294
|
+
These are recommended but not blocking.
|
|
295
|
+
Continuing with implementation...
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## Suggested Spec Updates
|
|
301
|
+
|
|
302
|
+
When user chooses Option A (Update spec), generate:
|
|
303
|
+
|
|
304
|
+
```markdown
|
|
305
|
+
### D{n}: Security Requirements (Industry Standard Alignment)
|
|
306
|
+
|
|
307
|
+
**Added based on industry best practices:**
|
|
308
|
+
|
|
309
|
+
#### Authentication Security
|
|
310
|
+
- Refresh token rotation: Generate new refresh token on each use
|
|
311
|
+
- Rate limiting: Max 5 login attempts per minute per IP
|
|
312
|
+
- Account lockout: Lock account for 15 minutes after 5 failed attempts
|
|
313
|
+
|
|
314
|
+
#### Rationale
|
|
315
|
+
These requirements align with OWASP Authentication Guidelines and
|
|
316
|
+
industry standard security practices for production applications.
|
|
317
|
+
|
|
318
|
+
**Source:** Feature Best Practice Validation in /csetup
|
|
319
|
+
**Added:** {date}
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## Conscious Skip Documentation
|
|
325
|
+
|
|
326
|
+
When user chooses Option B (Document skip):
|
|
327
|
+
|
|
328
|
+
```markdown
|
|
329
|
+
### D{n}: Conscious Security Trade-offs
|
|
330
|
+
|
|
331
|
+
**Skipped requirements (with justification):**
|
|
332
|
+
|
|
333
|
+
| Requirement | Why Skipped | Risk Level | Mitigation |
|
|
334
|
+
|-------------|-------------|------------|------------|
|
|
335
|
+
| Refresh token rotation | Internal tool, 3 users only | Low | Short session timeout (1 hour) |
|
|
336
|
+
| Rate limiting | Behind VPN, no public access | Low | VPN already rate-limits |
|
|
337
|
+
|
|
338
|
+
**Acknowledged by:** User decision in /csetup
|
|
339
|
+
**Date:** {date}
|
|
340
|
+
**Review reminder:** Re-evaluate if app becomes public-facing
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
## Integration with /csetup
|
|
346
|
+
|
|
347
|
+
This file is used in Step 2.6 of `/csetup`:
|
|
348
|
+
|
|
349
|
+
```typescript
|
|
350
|
+
// In csetup.md Step 2.6
|
|
351
|
+
|
|
352
|
+
// 1. Detect features
|
|
353
|
+
const features = detectFeatures(proposalContent, tasksContent, designContent)
|
|
354
|
+
|
|
355
|
+
// 2. For each Tier 1/2 feature, validate
|
|
356
|
+
for (const feature of features) {
|
|
357
|
+
const industryStandards = loadIndustryStandards(feature.type)
|
|
358
|
+
const comparison = compareSpecToIndustry(feature.type, designContent, industryStandards)
|
|
359
|
+
|
|
360
|
+
if (comparison.gaps.length > 0 && feature.tier <= 2) {
|
|
361
|
+
// Show gap report and get user decision
|
|
362
|
+
const decision = await showGapReport(comparison)
|
|
363
|
+
|
|
364
|
+
if (decision === 'A') {
|
|
365
|
+
// Generate spec update suggestions
|
|
366
|
+
await updateSpec(changeId, comparison.gaps)
|
|
367
|
+
} else if (decision === 'B') {
|
|
368
|
+
// Document conscious skip
|
|
369
|
+
await documentSkip(changeId, comparison.gaps)
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
## Best Practice Sources
|
|
378
|
+
|
|
379
|
+
When querying, use these sources in order:
|
|
380
|
+
1. **Context7** - For library-specific best practices
|
|
381
|
+
2. **OWASP** - For security best practices
|
|
382
|
+
3. **Industry standards** - PCI DSS, OAuth 2.0 RFC, etc.
|
|
383
|
+
|
|
384
|
+
---
|
|
385
|
+
|
|
386
|
+
This feature-first validation ensures specs are complete before we check if libraries support them.
|
package/README.md
CHANGED
|
@@ -29,10 +29,39 @@ cak init
|
|
|
29
29
|
|
|
30
30
|
## Features
|
|
31
31
|
|
|
32
|
-
- **
|
|
32
|
+
- **Zero-Maintenance Tech Detection (v2.3.0)** - Auto-detects ANY library in ANY language via Context7
|
|
33
|
+
- **4-Layer Validation** - Feature BP → Spec Alignment → Library Capability → Stack BP
|
|
34
|
+
- **Spec Drift Prevention** - Validates library supports spec before implementation
|
|
33
35
|
- **Cross-session Context** - `PROJECT_STATUS.yml` maintains state across sessions
|
|
34
36
|
- **Design System v2.0** - Interactive setup with theme selection
|
|
35
37
|
|
|
38
|
+
## Tech Detection (v2.3.0)
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
/csetup automatically detects libraries from:
|
|
42
|
+
├── Spec files (proposal.md, design.md, tasks.md)
|
|
43
|
+
├── JS/TS (package.json, imports)
|
|
44
|
+
├── Python (requirements.txt, pyproject.toml)
|
|
45
|
+
├── Rust (Cargo.toml)
|
|
46
|
+
├── Go (go.mod)
|
|
47
|
+
└── PHP/Ruby (composer.json, Gemfile)
|
|
48
|
+
|
|
49
|
+
Context7 validates → generates best-practices/*.md
|
|
50
|
+
Zero maintenance - works with any library!
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Validation Flow
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
/csetup
|
|
57
|
+
├── Step 2.6: Feature Best Practice (Auth, Payment, etc.)
|
|
58
|
+
├── Step 2.7: Stack Best Practice (auto-detected libraries)
|
|
59
|
+
└── Step 2.8: Library Capability (verify library supports spec)
|
|
60
|
+
|
|
61
|
+
/cdev
|
|
62
|
+
└── Agent Step 0.5: Double-check feasibility before implement
|
|
63
|
+
```
|
|
64
|
+
|
|
36
65
|
## Commands
|
|
37
66
|
|
|
38
67
|
**CLI:** `cak init` | `cak update`
|