ai-sprint-kit 1.3.1 → 2.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.
Files changed (64) hide show
  1. package/LICENSE +35 -123
  2. package/README.md +39 -207
  3. package/bin/ai-sprint.js +105 -0
  4. package/lib/auth.js +73 -0
  5. package/lib/installer.js +59 -195
  6. package/lib/messages.js +53 -0
  7. package/package.json +15 -18
  8. package/bin/cli.js +0 -135
  9. package/lib/scanner.js +0 -321
  10. package/templates/.claude/.env.example +0 -13
  11. package/templates/.claude/agents/debugger.md +0 -668
  12. package/templates/.claude/agents/devops.md +0 -728
  13. package/templates/.claude/agents/docs.md +0 -662
  14. package/templates/.claude/agents/implementer.md +0 -288
  15. package/templates/.claude/agents/planner.md +0 -273
  16. package/templates/.claude/agents/researcher.md +0 -454
  17. package/templates/.claude/agents/reviewer.md +0 -644
  18. package/templates/.claude/agents/security.md +0 -203
  19. package/templates/.claude/agents/tester.md +0 -647
  20. package/templates/.claude/commands/ai-sprint-auto.md +0 -150
  21. package/templates/.claude/commands/ai-sprint-code.md +0 -316
  22. package/templates/.claude/commands/ai-sprint-debug.md +0 -453
  23. package/templates/.claude/commands/ai-sprint-deploy.md +0 -475
  24. package/templates/.claude/commands/ai-sprint-docs.md +0 -519
  25. package/templates/.claude/commands/ai-sprint-plan.md +0 -136
  26. package/templates/.claude/commands/ai-sprint-review.md +0 -433
  27. package/templates/.claude/commands/ai-sprint-scan.md +0 -146
  28. package/templates/.claude/commands/ai-sprint-secure.md +0 -88
  29. package/templates/.claude/commands/ai-sprint-test.md +0 -352
  30. package/templates/.claude/commands/ai-sprint-validate.md +0 -253
  31. package/templates/.claude/settings.json +0 -27
  32. package/templates/.claude/skills/codebase-context/SKILL.md +0 -68
  33. package/templates/.claude/skills/codebase-context/references/reading-context.md +0 -68
  34. package/templates/.claude/skills/codebase-context/references/refresh-triggers.md +0 -82
  35. package/templates/.claude/skills/implementation/SKILL.md +0 -70
  36. package/templates/.claude/skills/implementation/references/error-handling.md +0 -106
  37. package/templates/.claude/skills/implementation/references/security-patterns.md +0 -73
  38. package/templates/.claude/skills/implementation/references/validation-patterns.md +0 -107
  39. package/templates/.claude/skills/memory/SKILL.md +0 -67
  40. package/templates/.claude/skills/memory/references/decisions-format.md +0 -68
  41. package/templates/.claude/skills/memory/references/learning-format.md +0 -74
  42. package/templates/.claude/skills/planning/SKILL.md +0 -72
  43. package/templates/.claude/skills/planning/references/plan-templates.md +0 -81
  44. package/templates/.claude/skills/planning/references/research-phase.md +0 -62
  45. package/templates/.claude/skills/planning/references/solution-design.md +0 -66
  46. package/templates/.claude/skills/quality-assurance/SKILL.md +0 -79
  47. package/templates/.claude/skills/quality-assurance/references/review-checklist.md +0 -72
  48. package/templates/.claude/skills/quality-assurance/references/security-checklist.md +0 -70
  49. package/templates/.claude/skills/quality-assurance/references/testing-strategy.md +0 -85
  50. package/templates/.claude/skills/quality-assurance/scripts/check-size.py +0 -333
  51. package/templates/.claude/statusline.sh +0 -126
  52. package/templates/.claude/workflows/development-rules.md +0 -133
  53. package/templates/.claude/workflows/orchestration-protocol.md +0 -194
  54. package/templates/.mcp.json.example +0 -36
  55. package/templates/CLAUDE.md +0 -412
  56. package/templates/README.md +0 -331
  57. package/templates/ai_context/codebase/.gitkeep +0 -0
  58. package/templates/ai_context/memory/active.md +0 -15
  59. package/templates/ai_context/memory/decisions.md +0 -18
  60. package/templates/ai_context/memory/learning.md +0 -22
  61. package/templates/ai_context/plans/.gitkeep +0 -0
  62. package/templates/ai_context/reports/.gitkeep +0 -0
  63. package/templates/docs/user-guide-th.md +0 -454
  64. package/templates/docs/user-guide.md +0 -595
@@ -1,433 +0,0 @@
1
- ---
2
- description: Comprehensive code quality review and best practices analysis
3
- argument-hint: [optional: specific file or directory to review]
4
- ---
5
-
6
- **THINK HARDER** - Thorough code review requires careful security and quality analysis.
7
-
8
- **Objective:** $ARGUMENTS
9
-
10
- ## Command: /ai-sprint-review
11
-
12
- Perform comprehensive code quality review focusing on security, maintainability, performance, and best practices.
13
-
14
- ## Usage
15
-
16
- ```
17
- /ai-sprint-review
18
- /ai-sprint-review src/
19
- /ai-sprint-review src/auth/login.ts
20
- ```
21
-
22
- ## Workflow
23
-
24
- ### 1. Code Analysis
25
- - Review code structure
26
- - Check for code smells
27
- - Identify security issues
28
- - Analyze performance
29
-
30
- ### 1.5. Design Principles Check (Warning)
31
- Run size checker:
32
- ```bash
33
- python3 .claude/skills/quality-assurance/scripts/check-size.py --path $SCOPE
34
- ```
35
- Flag (warning only):
36
- - Files >500 lines
37
- - Functions >50 lines
38
- - YAGNI violations (unused abstractions)
39
- - SRP violations (mixed concerns)
40
-
41
- ### 2. Security Review (Critical)
42
- - OWASP Top 10 compliance
43
- - SQL injection vulnerabilities
44
- - XSS vulnerabilities
45
- - Auth/authorization issues
46
- - Secret exposure
47
- - Input validation
48
-
49
- ### 3. Quality Check
50
- - Code maintainability
51
- - Proper error handling
52
- - Type safety
53
- - Performance optimization
54
- - Best practices
55
-
56
- ### 4. Generate Report
57
- - Critical issues (must fix)
58
- - High priority issues
59
- - Medium priority suggestions
60
- - Low priority improvements
61
- - Positive observations
62
-
63
- ## Review Categories
64
-
65
- ### 🔴 Critical Issues (Must Fix)
66
- - Security vulnerabilities
67
- - Data loss potential
68
- - Crash bugs
69
- - Performance killers
70
-
71
- ### 🟠 High Priority
72
- - Logic errors
73
- - Missing error handling
74
- - Performance problems
75
- - Maintainability issues
76
-
77
- ### 🟡 Medium Priority
78
- - Code smells
79
- - Refactoring opportunities
80
- - Documentation gaps
81
-
82
- ### 🟢 Low Priority
83
- - Style improvements
84
- - Minor optimizations
85
- - Naming suggestions
86
-
87
- ### 🟡 Design Principle Warnings
88
- - Files exceeding 500 lines
89
- - Functions exceeding 50 lines
90
- - Over-engineered abstractions
91
- - Mixed responsibilities (SRP)
92
-
93
- ## Example Review Report
94
-
95
- ```markdown
96
- # Code Review Report
97
-
98
- **Date:** 2025-12-24
99
- **Scope:** src/auth/
100
- **Overall Assessment:** Needs Improvement
101
-
102
- **Summary:**
103
- - 2 Critical issues
104
- - 4 High priority issues
105
- - 6 Medium priority issues
106
- - 3 Low priority suggestions
107
-
108
- **Recommendation:** Fix critical issues before deployment
109
-
110
- ---
111
-
112
- ## Critical Issues
113
-
114
- ### 1. SQL Injection Vulnerability
115
- **File:** `auth/login.ts:45`
116
- **Severity:** 🔴 Critical
117
-
118
- **Issue:**
119
- ```typescript
120
- const query = `SELECT * FROM users WHERE email = '${email}'`;
121
- const user = await db.query(query);
122
- ```
123
-
124
- **Problem:** Direct string interpolation allows SQL injection attacks.
125
-
126
- **Fix:**
127
- ```typescript
128
- const user = await db.users.findUnique({
129
- where: { email }
130
- });
131
- ```
132
-
133
- **Rationale:** Parameterized queries prevent SQL injection by separating code from data.
134
-
135
- ---
136
-
137
- ### 2. Exposed API Keys
138
- **File:** `config/api.ts:12`
139
- **Severity:** 🔴 Critical
140
-
141
- **Issue:**
142
- ```typescript
143
- const STRIPE_KEY = "sk_live_abc123";
144
- ```
145
-
146
- **Problem:** Hardcoded production secret in source code.
147
-
148
- **Fix:**
149
- ```typescript
150
- const STRIPE_KEY = process.env.STRIPE_SECRET_KEY;
151
- if (!STRIPE_KEY) {
152
- throw new Error('STRIPE_SECRET_KEY not configured');
153
- }
154
- ```
155
-
156
- ---
157
-
158
- ## High Priority Issues
159
-
160
- ### 3. Missing Error Handling
161
- **File:** `api/payment.ts:78`
162
- **Severity:** 🟠 High
163
-
164
- **Issue:**
165
- ```typescript
166
- async function processPayment(amount: number) {
167
- const result = await stripe.charges.create({ amount });
168
- return result;
169
- }
170
- ```
171
-
172
- **Problem:** No error handling for payment failures.
173
-
174
- **Fix:**
175
- ```typescript
176
- async function processPayment(amount: number) {
177
- try {
178
- const result = await stripe.charges.create({ amount });
179
- return { success: true, data: result };
180
- } catch (error) {
181
- logger.error('Payment failed', { error, amount });
182
- throw new PaymentError('Payment processing failed');
183
- }
184
- }
185
- ```
186
-
187
- ---
188
-
189
- ### 4. N+1 Query Problem
190
- **File:** `api/posts.ts:34`
191
- **Severity:** 🟠 High
192
-
193
- **Issue:**
194
- ```typescript
195
- const posts = await db.posts.findMany();
196
- for (const post of posts) {
197
- post.author = await db.users.findUnique({
198
- where: { id: post.authorId }
199
- });
200
- }
201
- ```
202
-
203
- **Problem:** Executes N+1 database queries (very slow).
204
-
205
- **Fix:**
206
- ```typescript
207
- const posts = await db.posts.findMany({
208
- include: { author: true }
209
- });
210
- ```
211
-
212
- **Impact:** 10-100x performance improvement.
213
-
214
- ---
215
-
216
- ## Medium Priority
217
-
218
- ### 5. Long Function (120 lines)
219
- **File:** `utils/validation.ts:15`
220
- **Severity:** 🟡 Medium
221
-
222
- **Recommendation:** Split into smaller functions:
223
- - `validateEmail()`
224
- - `validatePassword()`
225
- - `validateUserData()`
226
-
227
- **Benefits:** Easier to test, understand, and maintain.
228
-
229
- ---
230
-
231
- ### 6. Magic Numbers
232
- **File:** `cache.ts:23`
233
- **Severity:** 🟡 Medium
234
-
235
- **Issue:**
236
- ```typescript
237
- cache.set(key, value, 3600);
238
- ```
239
-
240
- **Fix:**
241
- ```typescript
242
- const CACHE_TTL_SECONDS = 60 * 60; // 1 hour
243
- cache.set(key, value, CACHE_TTL_SECONDS);
244
- ```
245
-
246
- ---
247
-
248
- ## Positive Observations
249
-
250
- ✅ Good error messages with context
251
- ✅ Comprehensive input validation in auth
252
- ✅ Well-structured database schema
253
- ✅ Good test coverage (87%)
254
-
255
- ## Refactoring Opportunities
256
-
257
- ### Duplicate Logic
258
- Similar validation in:
259
- - `api/users.ts:45-67`
260
- - `api/products.ts:34-56`
261
- - `api/orders.ts:23-45`
262
-
263
- **Recommendation:** Create shared `validateRequest()` utility.
264
-
265
- ---
266
-
267
- ## Testing Gaps
268
-
269
- **Files lacking tests:**
270
- - ⚠️ `api/webhooks.ts` (0% coverage)
271
- - ⚠️ `utils/legacy.ts` (45%)
272
-
273
- **Recommendation:** Prioritize webhook testing (security-critical).
274
-
275
- ---
276
-
277
- ## Security Score: 6/10
278
-
279
- **Strengths:**
280
- - ✅ Password hashing (bcrypt)
281
- - ✅ HTTPS enforced
282
- - ✅ CORS configured
283
-
284
- **Weaknesses:**
285
- - ❌ SQL injection vulnerability
286
- - ❌ Exposed API keys
287
- - ❌ Missing rate limiting
288
- - ❌ No CSRF protection
289
-
290
- ---
291
-
292
- ## Next Steps
293
-
294
- ### Immediate (Critical)
295
- 1. Fix SQL injection in `auth/login.ts:45`
296
- 2. Move API keys to environment variables
297
- 3. Add rate limiting
298
-
299
- ### Short Term (High)
300
- 1. Fix N+1 queries
301
- 2. Add error handling to payments
302
- 3. Implement CSRF protection
303
-
304
- ### Long Term (Medium)
305
- 1. Refactor long functions
306
- 2. Extract duplicate logic
307
- 3. Add missing tests
308
- ```
309
-
310
- ## Review Checklist
311
-
312
- ### Security
313
- - ✅ No SQL injection vulnerabilities
314
- - ✅ No XSS vulnerabilities
315
- - ✅ No hardcoded secrets
316
- - ✅ Proper authentication/authorization
317
- - ✅ Input validation everywhere
318
- - ✅ Error messages don't leak data
319
- - ✅ OWASP Top 10 compliance
320
-
321
- ### Code Quality
322
- - ✅ Functions < 50 lines
323
- - ✅ Clear naming
324
- - ✅ Single responsibility
325
- - ✅ Proper error handling
326
- - ✅ Type safety
327
- - ✅ No code duplication
328
-
329
- ### Performance
330
- - ✅ No N+1 queries
331
- - ✅ Efficient algorithms
332
- - ✅ Appropriate caching
333
- - ✅ No memory leaks
334
- - ✅ Database indexes exist
335
-
336
- ### Testing
337
- - ✅ >80% coverage
338
- - ✅ Critical paths 100% covered
339
- - ✅ Security tests exist
340
-
341
- ### Documentation
342
- - ✅ Public APIs documented
343
- - ✅ Complex logic commented
344
- - ✅ README up to date
345
-
346
- ## Integration with Other Commands
347
-
348
- **/ai-sprint-code** → **/ai-sprint-review**
349
- - After code generation, review for quality
350
-
351
- **/ai-sprint-review** → **/ai-sprint-secure**
352
- - Review identifies issues, security scan validates
353
-
354
- **/ai-sprint-review** → **/ai-sprint-test**
355
- - Review suggests missing tests
356
-
357
- ## Common Code Smells
358
-
359
- ### Long Functions
360
- ```typescript
361
- // ❌ Bad - 200 lines
362
- function processOrder() {
363
- // Too much logic
364
- }
365
-
366
- // ✅ Good - Split up
367
- function processOrder() {
368
- validateOrder();
369
- calculateTotal();
370
- processPayment();
371
- sendConfirmation();
372
- }
373
- ```
374
-
375
- ### Deep Nesting
376
- ```typescript
377
- // ❌ Bad - 4 levels deep
378
- if (user) {
379
- if (user.isActive) {
380
- if (user.hasPermission) {
381
- if (user.credits > 0) {
382
- // Do something
383
- }
384
- }
385
- }
386
- }
387
-
388
- // ✅ Good - Early returns
389
- if (!user) return;
390
- if (!user.isActive) return;
391
- if (!user.hasPermission) return;
392
- if (user.credits <= 0) return;
393
- // Do something
394
- ```
395
-
396
- ### God Objects
397
- ```typescript
398
- // ❌ Bad - Does everything
399
- class UserManager {
400
- createUser() {}
401
- deleteUser() {}
402
- sendEmail() {}
403
- processPayment() {}
404
- generateReport() {}
405
- }
406
-
407
- // ✅ Good - Single responsibility
408
- class UserService {}
409
- class EmailService {}
410
- class PaymentService {}
411
- class ReportService {}
412
- ```
413
-
414
- ## Success Criteria
415
-
416
- Review is successful when:
417
- - ✅ All critical issues identified
418
- - ✅ Specific fixes provided
419
- - ✅ Security thoroughly checked
420
- - ✅ Performance analyzed
421
- - ✅ Actionable recommendations
422
- - ✅ Positive feedback included
423
-
424
- ## Remember
425
-
426
- **Code review is collaborative:**
427
- - Make code better
428
- - Share knowledge
429
- - Maintain quality
430
- - Prevent bugs
431
- - Team alignment
432
-
433
- **Be respectful, specific, and constructive.**
@@ -1,146 +0,0 @@
1
- ---
2
- description: Scan codebase and update AI context documents
3
- argument-hint: [--full]
4
- ---
5
-
6
- # /ai-sprint-scan Command
7
-
8
- Scan the codebase and generate/update AI context documents for agent reference.
9
-
10
- ## What It Does
11
-
12
- 1. **Detects source code** - Finds src/, app/, lib/, and other code directories
13
- 2. **Runs Repomix** - Packages codebase into token-efficient format
14
- 3. **Generates structure** - Creates directory tree overview
15
- 4. **Updates metadata** - Records file count, token stats, timestamp
16
-
17
- ## Output Location
18
-
19
- ```
20
- ai_context/
21
- └── codebase/
22
- ├── overview.md # Human-readable compressed codebase
23
- ├── structure.md # Directory tree
24
- ├── repomix-output.xml # Token-efficient XML for AI consumption
25
- ├── scan-metadata.json # Stats (files, tokens, timestamp)
26
- └── .repomixignore # Custom exclude patterns
27
- ```
28
-
29
- ## Usage
30
-
31
- ```bash
32
- # Quick scan (default)
33
- /ai-sprint-scan
34
-
35
- # Full rescan (regenerate all files)
36
- /ai-sprint-scan --full
37
- ```
38
-
39
- ## When to Use
40
-
41
- - **After major changes** - New features, refactoring, file reorganization
42
- - **Before starting work** - Ensure agents have current codebase context
43
- - **After pulling changes** - Update context with team's changes
44
- - **Debugging agent confusion** - Refresh stale context
45
-
46
- ## Workflow
47
-
48
- Execute the following steps:
49
-
50
- ### Step 1: Check Current State
51
-
52
- ```bash
53
- # Check if ai_context/ai-sprint-codebase/ exists
54
- ls -la ai_context/ai-sprint-codebase/ 2>/dev/null || echo "No existing scan found"
55
- ```
56
-
57
- ### Step 2: Run Codebase Scan
58
-
59
- Use the `ai-sprint-kit scan` CLI command or run repomix directly:
60
-
61
- ```bash
62
- # Option A: Use AI Sprint CLI (if available)
63
- ai-sprint-kit scan
64
-
65
- # Option B: Run repomix directly
66
- npx repomix --compress --style xml -o ai_context/ai-sprint-codebase/repomix-output.xml
67
- npx repomix --compress --style markdown -o ai_context/ai-sprint-codebase/overview.md
68
- ```
69
-
70
- ### Step 3: Generate Structure
71
-
72
- ```bash
73
- # Generate directory tree
74
- tree -I 'node_modules|.git|.venv|__pycache__|dist|build' -L 4 > ai_context/ai-sprint-codebase/structure.md 2>/dev/null || \
75
- find . -type f -name "*.ts" -o -name "*.js" -o -name "*.py" | head -50 > ai_context/ai-sprint-codebase/structure.md
76
- ```
77
-
78
- ### Step 4: Update Metadata
79
-
80
- Create `ai_context/ai-sprint-codebase/ai-sprint-scan-metadata.json` with:
81
- - scanDate: Current timestamp
82
- - totalFiles: Number of files scanned
83
- - scanDuration: Time taken
84
-
85
- ### Step 5: Report Results
86
-
87
- Provide summary:
88
- - Files scanned
89
- - Token count (if available)
90
- - Output location
91
- - Any warnings or errors
92
-
93
- ## Customization
94
-
95
- ### Exclude Patterns
96
-
97
- Edit `ai_context/ai-sprint-codebase/.repomixignore` to exclude files:
98
-
99
- ```
100
- # Add custom patterns
101
- docs/archive/
102
- *.generated.ts
103
- legacy/
104
- ```
105
-
106
- ### Include Specific Directories
107
-
108
- For large monorepos, scan specific directories:
109
-
110
- ```bash
111
- npx repomix src/ lib/ --compress -o ai_context/ai-sprint-codebase/repomix-output.xml
112
- ```
113
-
114
- ## Token Efficiency
115
-
116
- Repomix compression achieves ~70% token reduction:
117
- - Removes implementation details, keeps signatures
118
- - Preserves semantic structure (classes, functions, types)
119
- - Uses Tree-sitter AST analysis
120
-
121
- **Example:**
122
- - Raw codebase: 100,000 tokens
123
- - Compressed: ~30,000 tokens
124
- - Savings: 70,000 tokens per agent context load
125
-
126
- ## Security
127
-
128
- Repomix includes Secretlint for credential detection:
129
- - Scans for API keys, tokens, passwords
130
- - Warns if secrets detected
131
- - Prevents accidental exposure in AI context
132
-
133
- ## Troubleshooting
134
-
135
- | Issue | Solution |
136
- |-------|----------|
137
- | "repomix not found" | Install: `npm install -g repomix` |
138
- | Scan takes too long | Add exclusions to .repomixignore |
139
- | Large output file | Use `--compress` flag or exclude directories |
140
- | Missing files | Check .gitignore and .repomixignore patterns |
141
-
142
- ## Related Commands
143
-
144
- - `/ai-sprint-plan` - Create implementation plans using scanned context
145
- - `/ai-sprint-code` - Generate code with codebase awareness
146
- - `/ai-sprint-debug` - Investigate issues with full context
@@ -1,88 +0,0 @@
1
- ---
2
- description: Run comprehensive security scan (SAST + secrets + dependencies)
3
- argument-hint: [path or scope]
4
- ---
5
-
6
- ## Command: /ai-sprint-secure
7
-
8
- Run security scans to detect vulnerabilities, secrets, and dependency issues.
9
-
10
- ## Usage
11
-
12
- ```
13
- /ai-sprint-secure
14
- /ai-sprint-secure src/
15
- /ai-sprint-secure --full
16
- ```
17
-
18
- ## Scan Types
19
-
20
- ### 1. SAST (Static Application Security Testing)
21
- - Code vulnerabilities
22
- - Security anti-patterns
23
- - Injection flaws
24
- - Authentication issues
25
-
26
- ### 2. Secret Detection
27
- - Hardcoded API keys
28
- - Passwords
29
- - Private keys
30
- - Tokens
31
- - Connection strings
32
-
33
- ### 3. Dependency Check
34
- - Known CVEs
35
- - Vulnerable packages
36
- - Outdated dependencies
37
- - Security advisories
38
-
39
- ### 4. OWASP Top 10 Compliance
40
- - Broken Access Control
41
- - Cryptographic Failures
42
- - Injection vulnerabilities
43
- - Security misconfigurations
44
-
45
- ## Workflow
46
-
47
- 1. **Delegate** to security agent
48
- 2. **Run** all security scans
49
- 3. **Analyze** findings
50
- 4. **Prioritize** by severity
51
- 5. **Report** results with remediation
52
-
53
- ## Output
54
-
55
- ```markdown
56
- # Security Scan Report
57
-
58
- ## Summary
59
- - Critical: X findings
60
- - High: X findings
61
- - Medium: X findings
62
- - Low: X findings
63
-
64
- ## Critical Issues
65
- [File:Line] - [Description]
66
- [Remediation steps]
67
-
68
- ## Secrets Found
69
- [File:Line] - [Type of secret]
70
- [How to fix]
71
-
72
- ## Vulnerable Dependencies
73
- [Package] - [CVE]
74
- [Update command]
75
- ```
76
-
77
- ## Exit Codes
78
-
79
- - `0` - No issues found
80
- - `1` - Low/Medium severity found
81
- - `2` - High severity found
82
- - `3` - Critical severity found
83
-
84
- ## Next Steps
85
-
86
- 1. Fix critical issues immediately
87
- 2. Address high severity before deployment
88
- 3. Plan medium/low fixes for next sprint