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.
- package/README.md +299 -0
- package/bin/cli.js +135 -0
- package/lib/installer.js +205 -0
- package/lib/scanner.js +341 -0
- package/package.json +55 -0
- package/templates/.claude/.env.example +13 -0
- package/templates/.claude/agents/debugger.md +667 -0
- package/templates/.claude/agents/devops.md +727 -0
- package/templates/.claude/agents/docs.md +661 -0
- package/templates/.claude/agents/implementer.md +235 -0
- package/templates/.claude/agents/planner.md +243 -0
- package/templates/.claude/agents/researcher.md +448 -0
- package/templates/.claude/agents/reviewer.md +610 -0
- package/templates/.claude/agents/security.md +202 -0
- package/templates/.claude/agents/tester.md +604 -0
- package/templates/.claude/commands/auto.md +85 -0
- package/templates/.claude/commands/code.md +301 -0
- package/templates/.claude/commands/debug.md +449 -0
- package/templates/.claude/commands/deploy.md +475 -0
- package/templates/.claude/commands/docs.md +519 -0
- package/templates/.claude/commands/plan.md +57 -0
- package/templates/.claude/commands/review.md +412 -0
- package/templates/.claude/commands/scan.md +146 -0
- package/templates/.claude/commands/secure.md +88 -0
- package/templates/.claude/commands/test.md +352 -0
- package/templates/.claude/commands/validate.md +238 -0
- package/templates/.claude/settings.json +27 -0
- package/templates/.claude/skills/codebase-context/SKILL.md +68 -0
- package/templates/.claude/skills/codebase-context/references/reading-context.md +68 -0
- package/templates/.claude/skills/codebase-context/references/refresh-triggers.md +82 -0
- package/templates/.claude/skills/implementation/SKILL.md +70 -0
- package/templates/.claude/skills/implementation/references/error-handling.md +106 -0
- package/templates/.claude/skills/implementation/references/security-patterns.md +73 -0
- package/templates/.claude/skills/implementation/references/validation-patterns.md +107 -0
- package/templates/.claude/skills/memory/SKILL.md +67 -0
- package/templates/.claude/skills/memory/references/decisions-format.md +68 -0
- package/templates/.claude/skills/memory/references/learning-format.md +74 -0
- package/templates/.claude/skills/planning/SKILL.md +72 -0
- package/templates/.claude/skills/planning/references/plan-templates.md +81 -0
- package/templates/.claude/skills/planning/references/research-phase.md +62 -0
- package/templates/.claude/skills/planning/references/solution-design.md +66 -0
- package/templates/.claude/skills/quality-assurance/SKILL.md +79 -0
- package/templates/.claude/skills/quality-assurance/references/review-checklist.md +72 -0
- package/templates/.claude/skills/quality-assurance/references/security-checklist.md +70 -0
- package/templates/.claude/skills/quality-assurance/references/testing-strategy.md +85 -0
- package/templates/.claude/statusline.sh +126 -0
- package/templates/.claude/workflows/development-rules.md +97 -0
- package/templates/.claude/workflows/orchestration-protocol.md +194 -0
- package/templates/.mcp.json.example +36 -0
- package/templates/CLAUDE.md +409 -0
- package/templates/README.md +331 -0
- package/templates/ai_context/codebase/.gitkeep +0 -0
- package/templates/ai_context/memory/active.md +15 -0
- package/templates/ai_context/memory/decisions.md +18 -0
- package/templates/ai_context/memory/learning.md +22 -0
- package/templates/ai_context/plans/.gitkeep +0 -0
- package/templates/ai_context/reports/.gitkeep +0 -0
- package/templates/docs/user-guide-th.md +454 -0
- package/templates/docs/user-guide.md +595 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Generate or refactor code with best practices and security
|
|
3
|
+
argument-hint: [what to build or refactor]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Command: /code
|
|
7
|
+
|
|
8
|
+
Generate production-grade code or refactor existing code following best practices, security guidelines, and design patterns.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
/code "implement user authentication with JWT"
|
|
14
|
+
/code "refactor the payment service to use async/await"
|
|
15
|
+
/code "add input validation to all API endpoints"
|
|
16
|
+
/code "optimize database queries in user service"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Workflow
|
|
20
|
+
|
|
21
|
+
### 1. Understand Requirements
|
|
22
|
+
- Clarify what needs to be built or refactored
|
|
23
|
+
- Ask questions if requirements unclear
|
|
24
|
+
- Identify affected files and components
|
|
25
|
+
|
|
26
|
+
### 2. Delegate to Implementer Agent
|
|
27
|
+
- Spawn implementer agent with detailed instructions
|
|
28
|
+
- Agent follows security-first principles
|
|
29
|
+
- Implements with proper error handling
|
|
30
|
+
|
|
31
|
+
### 3. Code Generation
|
|
32
|
+
- Generate clean, maintainable code
|
|
33
|
+
- Follow YAGNI, KISS, DRY principles
|
|
34
|
+
- Include proper TypeScript types
|
|
35
|
+
- Add necessary error handling
|
|
36
|
+
- Implement input validation
|
|
37
|
+
|
|
38
|
+
### 4. Security Checklist
|
|
39
|
+
**Automatically enforced:**
|
|
40
|
+
- ✅ No hardcoded secrets
|
|
41
|
+
- ✅ Input validation on all user inputs
|
|
42
|
+
- ✅ Parameterized queries (no SQL injection)
|
|
43
|
+
- ✅ Output encoding (no XSS)
|
|
44
|
+
- ✅ Proper authentication/authorization
|
|
45
|
+
- ✅ Error messages don't leak information
|
|
46
|
+
- ✅ OWASP Top 10 compliance
|
|
47
|
+
|
|
48
|
+
### 5. Quality Standards
|
|
49
|
+
**Code must be:**
|
|
50
|
+
- ✅ Type-safe (TypeScript/proper types)
|
|
51
|
+
- ✅ Well-structured (clear responsibilities)
|
|
52
|
+
- ✅ Properly tested (test cases generated)
|
|
53
|
+
- ✅ Documented (comments where needed)
|
|
54
|
+
- ✅ Performance-optimized (no N+1 queries)
|
|
55
|
+
|
|
56
|
+
## Code Generation Principles
|
|
57
|
+
|
|
58
|
+
### Security-First
|
|
59
|
+
```typescript
|
|
60
|
+
// ✅ Good - Secure
|
|
61
|
+
export async function createUser(data: CreateUserInput) {
|
|
62
|
+
// Input validation
|
|
63
|
+
const validated = validateUserInput(data);
|
|
64
|
+
|
|
65
|
+
// Parameterized query (no SQL injection)
|
|
66
|
+
const user = await db.users.create({
|
|
67
|
+
data: {
|
|
68
|
+
email: validated.email,
|
|
69
|
+
password: await hash(validated.password, 10)
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return user;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ❌ Bad - Insecure
|
|
77
|
+
export async function createUser(email, password) {
|
|
78
|
+
const query = `INSERT INTO users (email, password) VALUES ('${email}', '${password}')`;
|
|
79
|
+
await db.query(query); // SQL injection!
|
|
80
|
+
return email;
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Error Handling
|
|
85
|
+
```typescript
|
|
86
|
+
// ✅ Good
|
|
87
|
+
export async function getUser(id: string) {
|
|
88
|
+
try {
|
|
89
|
+
const user = await db.users.findUnique({ where: { id } });
|
|
90
|
+
|
|
91
|
+
if (!user) {
|
|
92
|
+
throw new NotFoundError(`User ${id} not found`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return user;
|
|
96
|
+
} catch (error) {
|
|
97
|
+
logger.error('Failed to get user', { error, id });
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// ❌ Bad - No error handling
|
|
103
|
+
export async function getUser(id) {
|
|
104
|
+
return await db.users.findUnique({ where: { id } });
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Type Safety
|
|
109
|
+
```typescript
|
|
110
|
+
// ✅ Good - Typed
|
|
111
|
+
interface CreateUserInput {
|
|
112
|
+
email: string;
|
|
113
|
+
password: string;
|
|
114
|
+
name?: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export async function createUser(data: CreateUserInput): Promise<User> {
|
|
118
|
+
// Implementation
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// ❌ Bad - No types
|
|
122
|
+
export async function createUser(data) {
|
|
123
|
+
// Implementation
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Examples
|
|
128
|
+
|
|
129
|
+
### Example 1: API Endpoint
|
|
130
|
+
```
|
|
131
|
+
/code "create REST API endpoint for user registration with email verification"
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Generated:**
|
|
135
|
+
```typescript
|
|
136
|
+
// api/auth/register/route.ts
|
|
137
|
+
import { hash } from 'bcrypt';
|
|
138
|
+
import { z } from 'zod';
|
|
139
|
+
|
|
140
|
+
const registerSchema = z.object({
|
|
141
|
+
email: z.string().email(),
|
|
142
|
+
password: z.string().min(8),
|
|
143
|
+
name: z.string().min(1)
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
export async function POST(request: Request) {
|
|
147
|
+
try {
|
|
148
|
+
const body = await request.json();
|
|
149
|
+
|
|
150
|
+
// Input validation
|
|
151
|
+
const validated = registerSchema.parse(body);
|
|
152
|
+
|
|
153
|
+
// Check if user exists
|
|
154
|
+
const existing = await db.users.findUnique({
|
|
155
|
+
where: { email: validated.email }
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
if (existing) {
|
|
159
|
+
return Response.json(
|
|
160
|
+
{ error: 'Email already registered' },
|
|
161
|
+
{ status: 400 }
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Create user
|
|
166
|
+
const user = await db.users.create({
|
|
167
|
+
data: {
|
|
168
|
+
email: validated.email,
|
|
169
|
+
password: await hash(validated.password, 10),
|
|
170
|
+
name: validated.name,
|
|
171
|
+
verified: false
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// Send verification email
|
|
176
|
+
await sendVerificationEmail(user.email, user.id);
|
|
177
|
+
|
|
178
|
+
return Response.json({
|
|
179
|
+
message: 'Registration successful. Check your email to verify.'
|
|
180
|
+
}, { status: 201 });
|
|
181
|
+
|
|
182
|
+
} catch (error) {
|
|
183
|
+
if (error instanceof z.ZodError) {
|
|
184
|
+
return Response.json(
|
|
185
|
+
{ error: 'Invalid input', details: error.errors },
|
|
186
|
+
{ status: 400 }
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
logger.error('Registration failed', { error });
|
|
191
|
+
return Response.json(
|
|
192
|
+
{ error: 'Internal server error' },
|
|
193
|
+
{ status: 500 }
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Example 2: Refactoring
|
|
200
|
+
```
|
|
201
|
+
/code "refactor this callback-based code to use async/await"
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Before:**
|
|
205
|
+
```javascript
|
|
206
|
+
function getUser(id, callback) {
|
|
207
|
+
db.query('SELECT * FROM users WHERE id = ?', [id], (err, result) => {
|
|
208
|
+
if (err) return callback(err);
|
|
209
|
+
callback(null, result);
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**After:**
|
|
215
|
+
```typescript
|
|
216
|
+
async function getUser(id: string): Promise<User> {
|
|
217
|
+
const user = await db.users.findUnique({
|
|
218
|
+
where: { id }
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
if (!user) {
|
|
222
|
+
throw new NotFoundError(`User ${id} not found`);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return user;
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Output
|
|
230
|
+
|
|
231
|
+
### Code Generated
|
|
232
|
+
- Clean, production-ready code
|
|
233
|
+
- Following project conventions
|
|
234
|
+
- With proper error handling
|
|
235
|
+
- Type-safe and secure
|
|
236
|
+
|
|
237
|
+
### Tests Suggested
|
|
238
|
+
- Unit tests for business logic
|
|
239
|
+
- Integration tests for APIs
|
|
240
|
+
- Edge cases covered
|
|
241
|
+
|
|
242
|
+
### Documentation Added
|
|
243
|
+
- Function/class comments
|
|
244
|
+
- Usage examples
|
|
245
|
+
- API endpoint docs (if applicable)
|
|
246
|
+
|
|
247
|
+
## Next Steps
|
|
248
|
+
|
|
249
|
+
After `/code` completion:
|
|
250
|
+
1. Review generated code
|
|
251
|
+
2. Run `/test` to generate tests
|
|
252
|
+
3. Run `/review` for quality check
|
|
253
|
+
4. Run `/secure` for security scan
|
|
254
|
+
5. Commit changes
|
|
255
|
+
|
|
256
|
+
## Common Use Cases
|
|
257
|
+
|
|
258
|
+
### New Features
|
|
259
|
+
```
|
|
260
|
+
/code "add pagination to the products API"
|
|
261
|
+
/code "implement password reset functionality"
|
|
262
|
+
/code "create admin dashboard with user management"
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Refactoring
|
|
266
|
+
```
|
|
267
|
+
/code "convert class components to functional components"
|
|
268
|
+
/code "split this 500-line file into smaller modules"
|
|
269
|
+
/code "replace REST with GraphQL for user API"
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Bug Fixes
|
|
273
|
+
```
|
|
274
|
+
/code "fix the race condition in payment processing"
|
|
275
|
+
/code "resolve memory leak in WebSocket handler"
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Performance
|
|
279
|
+
```
|
|
280
|
+
/code "optimize this N+1 query problem"
|
|
281
|
+
/code "add caching to frequently accessed data"
|
|
282
|
+
/code "implement lazy loading for images"
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Remember
|
|
286
|
+
|
|
287
|
+
**Code generation follows:**
|
|
288
|
+
- Security-first approach
|
|
289
|
+
- YAGNI, KISS, DRY principles
|
|
290
|
+
- Production-grade quality
|
|
291
|
+
- Comprehensive error handling
|
|
292
|
+
- Type safety
|
|
293
|
+
- Performance optimization
|
|
294
|
+
- Best practices (2025)
|
|
295
|
+
|
|
296
|
+
**Never generates:**
|
|
297
|
+
- Hardcoded secrets
|
|
298
|
+
- Unsafe SQL queries
|
|
299
|
+
- Unvalidated user inputs
|
|
300
|
+
- Missing error handling
|
|
301
|
+
- Type-unsafe code
|