ai-flow-dev 2.2.0 → 2.2.4

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 (74) hide show
  1. package/README.md +28 -24
  2. package/dist/cli.js +228 -418
  3. package/dist/cli.js.map +1 -1
  4. package/package.json +1 -1
  5. package/prompts/backend/flow-build-phase-0.md +286 -4
  6. package/prompts/backend/flow-build-phase-1.md +19 -0
  7. package/prompts/backend/flow-build-phase-2.md +19 -0
  8. package/prompts/backend/flow-build-phase-3.md +19 -0
  9. package/prompts/backend/flow-build-phase-4.md +19 -0
  10. package/prompts/backend/flow-build-phase-5.md +19 -0
  11. package/prompts/backend/flow-build-phase-6.md +19 -0
  12. package/prompts/backend/flow-build-phase-7.md +19 -0
  13. package/prompts/backend/flow-build-phase-9.md +14 -0
  14. package/prompts/backend/flow-build.md +2 -0
  15. package/prompts/backend/flow-check-review.md +20 -0
  16. package/prompts/backend/flow-check-test.md +14 -0
  17. package/prompts/backend/flow-check.md +67 -0
  18. package/prompts/backend/flow-commit.md +53 -0
  19. package/prompts/backend/flow-docs-sync.md +55 -53
  20. package/prompts/backend/flow-work-feature.md +42 -0
  21. package/prompts/backend/flow-work-fix.md +33 -0
  22. package/prompts/backend/flow-work-refactor.md +32 -0
  23. package/prompts/backend/flow-work-resume.md +32 -0
  24. package/prompts/backend/flow-work.md +129 -0
  25. package/prompts/frontend/flow-build-phase-0.md +363 -35
  26. package/prompts/frontend/flow-build-phase-1.md +433 -404
  27. package/prompts/frontend/flow-build-phase-2.md +508 -872
  28. package/prompts/frontend/flow-build-phase-3.md +629 -562
  29. package/prompts/frontend/flow-build-phase-4.md +438 -382
  30. package/prompts/frontend/flow-build-phase-5.md +559 -362
  31. package/prompts/frontend/flow-build-phase-6.md +383 -452
  32. package/prompts/frontend/flow-build-phase-7.md +818 -392
  33. package/prompts/frontend/flow-build-phase-9.md +14 -0
  34. package/prompts/frontend/flow-build.md +2 -0
  35. package/prompts/frontend/flow-check-review.md +20 -0
  36. package/prompts/frontend/flow-check-test.md +14 -0
  37. package/prompts/frontend/flow-check.md +67 -0
  38. package/prompts/frontend/flow-commit.md +53 -0
  39. package/prompts/frontend/flow-docs-sync.md +39 -35
  40. package/prompts/frontend/flow-work-feature.md +42 -0
  41. package/prompts/frontend/flow-work-fix.md +33 -0
  42. package/prompts/frontend/flow-work-refactor.md +32 -0
  43. package/prompts/frontend/flow-work-resume.md +32 -0
  44. package/prompts/frontend/flow-work.md +129 -0
  45. package/prompts/mobile/flow-build-phase-0.md +366 -37
  46. package/prompts/mobile/flow-build-phase-1.md +438 -493
  47. package/prompts/mobile/flow-build-phase-2.md +458 -464
  48. package/prompts/mobile/flow-build-phase-3.md +613 -487
  49. package/prompts/mobile/flow-build-phase-4.md +439 -258
  50. package/prompts/mobile/flow-build-phase-5.md +582 -250
  51. package/prompts/mobile/flow-build-phase-6.md +389 -359
  52. package/prompts/mobile/flow-build-phase-7.md +871 -285
  53. package/prompts/mobile/flow-build-phase-9.md +14 -0
  54. package/prompts/mobile/flow-build.md +2 -0
  55. package/prompts/mobile/flow-check-review.md +20 -0
  56. package/prompts/mobile/flow-check-test.md +14 -0
  57. package/prompts/mobile/flow-check.md +67 -0
  58. package/prompts/mobile/flow-commit.md +53 -0
  59. package/prompts/mobile/flow-docs-sync.md +39 -40
  60. package/prompts/mobile/flow-work-feature.md +42 -0
  61. package/prompts/mobile/flow-work-fix.md +33 -0
  62. package/prompts/mobile/flow-work-refactor.md +32 -0
  63. package/prompts/mobile/flow-work-resume.md +32 -0
  64. package/prompts/mobile/flow-work.md +129 -0
  65. package/prompts/shared/smart-skip-preflight.md +214 -0
  66. package/templates/AGENT.template.md +13 -3
  67. package/templates/backend/.clauderules.template +5 -4
  68. package/templates/backend/.cursorrules.template +1 -1
  69. package/prompts/backend/flow-dev-commit.md +0 -829
  70. package/prompts/backend/flow-dev-feature.md +0 -1948
  71. package/prompts/backend/flow-dev-fix.md +0 -952
  72. package/prompts/backend/flow-dev-refactor.md +0 -690
  73. package/prompts/backend/flow-dev-review.md +0 -372
  74. package/prompts/backend/flow-dev-work.md +0 -1081
@@ -1,1948 +0,0 @@
1
- ---
2
- description: Feature Development & Documentation Flow
3
- ---
4
-
5
- # AI Flow - Feature Development Workflow
6
-
7
- **YOU ARE AN EXPERT SOFTWARE ARCHITECT AND IMPLEMENTATION SPECIALIST.**
8
-
9
- Your mission is to create, modify, or refactor complete features through an interactive workflow when the user executes `/feature`.
10
- ---
11
- ## Command: `/feature`
12
-
13
- ### Objective
14
-
15
- Create, modify, or refactor complete functionalities with automatic documentation, tests, and validation.
16
-
17
- ### Usage Modes
18
-
19
- - **`/feature`** → Interactive mode (asks type: new/change/refactor)
20
- - **`/feature new`** → New functionality from scratch
21
- - **`/feature change`** → Modify existing functionality
22
- - **`/feature refactor`** → Refactor existing code
23
- - **`/feature HU-XXX-XXX`** → Implement specific User Story (from Phase 10)
24
- - **`/feature Feature Name`** → Implement feature from roadmap.md (Phase 9)
25
- ---
26
- ## Quick Examples
27
-
28
- ### With User Story (Recommended)
29
-
30
- ```bash
31
- /feature HU-001-001 # Auto-loads: acceptance criteria, tasks, tests, DoD
32
- # ✅ 0 questions asked, 5 SP, ~1.5h
33
- ```
34
-
35
- ### With Roadmap Feature
36
-
37
- ```bash
38
- /feature User Entity Repository # Auto-loads: tasks from roadmap.md
39
- # ✅ 0 questions asked, 12 SP, ~2-3h
40
- ```
41
-
42
- ### Interactive Mode
43
-
44
- ```bash
45
- /feature new # AI asks 5 questions, generates plan
46
- # ⏱️ 2-3 min questions, then implementation
47
- ```
48
- ---
49
- ## Workflow: 4 Phases (15-20 minutes)
50
-
51
- ### Phase 0: Detect Input Mode (5 seconds - automatic)
52
-
53
- **Check if User Story ID or Feature name provided:**
54
-
55
- ```typescript
56
- const input = getArguments(); // From /feature [args]
57
-
58
- if (input.match(/^HU-\d{3}-\d{3}$/)) {
59
- mode = 'USER_STORY';
60
- storyId = input; // e.g., HU-001-001
61
- // Load from docs/user-stories/EP-XXX/HU-XXX-XXX.md
62
- } else if (fs.existsSync('docs/roadmap.md')) {
63
- // Search for Feature in docs/roadmap.md matching input
64
- const roadmapContent = readFile('docs/roadmap.md');
65
- const featureMatch = roadmapContent.match(new RegExp(`### Feature.*${input}.*• (\d+) SP`));
66
- if (featureMatch) {
67
- mode = 'ROADMAP_FEATURE';
68
- featureName = input;
69
- // Extract tasks from docs/roadmap.md
70
- } else {
71
- mode = 'INTERACTIVE'; // Fallback to manual questions
72
- }
73
- } else {
74
- mode = 'INTERACTIVE'; // No roadmap/user-stories found
75
- }
76
- ```
77
-
78
- **Mode behavior:**
79
-
80
- | Mode | Source | Skip Phase 1 |
81
- | ----------------- | ---------------------------------------- | ------------------------ |
82
- | `USER_STORY` | `docs/user-stories/EP-XXX/HU-XXX-XXX.md` | ✅ Yes (auto-load spec) |
83
- | `ROADMAP_FEATURE` | `docs/roadmap.md` Feature section | ✅ Yes (auto-load tasks) |
84
- | `INTERACTIVE` | Manual questions | ❌ No (ask user) |
85
- ---
86
- ### Phase 1: Quick Specification (2-3 minutes or AUTO-SKIP)
87
-
88
- **IF mode = `USER_STORY`:** _(Skip questions, load from file)_
89
-
90
- ```
91
- ---
92
- 🚀 Feature Workflow | Phase 1/4: Specification (AUTO-LOADED)
93
- ---
94
- 📖 Loading User Story: HU-001-001
95
-
96
- Source: .ai-flow/user-stories/EP-001/HU-001-001.md
97
-
98
- ✅ Title: Login básico con email y contraseña
99
- ✅ Priority: Alta (P0)
100
- ✅ Story Points: 5 SP
101
- ✅ Acceptance Criteria: 3 scenarios (Gherkin)
102
- ✅ Technical Tasks: 6 tasks
103
- ✅ Test Cases: 8 QA test cases
104
- ✅ Definition of Done: 9 items
105
-
106
- Skipping manual questions (spec already defined)...
107
- ```
108
-
109
- **IF mode = `ROADMAP_FEATURE`:** _(Skip questions, load from roadmap)_
110
-
111
- ```
112
- ---
113
- 🚀 Feature Workflow | Phase 1/4: Specification (AUTO-LOADED)
114
- ---
115
- 🗺️ Loading Feature from docs/roadmap.md: User Entity & Repository
116
-
117
- ✅ Epic: 2 - Data Layer
118
- ✅ Priority: P0
119
- ✅ Story Points: 12 SP (~2-3d)
120
- ✅ Tasks: 8 tasks (T001-T008)
121
- ✅ Dependencies: None (foundational)
122
-
123
- Skipping manual questions (roadmap already defined)...
124
- ```
125
-
126
- **IF mode = `INTERACTIVE`:** _(Ask manual questions)_
127
-
128
- Ask 3-5 key questions to understand requirements:
129
-
130
- 1. **What do you want to build?** (describe in 1-2 sentences)
131
- 2. **What endpoints/functions do you need?**
132
- 3. **What database entities/models?**
133
- 4. **Special requirements?** (real-time, authentication, etc.)
134
-
135
- **Generate:** `.ai-flow/work/NNN-feature-name/spec.md`
136
-
137
- **Example:** `.ai-flow/work/003-user-authentication/spec.md`
138
-
139
- **IF loaded from User Story (HU-XXX-XXX):**
140
-
141
- - Copy `docs/user-stories/EP-XXX/HU-XXX-XXX.md` → `.ai-flow/work/NNN-HU-XXX-XXX/spec.md`
142
- - Include: User Story format, Acceptance Criteria (Gherkin), Technical Tasks, Test Cases, DoD
143
-
144
- **IF loaded from docs/roadmap.md Feature:**
145
-
146
- - Extract Feature section → `.ai-flow/work/NNN-feature-name/spec.md`
147
- - Include: Scope, Tasks (T001-T00N), Dependencies, Ready-to-execute command
148
-
149
- **Example interaction:**
150
-
151
- ```
152
- ---
153
- 🚀 Feature Workflow | Phase 1/4: Specification
154
- ---
155
- What do you want to build? (1-2 sentences)
156
- > [Wait for user response]
157
-
158
- What endpoints/functions do you need?
159
- > [Wait for user response]
160
-
161
- What database entities?
162
- > [Wait for user response]
163
-
164
- Special requirements? (real-time, auth, etc.)
165
- > [Wait for user response]
166
- ```
167
-
168
- ### Phase 2: Technical Plan (1 minute - auto-generated)
169
-
170
- #### Step 2.1: Auto-Assign Feature Number
171
-
172
- **Generate sequential feature number for tracking and organization:**
173
-
174
- ```
175
- 🔢 Assigning feature number...
176
-
177
- Scanning .ai-flow/work/ directory...
178
- Last feature: 002-notifications
179
- New feature: 003-[feature-name]
180
-
181
- Creating: .ai-flow/work/003-[feature-name]/
182
- ```
183
-
184
- **Numbering Rules:**
185
-
186
- - Auto-increment from existing features in `.ai-flow/work/`
187
- - Format: `NNN-feature-name` (e.g., `001-auth`, `002-notifications`)
188
- - Slug: Lowercase, hyphens, no special characters
189
- - If no existing features → Start at `001`
190
-
191
- **Example transformations:**
192
-
193
- - "User Authentication" → `003-user-authentication`
194
- - "Payment Processing" → `004-payment-processing`
195
- - "Real-Time Notifications" → `005-real-time-notifications`
196
-
197
- #### Step 2.2: Analyze Project Context & Load Tasks
198
-
199
- **IF mode = `USER_STORY` or `ROADMAP_FEATURE`:** _(Reuse existing tasks)_
200
-
201
- ```
202
- ---
203
- 📐 Technical Plan (LOADED from User Story HU-001-001)
204
- ---
205
- ✅ Story Points: 5 SP (from roadmap.md)
206
- ✅ Tasks: 6 technical tasks (inherited)
207
- ✅ Test Cases: 8 QA test cases (from acceptance criteria)
208
- ✅ Acceptance Criteria: 3 scenarios (Gherkin Given/When/Then)
209
-
210
- **Tasks from User Story:** (execution order with hybrid estimation)
211
-
212
- - [ ] [T-001-001] Write User entity tests • 1 SP (~1-2h)
213
- File: tests/unit/User.spec.ts
214
- Dependencies: None
215
-
216
- - [ ] [T-001-002] Create User entity • 1 SP (~1-2h)
217
- File: src/domain/entities/User.ts
218
- Dependencies: T-001-001
219
-
220
- - [ ] [T-001-003] Implement AuthService login method • 2 SP (~3-4h)
221
- File: src/services/AuthService.ts
222
- Dependencies: T-001-002
223
-
224
- - [ ] [T-001-004] Create POST /api/auth/login endpoint • 1 SP (~1-2h)
225
- File: src/controllers/AuthController.ts
226
- Dependencies: T-001-003
227
-
228
- - [ ] [T-001-005] Write integration tests • 2 SP (~3-4h)
229
- File: tests/integration/auth.spec.ts
230
- Dependencies: T-001-003
231
-
232
- - [ ] [T-001-006] Validate against Definition of Done • trivial (~15 min)
233
- - Code review approved
234
- - Tests passing (unit + integration)
235
- - QA test cases executed (8/8)
236
- - Documentation updated
237
- - Lint/format clean
238
- Dependencies: T-001-005
239
-
240
- **Acceptance Criteria Validation:**
241
-
242
- Will verify implementation against:
243
-
244
- ✅ Scenario 1: Login exitoso
245
- Dado que el usuario tiene credenciales válidas
246
- Cuando ingresa email y contraseña correctos
247
- Entonces recibe JWT token y accede al sistema
248
-
249
- ✅ Scenario 2: Credenciales inválidas
250
- Dado que el usuario ingresa credenciales incorrectas
251
- Cuando intenta iniciar sesión
252
- Entonces recibe error 401 con mensaje claro
253
-
254
- ✅ Scenario 3: Rate limiting
255
- Dado que el usuario falla login 5 veces en 15 minutos
256
- Cuando intenta login nuevamente
257
- Entonces recibe error 429 (Too Many Requests)
258
-
259
- **QA Test Cases to Execute:**
260
-
261
- After implementation, run 8 test cases:
262
- - TC-001-001: Login exitoso (Happy Path)
263
- - TC-001-002: Credenciales inválidas (Error Case)
264
- - TC-001-003: Rate limiting (Edge Case)
265
- - [... 5 more test cases from User Story]
266
-
267
- Ready to implement? (Y/n)
268
- ```
269
-
270
- **IF mode = `INTERACTIVE`:** _(Generate plan from scratch)_
271
-
272
- Based on the project's detected stack and existing patterns, auto-generate a technical plan.
273
-
274
- **Analyze:**
275
-
276
- - Read `AGENT.md` and `ai-instructions.md` for project context
277
- - Detect framework, ORM, and tech stack
278
- - Identify existing code patterns
279
-
280
- **Detect Complexity Automatically:**
281
-
282
- Count total tasks needed based on spec. Then classify:
283
-
284
- - **SIMPLE** (1-10 tasks): Single-phase implementation
285
- - Small changes, 1-2 files, minimal dependencies
286
- - Example: Add field to entity + update endpoint
287
- - **MEDIUM** (11-40 tasks): 2-4 phases
288
- - Multiple files, some cross-layer dependencies
289
- - Example: New entity with CRUD + validation + tests
290
- - **COMPLEX** (41-80 tasks): 4-8 phases
291
- - Multiple modules, integration, extensive testing
292
- - Example: Authentication system with multiple providers
293
- - **LARGE** (81+ tasks): 8-N phases
294
- - Feature affecting entire system, major refactoring
295
- - Example: Multi-tenant architecture implementation
296
-
297
- **Story Points Estimation (Fibonacci Scale):**
298
-
299
- > 📎 **Reference:** See [prompts/shared/story-points.md](../shared/story-points.md) for the Fibonacci scale and hybrid time estimation guidelines.
300
-
301
- ### Story Points to Time Conversion (Hybrid Estimation)
302
-
303
- **Use the reference above to add precise time estimates to each task.**
304
- | **3 SP** | 4-8 hours | (~4-8h) | Simple CRUD endpoint, basic entity |
305
- | **5 SP** | 1-2 days | (~1-2d) | Complex endpoint with business logic |
306
- | **8 SP** | 2-3 days | (~2-3d) | Auth flow, complex validation |
307
- | **13 SP** | 1 week | (~1w) | Complete module with full test coverage |
308
- | **21 SP** | 2 weeks | (~2w) | Major feature with integration |
309
- | **34 SP** | 3 weeks | (~3w) | Multiple related features (Epic-level) |
310
-
311
- > **Note:** Time assumes AI-assisted development (Copilot/Claude). Without AI, multiply by 2-3x.
312
- > For team velocity adjustment, track actual time vs estimates after 2-3 features.
313
-
314
- ### Task Format Reference (Spec-Kit Inspired)
315
-
316
- **Every task must follow this format:**
317
-
318
- ```markdown
319
- - [ ] [TaskID] [Optional:P] Description • SP (~time)
320
- File: exact/path/to/file.ts
321
- Dependencies: T001, T002 (or "None")
322
- ```
323
-
324
- **Task Format & Sequencing:**
325
-
326
- > 📎 **Reference:** See [prompts/shared/task-format.md](../shared/task-format.md) for the standard task structure, sequencing rules, and parallelization guidelines.
327
-
328
- **Parallelization Rules ([P] marker):**
329
-
330
- ✅ **Use [P] when:**
331
-
332
- - Tasks target different files
333
- - No shared dependencies
334
- - Can run simultaneously (e.g., independent entities, different test suites)
335
-
336
- ❌ **Don't use [P] when:**
337
-
338
- - Task depends on another incomplete task
339
- - Same file is modified
340
- - Shared resource (DB migration, config file)
341
-
342
- **Phase Structure (for MEDIUM/COMPLEX/LARGE):**
343
-
344
- Organize tasks into logical phases:
345
-
346
- 1. **Data Layer** - Entities, migrations, repositories
347
- 2. **Business Logic** - Services, validation, business rules
348
- 3. **API Layer** - Controllers, routes, DTOs
349
- 4. **Integration** - Connect layers, middleware, error handling
350
- 5. **Testing** - Unit tests, integration tests, E2E tests
351
- 6. **Documentation** - Update docs, examples, deployment notes
352
-
353
- **Show plan to user:**
354
-
355
- - Technical decisions (libraries, patterns)
356
- - Files to create/modify
357
- - Tasks organized by phases (or flat list if SIMPLE)
358
- - Dependencies between phases
359
- - Estimated time per phase
360
-
361
- **Generate:** `.ai-flow/work/NNN-feature-name/plan.md`
362
-
363
- **Example:** `.ai-flow/work/003-user-authentication/plan.md`
364
-
365
- **Example output (SIMPLE):**
366
-
367
- ```
368
- ---
369
- 📐 Technical Plan (auto-generated)
370
- ---
371
- Based on your project (Node.js + Express + PostgreSQL):
372
-
373
- **Complexity:** SIMPLE (8 tasks) • 3 SP (~15-20 min)
374
- ⏱️ **Est. Time:** 15-20 minutes
375
-
376
- **Stack decisions:**
377
- - Validation: joi ⚡
378
-
379
- **Files to modify:**
380
- - src/entities/User.entity.ts
381
- - src/controllers/UserController.ts
382
- - tests/user.test.ts
383
-
384
- **Tasks:** (execution order with hybrid estimation)
385
-
386
- - [ ] [T001] Add email field to User entity • 1 SP (~1-2h)
387
- File: src/entities/User.entity.ts
388
- Dependencies: None
389
-
390
- - [ ] [T002] Add migration for email column • 1 SP (~1h)
391
- File: src/migrations/002_add_email_to_users.ts
392
- Dependencies: T001 (needs entity schema)
393
-
394
- - [ ] [T003] [P] Update UserController validation • 1 SP (~1h)
395
- File: src/controllers/UserController.ts
396
- Dependencies: T001 (needs entity field)
397
-
398
- - [ ] [T004] [P] Update existing user tests • 1 SP (~1h)
399
- File: tests/user.test.ts
400
- Dependencies: T001 (can run parallel with T003)
401
-
402
- - [ ] [T005] Add email validation tests • 1 SP (~1-2h)
403
- File: tests/user.test.ts
404
- Dependencies: T003 (needs controller validation)
405
-
406
- - [ ] [T006] [P] Update API documentation • trivial (~15 min)
407
- File: docs/api.md
408
- Dependencies: None (can run parallel)
409
-
410
- - [ ] [T007] [P] Update data model documentation • trivial (~15 min)
411
- File: docs/data-model.md
412
- Dependencies: None (can run parallel)
413
-
414
- - [ ] [T008] Test endpoint manually • trivial (~10 min)
415
- Dependencies: T005 (needs all code complete)
416
-
417
- **Parallelization Notes:**
418
- - T003 and T004 can run in parallel (different concerns)
419
- - T006 and T007 can run in parallel (different docs)
420
-
421
- **Total:** 3 SP (~15-20 min with AI assistance)
422
-
423
- Review plan? (Y/n)
424
- ```
425
-
426
- **Example output (COMPLEX):**
427
-
428
- ```
429
- ---
430
- 📐 Technical Plan (auto-generated)
431
- ---
432
- Based on your project (Node.js + Express + PostgreSQL):
433
-
434
- **Complexity:** COMPLEX (52 tasks across 5 phases) • 34 SP (~2-3 hours)
435
- ⏱️ **Est. Time:** 2-3 hours (with AI assistance)
436
-
437
- **Stack decisions:**
438
- - Auth: JWT with jsonwebtoken ⭐
439
- - Validation: joi ⚡
440
- - Email: nodemailer 📧
441
-
442
- ## Phase 1: Data Layer • 8 SP (~30-40 min)
443
-
444
- **Tasks:** (Test-First approach, execution order)
445
-
446
- - [ ] [T001] [P] Write unit tests for User entity (8 tests) • 2 SP (~3-4h)
447
- File: tests/unit/entities/User.entity.spec.ts
448
- Tests: email format, password hashing, role validation, timestamps
449
- Dependencies: None (can run parallel with T003, T005)
450
-
451
- - [ ] [T002] Create User entity with validation • 2 SP (~3-4h)
452
- File: src/entities/User.entity.ts
453
- Implements: Email regex, password bcrypt, role enum, timestamps
454
- Dependencies: None
455
-
456
- - [ ] [T003] [P] Write unit tests for Session entity (4 tests) • 1 SP (~1-2h)
457
- File: tests/unit/entities/Session.entity.spec.ts
458
- Tests: session creation, expiration, invalidation
459
- Dependencies: None (can run parallel with T001)
460
-
461
- - [ ] [T004] Create Session entity • 1 SP (~1-2h)
462
- File: src/entities/Session.entity.ts
463
- Implements: User FK, token, expiration, status
464
- Dependencies: T002 (needs User entity)
465
-
466
- - [ ] [T005] [P] Write unit tests for RefreshToken entity (4 tests) • 1 SP (~1-2h)
467
- File: tests/unit/entities/RefreshToken.entity.spec.ts
468
- Tests: token generation, rotation, revocation
469
- Dependencies: None (can run parallel with T001, T003)
470
-
471
- - [ ] [T006] Create RefreshToken entity • 1 SP (~1-2h)
472
- File: src/entities/RefreshToken.entity.ts
473
- Implements: User FK, token, expiration, rotation tracking
474
- Dependencies: T002 (needs User entity)
475
-
476
- - [ ] [T007] Create database migrations • 1 SP (~1-2h)
477
- File: src/migrations/001_create_auth_tables.ts
478
- Creates: users, sessions, refresh_tokens tables with indexes
479
- Dependencies: T002, T004, T006 (needs all entity schemas)
480
-
481
- - [ ] [T008] Create IUserRepository interface • 1 SP (~1h)
482
- File: src/repositories/interfaces/IUserRepository.ts
483
- Methods: create, findById, findByEmail, update, delete
484
- Dependencies: T002 (needs User entity type)
485
-
486
- - [ ] [T009] Implement UserRepository • 1 SP (~1-2h)
487
- File: src/repositories/UserRepository.ts
488
- Implements: All CRUD methods from IUserRepository
489
- Dependencies: T002, T008
490
-
491
- - [ ] [T010] Create SessionRepository • 1 SP (~1h)
492
- File: src/repositories/SessionRepository.ts
493
- Methods: create, findByToken, invalidate, findActiveByUser
494
- Dependencies: T004 (needs Session entity)
495
-
496
- - [ ] [T011] Create RefreshTokenRepository • 1 SP (~1h)
497
- File: src/repositories/RefreshTokenRepository.ts
498
- Methods: create, findByToken, revoke, rotateToken
499
- Dependencies: T006 (needs RefreshToken entity)
500
-
501
- **Task Execution Graph (Phase 1):**
502
-
503
- ```
504
-
505
- T001 [P] ──┐
506
- T003 [P] ──┼──> (Tests can run parallel)
507
- T005 [P] ──┘
508
-
509
- T002 ──┬──> T004
510
- ├──> T006
511
- ├──> T007 (needs T002, T004, T006)
512
- ├──> T008 ──> T009
513
-
514
- └──> T010 (needs T004)
515
- T011 (needs T006)
516
-
517
- ```
518
-
519
- **Parallelization Notes (Phase 1):**
520
- - T001, T003, T005 can run in parallel (different test files)
521
- - T002 is foundational (blocks T004, T006, T008, T009)
522
- - T010 and T011 can run in parallel after T004/T006 complete
523
-
524
- ## Phase 2: Business Logic • 13 SP (~50-60 min)
525
-
526
- **Tasks:**
527
-
528
- - [ ] [T012] [P] Write unit tests for AuthService (12 tests) • 3 SP (~4-8h)
529
- File: tests/unit/services/AuthService.spec.ts
530
- Tests: register, login, logout, refresh, email verification
531
- Dependencies: None (can run parallel with T014, T016)
532
-
533
- - [ ] [T013] Create AuthService • 3 SP (~4-8h)
534
- File: src/services/AuthService.ts
535
- Implements: register, login, logout, refresh, verify email
536
- Dependencies: T009, T010, T011 (needs all repositories)
537
-
538
- - [ ] [T014] [P] Write unit tests for TokenService (8 tests) • 2 SP (~3-4h)
539
- File: tests/unit/services/TokenService.spec.ts
540
- Tests: JWT generation, verification, refresh token rotation
541
- Dependencies: None (can run parallel with T012)
542
-
543
- - [ ] [T015] Create TokenService • 2 SP (~3-4h)
544
- File: src/services/TokenService.ts
545
- Implements: generateAccessToken, generateRefreshToken, verifyToken
546
- Dependencies: None (utility service)
547
-
548
- - [ ] [T016] [P] Write unit tests for EmailService (6 tests) • 2 SP (~3-4h)
549
- File: tests/unit/services/EmailService.spec.ts
550
- Tests: send verification email, send password reset
551
- Dependencies: None (can run parallel with T012, T014)
552
-
553
- - [ ] [T017] Create EmailService • 2 SP (~3-4h)
554
- File: src/services/EmailService.ts
555
- Implements: sendVerificationEmail, sendPasswordResetEmail
556
- Dependencies: None (3rd party wrapper)
557
-
558
- - [ ] [T018] Implement password hashing utility • 1 SP (~1-2h)
559
- File: src/utils/password.util.ts
560
- Implements: hashPassword, comparePassword using bcrypt
561
- Dependencies: None
562
-
563
- - [ ] [T019] Implement JWT generation logic • 2 SP (~3-4h)
564
- File: src/utils/jwt.util.ts
565
- Implements: sign, verify, decode JWT with RS256
566
- Dependencies: None
567
-
568
- - [ ] [T020] Implement refresh token rotation • 2 SP (~3-4h)
569
- File: src/utils/token-rotation.util.ts
570
- Implements: rotation detection, security checks
571
- Dependencies: T015 (needs TokenService)
572
-
573
- - [ ] [T021] Implement email verification flow • 1 SP (~1-2h)
574
- File: src/services/EmailVerificationService.ts
575
- Implements: generate verification token, verify token
576
- Dependencies: T017 (needs EmailService)
577
-
578
- **Task Execution Graph (Phase 2):**
579
-
580
- ```
581
-
582
- T012 [P] ──┐
583
- T014 [P] ──┼──> (Test suites can run parallel)
584
- T016 [P] ──┘
585
-
586
- T009, T010, T011 (from Phase 1) ──> T013 (AuthService)
587
-
588
- T015 (TokenService) ──> T020 (Token rotation)
589
- T017 (EmailService) ──> T021 (Email verification)
590
- T018 (Password utils) ──> T013 (used by AuthService)
591
- T019 (JWT utils) ──> T013 (used by AuthService)
592
-
593
- ```
594
-
595
- **Parallelization Notes (Phase 2):**
596
- - All test tasks (T012, T014, T016) can run in parallel
597
- - T015, T017, T018, T019 can run in parallel (independent utilities)
598
- - T013 blocks on T009, T010, T011 from Phase 1
599
-
600
- ## Phase 3: API Layer • 8 SP (~30-40 min)
601
-
602
- **Tasks:**
603
-
604
- - [ ] [T022] [P] Write integration tests for AuthController (10 tests) • 3 SP (~4-8h)
605
- File: tests/integration/controllers/AuthController.spec.ts
606
- Tests: POST /register, POST /login, POST /refresh, POST /logout
607
- Dependencies: None (can run parallel with T024)
608
-
609
- - [ ] [T023] Create AuthController • 3 SP (~4-8h)
610
- File: src/controllers/AuthController.ts
611
- Implements: register, login, refresh, logout, verifyEmail endpoints
612
- Dependencies: T013 (needs AuthService)
613
-
614
- - [ ] [T024] [P] Write unit tests for auth middleware (6 tests) • 2 SP (~3-4h)
615
- File: tests/unit/middleware/auth.middleware.spec.ts
616
- Tests: JWT verification, token extraction, error handling
617
- Dependencies: None (can run parallel with T022)
618
-
619
- - [ ] [T025] Create auth middleware • 2 SP (~3-4h)
620
- File: src/middleware/auth.middleware.ts
621
- Implements: requireAuth, optionalAuth, requireRole
622
- Dependencies: T015 (needs TokenService)
623
-
624
- - [ ] [T026] Create validation schemas • 1 SP (~1-2h)
625
- File: src/validators/auth.validators.ts
626
- Implements: Joi schemas for register, login, refresh payloads
627
- Dependencies: None
628
-
629
- - [ ] [T027] Create DTOs • 1 SP (~1-2h)
630
- File: src/dtos/auth.dto.ts
631
- Implements: RegisterDTO, LoginDTO, AuthResponseDTO
632
- Dependencies: None
633
-
634
- - [ ] [T028] Setup auth routes • 1 SP (~1h)
635
- File: src/routes/auth.routes.ts
636
- Implements: Route registration with validation and middleware
637
- Dependencies: T023, T025, T026 (needs controller, middleware, validators)
638
-
639
- **Task Execution Graph (Phase 3):**
640
-
641
- ```
642
-
643
- T022 [P] ──┐
644
- T024 [P] ──┘──> (Test suites can run parallel)
645
-
646
- T013 (AuthService) ──> T023 (AuthController)
647
- T015 (TokenService) ──> T025 (Auth middleware)
648
-
649
- T026 (Validators) ──┐
650
- T027 (DTOs) ├──> T028 (Routes)
651
- T023 (Controller) ┘
652
- T025 (Middleware) ─┘
653
-
654
- ```
655
-
656
- ## Phase 4: Integration • 3 SP (~15-20 min)
657
-
658
- **Tasks:**
659
-
660
- - [ ] [T029] Connect services to controllers • 1 SP (~1-2h)
661
- File: src/app.ts
662
- Implements: Dependency injection setup for controllers
663
- Dependencies: T023 (needs AuthController)
664
-
665
- - [ ] [T030] Add global error handling middleware • 1 SP (~1-2h)
666
- File: src/middleware/error.middleware.ts
667
- Implements: Catch all errors, format responses, log errors
668
- Dependencies: None
669
-
670
- - [ ] [T031] Configure CORS and security headers • 1 SP (~1h)
671
- File: src/middleware/security.middleware.ts
672
- Implements: CORS config, Helmet setup, rate limiting
673
- Dependencies: None
674
-
675
- - [ ] [T032] Register auth routes in main app • trivial (~30 min)
676
- File: src/app.ts
677
- Implements: app.use('/api/auth', authRoutes)
678
- Dependencies: T028 (needs auth routes)
679
-
680
- - [ ] [T033] Add environment variable validation • 1 SP (~1h)
681
- File: src/config/env.validation.ts
682
- Implements: Validate JWT_SECRET, DATABASE_URL, EMAIL config
683
- Dependencies: None
684
-
685
- **Task Execution Graph (Phase 4):**
686
-
687
- ```
688
-
689
- T030, T031, T033 [P] ──> (Can run parallel - different concerns)
690
-
691
- T028 ──> T029 ──> T032 (Sequential: routes → DI → registration)
692
-
693
- ```
694
-
695
- ## Phase 5: Testing & Docs • 2 SP (~10-15 min)
696
-
697
- **Tasks:**
698
-
699
- - [ ] [T034] Run full test suite and fix issues • 1 SP (~1-2h)
700
- File: N/A (command: npm test)
701
- Validates: All 47 tests passing, coverage ≥ 80%
702
- Dependencies: T001-T033 (needs all tests written)
703
-
704
- - [ ] [T035] Integration test for complete auth flow • 1 SP (~1-2h)
705
- File: tests/integration/auth-flow.spec.ts
706
- Tests: Full flow from register → login → refresh → logout
707
- Dependencies: T034 (needs all individual tests passing)
708
-
709
- - [ ] [T036] [P] Update API documentation • trivial (~20 min)
710
- File: docs/api.md
711
- Updates: Add 5 auth endpoints with request/response examples
712
- Dependencies: None (can run parallel with T037, T038)
713
-
714
- - [ ] [T037] [P] Update data model documentation • trivial (~15 min)
715
- File: docs/data-model.md
716
- Updates: Add User, Session, RefreshToken entities with relationships
717
- Dependencies: None (can run parallel with T036, T038)
718
-
719
- - [ ] [T038] [P] Update security documentation • trivial (~15 min)
720
- File: specs/security.md
721
- Updates: Document JWT flow, refresh token rotation, password policy
722
- Dependencies: None (can run parallel with T036, T037)
723
-
724
- - [ ] [T039] Add environment variables to .env.example • trivial (~10 min)
725
- File: .env.example
726
- Updates: Add JWT_SECRET, JWT_EXPIRATION, REFRESH_TOKEN_EXPIRATION
727
- Dependencies: None
728
-
729
- **Task Execution Graph (Phase 5):**
730
-
731
- ```
732
-
733
- T001-T033 ──> T034 (Run all tests) ──> T035 (E2E flow test)
734
-
735
- T036 [P] ──┐
736
- T037 [P] ──┼──> (Documentation updates can run parallel)
737
- T038 [P] ──┘
738
-
739
- T039 (env example) ──> (Independent, can run anytime)
740
-
741
- ```
742
-
743
- **Parallelization Notes (Phase 5):**
744
- - All documentation tasks (T036, T037, T038) can run in parallel
745
- - T034 must complete before T035 (E2E depends on unit/integration tests)
746
- - T039 is independent and can run anytime
747
- ---
748
- **Total:** 34 SP • 39 tasks • ~2-3 hours with AI assistance
749
- ---
750
- **Parallelization Summary:**
751
- - ✅ Phase 1: 3 test tasks parallel (T001, T003, T005)
752
- - ✅ Phase 2: 3 test tasks + 4 utility tasks parallel
753
- - ✅ Phase 3: 2 test tasks parallel (T022, T024)
754
- - ✅ Phase 4: 3 tasks parallel (T030, T031, T033)
755
- - ✅ Phase 5: 3 documentation tasks parallel (T036, T037, T038)
756
- - ⚡ With 2 devs: ~40% time savings via parallelization
757
- - ⚡ With 3 devs: ~50% time savings via parallelization
758
-
759
- Review plan? (Y/n)
760
- ```
761
- ---
762
- ### Phase 0.5: Git Branch Setup (Optional, 30 seconds)
763
-
764
- **After user confirms plan, detect Git repository:**
765
-
766
- ```bash
767
- git rev-parse --git-dir 2>/dev/null
768
- ```
769
-
770
- **If NO Git repository found:**
771
-
772
- ```
773
- ℹ️ No Git repository detected
774
-
775
- Git integration is disabled for this session.
776
- To enable Git features, initialize a repository first:
777
- git init
778
- git remote add origin <url>
779
-
780
- Continue without Git? (Y/n)
781
- ```
782
-
783
- **If Git repository detected:**
784
-
785
- ```
786
- ---
787
- 🌿 Git Integration
788
- ---
789
- Git repository detected ✅
790
- Current branch: main
791
- Status: clean
792
-
793
- Feature: notifications-websocket
794
- Suggested branch: feature/notifications-websocket
795
-
796
- Create new branch and enable Git integration?
797
-
798
- A) ⭐ Yes - Create branch + auto-commit per phase (Recommended for MEDIUM/COMPLEX/LARGE)
799
- B) Yes - Create branch + single commit at end (Good for SIMPLE)
800
- C) Work on current branch (no branch creation)
801
- D) Skip Git integration (work without commits)
802
-
803
- Your choice (A): __
804
- ```
805
-
806
- **Smart defaults based on complexity:**
807
-
808
- - **SIMPLE** (1-10 tasks) → Suggest **Option B** (single commit at end)
809
- - **MEDIUM/COMPLEX/LARGE** (11+ tasks) → Suggest **Option A** (commit per phase)
810
-
811
- **Edge Case 1: Uncommitted Changes Detected**
812
-
813
- ```bash
814
- git status --porcelain
815
- ```
816
-
817
- If output is non-empty:
818
-
819
- ```
820
- ⚠️ Uncommitted changes detected:
821
-
822
- M src/controllers/UserController.ts
823
- M src/services/AuthService.ts
824
- ?? new-file.ts
825
-
826
- Options:
827
- A) Stash changes and proceed (git stash)
828
- B) Commit changes first (I'll guide you)
829
- C) Continue anyway (changes will be included)
830
- D) Cancel workflow
831
-
832
- Your choice (A): __
833
- ```
834
-
835
- **If A selected:** `git stash && git stash list` → Show stash confirmation
836
- **If B selected:** Guide conventional commit, then continue
837
- **If D selected:** Exit workflow
838
-
839
- **Edge Case 2: Already on Feature Branch**
840
-
841
- ```bash
842
- git rev-parse --abbrev-ref HEAD
843
- ```
844
-
845
- If result starts with `feature/`, `fix/`, or `refactor/`:
846
-
847
- ```
848
- ⚠️ You're currently on branch: feature/other-work
849
-
850
- Options:
851
- A) Continue on this branch (may mix work)
852
- B) Create new branch from current (branch off)
853
- C) Switch to main/develop first (recommended)
854
- D) Skip Git integration
855
-
856
- Your choice (C): __
857
- ```
858
-
859
- **If C selected:** `git checkout main` → Then proceed with branch creation
860
-
861
- **Edge Case 3: Branch Name Already Exists**
862
-
863
- ```bash
864
- git show-ref --verify --quiet refs/heads/feature/notifications-websocket
865
- ```
866
-
867
- If exists:
868
-
869
- ```
870
- ⚠️ Branch 'feature/notifications-websocket' already exists
871
-
872
- Options:
873
- A) Use different name (feature/notifications-websocket-v2)
874
- B) Checkout existing branch (continue previous work)
875
- C) Skip Git integration
876
-
877
- Your choice (A): __
878
- ```
879
-
880
- **Edge Case 4: Detached HEAD State**
881
-
882
- ```bash
883
- git symbolic-ref -q HEAD || echo "detached"
884
- ```
885
-
886
- If detached:
887
-
888
- ```
889
- ⚠️ Detached HEAD state detected
890
-
891
- You're not on a branch. Git integration requires a branch.
892
-
893
- Options:
894
- A) Create new branch here (git checkout -b feature/notifications)
895
- B) Go back to previous branch (git checkout -)
896
- C) Switch to main (git checkout main)
897
- D) Skip Git integration
898
-
899
- Your choice (C): __
900
- ```
901
-
902
- **Actions if user enables Git integration (Options A or B):**
903
-
904
- 1. **Create branch:**
905
-
906
- ```bash
907
- git checkout -b feature/notifications-websocket
908
- ```
909
-
910
- 2. **Update status.json:**
911
-
912
- ```json
913
- {
914
- "git": {
915
- "enabled": true,
916
- "autoCommit": "phase" | "end", // Based on user choice A or B
917
- "branchCreated": true,
918
- "branchName": "feature/notifications-websocket",
919
- "sourceBranch": "main",
920
- "commits": [],
921
- "lastCommitSha": null,
922
- "uncommittedChanges": false,
923
- "readyForPR": false,
924
- "prSuggested": false
925
- }
926
- }
927
- ```
928
-
929
- 3. **Show confirmation:**
930
-
931
- ```
932
- ✅ Branch created: feature/notifications-websocket
933
- 📦 Git commits will be created: per phase
934
-
935
- Proceeding to implementation...
936
- ```
937
-
938
- **If user skips Git (Options C or D):**
939
-
940
- ```json
941
- {
942
- "git": {
943
- "enabled": false
944
- }
945
- }
946
- ```
947
- ---
948
- ### Phase 3: Progressive Implementation (10-15 minutes)
949
-
950
- **STEP 3.1: Choose Implementation Mode**
951
-
952
- After user confirms plan (Review plan? Y), suggest smart default based on complexity:
953
-
954
- **Smart Defaults:**
955
-
956
- - **SIMPLE** → Mode 1 (Auto) - Fast, no pauses needed
957
- - **MEDIUM** → Mode 2 (Phase-by-phase) - Balanced control
958
- - **COMPLEX/LARGE** → Mode 2 (Phase-by-phase) - Review between phases
959
-
960
- Ask with recommended default:
961
-
962
- ```
963
- ---
964
- ⚙️ Implementation Mode
965
- ---
966
- Recommended: Phase-by-phase (based on COMPLEX feature)
967
-
968
- How do you want to proceed?
969
-
970
- 1. 🚀 Auto (implement all tasks automatically)
971
- 2. 📋 Phase-by-phase (pause after each phase for review) ⭐ RECOMMENDED
972
- 3. 🔍 Task-by-task (manual approval for each task)
973
- 4. 💾 Save and resume later
974
-
975
- Your choice (2): [1/2/3/4]
976
- ```
977
-
978
- **Note:** User can override recommended mode by typing different number, or press Enter to accept default.
979
-
980
- **STEP 3.2: Execute Based on Mode**
981
-
982
- #### Mode 1: Auto (Default for SIMPLE features)
983
-
984
- Execute all tasks automatically with progress updates:
985
-
986
- ```
987
- ---
988
- ⚙️ Implementation (Auto Mode)
989
- ---
990
- Task 1/12: Create User entity ✅
991
- Task 2/12: Create AuthService ✅
992
- Task 3/12: Create AuthController ✅
993
- ...
994
- Task 12/12: Update documentation ✅
995
-
996
- All tasks completed! ✅
997
- ```
998
-
999
- #### Mode 2: Phase-by-phase (Recommended for COMPLEX features)
1000
-
1001
- Execute one phase at a time, pause for review:
1002
-
1003
- ```
1004
- ---
1005
- ⚙️ Implementation (Phase-by-phase Mode)
1006
- ---
1007
- PHASE 1/5: Data Layer
1008
- ├── Task 1.1: Create User entity ✅
1009
- ├── Task 1.2: Create Session entity ✅
1010
- ├── Task 1.3: Create RefreshToken entity ✅
1011
- ├── Task 1.4: Create migrations ✅
1012
- ├── Task 1.5: Create UserRepository ✅
1013
- └── ... (5 more tasks) ✅
1014
- ---
1015
- ✅ Phase 1 Complete (10/10 tasks)
1016
- ---
1017
- 📁 Files created:
1018
- - src/entities/User.entity.ts
1019
- - src/entities/Session.entity.ts
1020
- - src/entities/RefreshToken.entity.ts
1021
- - src/migrations/001_create_auth_tables.ts
1022
- - src/repositories/UserRepository.ts
1023
-
1024
- **If git.enabled === true AND git.autoCommit === "phase":**
1025
-
1026
- **Pre-commit Validation:**
1027
-
1028
- ```
1029
-
1030
- 🔍 Running pre-commit checks...
1031
- ✅ Lint passed (eslint --fix applied)
1032
- ✅ Tests passed (24/24, +10 new tests)
1033
- ✅ Type check passed
1034
-
1035
- ```
1036
-
1037
- **If validation FAILS:**
1038
-
1039
- ```
1040
-
1041
- ❌ Pre-commit checks failed:
1042
-
1043
- Lint errors (2):
1044
-
1045
- - src/entities/User.entity.ts:15 - Missing semicolon
1046
- - src/entities/Session.entity.ts:22 - Unused import
1047
-
1048
- Options:
1049
- A) Fix issues automatically and retry
1050
- B) Skip commit (continue without committing)
1051
- C) Show errors and let me fix manually
1052
- D) Force commit anyway (not recommended)
1053
-
1054
- Your choice (A): \_\_
1055
-
1056
- ```
1057
-
1058
- **If option A:** Run fixes, re-validate, continue
1059
- **If option B:** Skip commit, set `uncommittedChanges: true`
1060
- **If option C:** Show errors, pause workflow
1061
- **If option D:** Commit with `--no-verify`
1062
-
1063
- **If validation PASSES:**
1064
-
1065
- ```
1066
-
1067
- 📦 Creating commit for Phase 1...
1068
-
1069
- Conventional Commit:
1070
- Type: feat
1071
- Scope: entities
1072
- Subject: add authentication entities and migrations
1073
-
1074
- Generated commit message:
1075
- ───────────────────────────────────────────────────────
1076
- feat(entities): add authentication entities and migrations
1077
-
1078
- - Create User entity with email verification
1079
- - Create Session entity for active sessions tracking
1080
- - Create RefreshToken entity with rotation support
1081
- - Add migrations for auth tables
1082
- - Add UserRepository with findByEmail method
1083
-
1084
- Files changed: 5
1085
- Lines added: 245
1086
- ───────────────────────────────────────────────────────
1087
-
1088
- Commit this? (Y/n/edit): \_\_
1089
-
1090
- ````
1091
-
1092
- **If Y:** Execute commit
1093
- **If n:** Skip commit
1094
- **If edit:** Allow editing commit message
1095
-
1096
- **Execute commit:**
1097
-
1098
- ```bash
1099
- git add .
1100
- git commit -m "feat(entities): add authentication entities and migrations
1101
-
1102
- - Create User entity with email verification
1103
- - Create Session entity for active sessions tracking
1104
- - Create RefreshToken entity with rotation support
1105
- - Add migrations for auth tables
1106
- - Add UserRepository with findByEmail method"
1107
- ````
1108
-
1109
- **Update status.json:**
1110
-
1111
- ```json
1112
- {
1113
- "git": {
1114
- "commits": [
1115
- {
1116
- "sha": "abc123def456",
1117
- "type": "feat",
1118
- "scope": "entities",
1119
- "message": "add authentication entities and migrations",
1120
- "phase": 1,
1121
- "timestamp": "2025-12-04T14:30:00Z",
1122
- "filesChanged": 5
1123
- }
1124
- ],
1125
- "lastCommitSha": "abc123def456",
1126
- "uncommittedChanges": false
1127
- }
1128
- }
1129
- ```
1130
-
1131
- **Show confirmation:**
1132
-
1133
- ```
1134
- ✅ Committed: abc123de
1135
- feat(entities): add authentication entities and migrations
1136
- ```
1137
-
1138
- Continue to Phase 2? (Y/n/pause)
1139
-
1140
- > Y
1141
-
1142
- PHASE 2/5: Business Logic
1143
- ├── Task 2.1: Create AuthService ✅
1144
- ...
1145
-
1146
- ```
1147
-
1148
- **Options after each phase:**
1149
-
1150
- - **Y** → Continue to next phase
1151
- - **n** → Stop and allow modifications
1152
- - **pause** → Save progress and exit (can resume with `/work resume`)
1153
-
1154
- #### Mode 3: Task-by-task (Maximum control)
1155
-
1156
- Ask confirmation before each task:
1157
-
1158
- ```
1159
- ---
1160
- ⚙️ Implementation (Task-by-task Mode)
1161
- ---
1162
- Next task: Create User entity
1163
- Files to create: src/entities/User.entity.ts
1164
-
1165
- Proceed? (Y/n/skip/pause)
1166
-
1167
- > Y
1168
-
1169
- [Creates User.entity.ts]
1170
-
1171
- ✅ Task 1/12 complete
1172
-
1173
- Next task: Create AuthService
1174
- Files to create: src/services/AuthService.ts
1175
-
1176
- Proceed? (Y/n/skip/pause)
1177
-
1178
- > Y
1179
-
1180
- ```
1181
-
1182
- **Options for each task:**
1183
-
1184
- - **Y** → Execute task
1185
- - **n** → Stop (allow manual work)
1186
- - **skip** → Skip this task
1187
- - **pause** → Save and exit
1188
-
1189
- #### Mode 4: Save and resume later
1190
-
1191
- Save current state and exit:
1192
-
1193
- ```
1194
- ---
1195
- 💾 Progress Saved
1196
- ---
1197
- Current progress: 0/52 tasks (0%)
1198
- Status: Ready to start
1199
-
1200
- To resume: /work resume feature-[name]
1201
-
1202
- ```
1203
-
1204
- **Generate:** `.ai-flow/work/NNN-feature-name/tasks.md` (with ✅ checkmarks)
1205
-
1206
- **Example:** `.ai-flow/work/003-user-authentication/tasks.md`
1207
-
1208
- **Implementation rules:**
1209
-
1210
- - Follow project conventions detected in codebase
1211
- - Use same code style as existing files
1212
- - Write tests for all new code
1213
- - Validate each task before marking complete
1214
- - Update status.json after each task/phase
1215
-
1216
- ### Phase 4: Security Check + Validation + Auto-Archive (1-2 minutes)
1217
-
1218
- **IF mode = `USER_STORY`:** *(Validate against Definition of Done)*
1219
-
1220
- ```
1221
- ---
1222
- ✅ Definition of Done Validation (from HU-001-001)
1223
- ---
1224
- Validating User Story completion...
1225
-
1226
- ✅ Código implementado siguiendo ai-instructions.md
1227
- ✅ Code review aprobado (mín 1 revisor) [Simulated: Auto-approved by AI]
1228
- ✅ Tests unitarios escritos (cobertura > 80%) [Coverage: 92%]
1229
- ✅ Tests de integración pasando [8/8 passing]
1230
- ✅ Casos de prueba QA ejecutados y aprobados (8/8)
1231
- ✅ TC-001-001: Login exitoso (Happy Path)
1232
- ✅ TC-001-002: Credenciales inválidas (Error Case)
1233
- ✅ TC-001-003: Rate limiting (Edge Case)
1234
- ... [5 more test cases]
1235
- ✅ Documentación técnica actualizada (docs/api.md)
1236
- ✅ Sin errores de lint ni formateo
1237
- ⚠️ Deploy a staging exitoso [SKIP: Local development]
1238
- ⚠️ Product Owner aprobó la funcionalidad [SKIP: Manual step]
1239
- ---
1240
- Acceptance Criteria Verification
1241
- ---
1242
- ✅ Scenario 1: Login exitoso
1243
- Test: TC-001-001 passed
1244
- Verified: JWT token returned with valid exp, user_id, role
1245
-
1246
- ✅ Scenario 2: Credenciales inválidas
1247
- Test: TC-001-002 passed
1248
- Verified: 401 status with clear error message
1249
-
1250
- ✅ Scenario 3: Rate limiting
1251
- Test: TC-001-003 passed
1252
- Verified: 429 status after 5 failed attempts in 15 minutes
1253
-
1254
- All acceptance criteria met! ✅
1255
-
1256
- ```
1257
-
1258
- **IF mode = `ROADMAP_FEATURE` or `INTERACTIVE`:** *(Standard security check)*
1259
-
1260
- **Security Quick Check:**
1261
- Ask 1-2 questions about production considerations:
1262
-
1263
- - Add rate limiting?
1264
- - Input validation sufficient?
1265
- - Consider [specific concern] for production?
1266
-
1267
- **Auto-Archive:**
1268
-
1269
- 1. Move work to `.ai-flow/archive/YYYY-MM/feature-[name]/`
1270
- 2. Update affected documentation:
1271
- - `docs/api.md` (if new endpoints)
1272
- - `docs/data-model.md` (if new entities)
1273
- - `specs/security.md` (if auth/permissions changed)
1274
- 3. Generate final summary
1275
-
1276
- **Example output:**
1277
-
1278
- ```
1279
- ---
1280
- 🔒 Security Quick Check
1281
- ---
1282
- ✅ Password hashing: bcrypt cost 12
1283
- ✅ JWT secret: from env variable
1284
- ⚠️ Consider: Rate limiting on login endpoint
1285
-
1286
- Add rate limiting now? (Y/n)
1287
-
1288
- ```
1289
-
1290
- **Documentation Updates:**
1291
-
1292
- Update affected documentation files:
1293
- - `docs/api.md` - Add new endpoints
1294
- - `docs/data-model.md` - Add new entities
1295
- - `.env.example` - Add new environment variables
1296
-
1297
- **If git.enabled === true:**
1298
-
1299
- **Final Documentation Commit:**
1300
-
1301
- ```
1302
-
1303
- 📦 Creating final documentation commit...
1304
-
1305
- Conventional Commit:
1306
- Type: docs
1307
- Scope: api
1308
- Subject: update documentation for authentication feature
1309
-
1310
- Generated commit message:
1311
- ───────────────────────────────────────────────────────
1312
- docs(api): update documentation for authentication feature
1313
-
1314
- - Add 5 authentication endpoints with examples
1315
- - Update data model with User, Session, RefreshToken entities
1316
- - Add environment variables for JWT configuration
1317
- - Document rate limiting on auth endpoints
1318
-
1319
- Files changed: 3
1320
- ───────────────────────────────────────────────────────
1321
-
1322
- Commit? (Y/n): \_\_
1323
-
1324
- ```
1325
-
1326
- **After final commit:**
1327
-
1328
- ```
1329
- ---
1330
- ✅ Feature Complete!
1331
- ---
1332
- **IF mode = `USER_STORY`:**
1333
-
1334
- ```
1335
- Summary:
1336
-
1337
- - User Story: HU-001-001 - Login básico con email y contraseña
1338
- - Epic: EP-001 - Autenticación y Seguridad
1339
- - Priority: Alta (P0)
1340
- - Story Points: 5 SP (estimated) → 4.8 SP (actual)
1341
- - Time: 1.5 hours (estimated: 6-8h with AI assistance)
1342
- - Files: 6 created, 2 modified
1343
- - Tests: 8 added (all passing ✅)
1344
-
1345
- ✅ Acceptance Criteria: 3/3 verified
1346
- ✅ Test Cases: 8/8 executed and passed
1347
- ✅ Definition of Done: 7/9 completed (2 manual steps pending)
1348
-
1349
- Dependencies resolved:
1350
- ✅ Blocks: HU-001-002 (OAuth login) - Ready to start
1351
- ✅ Blocks: HU-002-001 (User CRUD) - Ready to start
1352
-
1353
- 📖 User Story Status: COMPLETED ✅
1354
- File: .ai-flow/user-stories/EP-001/HU-001-001.md updated with completion date
1355
- ```
1356
-
1357
- **IF mode = `ROADMAP_FEATURE` or `INTERACTIVE`:**
1358
-
1359
- ```
1360
- Summary:
1361
-
1362
- - Feature: JWT authentication system
1363
- - Files: 28 created, 5 modified
1364
- - Tests: 47 added (all passing ✅)
1365
- - Time: 2.5 hours
1366
- - Complexity: COMPLEX (52 tasks, 5 phases)
1367
- ```
1368
-
1369
- 📦 Git Summary:
1370
- Branch: feature/auth-jwt-system
1371
- Source: main
1372
- Commits: 6
1373
-
1374
- 1. feat(entities): add authentication entities and migrations
1375
- 2. feat(services): implement AuthService and TokenService
1376
- 3. feat(api): add authentication endpoints
1377
- 4. feat(middleware): add JWT verification middleware
1378
- 5. test(auth): add comprehensive test suite
1379
- 6. docs(api): update documentation for authentication feature
1380
-
1381
- All changes committed ✅
1382
- Ready for Pull Request ✅
1383
- ---
1384
- Would you like to create a Pull Request?
1385
-
1386
- A) Show PR command (recommended)
1387
- B) No, I'll create it later
1388
-
1389
- Your choice (A): \_\_
1390
-
1391
- ```
1392
-
1393
- **If option A selected:**
1394
-
1395
- ```
1396
-
1397
- To create a Pull Request, run:
1398
-
1399
- gh pr create \
1400
- --title "feat: JWT authentication system" \
1401
- --body "## Summary
1402
- Implements complete JWT authentication with refresh tokens, email verification, and session management.
1403
-
1404
- ## Changes
1405
-
1406
- - **Entities:** User, Session, RefreshToken with relationships
1407
- - **Services:** AuthService, TokenService, EmailService
1408
- - **API:** 5 endpoints (register, login, refresh, logout, verify-email)
1409
- - **Security:** bcrypt password hashing, JWT with RS256
1410
- - **Tests:** 47 tests (unit + integration), 95% coverage
1411
-
1412
- ## Documentation
1413
-
1414
- - API endpoints documented in docs/api.md
1415
- - Data model updated in docs/data-model.md
1416
- - Environment variables in .env.example
1417
-
1418
- ## Testing
1419
-
1420
- - ✅ All 47 tests passing
1421
- - ✅ Lint checks passed
1422
- - ✅ Type checks passed
1423
- - ✅ Security review completed" \
1424
- --base main \
1425
- --head feature/auth-jwt-system
1426
-
1427
- Or open in browser:
1428
- https://github.com/[user]/[repo]/compare/main...feature/auth-jwt-system
1429
-
1430
- ````
1431
-
1432
- **Update status.json:**
1433
-
1434
- ```json
1435
- {
1436
- "git": {
1437
- "readyForPR": true,
1438
- "prSuggested": true
1439
- }
1440
- }
1441
- ````
1442
- ---
1443
- ## Files Generated
1444
-
1445
- ### During workflow (work directory):
1446
-
1447
- ```
1448
- .ai-flow/work/NNN-feature-name/
1449
- ├── spec.md # What is being built
1450
- ├── plan.md # How it will be built
1451
- ├── tasks.md # Checklist with ✅
1452
- ├── status.json # Metadata (progress, timestamps)
1453
-
1454
- **Example:** `.ai-flow/work/003-user-authentication/`
1455
- └── implementation.md # Optional implementation notes
1456
- ```
1457
-
1458
- ### After completion (archive):
1459
-
1460
- ```
1461
- .ai-flow/archive/YYYY-MM/NNN-feature-name/
1462
- ├── spec.md
1463
- ├── plan.md
1464
- ├── tasks.md
1465
- └── summary.md # Final summary with stats
1466
-
1467
- **Example:** `.ai-flow/archive/2025-01/003-user-authentication/`
1468
- ```
1469
- ---
1470
- ## status.json Schema
1471
-
1472
- ```json
1473
- {
1474
- "name": "feature-notifications",
1475
- "type": "feature",
1476
- "subtype": "new" | "change" | "refactor",
1477
- "complexity": "simple" | "medium" | "complex" | "large",
1478
- "status": "in_progress" | "completed" | "paused",
1479
- "phase": "spec" | "plan" | "implementation" | "done",
1480
- "implementationMode": "auto" | "phase-by-phase" | "task-by-task",
1481
- "progress": {
1482
- "completed": 12,
1483
- "total": 52,
1484
- "percentage": 23,
1485
- "currentPhase": 2,
1486
- "totalPhases": 5,
1487
- "currentTask": "2.3"
1488
- },
1489
- "phases": [
1490
- {
1491
- "id": 1,
1492
- "name": "Data Layer",
1493
- "tasks": 10,
1494
- "completed": 10,
1495
- "status": "completed"
1496
- },
1497
- {
1498
- "id": 2,
1499
- "name": "Business Logic",
1500
- "tasks": 15,
1501
- "completed": 2,
1502
- "status": "in_progress"
1503
- }
1504
- ],
1505
- "created": "2025-01-20T10:00:00Z",
1506
- "updated": "2025-01-20T15:30:00Z",
1507
- "lastPauseReason": "User requested pause after Phase 1",
1508
- "filesCreated": ["src/entities/Notification.entity.ts", "..."],
1509
- "filesModified": ["src/app.ts"],
1510
- "affectedDocs": ["docs/api.md", "docs/data-model.md"],
1511
- "git": {
1512
- "enabled": true,
1513
- "autoCommit": "phase" | "end" | "off",
1514
- "branchCreated": true,
1515
- "branchName": "feature/notifications-websocket",
1516
- "sourceBranch": "main",
1517
- "commits": [
1518
- {
1519
- "sha": "abc123def456",
1520
- "type": "feat",
1521
- "scope": "entities",
1522
- "message": "add Notification entity with websocket support",
1523
- "phase": 1,
1524
- "timestamp": "2025-01-20T14:30:00Z",
1525
- "filesChanged": 5
1526
- },
1527
- {
1528
- "sha": "def456abc789",
1529
- "type": "feat",
1530
- "scope": "services",
1531
- "message": "implement NotificationService with real-time delivery",
1532
- "phase": 2,
1533
- "timestamp": "2025-01-20T15:00:00Z",
1534
- "filesChanged": 8
1535
- }
1536
- ],
1537
- "lastCommitSha": "def456abc789",
1538
- "uncommittedChanges": false,
1539
- "readyForPR": false,
1540
- "prSuggested": false
1541
- }
1542
- }
1543
- ```
1544
- ---
1545
- ## Git Integration
1546
-
1547
- ### Overview
1548
-
1549
- Git integration is **optional** and **non-intrusive**. It helps isolate changes in feature branches and create atomic commits automatically per phase or at the end.
1550
-
1551
- **Key Benefits:**
1552
-
1553
- - ✅ Automatic branch creation with smart naming (`feature/[name]`)
1554
- - ✅ Conventional Commits enforced (feat/fix/refactor/docs/test)
1555
- - ✅ Pre-commit validation (lint + tests + type check)
1556
- - ✅ Atomic commits per phase (MEDIUM/COMPLEX/LARGE) or single commit (SIMPLE)
1557
- - ✅ Pull Request suggestion with pre-filled template
1558
- - ❌ **NO automatic push** (always local only for safety)
1559
-
1560
- ### When Git is Used
1561
-
1562
- **Branch Creation:** Optional at Phase 0.5 (after plan approval, before implementation)
1563
- **Commit Points:**
1564
-
1565
- - **SIMPLE features** (1-10 tasks): Single commit at end
1566
- - **MEDIUM/COMPLEX/LARGE** (11+ tasks): Commit after each phase completion
1567
-
1568
- ### Conventional Commits Format
1569
-
1570
- **Enforced types:**
1571
-
1572
- - `feat` - New feature or functionality
1573
- - `fix` - Bug fix
1574
- - `refactor` - Code refactoring
1575
- - `docs` - Documentation updates
1576
- - `test` - Test additions or updates
1577
- - `chore` - Maintenance tasks
1578
- - `perf` - Performance improvements
1579
- - `style` - Code style changes (formatting, etc.)
1580
-
1581
- **Format:**
1582
-
1583
- ```
1584
- <type>(<scope>): <subject>
1585
-
1586
- <body>
1587
-
1588
- <footer>
1589
- ```
1590
-
1591
- **Examples:**
1592
-
1593
- ```bash
1594
- # Feature with entities
1595
- feat(entities): add Notification and NotificationSetting entities
1596
-
1597
- - Create Notification entity with user relationship
1598
- - Create NotificationSetting entity for preferences
1599
- - Add migrations for notifications tables
1600
- - Add indexes for performance
1601
-
1602
- # Feature with services
1603
- feat(services): implement NotificationService with real-time delivery
1604
-
1605
- - NotificationService with create, read, mark as read
1606
- - WebSocket integration for real-time push
1607
- - Email fallback for offline users
1608
- - Unit tests for all methods
1609
-
1610
- # Documentation update
1611
- docs(api): update documentation for notifications feature
1612
-
1613
- - Add 3 notification endpoints with examples
1614
- - Update data model with Notification entity
1615
- - Add environment variables for WebSocket
1616
- ```
1617
-
1618
- ### Pre-commit Validation
1619
-
1620
- **Runs automatically before every commit:**
1621
-
1622
- 1. **Lint check** - ESLint/Prettier/Black/etc.
1623
- 2. **Test execution** - Run full test suite
1624
- 3. **Type check** - TypeScript/MyPy (if applicable)
1625
-
1626
- **If validation fails:**
1627
-
1628
- - Show errors clearly with file and line numbers
1629
- - Offer to auto-fix (if possible)
1630
- - Allow skip or manual fix
1631
- - Force commit option available (not recommended)
1632
-
1633
- **Example validation output:**
1634
-
1635
- ```
1636
- 🔍 Running pre-commit checks...
1637
- ✅ Lint passed (eslint --fix applied)
1638
- ✅ Tests passed (47/47, +12 new tests)
1639
- ✅ Type check passed
1640
-
1641
- Ready to commit ✅
1642
- ```
1643
-
1644
- ### Edge Cases Handled
1645
-
1646
- 1. ✅ **Uncommitted changes** - Stash, commit first, or continue with them
1647
- 2. ✅ **Already on feature branch** - Continue, branch off, or switch to main
1648
- 3. ✅ **Branch name conflict** - Suggest alternative name or checkout existing
1649
- 4. ✅ **Detached HEAD** - Prompt to create branch or switch to existing
1650
- 5. ✅ **No Git repository** - Disable Git integration gracefully
1651
- 6. ✅ **Behind remote** - Suggest pull before starting (if applicable)
1652
- 7. ✅ **Merge conflicts** - Pause and instruct manual resolution
1653
- 8. ✅ **Large changesets** - Suggest splitting commits by logical groups
1654
- 9. ✅ **Validation failures** - Auto-fix, skip, show errors, or force commit
1655
-
1656
- ### Workflow Example (COMPLEX Feature)
1657
-
1658
- ```
1659
- 1. User runs: /feature new
1660
- 2. Phase 1: Specification (user answers questions)
1661
- 3. Phase 2: Technical Plan (AI generates plan, 52 tasks, 5 phases)
1662
- 4. Phase 0.5: Git Setup
1663
- → Detect Git repo ✅
1664
- → Suggest: feature/auth-jwt-system
1665
- → User confirms: Create branch + commit per phase
1666
- → Branch created ✅
1667
- 5. Phase 3: Implementation (Phase-by-phase mode)
1668
- → Phase 1: Data Layer (10 tasks)
1669
- → Pre-commit validation ✅
1670
- → Commit: feat(entities): add authentication entities
1671
- → Phase 2: Business Logic (15 tasks)
1672
- → Pre-commit validation ✅
1673
- → Commit: feat(services): implement auth services
1674
- → ... (continue for remaining phases)
1675
- 6. Phase 4: Security Check + Archive
1676
- → Update documentation
1677
- → Final commit: docs(api): update auth documentation
1678
- → Show PR command: gh pr create ...
1679
- 7. Done! 6 commits ready for PR ✅
1680
- ```
1681
-
1682
- ### Configuration (Optional)
1683
-
1684
- **File:** `.ai-flow/core/config.json`
1685
-
1686
- ```json
1687
- {
1688
- "git": {
1689
- "enabled": true,
1690
- "autoCommit": "phase", // "phase" | "end" | "off"
1691
- "autoCreateBranch": true,
1692
- "branchPrefix": "feature", // "feature" | "feat" | "work"
1693
- "commitFormat": "conventional", // always conventional
1694
- "pushAfterCommit": false, // always false
1695
- "prSuggestion": true
1696
- }
1697
- }
1698
- ```
1699
-
1700
- ### Messages Style
1701
-
1702
- **Non-intrusive, informative, brief:**
1703
-
1704
- ✅ **Good:**
1705
-
1706
- ```
1707
- ✅ Committed: abc123de
1708
- feat(entities): add notification entities
1709
- ```
1710
-
1711
- ❌ **Bad:**
1712
-
1713
- ```
1714
- 🎉🎉🎉 COMMIT SUCCESSFUL! 🎉🎉🎉
1715
- SHA: abc123def456789abcdef123456789abcdef1234
1716
- Author: John Doe <john@example.com>
1717
- Date: Wed Dec 4 15:30:00 2025 -0500
1718
- Files changed: 5 insertions(+), 2 deletions(-)
1719
- Would you like to push to remote? (Y/n)
1720
- Configure CI/CD pipeline? (Y/n)
1721
- Set up code review? (Y/n)
1722
- ...
1723
- ```
1724
-
1725
- ### Disabling Git Integration
1726
-
1727
- **To work without Git:**
1728
-
1729
- 1. **During Phase 0.5:** Select option D (Skip Git integration)
1730
- 2. **In config:** Set `"enabled": false`
1731
- 3. **No Git repo:** Automatically disabled
1732
-
1733
- **Git integration will never block your workflow.**
1734
- ---
1735
- ## Important Rules
1736
-
1737
- ### 1. Project Context
1738
-
1739
- **Before starting ANY work:**
1740
-
1741
- - Read `AGENT.md` for project guidelines
1742
- - Read `ai-instructions.md` for tech stack and conventions
1743
- - Scan existing code to understand patterns
1744
- - Follow project's existing code style
1745
-
1746
- ### 2. Continuous Validation
1747
-
1748
- - Each task must validate before moving to next
1749
- - Tests must pass before marking task complete
1750
- - Spec requirements must be 100% fulfilled
1751
- - No placeholders - only working code
1752
- - Update status.json after each task/phase completion
1753
- - In phase-by-phase mode, validate entire phase before pausing
1754
-
1755
- ### 3. Automatic Documentation
1756
-
1757
- - Update all affected docs when archiving
1758
- - Maintain consistency with existing documentation
1759
- - Use same format as existing docs
1760
- - Include examples in API documentation
1761
-
1762
- ### 4. Quality Standards
1763
-
1764
- - Write tests for all new functionality
1765
- - Follow SOLID principles
1766
- - Handle errors appropriately
1767
- - Add input validation
1768
- - Consider security implications
1769
- ---
1770
- ## Example Outputs
1771
-
1772
- ### Example 1: SIMPLE Feature (Auto Mode)
1773
-
1774
- ```
1775
- ---
1776
- ✅ Feature Complete!
1777
- ---
1778
- Complexity: SIMPLE
1779
- Mode: Auto
1780
- Duration: 18 minutes
1781
-
1782
- Summary:
1783
- - 8 tasks completed
1784
- - 3 files modified
1785
- - 5 tests passed (100% coverage)
1786
- - Documentation updated
1787
-
1788
- ✏️ Files modified:
1789
- - src/entities/User.entity.ts
1790
- - src/controllers/UserController.ts
1791
- - tests/user.test.ts
1792
-
1793
- 📚 Documentation updated:
1794
- - docs/data-model.md (added email field)
1795
-
1796
- 📦 Work archived: .ai-flow/archive/2025-01/feature-user-email/
1797
-
1798
- Next steps:
1799
- 1. Run tests: npm test
1800
- 2. Test endpoint manually
1801
- ```
1802
-
1803
- ### Example 2: COMPLEX Feature (Phase-by-phase Mode)
1804
-
1805
- ```
1806
- ---
1807
- ✅ Feature Complete!
1808
- ---
1809
- Complexity: COMPLEX
1810
- Mode: Phase-by-phase
1811
- Duration: 2h 15min (across 5 phases)
1812
-
1813
- Summary:
1814
- - 52 tasks completed across 5 phases
1815
- - 15 files created
1816
- - 4 files modified
1817
- - 48 tests passed (98% coverage)
1818
- - Documentation updated
1819
-
1820
- 📁 Files created (by phase):
1821
- PHASE 1 - Data Layer:
1822
- - src/entities/User.entity.ts
1823
- - src/entities/Session.entity.ts
1824
- - src/entities/RefreshToken.entity.ts
1825
- - src/repositories/UserRepository.ts
1826
- - src/migrations/001_create_auth_tables.ts
1827
-
1828
- PHASE 2 - Business Logic:
1829
- - src/services/AuthService.ts
1830
- - src/services/TokenService.ts
1831
- - src/services/EmailService.ts
1832
-
1833
- PHASE 3 - API Layer:
1834
- - src/controllers/AuthController.ts
1835
- - src/middleware/auth.middleware.ts
1836
- - src/validators/auth.validators.ts
1837
-
1838
- PHASE 4 - Integration:
1839
- - src/routes/auth.routes.ts
1840
-
1841
- PHASE 5 - Testing:
1842
- - tests/unit/AuthService.test.ts
1843
- - tests/integration/auth.api.test.ts
1844
-
1845
- ✏️ Files modified:
1846
- - src/app.ts (registered routes)
1847
- - src/routes/index.ts
1848
- - package.json (added dependencies)
1849
- - .env.example (added JWT variables)
1850
-
1851
- 📚 Documentation updated:
1852
- - docs/api.md (added 5 auth endpoints)
1853
- - docs/data-model.md (added 3 auth entities)
1854
- - specs/security.md (added JWT auth flow)
1855
-
1856
- 📦 Work archived: .ai-flow/archive/2025-01/feature-user-auth/
1857
-
1858
- Next steps:
1859
- 1. Run tests: npm test
1860
- 2. Configure JWT secrets in .env
1861
- 3. Start server: npm run dev
1862
- 4. Test auth flow manually
1863
- ```
1864
- ---
1865
- ## Mode-Specific Behaviors
1866
-
1867
- ### `/feature new` - New Functionality
1868
-
1869
- - Start from scratch
1870
- - Create all files needed
1871
- - Generate comprehensive tests
1872
- - Full documentation
1873
-
1874
- ### `/feature change` - Modify Existing
1875
-
1876
- - Identify affected files first
1877
- - Show delta of changes (ADDED/MODIFIED/REMOVED)
1878
- - Update existing tests
1879
- - Update documentation sections
1880
-
1881
- ### `/feature refactor` - Refactor Code
1882
-
1883
- - Analyze code to refactor
1884
- - Create refactoring plan
1885
- - Execute incrementally
1886
- - Ensure tests still pass
1887
- - Update documentation only if architecture changes
1888
- ---
1889
- ## Common Use Cases
1890
-
1891
- ### 1. Sprint Development (with User Stories)
1892
-
1893
- ```bash
1894
- /feature HU-001-001 # Login: 5 SP, 1.5h
1895
- /feature HU-001-002 # OAuth: 3 SP, 1h
1896
- /feature HU-002-001 # User CRUD: 8 SP, 2h
1897
- # Sprint: 16 SP in 4.5h
1898
- ```
1899
-
1900
- ### 2. Rapid Prototyping (with roadmap)
1901
-
1902
- ```bash
1903
- /feature User Entity Repository # 12 SP
1904
- /feature Product Entity Repository # 8 SP
1905
- /feature Order Entity Repository # 5 SP
1906
- # Data layer: 25 SP in ~2 days
1907
- ```
1908
-
1909
- ### 3. Feature Not Planned (interactive)
1910
-
1911
- ```bash
1912
- /feature new
1913
- # AI asks: What to build?
1914
- > Real-time notifications with WebSockets
1915
- # Generates: 24 tasks, 13 SP, ~3h
1916
- ```
1917
-
1918
- ### 4. Bug Fix or Quick Change
1919
-
1920
- ```bash
1921
- /feature change
1922
- # AI asks: What to modify?
1923
- > Add rate limiting to login endpoint
1924
- # Updates: middleware, tests, docs (~30 min)
1925
- ```
1926
-
1927
- ### 5. Code Quality Improvement
1928
-
1929
- ```bash
1930
- /feature refactor
1931
- # AI asks: What to refactor?
1932
- > Extract duplicate validation logic to shared module
1933
- # Refactors: 6 files, tests pass, docs updated (~1h)
1934
- ```
1935
- ---
1936
- ## Key Benefits by Mode
1937
-
1938
- | Mode | Setup | Validation | Best For |
1939
- | --------------- | ------- | ------------- | ----------- |
1940
- | **HU-XXX-XXX** | 0 min | Gherkin + DoD | Scrum teams |
1941
- | **Roadmap** | 0 min | Standard | Quick impl |
1942
- | **Interactive** | 2-3 min | Standard | Exploration |
1943
- ---
1944
- **BEGIN EXECUTION when user runs `/feature`, `/feature new`, `/feature change`, or `/feature refactor`**
1945
-
1946
-
1947
-
1948
-