ai-sprint-kit 1.1.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 (59) hide show
  1. package/README.md +299 -0
  2. package/bin/cli.js +135 -0
  3. package/lib/installer.js +205 -0
  4. package/lib/scanner.js +341 -0
  5. package/package.json +55 -0
  6. package/templates/.claude/.env.example +13 -0
  7. package/templates/.claude/agents/debugger.md +667 -0
  8. package/templates/.claude/agents/devops.md +727 -0
  9. package/templates/.claude/agents/docs.md +661 -0
  10. package/templates/.claude/agents/implementer.md +235 -0
  11. package/templates/.claude/agents/planner.md +243 -0
  12. package/templates/.claude/agents/researcher.md +448 -0
  13. package/templates/.claude/agents/reviewer.md +610 -0
  14. package/templates/.claude/agents/security.md +202 -0
  15. package/templates/.claude/agents/tester.md +604 -0
  16. package/templates/.claude/commands/auto.md +85 -0
  17. package/templates/.claude/commands/code.md +301 -0
  18. package/templates/.claude/commands/debug.md +449 -0
  19. package/templates/.claude/commands/deploy.md +475 -0
  20. package/templates/.claude/commands/docs.md +519 -0
  21. package/templates/.claude/commands/plan.md +57 -0
  22. package/templates/.claude/commands/review.md +412 -0
  23. package/templates/.claude/commands/scan.md +146 -0
  24. package/templates/.claude/commands/secure.md +88 -0
  25. package/templates/.claude/commands/test.md +352 -0
  26. package/templates/.claude/commands/validate.md +238 -0
  27. package/templates/.claude/settings.json +27 -0
  28. package/templates/.claude/skills/codebase-context/SKILL.md +68 -0
  29. package/templates/.claude/skills/codebase-context/references/reading-context.md +68 -0
  30. package/templates/.claude/skills/codebase-context/references/refresh-triggers.md +82 -0
  31. package/templates/.claude/skills/implementation/SKILL.md +70 -0
  32. package/templates/.claude/skills/implementation/references/error-handling.md +106 -0
  33. package/templates/.claude/skills/implementation/references/security-patterns.md +73 -0
  34. package/templates/.claude/skills/implementation/references/validation-patterns.md +107 -0
  35. package/templates/.claude/skills/memory/SKILL.md +67 -0
  36. package/templates/.claude/skills/memory/references/decisions-format.md +68 -0
  37. package/templates/.claude/skills/memory/references/learning-format.md +74 -0
  38. package/templates/.claude/skills/planning/SKILL.md +72 -0
  39. package/templates/.claude/skills/planning/references/plan-templates.md +81 -0
  40. package/templates/.claude/skills/planning/references/research-phase.md +62 -0
  41. package/templates/.claude/skills/planning/references/solution-design.md +66 -0
  42. package/templates/.claude/skills/quality-assurance/SKILL.md +79 -0
  43. package/templates/.claude/skills/quality-assurance/references/review-checklist.md +72 -0
  44. package/templates/.claude/skills/quality-assurance/references/security-checklist.md +70 -0
  45. package/templates/.claude/skills/quality-assurance/references/testing-strategy.md +85 -0
  46. package/templates/.claude/statusline.sh +126 -0
  47. package/templates/.claude/workflows/development-rules.md +97 -0
  48. package/templates/.claude/workflows/orchestration-protocol.md +194 -0
  49. package/templates/.mcp.json.example +36 -0
  50. package/templates/CLAUDE.md +409 -0
  51. package/templates/README.md +331 -0
  52. package/templates/ai_context/codebase/.gitkeep +0 -0
  53. package/templates/ai_context/memory/active.md +15 -0
  54. package/templates/ai_context/memory/decisions.md +18 -0
  55. package/templates/ai_context/memory/learning.md +22 -0
  56. package/templates/ai_context/plans/.gitkeep +0 -0
  57. package/templates/ai_context/reports/.gitkeep +0 -0
  58. package/templates/docs/user-guide-th.md +454 -0
  59. package/templates/docs/user-guide.md +595 -0
@@ -0,0 +1,412 @@
1
+ ---
2
+ description: Comprehensive code quality review and best practices analysis
3
+ argument-hint: [optional: specific file or directory to review]
4
+ ---
5
+
6
+ ## Command: /review
7
+
8
+ Perform comprehensive code quality review focusing on security, maintainability, performance, and best practices.
9
+
10
+ ## Usage
11
+
12
+ ```
13
+ /review
14
+ /review src/
15
+ /review src/auth/login.ts
16
+ ```
17
+
18
+ ## Workflow
19
+
20
+ ### 1. Code Analysis
21
+ - Review code structure
22
+ - Check for code smells
23
+ - Identify security issues
24
+ - Analyze performance
25
+
26
+ ### 2. Security Review (Critical)
27
+ - OWASP Top 10 compliance
28
+ - SQL injection vulnerabilities
29
+ - XSS vulnerabilities
30
+ - Auth/authorization issues
31
+ - Secret exposure
32
+ - Input validation
33
+
34
+ ### 3. Quality Check
35
+ - Code maintainability
36
+ - Proper error handling
37
+ - Type safety
38
+ - Performance optimization
39
+ - Best practices
40
+
41
+ ### 4. Generate Report
42
+ - Critical issues (must fix)
43
+ - High priority issues
44
+ - Medium priority suggestions
45
+ - Low priority improvements
46
+ - Positive observations
47
+
48
+ ## Review Categories
49
+
50
+ ### 🔴 Critical Issues (Must Fix)
51
+ - Security vulnerabilities
52
+ - Data loss potential
53
+ - Crash bugs
54
+ - Performance killers
55
+
56
+ ### 🟠 High Priority
57
+ - Logic errors
58
+ - Missing error handling
59
+ - Performance problems
60
+ - Maintainability issues
61
+
62
+ ### 🟡 Medium Priority
63
+ - Code smells
64
+ - Refactoring opportunities
65
+ - Documentation gaps
66
+
67
+ ### 🟢 Low Priority
68
+ - Style improvements
69
+ - Minor optimizations
70
+ - Naming suggestions
71
+
72
+ ## Example Review Report
73
+
74
+ ```markdown
75
+ # Code Review Report
76
+
77
+ **Date:** 2025-12-24
78
+ **Scope:** src/auth/
79
+ **Overall Assessment:** Needs Improvement
80
+
81
+ **Summary:**
82
+ - 2 Critical issues
83
+ - 4 High priority issues
84
+ - 6 Medium priority issues
85
+ - 3 Low priority suggestions
86
+
87
+ **Recommendation:** Fix critical issues before deployment
88
+
89
+ ---
90
+
91
+ ## Critical Issues
92
+
93
+ ### 1. SQL Injection Vulnerability
94
+ **File:** `auth/login.ts:45`
95
+ **Severity:** 🔴 Critical
96
+
97
+ **Issue:**
98
+ ```typescript
99
+ const query = `SELECT * FROM users WHERE email = '${email}'`;
100
+ const user = await db.query(query);
101
+ ```
102
+
103
+ **Problem:** Direct string interpolation allows SQL injection attacks.
104
+
105
+ **Fix:**
106
+ ```typescript
107
+ const user = await db.users.findUnique({
108
+ where: { email }
109
+ });
110
+ ```
111
+
112
+ **Rationale:** Parameterized queries prevent SQL injection by separating code from data.
113
+
114
+ ---
115
+
116
+ ### 2. Exposed API Keys
117
+ **File:** `config/api.ts:12`
118
+ **Severity:** 🔴 Critical
119
+
120
+ **Issue:**
121
+ ```typescript
122
+ const STRIPE_KEY = "sk_live_abc123";
123
+ ```
124
+
125
+ **Problem:** Hardcoded production secret in source code.
126
+
127
+ **Fix:**
128
+ ```typescript
129
+ const STRIPE_KEY = process.env.STRIPE_SECRET_KEY;
130
+ if (!STRIPE_KEY) {
131
+ throw new Error('STRIPE_SECRET_KEY not configured');
132
+ }
133
+ ```
134
+
135
+ ---
136
+
137
+ ## High Priority Issues
138
+
139
+ ### 3. Missing Error Handling
140
+ **File:** `api/payment.ts:78`
141
+ **Severity:** 🟠 High
142
+
143
+ **Issue:**
144
+ ```typescript
145
+ async function processPayment(amount: number) {
146
+ const result = await stripe.charges.create({ amount });
147
+ return result;
148
+ }
149
+ ```
150
+
151
+ **Problem:** No error handling for payment failures.
152
+
153
+ **Fix:**
154
+ ```typescript
155
+ async function processPayment(amount: number) {
156
+ try {
157
+ const result = await stripe.charges.create({ amount });
158
+ return { success: true, data: result };
159
+ } catch (error) {
160
+ logger.error('Payment failed', { error, amount });
161
+ throw new PaymentError('Payment processing failed');
162
+ }
163
+ }
164
+ ```
165
+
166
+ ---
167
+
168
+ ### 4. N+1 Query Problem
169
+ **File:** `api/posts.ts:34`
170
+ **Severity:** 🟠 High
171
+
172
+ **Issue:**
173
+ ```typescript
174
+ const posts = await db.posts.findMany();
175
+ for (const post of posts) {
176
+ post.author = await db.users.findUnique({
177
+ where: { id: post.authorId }
178
+ });
179
+ }
180
+ ```
181
+
182
+ **Problem:** Executes N+1 database queries (very slow).
183
+
184
+ **Fix:**
185
+ ```typescript
186
+ const posts = await db.posts.findMany({
187
+ include: { author: true }
188
+ });
189
+ ```
190
+
191
+ **Impact:** 10-100x performance improvement.
192
+
193
+ ---
194
+
195
+ ## Medium Priority
196
+
197
+ ### 5. Long Function (120 lines)
198
+ **File:** `utils/validation.ts:15`
199
+ **Severity:** 🟡 Medium
200
+
201
+ **Recommendation:** Split into smaller functions:
202
+ - `validateEmail()`
203
+ - `validatePassword()`
204
+ - `validateUserData()`
205
+
206
+ **Benefits:** Easier to test, understand, and maintain.
207
+
208
+ ---
209
+
210
+ ### 6. Magic Numbers
211
+ **File:** `cache.ts:23`
212
+ **Severity:** 🟡 Medium
213
+
214
+ **Issue:**
215
+ ```typescript
216
+ cache.set(key, value, 3600);
217
+ ```
218
+
219
+ **Fix:**
220
+ ```typescript
221
+ const CACHE_TTL_SECONDS = 60 * 60; // 1 hour
222
+ cache.set(key, value, CACHE_TTL_SECONDS);
223
+ ```
224
+
225
+ ---
226
+
227
+ ## Positive Observations
228
+
229
+ ✅ Good error messages with context
230
+ ✅ Comprehensive input validation in auth
231
+ ✅ Well-structured database schema
232
+ ✅ Good test coverage (87%)
233
+
234
+ ## Refactoring Opportunities
235
+
236
+ ### Duplicate Logic
237
+ Similar validation in:
238
+ - `api/users.ts:45-67`
239
+ - `api/products.ts:34-56`
240
+ - `api/orders.ts:23-45`
241
+
242
+ **Recommendation:** Create shared `validateRequest()` utility.
243
+
244
+ ---
245
+
246
+ ## Testing Gaps
247
+
248
+ **Files lacking tests:**
249
+ - ⚠️ `api/webhooks.ts` (0% coverage)
250
+ - ⚠️ `utils/legacy.ts` (45%)
251
+
252
+ **Recommendation:** Prioritize webhook testing (security-critical).
253
+
254
+ ---
255
+
256
+ ## Security Score: 6/10
257
+
258
+ **Strengths:**
259
+ - ✅ Password hashing (bcrypt)
260
+ - ✅ HTTPS enforced
261
+ - ✅ CORS configured
262
+
263
+ **Weaknesses:**
264
+ - ❌ SQL injection vulnerability
265
+ - ❌ Exposed API keys
266
+ - ❌ Missing rate limiting
267
+ - ❌ No CSRF protection
268
+
269
+ ---
270
+
271
+ ## Next Steps
272
+
273
+ ### Immediate (Critical)
274
+ 1. Fix SQL injection in `auth/login.ts:45`
275
+ 2. Move API keys to environment variables
276
+ 3. Add rate limiting
277
+
278
+ ### Short Term (High)
279
+ 1. Fix N+1 queries
280
+ 2. Add error handling to payments
281
+ 3. Implement CSRF protection
282
+
283
+ ### Long Term (Medium)
284
+ 1. Refactor long functions
285
+ 2. Extract duplicate logic
286
+ 3. Add missing tests
287
+ ```
288
+
289
+ ## Review Checklist
290
+
291
+ ### Security
292
+ - ✅ No SQL injection vulnerabilities
293
+ - ✅ No XSS vulnerabilities
294
+ - ✅ No hardcoded secrets
295
+ - ✅ Proper authentication/authorization
296
+ - ✅ Input validation everywhere
297
+ - ✅ Error messages don't leak data
298
+ - ✅ OWASP Top 10 compliance
299
+
300
+ ### Code Quality
301
+ - ✅ Functions < 50 lines
302
+ - ✅ Clear naming
303
+ - ✅ Single responsibility
304
+ - ✅ Proper error handling
305
+ - ✅ Type safety
306
+ - ✅ No code duplication
307
+
308
+ ### Performance
309
+ - ✅ No N+1 queries
310
+ - ✅ Efficient algorithms
311
+ - ✅ Appropriate caching
312
+ - ✅ No memory leaks
313
+ - ✅ Database indexes exist
314
+
315
+ ### Testing
316
+ - ✅ >80% coverage
317
+ - ✅ Critical paths 100% covered
318
+ - ✅ Security tests exist
319
+
320
+ ### Documentation
321
+ - ✅ Public APIs documented
322
+ - ✅ Complex logic commented
323
+ - ✅ README up to date
324
+
325
+ ## Integration with Other Commands
326
+
327
+ **/code** → **/review**
328
+ - After code generation, review for quality
329
+
330
+ **/review** → **/secure**
331
+ - Review identifies issues, security scan validates
332
+
333
+ **/review** → **/test**
334
+ - Review suggests missing tests
335
+
336
+ ## Common Code Smells
337
+
338
+ ### Long Functions
339
+ ```typescript
340
+ // ❌ Bad - 200 lines
341
+ function processOrder() {
342
+ // Too much logic
343
+ }
344
+
345
+ // ✅ Good - Split up
346
+ function processOrder() {
347
+ validateOrder();
348
+ calculateTotal();
349
+ processPayment();
350
+ sendConfirmation();
351
+ }
352
+ ```
353
+
354
+ ### Deep Nesting
355
+ ```typescript
356
+ // ❌ Bad - 4 levels deep
357
+ if (user) {
358
+ if (user.isActive) {
359
+ if (user.hasPermission) {
360
+ if (user.credits > 0) {
361
+ // Do something
362
+ }
363
+ }
364
+ }
365
+ }
366
+
367
+ // ✅ Good - Early returns
368
+ if (!user) return;
369
+ if (!user.isActive) return;
370
+ if (!user.hasPermission) return;
371
+ if (user.credits <= 0) return;
372
+ // Do something
373
+ ```
374
+
375
+ ### God Objects
376
+ ```typescript
377
+ // ❌ Bad - Does everything
378
+ class UserManager {
379
+ createUser() {}
380
+ deleteUser() {}
381
+ sendEmail() {}
382
+ processPayment() {}
383
+ generateReport() {}
384
+ }
385
+
386
+ // ✅ Good - Single responsibility
387
+ class UserService {}
388
+ class EmailService {}
389
+ class PaymentService {}
390
+ class ReportService {}
391
+ ```
392
+
393
+ ## Success Criteria
394
+
395
+ Review is successful when:
396
+ - ✅ All critical issues identified
397
+ - ✅ Specific fixes provided
398
+ - ✅ Security thoroughly checked
399
+ - ✅ Performance analyzed
400
+ - ✅ Actionable recommendations
401
+ - ✅ Positive feedback included
402
+
403
+ ## Remember
404
+
405
+ **Code review is collaborative:**
406
+ - Make code better
407
+ - Share knowledge
408
+ - Maintain quality
409
+ - Prevent bugs
410
+ - Team alignment
411
+
412
+ **Be respectful, specific, and constructive.**
@@ -0,0 +1,146 @@
1
+ ---
2
+ description: Scan codebase and update AI context documents
3
+ argument-hint: [--full]
4
+ ---
5
+
6
+ # /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
+ /scan
34
+
35
+ # Full rescan (regenerate all files)
36
+ /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/codebase/ exists
54
+ ls -la ai_context/codebase/ 2>/dev/null || echo "No existing scan found"
55
+ ```
56
+
57
+ ### Step 2: Run Codebase Scan
58
+
59
+ Use the `ai-sprint scan` CLI command or run repomix directly:
60
+
61
+ ```bash
62
+ # Option A: Use AI Sprint CLI (if available)
63
+ ai-sprint scan
64
+
65
+ # Option B: Run repomix directly
66
+ npx repomix --compress --style xml -o ai_context/codebase/repomix-output.xml
67
+ npx repomix --compress --style markdown -o ai_context/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/codebase/structure.md 2>/dev/null || \
75
+ find . -type f -name "*.ts" -o -name "*.js" -o -name "*.py" | head -50 > ai_context/codebase/structure.md
76
+ ```
77
+
78
+ ### Step 4: Update Metadata
79
+
80
+ Create `ai_context/codebase/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/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/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
+ - `/plan` - Create implementation plans using scanned context
145
+ - `/code` - Generate code with codebase awareness
146
+ - `/debug` - Investigate issues with full context
@@ -0,0 +1,88 @@
1
+ ---
2
+ description: Run comprehensive security scan (SAST + secrets + dependencies)
3
+ argument-hint: [path or scope]
4
+ ---
5
+
6
+ ## Command: /secure
7
+
8
+ Run security scans to detect vulnerabilities, secrets, and dependency issues.
9
+
10
+ ## Usage
11
+
12
+ ```
13
+ /secure
14
+ /secure src/
15
+ /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