kiro-spec-engine 1.3.0 → 1.4.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/CHANGELOG.md +85 -0
- package/README.md +228 -367
- package/README.zh.md +0 -330
- package/docs/README.md +223 -0
- package/docs/command-reference.md +252 -0
- package/docs/examples/add-export-command/design.md +194 -0
- package/docs/examples/add-export-command/requirements.md +110 -0
- package/docs/examples/add-export-command/tasks.md +88 -0
- package/docs/examples/add-rest-api/design.md +855 -0
- package/docs/examples/add-rest-api/requirements.md +323 -0
- package/docs/examples/add-rest-api/tasks.md +355 -0
- package/docs/examples/add-user-dashboard/design.md +192 -0
- package/docs/examples/add-user-dashboard/requirements.md +143 -0
- package/docs/examples/add-user-dashboard/tasks.md +91 -0
- package/docs/faq.md +696 -0
- package/docs/integration-modes.md +529 -0
- package/docs/integration-philosophy.md +313 -0
- package/docs/quick-start-with-ai-tools.md +374 -0
- package/docs/quick-start.md +711 -0
- package/docs/spec-workflow.md +453 -0
- package/docs/tools/claude-guide.md +653 -0
- package/docs/tools/cursor-guide.md +705 -0
- package/docs/tools/generic-guide.md +445 -0
- package/docs/tools/kiro-guide.md +308 -0
- package/docs/tools/vscode-guide.md +444 -0
- package/docs/tools/windsurf-guide.md +390 -0
- package/docs/troubleshooting.md +795 -0
- package/docs/zh/README.md +275 -0
- package/docs/zh/quick-start.md +711 -0
- package/docs/zh/tools/claude-guide.md +348 -0
- package/docs/zh/tools/cursor-guide.md +280 -0
- package/docs/zh/tools/generic-guide.md +498 -0
- package/docs/zh/tools/kiro-guide.md +342 -0
- package/docs/zh/tools/vscode-guide.md +448 -0
- package/docs/zh/tools/windsurf-guide.md +377 -0
- package/package.json +1 -1
|
@@ -0,0 +1,705 @@
|
|
|
1
|
+
# Using kse with Cursor
|
|
2
|
+
|
|
3
|
+
> Complete guide to integrating kse with Cursor IDE for AI-assisted development
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**Version**: 1.0.0
|
|
8
|
+
**Last Updated**: 2026-01-23
|
|
9
|
+
**Tool**: Cursor IDE
|
|
10
|
+
**Integration Mode**: Manual Export
|
|
11
|
+
**Estimated Setup Time**: 5 minutes
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Overview
|
|
16
|
+
|
|
17
|
+
**Cursor** is an AI-powered IDE built on VS Code that provides intelligent code completion, chat-based coding, and AI pair programming through Composer mode.
|
|
18
|
+
|
|
19
|
+
**kse integration with Cursor** uses the **Manual Export** mode, where you export Spec context and provide it to Cursor's AI features (Chat, Composer, or inline suggestions).
|
|
20
|
+
|
|
21
|
+
### Why Use kse with Cursor?
|
|
22
|
+
|
|
23
|
+
- ✅ **Structured context** - Cursor understands your requirements and design
|
|
24
|
+
- ✅ **Better code generation** - AI follows your architecture decisions
|
|
25
|
+
- ✅ **Consistent implementation** - All code matches your Spec
|
|
26
|
+
- ✅ **Progress tracking** - Know what's done and what's next
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Integration Mode
|
|
31
|
+
|
|
32
|
+
**Mode:** Manual Export
|
|
33
|
+
|
|
34
|
+
**How it works:**
|
|
35
|
+
1. You create Specs in kse (requirements, design, tasks)
|
|
36
|
+
2. You export context using `kse context export`
|
|
37
|
+
3. You provide context to Cursor (Chat, Composer, or .cursorrules)
|
|
38
|
+
4. Cursor generates code based on your Spec
|
|
39
|
+
5. You update task status in tasks.md
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Setup
|
|
44
|
+
|
|
45
|
+
### Prerequisites
|
|
46
|
+
|
|
47
|
+
- **Cursor IDE** installed ([Download](https://cursor.sh/))
|
|
48
|
+
- **kse** installed globally (`npm install -g kiro-spec-engine`)
|
|
49
|
+
- **Project adopted** by kse (`kse adopt`)
|
|
50
|
+
|
|
51
|
+
### Step 1: Configure Cursor for kse
|
|
52
|
+
|
|
53
|
+
Create a `.cursorrules` file in your project root:
|
|
54
|
+
|
|
55
|
+
```markdown
|
|
56
|
+
# Project Rules
|
|
57
|
+
|
|
58
|
+
This project uses kse (Kiro Spec Engine) for spec-driven development.
|
|
59
|
+
|
|
60
|
+
## Spec Location
|
|
61
|
+
All Specs are in `.kiro/specs/` directory.
|
|
62
|
+
|
|
63
|
+
## Before Implementing Features
|
|
64
|
+
1. Check if a Spec exists in `.kiro/specs/`
|
|
65
|
+
2. Read the requirements.md, design.md, and tasks.md
|
|
66
|
+
3. Follow the design architecture exactly
|
|
67
|
+
4. Update tasks.md when completing tasks
|
|
68
|
+
|
|
69
|
+
## Spec Structure
|
|
70
|
+
- requirements.md - What we're building and why
|
|
71
|
+
- design.md - How we're building it (architecture, APIs, components)
|
|
72
|
+
- tasks.md - Step-by-step implementation plan
|
|
73
|
+
|
|
74
|
+
## Example
|
|
75
|
+
For user login feature:
|
|
76
|
+
- Spec: `.kiro/specs/01-00-user-login/`
|
|
77
|
+
- Design: `.kiro/specs/01-00-user-login/design.md`
|
|
78
|
+
- Tasks: `.kiro/specs/01-00-user-login/tasks.md`
|
|
79
|
+
|
|
80
|
+
## Code Standards
|
|
81
|
+
[Add your project-specific coding standards here]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Step 2: Create Shell Alias (Optional but Recommended)
|
|
85
|
+
|
|
86
|
+
Add to your `~/.bashrc` or `~/.zshrc`:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Quick export and copy to clipboard
|
|
90
|
+
alias kse-clip='kse context export $1 && cat .kiro/specs/$1/context-export.md | pbcopy && echo "✅ Context copied to clipboard"'
|
|
91
|
+
|
|
92
|
+
# Generate task-specific prompt
|
|
93
|
+
alias kse-task='kse prompt generate $1 $2 --tool=cursor'
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Reload your shell:
|
|
97
|
+
```bash
|
|
98
|
+
source ~/.bashrc # or source ~/.zshrc
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Workflow
|
|
104
|
+
|
|
105
|
+
### Method 1: Using Cursor Composer (Recommended) ⭐
|
|
106
|
+
|
|
107
|
+
**Best for:** Implementing complete features or multiple related tasks
|
|
108
|
+
|
|
109
|
+
**Step 1: Export context**
|
|
110
|
+
```bash
|
|
111
|
+
kse context export 01-00-user-login
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Step 2: Copy context**
|
|
115
|
+
```bash
|
|
116
|
+
# macOS
|
|
117
|
+
cat .kiro/specs/01-00-user-login/context-export.md | pbcopy
|
|
118
|
+
|
|
119
|
+
# Windows
|
|
120
|
+
type .kiro\specs\01-00-user-login\context-export.md | clip
|
|
121
|
+
|
|
122
|
+
# Or use alias
|
|
123
|
+
kse-clip 01-00-user-login
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Step 3: Open Cursor Composer**
|
|
127
|
+
- Press `Cmd+K` (macOS) or `Ctrl+K` (Windows/Linux)
|
|
128
|
+
- Or click the Composer icon in the sidebar
|
|
129
|
+
|
|
130
|
+
**Step 4: Provide context and instructions**
|
|
131
|
+
```
|
|
132
|
+
[Paste the entire context from context-export.md]
|
|
133
|
+
|
|
134
|
+
Please implement task 1.1: "Create AuthController class"
|
|
135
|
+
|
|
136
|
+
Follow the design document exactly:
|
|
137
|
+
- Use the specified API endpoints
|
|
138
|
+
- Implement all methods as designed
|
|
139
|
+
- Include error handling as specified
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Step 5: Review and accept changes**
|
|
143
|
+
- Cursor will show proposed file changes
|
|
144
|
+
- Review each change carefully
|
|
145
|
+
- Accept or modify as needed
|
|
146
|
+
|
|
147
|
+
**Step 6: Update task status**
|
|
148
|
+
Edit `.kiro/specs/01-00-user-login/tasks.md`:
|
|
149
|
+
```markdown
|
|
150
|
+
- [x] 1.1 Create AuthController class ← Changed from [ ] to [x]
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Method 2: Using Cursor Chat
|
|
154
|
+
|
|
155
|
+
**Best for:** Quick questions, debugging, or small changes
|
|
156
|
+
|
|
157
|
+
**Step 1: Generate task-specific prompt**
|
|
158
|
+
```bash
|
|
159
|
+
kse prompt generate 01-00-user-login 1.1 --tool=cursor
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**Step 2: Open Cursor Chat**
|
|
163
|
+
- Press `Cmd+L` (macOS) or `Ctrl+L` (Windows/Linux)
|
|
164
|
+
- Or click the Chat icon in the sidebar
|
|
165
|
+
|
|
166
|
+
**Step 3: Paste prompt and ask**
|
|
167
|
+
```
|
|
168
|
+
[Paste the generated prompt]
|
|
169
|
+
|
|
170
|
+
Can you implement this following the design document?
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**Step 4: Iterate**
|
|
174
|
+
```
|
|
175
|
+
You: "Add error handling for invalid email"
|
|
176
|
+
Cursor: [Generates error handling code]
|
|
177
|
+
|
|
178
|
+
You: "Add unit tests for this"
|
|
179
|
+
Cursor: [Generates tests]
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Method 3: Using Inline Suggestions
|
|
183
|
+
|
|
184
|
+
**Best for:** Writing code with AI assistance as you type
|
|
185
|
+
|
|
186
|
+
**Step 1: Add context in comments**
|
|
187
|
+
```javascript
|
|
188
|
+
// Task 1.1: Create AuthController class
|
|
189
|
+
// See: .kiro/specs/01-00-user-login/design.md
|
|
190
|
+
//
|
|
191
|
+
// Requirements:
|
|
192
|
+
// - POST /api/auth/login endpoint
|
|
193
|
+
// - Validate email and password
|
|
194
|
+
// - Return JWT token on success
|
|
195
|
+
// - Return error message on failure
|
|
196
|
+
|
|
197
|
+
class AuthController {
|
|
198
|
+
// Cursor will suggest implementation based on comments
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
**Step 2: Let Cursor suggest**
|
|
202
|
+
- Start typing
|
|
203
|
+
- Cursor suggests code based on your comments and Spec files
|
|
204
|
+
- Press `Tab` to accept suggestions
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Example Workflow
|
|
209
|
+
|
|
210
|
+
### Complete Feature Implementation
|
|
211
|
+
|
|
212
|
+
**Scenario:** Implement user login feature
|
|
213
|
+
|
|
214
|
+
**1. Create and write Spec**
|
|
215
|
+
```bash
|
|
216
|
+
kse create-spec 01-00-user-login
|
|
217
|
+
# Edit requirements.md, design.md, tasks.md
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
**2. Export context**
|
|
221
|
+
```bash
|
|
222
|
+
kse-clip 01-00-user-login
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
**3. Open Cursor Composer (Cmd+K)**
|
|
226
|
+
```
|
|
227
|
+
[Paste context]
|
|
228
|
+
|
|
229
|
+
I need to implement the user login feature according to this Spec.
|
|
230
|
+
|
|
231
|
+
Let's start with task 1.1: "Set up project dependencies"
|
|
232
|
+
|
|
233
|
+
Please:
|
|
234
|
+
1. Install the required packages (express, bcrypt, jsonwebtoken, validator)
|
|
235
|
+
2. Create the basic project structure
|
|
236
|
+
3. Set up TypeScript configuration if needed
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
**4. Cursor generates:**
|
|
240
|
+
```bash
|
|
241
|
+
# package.json updates
|
|
242
|
+
# tsconfig.json (if TypeScript)
|
|
243
|
+
# Basic folder structure
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
**5. Continue with next task**
|
|
247
|
+
```
|
|
248
|
+
Great! Now let's implement task 1.2: "Create User model and database schema"
|
|
249
|
+
|
|
250
|
+
Follow the design document:
|
|
251
|
+
- User interface with id, email, passwordHash, name, createdAt, lastLoginAt
|
|
252
|
+
- Database migration for users table
|
|
253
|
+
- Index on email field
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
**6. Iterate through all tasks**
|
|
257
|
+
```
|
|
258
|
+
Task 2.1: Implement ValidationService
|
|
259
|
+
Task 2.2: Implement AuthService
|
|
260
|
+
Task 2.3: Implement UserRepository
|
|
261
|
+
Task 3.1: Implement AuthController
|
|
262
|
+
...
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
**7. Update tasks.md as you go**
|
|
266
|
+
```markdown
|
|
267
|
+
- [x] 1.1 Set up project dependencies
|
|
268
|
+
- [x] 1.2 Create User model and database schema
|
|
269
|
+
- [x] 2.1 Implement ValidationService
|
|
270
|
+
- [ ] 2.2 Implement AuthService
|
|
271
|
+
...
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Tips & Best Practices
|
|
277
|
+
|
|
278
|
+
### 1. Use Composer for Complex Tasks
|
|
279
|
+
|
|
280
|
+
**Good for Composer:**
|
|
281
|
+
- Implementing entire components
|
|
282
|
+
- Creating multiple related files
|
|
283
|
+
- Refactoring across files
|
|
284
|
+
- Setting up project structure
|
|
285
|
+
|
|
286
|
+
**Example:**
|
|
287
|
+
```
|
|
288
|
+
Implement the entire AuthService according to the design:
|
|
289
|
+
- hashPassword() method
|
|
290
|
+
- authenticate() method
|
|
291
|
+
- generateToken() method
|
|
292
|
+
- Include all error handling
|
|
293
|
+
- Add JSDoc comments
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### 2. Use Chat for Clarifications
|
|
297
|
+
|
|
298
|
+
**Good for Chat:**
|
|
299
|
+
- Understanding design decisions
|
|
300
|
+
- Debugging issues
|
|
301
|
+
- Quick modifications
|
|
302
|
+
- Asking "why" questions
|
|
303
|
+
|
|
304
|
+
**Example:**
|
|
305
|
+
```
|
|
306
|
+
Why does the design specify bcrypt with 10 salt rounds?
|
|
307
|
+
What are the security implications?
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### 3. Reference Spec Files in Code
|
|
311
|
+
|
|
312
|
+
**Add comments that reference Specs:**
|
|
313
|
+
```javascript
|
|
314
|
+
/**
|
|
315
|
+
* AuthController handles user authentication
|
|
316
|
+
*
|
|
317
|
+
* Spec: .kiro/specs/01-00-user-login/design.md
|
|
318
|
+
* Requirements: FR-1, FR-2, FR-3
|
|
319
|
+
*
|
|
320
|
+
* @see .kiro/specs/01-00-user-login/design.md#authcontroller
|
|
321
|
+
*/
|
|
322
|
+
class AuthController {
|
|
323
|
+
// ...
|
|
324
|
+
}
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### 4. Break Large Specs into Tasks
|
|
328
|
+
|
|
329
|
+
**Instead of:**
|
|
330
|
+
```
|
|
331
|
+
Implement the entire user login feature
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
**Do:**
|
|
335
|
+
```
|
|
336
|
+
Implement task 1.1: Create AuthController class
|
|
337
|
+
[After completion]
|
|
338
|
+
Implement task 1.2: Add input validation
|
|
339
|
+
[After completion]
|
|
340
|
+
Implement task 1.3: Add authentication logic
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### 5. Use .cursorrules for Consistency
|
|
344
|
+
|
|
345
|
+
**Update .cursorrules with project standards:**
|
|
346
|
+
```markdown
|
|
347
|
+
## Code Style
|
|
348
|
+
- Use TypeScript
|
|
349
|
+
- Use async/await (not .then())
|
|
350
|
+
- All functions must have JSDoc comments
|
|
351
|
+
- Use descriptive variable names
|
|
352
|
+
|
|
353
|
+
## Testing
|
|
354
|
+
- Write tests for all public methods
|
|
355
|
+
- Use Jest for testing
|
|
356
|
+
- Aim for 80%+ code coverage
|
|
357
|
+
|
|
358
|
+
## Error Handling
|
|
359
|
+
- Use try-catch for async operations
|
|
360
|
+
- Return structured error objects
|
|
361
|
+
- Log errors with context
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### 6. Keep Context Fresh
|
|
365
|
+
|
|
366
|
+
**Re-export after Spec changes:**
|
|
367
|
+
```bash
|
|
368
|
+
# After editing design.md
|
|
369
|
+
kse context export 01-00-user-login
|
|
370
|
+
|
|
371
|
+
# Copy new context
|
|
372
|
+
kse-clip 01-00-user-login
|
|
373
|
+
|
|
374
|
+
# Provide to Cursor again
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
### 7. Use Task-Specific Prompts for Large Specs
|
|
378
|
+
|
|
379
|
+
**For large Specs (>5KB context):**
|
|
380
|
+
```bash
|
|
381
|
+
# Instead of exporting entire Spec
|
|
382
|
+
kse prompt generate 01-00-user-login 1.1 --tool=cursor
|
|
383
|
+
|
|
384
|
+
# Generates focused prompt for just task 1.1
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
---
|
|
388
|
+
|
|
389
|
+
## Common Pitfalls
|
|
390
|
+
|
|
391
|
+
### ❌ Pitfall 1: Not Providing Enough Context
|
|
392
|
+
|
|
393
|
+
**Problem:**
|
|
394
|
+
```
|
|
395
|
+
Cursor: "Implement user login"
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
**Solution:**
|
|
399
|
+
```
|
|
400
|
+
[Paste full context from context-export.md]
|
|
401
|
+
|
|
402
|
+
Implement task 1.1: "Create AuthController class"
|
|
403
|
+
|
|
404
|
+
Follow the design document exactly:
|
|
405
|
+
- API endpoint: POST /api/auth/login
|
|
406
|
+
- Request format: { email, password }
|
|
407
|
+
- Response format: { token } or { error }
|
|
408
|
+
- Use the specified error messages
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
### ❌ Pitfall 2: Forgetting to Update Tasks
|
|
412
|
+
|
|
413
|
+
**Problem:** Tasks.md gets out of sync with actual progress
|
|
414
|
+
|
|
415
|
+
**Solution:** Update tasks.md immediately after completing each task
|
|
416
|
+
|
|
417
|
+
### ❌ Pitfall 3: Not Using .cursorrules
|
|
418
|
+
|
|
419
|
+
**Problem:** Cursor doesn't know about your Specs
|
|
420
|
+
|
|
421
|
+
**Solution:** Create .cursorrules file with Spec location and structure
|
|
422
|
+
|
|
423
|
+
### ❌ Pitfall 4: Accepting All Suggestions Blindly
|
|
424
|
+
|
|
425
|
+
**Problem:** AI-generated code may not be perfect
|
|
426
|
+
|
|
427
|
+
**Solution:** Always review Cursor's suggestions before accepting
|
|
428
|
+
|
|
429
|
+
---
|
|
430
|
+
|
|
431
|
+
## Troubleshooting
|
|
432
|
+
|
|
433
|
+
### Issue: Cursor doesn't follow the design
|
|
434
|
+
|
|
435
|
+
**Solution 1:** Be more explicit in your prompt
|
|
436
|
+
```
|
|
437
|
+
Strictly follow the design document in .kiro/specs/01-00-user-login/design.md
|
|
438
|
+
|
|
439
|
+
Do not deviate from:
|
|
440
|
+
- The specified API endpoints
|
|
441
|
+
- The component structure
|
|
442
|
+
- The error handling approach
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
**Solution 2:** Include design excerpts in prompt
|
|
446
|
+
```
|
|
447
|
+
According to the design:
|
|
448
|
+
|
|
449
|
+
## API Design
|
|
450
|
+
POST /api/auth/login
|
|
451
|
+
Request: { email: string, password: string }
|
|
452
|
+
Response: { token: string } or { error: string }
|
|
453
|
+
|
|
454
|
+
Please implement exactly as specified.
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### Issue: Context too large for Cursor
|
|
458
|
+
|
|
459
|
+
**Solution:** Use task-specific prompts
|
|
460
|
+
```bash
|
|
461
|
+
kse prompt generate 01-00-user-login 1.1 --tool=cursor --max-length=5000
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
### Issue: Cursor suggests wrong file locations
|
|
465
|
+
|
|
466
|
+
**Solution:** Specify file paths explicitly
|
|
467
|
+
```
|
|
468
|
+
Create the AuthController in src/controllers/AuthController.ts
|
|
469
|
+
|
|
470
|
+
[Rest of prompt]
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
### Issue: Lost context in long conversation
|
|
474
|
+
|
|
475
|
+
**Solution:** Re-paste context periodically
|
|
476
|
+
```
|
|
477
|
+
Let me re-provide the Spec context to ensure we're aligned:
|
|
478
|
+
|
|
479
|
+
[Paste context again]
|
|
480
|
+
|
|
481
|
+
Now let's continue with task 2.1...
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
---
|
|
485
|
+
|
|
486
|
+
## Advanced Techniques
|
|
487
|
+
|
|
488
|
+
### 1. Multi-File Implementation
|
|
489
|
+
|
|
490
|
+
**Use Composer to create multiple files at once:**
|
|
491
|
+
```
|
|
492
|
+
Implement the complete authentication system:
|
|
493
|
+
|
|
494
|
+
Files to create:
|
|
495
|
+
1. src/controllers/AuthController.ts
|
|
496
|
+
2. src/services/AuthService.ts
|
|
497
|
+
3. src/services/ValidationService.ts
|
|
498
|
+
4. src/repositories/UserRepository.ts
|
|
499
|
+
5. tests/auth.test.ts
|
|
500
|
+
|
|
501
|
+
Follow the design document for each component.
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
### 2. Iterative Refinement
|
|
505
|
+
|
|
506
|
+
**Start simple, then enhance:**
|
|
507
|
+
```
|
|
508
|
+
Step 1: "Implement basic AuthController with login endpoint"
|
|
509
|
+
[Review and accept]
|
|
510
|
+
|
|
511
|
+
Step 2: "Add input validation to the login endpoint"
|
|
512
|
+
[Review and accept]
|
|
513
|
+
|
|
514
|
+
Step 3: "Add error handling and rate limiting"
|
|
515
|
+
[Review and accept]
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
### 3. Test-Driven Development
|
|
519
|
+
|
|
520
|
+
**Generate tests first:**
|
|
521
|
+
```
|
|
522
|
+
Based on the design document, generate unit tests for AuthService:
|
|
523
|
+
- Test hashPassword()
|
|
524
|
+
- Test authenticate() with valid credentials
|
|
525
|
+
- Test authenticate() with invalid credentials
|
|
526
|
+
- Test generateToken()
|
|
527
|
+
|
|
528
|
+
Use Jest and follow the test structure in the design.
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
Then implement:
|
|
532
|
+
```
|
|
533
|
+
Now implement AuthService to make these tests pass.
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
### 4. Code Review Mode
|
|
537
|
+
|
|
538
|
+
**Use Chat to review generated code:**
|
|
539
|
+
```
|
|
540
|
+
Review the AuthController implementation:
|
|
541
|
+
1. Does it follow the design document?
|
|
542
|
+
2. Are there any security issues?
|
|
543
|
+
3. Is error handling complete?
|
|
544
|
+
4. Are there any edge cases we missed?
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
---
|
|
548
|
+
|
|
549
|
+
## Integration with Other Tools
|
|
550
|
+
|
|
551
|
+
### With Git
|
|
552
|
+
|
|
553
|
+
```bash
|
|
554
|
+
# Commit Spec changes
|
|
555
|
+
git add .kiro/specs/01-00-user-login/
|
|
556
|
+
git commit -m "Add user login Spec"
|
|
557
|
+
|
|
558
|
+
# Commit implementation
|
|
559
|
+
git add src/
|
|
560
|
+
git commit -m "Implement user login (task 1.1-1.3)"
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
### With Testing
|
|
564
|
+
|
|
565
|
+
```bash
|
|
566
|
+
# After Cursor generates code
|
|
567
|
+
npm test
|
|
568
|
+
|
|
569
|
+
# If tests fail, ask Cursor to fix
|
|
570
|
+
# In Cursor Chat:
|
|
571
|
+
"The tests are failing with this error: [paste error]
|
|
572
|
+
Please fix the implementation."
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
### With Code Review
|
|
576
|
+
|
|
577
|
+
```bash
|
|
578
|
+
# Export context for reviewer
|
|
579
|
+
kse context export 01-00-user-login
|
|
580
|
+
|
|
581
|
+
# Share context-export.md with reviewer
|
|
582
|
+
# Reviewer can see requirements and design
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
---
|
|
586
|
+
|
|
587
|
+
## Example Prompts
|
|
588
|
+
|
|
589
|
+
### Starting a Feature
|
|
590
|
+
```
|
|
591
|
+
I've provided the complete Spec for user login feature.
|
|
592
|
+
|
|
593
|
+
Please implement task 1.1: "Set up project dependencies"
|
|
594
|
+
|
|
595
|
+
Install these packages:
|
|
596
|
+
- express
|
|
597
|
+
- bcrypt
|
|
598
|
+
- jsonwebtoken
|
|
599
|
+
- validator
|
|
600
|
+
- express-rate-limit
|
|
601
|
+
|
|
602
|
+
Also set up TypeScript if not already configured.
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
### Implementing a Component
|
|
606
|
+
```
|
|
607
|
+
Implement the AuthService according to the design document:
|
|
608
|
+
|
|
609
|
+
Location: src/services/AuthService.ts
|
|
610
|
+
|
|
611
|
+
Methods to implement:
|
|
612
|
+
1. hashPassword(password: string): Promise<string>
|
|
613
|
+
- Use bcrypt with 10 salt rounds
|
|
614
|
+
|
|
615
|
+
2. authenticate(email: string, password: string): Promise<User | null>
|
|
616
|
+
- Find user by email
|
|
617
|
+
- Compare password hash
|
|
618
|
+
- Return user if valid, null if invalid
|
|
619
|
+
|
|
620
|
+
3. generateToken(user: User): string
|
|
621
|
+
- Create JWT token
|
|
622
|
+
- Include user id and email
|
|
623
|
+
- Expire in 24 hours
|
|
624
|
+
|
|
625
|
+
Include error handling and JSDoc comments.
|
|
626
|
+
```
|
|
627
|
+
|
|
628
|
+
### Adding Tests
|
|
629
|
+
```
|
|
630
|
+
Create comprehensive unit tests for AuthService:
|
|
631
|
+
|
|
632
|
+
Location: tests/services/AuthService.test.ts
|
|
633
|
+
|
|
634
|
+
Test cases:
|
|
635
|
+
1. hashPassword() generates valid bcrypt hash
|
|
636
|
+
2. authenticate() returns user with valid credentials
|
|
637
|
+
3. authenticate() returns null with invalid credentials
|
|
638
|
+
4. authenticate() returns null for non-existent user
|
|
639
|
+
5. generateToken() creates valid JWT
|
|
640
|
+
6. generateToken() includes correct user data
|
|
641
|
+
|
|
642
|
+
Use Jest and follow AAA pattern (Arrange, Act, Assert).
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
### Debugging
|
|
646
|
+
```
|
|
647
|
+
The login endpoint is returning 500 error with this message:
|
|
648
|
+
[paste error]
|
|
649
|
+
|
|
650
|
+
The implementation is in src/controllers/AuthController.ts
|
|
651
|
+
|
|
652
|
+
According to the design document, it should:
|
|
653
|
+
- Validate inputs
|
|
654
|
+
- Call AuthService.authenticate()
|
|
655
|
+
- Return token on success
|
|
656
|
+
- Return error on failure
|
|
657
|
+
|
|
658
|
+
Please help debug and fix the issue.
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
---
|
|
662
|
+
|
|
663
|
+
## Related Documentation
|
|
664
|
+
|
|
665
|
+
- **[Quick Start Guide](../quick-start.md)** - Get started with kse
|
|
666
|
+
- **[Integration Modes](../integration-modes.md)** - Understanding integration modes
|
|
667
|
+
- **[Spec Workflow](../spec-workflow.md)** - Creating effective Specs
|
|
668
|
+
- **[Command Reference](../command-reference.md)** - All kse commands
|
|
669
|
+
|
|
670
|
+
---
|
|
671
|
+
|
|
672
|
+
## Summary
|
|
673
|
+
|
|
674
|
+
**Cursor + kse workflow:**
|
|
675
|
+
1. Create Spec in kse (requirements, design, tasks)
|
|
676
|
+
2. Export context: `kse context export spec-name`
|
|
677
|
+
3. Use Cursor Composer (Cmd+K) or Chat (Cmd+L)
|
|
678
|
+
4. Provide context and implement tasks
|
|
679
|
+
5. Update tasks.md as you complete tasks
|
|
680
|
+
|
|
681
|
+
**Key advantages:**
|
|
682
|
+
- ✅ Structured, consistent code generation
|
|
683
|
+
- ✅ AI follows your architecture
|
|
684
|
+
- ✅ Clear progress tracking
|
|
685
|
+
- ✅ Better code quality
|
|
686
|
+
|
|
687
|
+
**Best practices:**
|
|
688
|
+
- Use Composer for complex tasks
|
|
689
|
+
- Use Chat for quick questions
|
|
690
|
+
- Keep .cursorrules updated
|
|
691
|
+
- Re-export context after Spec changes
|
|
692
|
+
- Review all AI suggestions
|
|
693
|
+
|
|
694
|
+
**Start using kse with Cursor:** 🚀
|
|
695
|
+
```bash
|
|
696
|
+
kse adopt
|
|
697
|
+
kse create-spec 01-00-my-feature
|
|
698
|
+
kse context export 01-00-my-feature
|
|
699
|
+
# Open Cursor Composer (Cmd+K) and paste context
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
---
|
|
703
|
+
|
|
704
|
+
**Version**: 1.0.0
|
|
705
|
+
**Last Updated**: 2026-01-23
|