ai-sprint-kit 1.3.0 → 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 +62 -174
  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 -341
  10. package/templates/.claude/.env.example +0 -13
  11. package/templates/.claude/agents/debugger.md +0 -667
  12. package/templates/.claude/agents/devops.md +0 -727
  13. package/templates/.claude/agents/docs.md +0 -661
  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 -453
  17. package/templates/.claude/agents/reviewer.md +0 -643
  18. package/templates/.claude/agents/security.md +0 -202
  19. package/templates/.claude/agents/tester.md +0 -646
  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 -409
  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,453 +0,0 @@
1
- ---
2
- description: Investigate and fix bugs with root cause analysis
3
- argument-hint: [bug description or error message]
4
- ---
5
-
6
- **THINK HARDER** - Systematic root cause analysis requires careful investigation.
7
-
8
- **Objective:** $ARGUMENTS
9
-
10
- ## Command: /ai-sprint-debug
11
-
12
- Systematically investigate bugs, perform root cause analysis, and provide fixes with regression tests.
13
-
14
- ## Usage
15
-
16
- ```
17
- /ai-sprint-debug "users can't login"
18
- /ai-sprint-debug "500 error on checkout"
19
- /ai-sprint-debug "memory leak in WebSocket handler"
20
- /ai-sprint-debug "database query is slow"
21
- ```
22
-
23
- ## Workflow
24
-
25
- ### 0. Initialize Context
26
- - Get timestamp: `date "+%y%m%d-%H%M"` (DO NOT guess dates)
27
- - Check `ai_context/memory/learning.md` for known bug patterns
28
-
29
- ### 1. Understand the Problem
30
- - What's the expected behavior?
31
- - What's the actual behavior?
32
- - When did it start?
33
- - Can it be reproduced?
34
- - Any error messages/stack traces?
35
-
36
- ### 2. Reproduce the Bug
37
- - Find minimal reproduction steps
38
- - Document exact conditions
39
- - Identify patterns (timing, data, environment)
40
-
41
- ### 3. Investigate Root Cause
42
- - Analyze error messages
43
- - Check logs (app, server, database)
44
- - Review recent changes
45
- - Use debugging tools
46
-
47
- ### 4. Fix the Bug
48
- - Implement minimal fix
49
- - Test thoroughly
50
- - Add regression test
51
- - Document the fix
52
-
53
- ## Debugging Process
54
-
55
- ### Phase 1: Gather Information
56
- ```markdown
57
- ## Bug Report
58
-
59
- **Error:** "Cannot read property 'name' of undefined"
60
-
61
- **Expected:** User profile displays name
62
- **Actual:** Application crashes
63
-
64
- **Reproduction:**
65
- 1. Go to /profile
66
- 2. Click "Edit Profile"
67
- 3. Error occurs
68
-
69
- **Stack Trace:**
70
- ```
71
- Error: Cannot read property 'name' of undefined
72
- at ProfilePage (app/profile/page.tsx:45)
73
- at renderComponent (react.js:123)
74
- ```
75
-
76
- **Logs:**
77
- ```
78
- [ERROR] User data undefined for ID: user_123
79
- [DEBUG] Database query returned null
80
- ```
81
- ```
82
-
83
- ### Phase 2: Analyze Root Cause
84
- ```typescript
85
- // Bug location: app/profile/page.tsx:45
86
- function ProfilePage() {
87
- const user = await getUser(userId);
88
- return <div>{user.name}</div>; // ← Crashes here if user is null
89
- }
90
- ```
91
-
92
- **Root Cause:** No null check after database query.
93
-
94
- ### Phase 3: Implement Fix
95
- ```typescript
96
- // Fixed version
97
- async function ProfilePage() {
98
- const user = await getUser(userId);
99
-
100
- if (!user) {
101
- throw new NotFoundError('User not found');
102
- }
103
-
104
- return <div>{user.name}</div>;
105
- }
106
- ```
107
-
108
- ### Phase 4: Add Regression Test
109
- ```typescript
110
- test('handles missing user gracefully', async () => {
111
- const response = await request(app)
112
- .get('/profile/invalid-user-id');
113
-
114
- expect(response.status).toBe(404);
115
- expect(response.body.error).toContain('User not found');
116
- });
117
- ```
118
-
119
- ## Common Bug Patterns
120
-
121
- ### 1. Null/Undefined Errors
122
- ```typescript
123
- // Bug
124
- function getUser(id) {
125
- const user = users.find(u => u.id === id);
126
- return user.name; // Error if user is undefined
127
- }
128
-
129
- // Fix
130
- function getUser(id) {
131
- const user = users.find(u => u.id === id);
132
- if (!user) {
133
- throw new NotFoundError(`User ${id} not found`);
134
- }
135
- return user.name;
136
- }
137
- ```
138
-
139
- ### 2. Race Conditions
140
- ```typescript
141
- // Bug
142
- let count = 0;
143
- async function increment() {
144
- const current = count;
145
- await delay(10);
146
- count = current + 1; // Race condition
147
- }
148
-
149
- // Fix (use atomic operations)
150
- let count = 0;
151
- const lock = new AsyncLock();
152
-
153
- async function increment() {
154
- await lock.acquire('count', async () => {
155
- count++;
156
- });
157
- }
158
- ```
159
-
160
- ### 3. Memory Leaks
161
- ```typescript
162
- // Bug - event listener not removed
163
- class Component {
164
- constructor() {
165
- window.addEventListener('resize', this.handleResize);
166
- }
167
- }
168
-
169
- // Fix - cleanup in destructor
170
- class Component {
171
- constructor() {
172
- this.handleResize = this.handleResize.bind(this);
173
- window.addEventListener('resize', this.handleResize);
174
- }
175
-
176
- destroy() {
177
- window.removeEventListener('resize', this.handleResize);
178
- }
179
- }
180
- ```
181
-
182
- ### 4. Type Errors
183
- ```typescript
184
- // Bug - type coercion
185
- function add(a, b) {
186
- return a + b;
187
- }
188
-
189
- add("10", 20); // "1020" (string concatenation)
190
-
191
- // Fix - proper types
192
- function add(a: number, b: number): number {
193
- return Number(a) + Number(b);
194
- }
195
- ```
196
-
197
- ### 5. SQL N+1 Queries
198
- ```typescript
199
- // Bug - N+1 queries
200
- const posts = await db.posts.findMany();
201
- for (const post of posts) {
202
- post.author = await db.users.findUnique({ where: { id: post.authorId } });
203
- }
204
-
205
- // Fix - single query with join
206
- const posts = await db.posts.findMany({
207
- include: { author: true }
208
- });
209
- ```
210
-
211
- ## Debugging Tools
212
-
213
- ### Console Logging
214
- ```typescript
215
- // Strategic logging
216
- console.log('Before API call:', { userId, timestamp: Date.now() });
217
- const user = await fetchUser(userId);
218
- console.log('After API call:', { user, timestamp: Date.now() });
219
- ```
220
-
221
- ### Debugger Breakpoints
222
- ```typescript
223
- function calculateTotal(items) {
224
- debugger; // Pauses execution here
225
- return items.reduce((sum, item) => sum + item.price, 0);
226
- }
227
- ```
228
-
229
- ### Stack Trace Analysis
230
- ```
231
- Error: Cannot read property 'name' of undefined
232
- at getUser (app.js:45:12) ← Problem here
233
- at handleRequest (server.js:89:5) ← Called from here
234
- ```
235
-
236
- ### Log Analysis
237
- ```bash
238
- # Find errors
239
- grep "ERROR" app.log
240
-
241
- # Count error types
242
- grep "ERROR" app.log | sort | uniq -c
243
-
244
- # Track specific user
245
- grep "userId:12345" app.log
246
- ```
247
-
248
- ## Memory Integration
249
-
250
- Before debugging:
251
- - Check `ai_context/memory/learning.md` for past bug patterns
252
-
253
- After debugging:
254
- - Update `ai_context/memory/learning.md` with new bug pattern
255
- - Save report to `ai_context/reports/ai-sprint-debug-{timestamp}-{slug}.md`
256
-
257
- ## Debug Report
258
-
259
- Save to: `ai_context/reports/ai-sprint-debug-YYMMDD-slug.md`
260
-
261
- ```markdown
262
- # Bug Fix Report
263
-
264
- **Date:** {use bash: date "+%Y-%m-%d"}
265
- **Bug:** Users unable to login
266
- **Severity:** Critical
267
- **Status:** Fixed
268
-
269
- ## Problem
270
-
271
- **Expected:** User logs in with valid credentials
272
- **Actual:** Login fails with "Invalid token" error
273
-
274
- **Reproduction:**
275
- 1. Go to /login
276
- 2. Enter email: test@example.com
277
- 3. Enter password: correct-password
278
- 4. Error: "Invalid token"
279
-
280
- ## Investigation
281
-
282
- **Stack Trace:**
283
- ```
284
- Error: Invalid token
285
- at validateToken (auth.ts:45)
286
- at loginUser (api/auth.ts:23)
287
- ```
288
-
289
- **Logs:**
290
- ```
291
- [ERROR] Token verification failed: jwt malformed
292
- [DEBUG] Token received: undefined
293
- ```
294
-
295
- **Root Cause:**
296
- JWT token generated but not included in API response.
297
-
298
- ## Fix
299
-
300
- ```typescript
301
- // Before (bug)
302
- const token = generateJWT(user);
303
- return { user }; // Token not returned!
304
-
305
- // After (fixed)
306
- const token = generateJWT(user);
307
- return { user, token };
308
- ```
309
-
310
- ## Verification
311
-
312
- - ✅ Login now works
313
- - ✅ Token present in response
314
- - ✅ No regressions
315
- - ✅ Regression test added
316
-
317
- ## Regression Test
318
-
319
- ```typescript
320
- test('login returns JWT token', async () => {
321
- const response = await request(app)
322
- .post('/api/auth/login')
323
- .send({ email: 'test@example.com', password: 'password' });
324
-
325
- expect(response.body).toHaveProperty('token');
326
- expect(response.body.token).toMatch(/^eyJ/);
327
- });
328
- ```
329
-
330
- ## Prevention
331
-
332
- Added similar fix to `/api/auth/register`.
333
- Updated docs to always return auth tokens.
334
- ```
335
-
336
- ## Performance Debugging
337
-
338
- ### Slow Queries
339
- ```sql
340
- -- Find slow queries (PostgreSQL)
341
- SELECT query, calls, mean_time
342
- FROM pg_stat_statements
343
- WHERE mean_time > 100
344
- ORDER BY mean_time DESC;
345
-
346
- -- Check for missing indexes
347
- EXPLAIN ANALYZE
348
- SELECT * FROM users WHERE email = 'test@example.com';
349
- ```
350
-
351
- ### Memory Profiling
352
- ```javascript
353
- // Node.js heap snapshot
354
- const v8 = require('v8');
355
- v8.writeHeapSnapshot('./heap-snapshot.heapsnapshot');
356
- ```
357
-
358
- ### Performance Timing
359
- ```typescript
360
- console.time('operation');
361
- await expensiveOperation();
362
- console.timeEnd('operation'); // operation: 1234ms
363
- ```
364
-
365
- ## Git Bisect (Find When Bug Was Introduced)
366
- ```bash
367
- git bisect start
368
- git bisect bad # Current commit has bug
369
- git bisect good v1.2.0 # v1.2.0 was working
370
- # Git checks out middle commit
371
- npm test # Test if bug exists
372
- git bisect good # or bad
373
- # Repeat until bug commit found
374
- git bisect reset
375
- ```
376
-
377
- ## Integration with Other Commands
378
-
379
- **/ai-sprint-debug** → **/ai-sprint-test**
380
- - After fixing bug, add regression test
381
-
382
- **/ai-sprint-debug** → **/ai-sprint-review**
383
- - Review fix for quality and security
384
-
385
- **/ai-sprint-debug** → **/ai-sprint-secure**
386
- - If security bug, run security scan
387
-
388
- ## Debug Checklist
389
-
390
- ### Investigation
391
- - ✅ Read full error message
392
- - ✅ Analyze stack trace
393
- - ✅ Reproduce reliably
394
- - ✅ Check recent changes
395
- - ✅ Search error online
396
-
397
- ### Fix
398
- - ✅ Minimal change (don't refactor while debugging)
399
- - ✅ Test thoroughly
400
- - ✅ No new bugs introduced
401
- - ✅ Edge cases handled
402
-
403
- ### Prevention
404
- - ✅ Regression test added
405
- - ✅ Root cause documented
406
- - ✅ Similar bugs prevented
407
- - ✅ Team notified
408
-
409
- ## Common Debugging Strategies
410
-
411
- ### Binary Search
412
- ```typescript
413
- // Bug somewhere in 1000-line function
414
- // Add logs to narrow down
415
- function complexFunction() {
416
- console.log('Step 1 OK'); // Works
417
- // ... 500 lines ...
418
- console.log('Step 2 OK'); // Works
419
- // ... 500 lines ...
420
- console.log('Step 3 OK'); // Doesn't print → bug before this
421
- }
422
- ```
423
-
424
- ### Rubber Duck Debugging
425
- 1. Explain code line-by-line
426
- 2. Often find bug while explaining
427
- 3. Write it down or talk to AI
428
-
429
- ### Divide and Conquer
430
- 1. Disable half the code
431
- 2. See if bug still occurs
432
- 3. Narrow down to problematic section
433
-
434
- ## Success Criteria
435
-
436
- Debugging is successful when:
437
- - ✅ Root cause identified
438
- - ✅ Bug fixed (not masked)
439
- - ✅ Fix verified with tests
440
- - ✅ Regression test prevents recurrence
441
- - ✅ No new bugs introduced
442
- - ✅ Documented for future
443
-
444
- ## Remember
445
-
446
- **Good debugging:**
447
- - Understands problem fully before fixing
448
- - Makes minimal changes
449
- - Tests thoroughly
450
- - Prevents recurrence
451
- - Documents findings
452
-
453
- **"Hours of debugging can save minutes of planning."**