ai-flow-dev 1.3.0 → 2.0.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.
Files changed (44) hide show
  1. package/README.md +97 -30
  2. package/dist/cli.js +94 -110
  3. package/dist/cli.js.map +1 -1
  4. package/package.json +6 -2
  5. package/prompts/backend/{flow-bootstrap-phase-0.md → flow-build-phase-0.md} +5 -3
  6. package/prompts/backend/{flow-bootstrap-phase-1.md → flow-build-phase-1.md} +36 -41
  7. package/prompts/backend/{flow-bootstrap-phase-2.md → flow-build-phase-2.md} +80 -68
  8. package/prompts/backend/{flow-bootstrap-phase-3.md → flow-build-phase-3.md} +82 -61
  9. package/prompts/backend/{flow-bootstrap-phase-5.md → flow-build-phase-5.md} +10 -9
  10. package/prompts/backend/{flow-bootstrap-phase-6.md → flow-build-phase-6.md} +8 -7
  11. package/prompts/backend/{flow-bootstrap-phase-7.md → flow-build-phase-7.md} +5 -3
  12. package/prompts/backend/{flow-bootstrap-phase-8.md → flow-build-phase-8.md} +410 -543
  13. package/prompts/backend/{flow-bootstrap-phase-9.md → flow-build-phase-9.md} +472 -91
  14. package/prompts/backend/{flow-bootstrap.md → flow-build.md} +212 -140
  15. package/prompts/backend/flow-dev-feature.md +447 -68
  16. package/prompts/backend/flow-dev-fix.md +81 -8
  17. package/prompts/backend/flow-docs-sync.md +2 -1
  18. package/prompts/frontend/{flow-bootstrap-phase-0.md → flow-build-phase-0.md} +3 -2
  19. package/prompts/frontend/{flow-bootstrap-phase-1.md → flow-build-phase-1.md} +2 -1
  20. package/prompts/frontend/{flow-bootstrap-phase-2.md → flow-build-phase-2.md} +2 -1
  21. package/prompts/frontend/{flow-bootstrap-phase-3.md → flow-build-phase-3.md} +2 -1
  22. package/prompts/frontend/{flow-bootstrap-phase-4.md → flow-build-phase-4.md} +4 -2
  23. package/prompts/frontend/{flow-bootstrap-phase-5.md → flow-build-phase-5.md} +2 -1
  24. package/prompts/frontend/{flow-bootstrap-phase-6.md → flow-build-phase-6.md} +2 -1
  25. package/prompts/frontend/{flow-bootstrap-phase-8.md → flow-build-phase-8.md} +238 -22
  26. package/prompts/frontend/{flow-bootstrap.md → flow-build.md} +108 -25
  27. package/prompts/frontend/flow-docs-sync.md +3 -2
  28. package/prompts/mobile/{flow-bootstrap-phase-0.md → flow-build-phase-0.md} +3 -2
  29. package/prompts/mobile/{flow-bootstrap-phase-1.md → flow-build-phase-1.md} +2 -1
  30. package/prompts/mobile/{flow-bootstrap-phase-2.md → flow-build-phase-2.md} +2 -1
  31. package/prompts/mobile/{flow-bootstrap-phase-3.md → flow-build-phase-3.md} +2 -1
  32. package/prompts/mobile/{flow-bootstrap-phase-4.md → flow-build-phase-4.md} +2 -1
  33. package/prompts/mobile/{flow-bootstrap-phase-5.md → flow-build-phase-5.md} +2 -1
  34. package/prompts/mobile/{flow-bootstrap-phase-6.md → flow-build-phase-6.md} +2 -1
  35. package/prompts/mobile/{flow-bootstrap-phase-8.md → flow-build-phase-8.md} +249 -23
  36. package/prompts/mobile/{flow-bootstrap.md → flow-build.md} +107 -26
  37. package/prompts/mobile/flow-docs-sync.md +3 -2
  38. package/templates/{mobile/AGENT.template.md → AGENT.template.md} +2 -17
  39. package/templates/backend/.clauderules.template +1 -1
  40. package/templates/backend/.cursorrules.template +1 -1
  41. package/templates/shared/AGENT.template.md +0 -252
  42. /package/prompts/backend/{flow-bootstrap-phase-4.md → flow-build-phase-4.md} +0 -0
  43. /package/prompts/frontend/{flow-bootstrap-phase-7.md → flow-build-phase-7.md} +0 -0
  44. /package/prompts/mobile/{flow-bootstrap-phase-7.md → flow-build-phase-7.md} +0 -0
@@ -259,6 +259,89 @@ Story Points | Complexity | Typical Time | Examples
259
259
  34 SP | Epic | 3 weeks | Multiple related features
260
260
  ```
261
261
 
262
+ ---
263
+
264
+ ### Story Points to Time Conversion (Hybrid Estimation)
265
+
266
+ **Use this table to add time estimates to each task:**
267
+
268
+ | Story Points | Time Estimate (solo dev) | Time Range | Example Task |
269
+ | ------------ | ------------------------ | ---------- | --------------------------------------- |
270
+ | **1 SP** | 1-2 hours | (~1-2h) | Add enum value, simple config change |
271
+ | **2 SP** | 3-4 hours | (~3-4h) | Write 5-8 unit tests, basic validation |
272
+ | **3 SP** | 4-8 hours | (~4-8h) | Simple CRUD endpoint, basic entity |
273
+ | **5 SP** | 1-2 days | (~1-2d) | Complex endpoint with business logic |
274
+ | **8 SP** | 2-3 days | (~2-3d) | Auth flow, complex validation |
275
+ | **13 SP** | 1 week | (~1w) | Complete module with full test coverage |
276
+ | **21 SP** | 2 weeks | (~2w) | Major feature with integration |
277
+ | **34 SP** | 3 weeks | (~3w) | Multiple related features (Epic-level) |
278
+
279
+ > **Note:** Time assumes AI-assisted development (GitHub Copilot, Claude, etc.). Without AI assistance, multiply time estimates by 2-3x.
280
+ >
281
+ > **Velocity Tracking:** After completing 2-3 features, compare actual time vs estimates to calibrate your team's velocity. Adjust remaining estimates accordingly.
282
+
283
+ **How to use hybrid estimation:**
284
+
285
+ - Each task shows **both** Story Points and time: `• 2 SP (~3-4h)`
286
+ - Story Points measure **complexity** (stable across teams)
287
+ - Time estimates measure **effort** (varies by team velocity)
288
+ - Track both to improve estimation accuracy over time
289
+
290
+ ---
291
+
292
+ ### Task Format Reference (Spec-Kit Inspired)
293
+
294
+ **Every task must follow this format:**
295
+
296
+ ```markdown
297
+ - [ ] [TaskID] [Optional:P] [Optional:StoryTag] Description • SP (~time)
298
+ File: exact/path/to/file.ts
299
+ Dependencies: T001, T002 (or "None")
300
+ ```
301
+
302
+ **Components explained:**
303
+
304
+ - **[TaskID]**: Sequential ID in execution order (T001, T002, ..., T099, T100)
305
+ - **[P] marker**: ONLY for parallelizable tasks (different files, no blocking deps)
306
+ - **[StoryTag]**: Links task to user story ([US1], [US2]) - only in story phases
307
+ - **Description**: What to implement (specific, LLM-completable without additional context)
308
+ - **• SP (~time)**: Hybrid estimation - Story Points + time (e.g., "2 SP (~3-4h)", "5 SP (~1-2d)")
309
+ - **File path**: Exact file where work happens (REQUIRED)
310
+ - **Dependencies**: Which tasks must complete first (REQUIRED, even if "None")
311
+
312
+ **Task Sequencing Rules:**
313
+
314
+ 1. **Tests BEFORE implementation** (TDD approach)
315
+ 2. **Models → Services → Controllers → Endpoints** (layer dependency order)
316
+ 3. **Core utilities BEFORE features** that use them
317
+ 4. **Database migrations BEFORE data access code**
318
+ 5. **Interfaces BEFORE implementations**
319
+
320
+ **Parallelization Rules ([P] marker):**
321
+
322
+ ✅ **Use [P] when:**
323
+
324
+ - Tasks target different files
325
+ - No shared dependencies between tasks
326
+ - Can run simultaneously (e.g., independent entities, different modules)
327
+
328
+ ❌ **Don't use [P] when:**
329
+
330
+ - Task depends on another incomplete task
331
+ - Same file is modified by multiple tasks
332
+ - Shared resource (DB migration, config file, shared service)
333
+
334
+ **Example task with all components:**
335
+
336
+ ```markdown
337
+ - [ ] [T042] [P] Write unit tests for Product entity validation (12 tests) • 2 SP (~3-4h)
338
+ File: tests/unit/entities/Product.entity.spec.ts
339
+ Tests: price validation, stock constraints, name required, category FK
340
+ Dependencies: None (can run parallel with other test tasks)
341
+ ```
342
+
343
+ ---
344
+
262
345
  **Feature Breakdown Logic:**
263
346
 
264
347
  For each Epic:
@@ -275,84 +358,165 @@ For each Epic:
275
358
 
276
359
  **Feature Template:**
277
360
 
278
- ````markdown
279
- ### Feature {{NUMBER}}: {{FEATURE_NAME}} • {{SP}} SP
361
+ ```markdown
362
+ ### Feature {{NUMBER}}: {{FEATURE_NAME}} • {{SP}} SP (~{{TIME}})
280
363
 
281
- ⏱️ **Est. Time:** {{TIME_RANGE}}
282
- 🎯 **Priority:** {{PRIORITY}}
283
- 📋 **Dependencies:** {{DEPENDENCIES}}
364
+ **Scope:** {{ENTITY}} entity + {{ENDPOINT_COUNT}} endpoints + {{TEST_COUNT}} tests
284
365
 
285
- **Scope:**
366
+ **Tasks:**
367
+
368
+ - [ ] T0XX [P] Write {{ENTITY}} entity tests • 2 SP (~3-4h) → tests/unit/{{ENTITY}}.spec.ts
369
+ - [ ] T0YY Create {{ENTITY}} entity • 2 SP (~3-4h) → src/entities/{{ENTITY}}.ts
370
+ - [ ] T0ZZ Create I{{REPOSITORY}} interface • 1 SP (~1-2h) → src/repositories/I{{REPOSITORY}}.ts
371
+ - [ ] T0AA Implement {{REPOSITORY}} • 2 SP (~3-4h) → src/repositories/{{REPOSITORY}}.ts (after T0YY, T0ZZ)
372
+ - [ ] T0BB Implement {{SERVICE}} business logic • 3 SP (~4-8h) → src/services/{{SERVICE}}.ts (after T0AA)
373
+ - [ ] T0CC Create {{CONTROLLER}} endpoints • 2 SP (~3-4h) → src/controllers/{{CONTROLLER}}.ts (after T0BB)
374
+ - [ ] T0DD [P] Write integration tests • 2 SP (~3-4h) → tests/integration/{{CONTROLLER}}.spec.ts
375
+ - [ ] T0EE [P] Update API docs • 1 SP (~1h) → docs/api.md
376
+
377
+ **Parallel:** T0XX, T0DD, T0EE can run together
378
+
379
+ **Done when:** All endpoints work + tests pass + coverage ≥ {{COVERAGE}}%
380
+
381
+ **Start:** `/feature new "{{FEATURE_NAME}}"`
382
+ ```
383
+
384
+ `````
385
+
386
+ **Example (Real Project):**
286
387
 
287
- - {{ENDPOINT_1}} ({{METHOD}})
288
- - {{ENDPOINT_2}} ({{METHOD}})
289
- - Entity: {{ENTITY_NAME}}
290
- - Tests: {{TEST_COUNT}} ({{TEST_TYPES}})
388
+ ````markdown
389
+ ### Feature 2.1: User Entity & Repository • 12 SP (~2-3d)
390
+
391
+ **Scope:** User entity + CRUD endpoints + 12 tests
291
392
 
292
393
  **Tasks:**
293
394
 
294
- - [ ] Create {{ENTITY}} entity with validation • {{SP}} SP
295
- - [ ] Create {{REPOSITORY}} repository{{SP}} SP
296
- - [ ] Implement {{SERVICE}} service{{SP}} SP
297
- - [ ] Create {{CONTROLLER}} controller{{SP}} SP
298
- - [ ] Add {{ENDPOINT_1}} endpoint{{SP}} SP
299
- - [ ] Add {{ENDPOINT_2}} endpoint{{SP}} SP
300
- - [ ] Write unit tests for service ({{COUNT}} tests) • {{SP}} SP
301
- - [ ] Write integration tests for endpoints ({{COUNT}} tests) {{SP}} SP
302
- - [ ] Update API documentation • {{SP}} SP
303
- - [ ] Update data model documentation • {{SP}} SP
395
+ - [ ] T001 [P] Write User entity validation tests 2 SP (~3-4h) → tests/unit/User.entity.spec.ts
396
+ - [ ] T002 Create User entity (email, password, role) 2 SP (~3-4h) → src/entities/User.entity.ts
397
+ - [ ] T003 Create IUserRepository interface 1 SP (~1-2h) → src/repositories/IUserRepository.ts
398
+ - [ ] T004 Implement UserRepository with Prisma 2 SP (~3-4h) → src/repositories/UserRepository.ts (after T002, T003)
399
+ - [ ] T005 Implement UserService business logic 3 SP (~4-8h) → src/services/UserService.ts (after T004)
400
+ - [ ] T006 Create UserController (CRUD endpoints) 2 SP (~3-4h) → src/controllers/UserController.ts (after T005)
401
+ - [ ] T007 [P] Write integration tests (4 tests) • 2 SP (~3-4h) → tests/integration/UserController.spec.ts
402
+ - [ ] T008 [P] Update API docs • 1 SP (~1h) docs/api.md
304
403
 
305
- **Acceptance Criteria:**
404
+ **Parallel tasks:** T001, T007, T008 (different files)
306
405
 
307
- - [ ] All endpoints return correct responses
308
- - [ ] {{VALIDATION_RULES}} are enforced
309
- - [ ] Test coverage ≥ {{COVERAGE_TARGET}}%
310
- - [ ] API documentation is updated
311
- - [ ] Code passes linting and type-check
406
+ **Done when:** GET/POST/PUT/DELETE /users working + 12 tests pass + coverage ≥ 80%
407
+ `````
312
408
 
313
- **Ready-to-execute command:**
409
+ ---
314
410
 
315
- ```bash
316
- /feature new "{{FEATURE_NAME}}"
411
+ **Example (Simplified Format):**
412
+
413
+ ```markdown
414
+ ### Feature 2.1: User Entity & Repository • 12 SP (~2-3d)
415
+
416
+ **Scope:** User entity + CRUD endpoints + 12 tests
417
+
418
+ **Tasks:**
419
+
420
+ - [ ] T001 [P] Write User entity validation tests • 2 SP (~3-4h) → tests/unit/User.entity.spec.ts
421
+ - [ ] T002 Create User entity (email, password, role) • 2 SP (~3-4h) → src/entities/User.entity.ts
422
+ - [ ] T003 Create IUserRepository interface • 1 SP (~1-2h) → src/repositories/IUserRepository.ts
423
+ - [ ] T004 Implement UserRepository with Prisma • 2 SP (~3-4h) → src/repositories/UserRepository.ts (after T002, T003)
424
+ - [ ] T005 Implement UserService business logic • 3 SP (~4-8h) → src/services/UserService.ts (after T004)
425
+ - [ ] T006 Create UserController (CRUD endpoints) • 2 SP (~3-4h) → src/controllers/UserController.ts (after T005)
426
+ - [ ] T007 [P] Write integration tests (4 tests) • 2 SP (~3-4h) → tests/integration/UserController.spec.ts
427
+ - [ ] T008 [P] Update API docs • 1 SP (~1h) → docs/api.md
428
+
429
+ **Parallel tasks:** T001, T007, T008 (different files)
430
+
431
+ **Done when:** GET/POST/PUT/DELETE /users working + 12 tests pass + coverage ≥ 80%
432
+
433
+ **Start:** `/feature new "User Entity & Repository"`
317
434
  ```
318
- ````
319
435
 
320
- ````
436
+ ---
321
437
 
322
- **Example Feature Breakdown:**
438
+ **Original Feature Breakdown Example:**
323
439
 
324
440
  ```markdown
325
441
  ## 💾 Epic 2: Data Layer • 34 SP
326
442
 
327
- ### Feature 2.1: User Entity & Repository • 5 SP
443
+ ### Feature 2.1: User Entity & Repository (Detailed Version) • 5 SP
328
444
 
329
- ⏱️ **Est. Time:** 1-2 days
445
+ ⏱️ **Est. Time:** 1-2 days (~12-16h total)
330
446
  🎯 **Priority:** P0
331
- 📋 **Dependencies:** None
447
+ 📋 **Dependencies:** None (foundational entity)
448
+ 🏷️ **User Story:** [US1] As a system, I need to store user data securely
332
449
 
333
450
  **Scope:**
451
+
334
452
  - Entity: User (id, email, username, passwordHash, role, createdAt, updatedAt)
335
453
  - Repository: IUserRepository with CRUD operations
336
454
  - Validation: Email format, username constraints, password strength
337
455
  - Tests: 8 unit tests, 4 integration tests
338
456
 
339
- **Tasks:**
340
- - [ ] Create User entity with field validation • 2 SP
341
- - [ ] Create IUserRepository interface1 SP
342
- - [ ] Implement UserRepository (Prisma/TypeORM) • 1 SP
343
- - [ ] Add database migration for users table • 1 SP
344
- - [ ] Add indexes (email unique, username unique) • 1 SP
345
- - [ ] Write unit tests for User entity validation (8 tests) • 2 SP
346
- - [ ] Write integration tests for UserRepository (4 tests) • 2 SP
347
- - [ ] Update docs/data-model.md • 1 SP
457
+ **Tasks:** (Test-First, execution order, hybrid estimation)
458
+
459
+ - [ ] [T001] [P] Write unit tests for User entity validation (8 tests) 2 SP (~3-4h)
460
+ File: tests/unit/entities/User.entity.spec.ts
461
+ Tests: email format, username constraints, password hashing, role enum, timestamps
462
+ Dependencies: None (can run parallel with other test tasks)
463
+
464
+ - [ ] [T002] Create User entity with field validation • 2 SP (~3-4h)
465
+ File: src/entities/User.entity.ts
466
+ Implements: Email validation regex, username 3-20 chars, password bcrypt hashing
467
+ Dependencies: None
468
+
469
+ - [ ] [T003] [P] Create IUserRepository interface • 1 SP (~1-2h)
470
+ File: src/repositories/interfaces/IUserRepository.ts
471
+ Methods: create, findById, findByEmail, findAll, update, delete
472
+ Dependencies: T002 (needs User entity type)
473
+
474
+ - [ ] [T004] Implement UserRepository with Prisma/TypeORM • 1 SP (~1-2h)
475
+ File: src/repositories/UserRepository.ts
476
+ Implements: All CRUD methods from IUserRepository interface
477
+ Dependencies: T002 (User entity), T003 (interface)
478
+
479
+ - [ ] [T005] Add database migration for users table • 1 SP (~1-2h)
480
+ File: migrations/001_create_users_table.ts (Prisma) or similar
481
+ Schema: All User fields + indexes (email unique, username unique)
482
+ Dependencies: T002 (User entity schema)
483
+
484
+ - [ ] [T006] Write integration tests for UserRepository (4 tests) • 2 SP (~3-4h)
485
+ File: tests/integration/repositories/UserRepository.spec.ts
486
+ Tests: CRUD operations, unique constraints, transactions, error handling
487
+ Dependencies: T004 (UserRepository), T005 (migration)
488
+
489
+ - [ ] [T007] Update data model documentation • 1 SP (~1h)
490
+ File: docs/data-model.md
491
+ Add: User entity schema, relationships, validation rules
492
+ Dependencies: T002 (User entity complete)
348
493
 
349
494
  **Acceptance Criteria:**
350
- - [ ] User entity validates email format
351
- - [ ] Password is hashed before storage
352
- - [ ] Repository handles all CRUD operations
353
- - [ ] Migration creates table with correct schema
354
- - [ ] Test coverage 80%
355
- - [ ] No TypeScript errors
495
+
496
+ - [ ] User entity validates email format (regex: RFC 5322)
497
+ - [ ] Password is hashed with bcrypt (cost factor 10) before storage
498
+ - [ ] Repository handles all CRUD operations correctly
499
+ - [ ] Migration creates table with correct schema + indexes
500
+ - [ ] Test coverage ≥ 80% (measured by Jest/Vitest)
501
+ - [ ] No TypeScript errors (strict mode)
502
+ - [ ] All 12 tests passing (8 unit + 4 integration)
503
+
504
+ **Task Execution Graph:**
505
+ ```
506
+
507
+ T001 [P] ──┐
508
+ ├──> T002 ──┬──> T003 ──> T004 ──┬──> T006
509
+ │ │ │
510
+ │ └──> T005 ────────────┘
511
+ │ │
512
+ └─────────────────────────────────┴──> T007
513
+
514
+ ````
515
+
516
+ **Parallelization Notes:**
517
+ - T001 can run parallel to other test tasks (different file)
518
+ - T005 can start as soon as T002 completes (don't need to wait for T004)
519
+ - T007 (docs) can run while T006 (tests) runs
356
520
 
357
521
  **Ready-to-execute command:**
358
522
  ```bash
@@ -363,40 +527,96 @@ For each Epic:
363
527
 
364
528
  ### Feature 2.2: Product Entity & Repository • 8 SP
365
529
 
366
- ⏱️ **Est. Time:** 2-3 days
530
+ ⏱️ **Est. Time:** 2-3 days (~16-24h total)
367
531
  🎯 **Priority:** P0
368
- 📋 **Dependencies:** Feature 2.4 (Category entity)
532
+ 📋 **Dependencies:** Feature 2.4 (Category entity - needs Category FK)
533
+ 🏷️ **User Story:** [US2] As a store owner, I need to manage product catalog with search
369
534
 
370
535
  **Scope:**
371
536
 
372
537
  - Entity: Product (id, name, description, price, stock, categoryId, images, createdAt, updatedAt)
373
- - Repository: IProductRepository with CRUD + search
538
+ - Repository: IProductRepository with CRUD + search/filter
374
539
  - Validation: Price > 0, stock ≥ 0, name required
375
540
  - Relationships: belongsTo Category
376
541
  - Tests: 12 unit tests, 6 integration tests
377
542
 
378
- **Tasks:**
379
-
380
- - [ ] Create Product entity with validation • 3 SP
381
- - [ ] Add relationship to Category (FK constraint) • 1 SP
382
- - [ ] Create IProductRepository interface 1 SP
383
- - [ ] Implement ProductRepository with search/filter methods • 2 SP
384
- - [ ] Add database migration for products table • 1 SP
385
- - [ ] Add indexes (categoryId, name for search)1 SP
386
- - [ ] Implement inventory tracking logic • 2 SP
387
- - [ ] Write unit tests for Product entity (12 tests) 3 SP
388
- - [ ] Write integration tests for ProductRepository (6 tests) • 2 SP
389
- - [ ] Write tests for search/filter functionality (4 tests) • 2 SP
390
- - [ ] Update docs/data-model.md • 1 SP
543
+ **Tasks:** (Test-First, execution order, hybrid estimation)
544
+
545
+ - [ ] [T008] [P] Write unit tests for Product entity validation (12 tests) • 3 SP (~4-8h)
546
+ File: tests/unit/entities/Product.entity.spec.ts
547
+ Tests: price validation, stock constraints, name required, category FK, images array
548
+ Dependencies: T007 (Category entity exists for FK testing)
549
+
550
+ - [ ] [T009] Create Product entity with validation + Category FK 3 SP (~4-8h)
551
+ File: src/entities/Product.entity.ts
552
+ Implements: Price > 0, stock 0, name required, belongs to Category relationship
553
+ Dependencies: T007 (Category entity), T008 (tests)
554
+
555
+ - [ ] [T010] Create IProductRepository interface • 1 SP (~1-2h)
556
+ File: src/repositories/interfaces/IProductRepository.ts
557
+ Methods: CRUD + search(query), filterByCategory(categoryId), updateStock(id, quantity)
558
+ Dependencies: T009 (Product entity)
559
+
560
+ - [ ] [T011] Implement ProductRepository with search/filter methods • 2 SP (~3-4h)
561
+ File: src/repositories/ProductRepository.ts
562
+ Implements: All CRUD + search (case-insensitive name), filter by category
563
+ Dependencies: T009 (entity), T010 (interface)
564
+
565
+ - [ ] [T012] Add database migration for products table • 1 SP (~1-2h)
566
+ File: migrations/002_create_products_table.ts
567
+ Schema: All Product fields + FK to categories + indexes (categoryId, name)
568
+ Dependencies: T009 (Product entity schema)
569
+
570
+ - [ ] [T013] Implement inventory tracking logic • 2 SP (~3-4h)
571
+ File: src/repositories/ProductRepository.ts (extend)
572
+ Logic: Atomic stock decrements, prevent negative stock, transaction support
573
+ Dependencies: T011 (ProductRepository base)
574
+
575
+ - [ ] [T014] Write integration tests for ProductRepository (6 tests) • 2 SP (~3-4h)
576
+ File: tests/integration/repositories/ProductRepository.spec.ts
577
+ Tests: CRUD, search, filter by category, stock updates, FK constraints
578
+ Dependencies: T011, T012, T013
579
+
580
+ - [ ] [T015] Write tests for search/filter functionality (4 tests) • 2 SP (~3-4h)
581
+ File: tests/integration/repositories/ProductRepository.search.spec.ts
582
+ Tests: Case-insensitive search, partial match, filter by category, pagination
583
+ Dependencies: T011 (search implementation)
584
+
585
+ - [ ] [T016] Update data model documentation • 1 SP (~1h)
586
+ File: docs/data-model.md
587
+ Add: Product entity schema, Category relationship, search indexes
588
+ Dependencies: T009 (Product entity complete)
391
589
 
392
590
  **Acceptance Criteria:**
393
591
 
394
- - [ ] Product validates price and stock constraints
395
- - [ ] Search by name works (case-insensitive)
396
- - [ ] Filter by category works
397
- - [ ] Inventory decrements correctly
398
- - [ ] Migration includes FK constraint to categories
592
+ - [ ] Product validates price > 0 and stock ≥ 0
593
+ - [ ] Search by name works (case-insensitive, partial match)
594
+ - [ ] Filter by category returns only products in that category
595
+ - [ ] Inventory decrements correctly with atomic operations
596
+ - [ ] Stock cannot go negative (validation error)
597
+ - [ ] Migration includes FK constraint to categories + indexes
399
598
  - [ ] Test coverage ≥ 80%
599
+ - [ ] All 22 tests passing (12 unit + 6 integration + 4 search)
600
+
601
+ **Task Execution Graph:**
602
+
603
+ ```
604
+ T007 (Category) ──> T008 [P] (tests) ──> T009 (entity) ──┬──> T010 (interface) ──> T011 (repo) ──> T013 (inventory)
605
+ │ │
606
+ └──> T012 (migration) ─────────────────────┬─┤
607
+ │ │
608
+ T014 <──────────────────────────────────────────────┤ │
609
+ T015 <────────────────────────────────────────────────┘
610
+ T016 <── T009
611
+
612
+ [P] = Can run parallel with other test tasks
613
+ ```
614
+
615
+ **Parallelization Notes:**
616
+
617
+ - T008 (tests) can run parallel to other entity test tasks
618
+ - T014 (integration tests) and T015 (search tests) can run in parallel (different test files)
619
+ - T016 (docs) can run while tests are executing
400
620
 
401
621
  **Ready-to-execute command:**
402
622
 
@@ -437,6 +657,58 @@ For each Epic:
437
657
  - Independent entities can be built in parallel
438
658
  - Independent epics (after foundation) can be worked simultaneously
439
659
 
660
+ 4. **Task-Level Dependencies** (Spec-Kit Inspired):
661
+ - For each Feature, analyze task dependencies at granular level
662
+ - Identify parallelization opportunities **within** Features (not just between)
663
+ - Generate task execution graph per Epic showing exact task order
664
+
665
+ **Task Dependency Matrix Example:**
666
+
667
+ ```
668
+ Epic 2: Data Layer
669
+
670
+ Feature 2.1: User Entity (5 SP)
671
+ ├─ T001 [P] Write User entity tests → No deps (can run parallel)
672
+ ├─ T002 Create User entity → Depends on: None
673
+ ├─ T003 [P] Create IUserRepository interface → Depends on: T002
674
+ ├─ T004 Implement UserRepository → Depends on: T002, T003
675
+ ├─ T005 Add users table migration → Depends on: T002
676
+ ├─ T006 Write UserRepository integration tests → Depends on: T004, T005
677
+ └─ T007 Update data model docs → Depends on: T002
678
+
679
+ Feature 2.2: Category Entity (3 SP) [Can run PARALLEL to Feature 2.1]
680
+ ├─ T008 [P] Write Category entity tests → No deps
681
+ ├─ T009 Create Category entity → Depends on: None
682
+ ├─ T010 Create CategoryRepository → Depends on: T009
683
+ └─ T011 Update data model docs → Depends on: T009
684
+
685
+ Feature 2.3: Product Entity (8 SP) [BLOCKS on Feature 2.2 - needs Category FK]
686
+ ├─ T012 Write Product entity tests → Depends on: T009 (Category entity)
687
+ ├─ T013 Create Product entity with Category FK → Depends on: T009, T012
688
+ ├─ T014 Create IProductRepository → Depends on: T013
689
+ ├─ T015 Implement ProductRepository with search → Depends on: T013, T014
690
+ ├─ T016 Write ProductRepository tests → Depends on: T015
691
+ └─ T017 Update data model docs → Depends on: T013
692
+ ```
693
+
694
+ **Parallelization Analysis:**
695
+
696
+ ✅ **Feature-Level Parallelization:**
697
+ - Feature 2.1 (User) and Feature 2.2 (Category) can run in PARALLEL → 40% time save
698
+ - Feature 2.3 (Product) BLOCKS on Feature 2.2 → must wait for Category entity
699
+
700
+ ✅ **Task-Level Parallelization (within Feature 2.1):**
701
+ - T001 (tests) can run parallel to T002 (entity) if desired (TDD: run tests first recommended)
702
+ - T003 (interface) and T005 (migration) can run in parallel (both depend only on T002)
703
+ - T006 (integration tests) and T007 (docs) can run in parallel
704
+
705
+ ⚡ **Team Scaling:**
706
+ - With 1 dev: Features run sequentially → ~16 hours (Feature 2.1) + ~8 hours (Feature 2.2) + ~16 hours (Feature 2.3) = 40 hours total
707
+ - With 2 devs: Feature 2.1 + 2.2 parallel → ~16 hours + ~16 hours (Product) = 32 hours total (20% save)
708
+ - With 3 devs: Task-level parallelization within features → ~28 hours total (30% save)
709
+
710
+ ---
711
+
440
712
  **Generate Mermaid Dependency Graph:**
441
713
 
442
714
  ```mermaid
@@ -524,14 +796,14 @@ With 3 developers: ~9 weeks (47% time savings)
524
796
 
525
797
  ### Step 9.5: Generate Roadmap Document (2-5 minutes - automatic)
526
798
 
527
- **Generate `.ai-flow/roadmap.md` with complete implementation plan:**
799
+ **Generate `roadmap.md` with complete implementation plan:**
528
800
 
529
801
  ```
530
802
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
531
803
  📝 Step 9.5/6: Generating Roadmap Document
532
804
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
533
805
 
534
- Writing to .ai-flow/roadmap.md...
806
+ Writing to roadmap.md...
535
807
  ```
536
808
 
537
809
  **Roadmap Document Structure:**
@@ -595,6 +867,91 @@ Use this table to translate Story Points to time estimates:
595
867
 
596
868
  ---
597
869
 
870
+ ## 🔄 5-Phase Execution Model (Spec-Kit Inspired)
871
+
872
+ Our roadmap follows a battle-tested 5-phase approach for predictable, incremental delivery:
873
+
874
+ ### Phase 0: Setup (Pre-Foundation)
875
+
876
+ **Goal:** Project initialization
877
+ **Duration:** 1-2 days (already done by `/project-scaffold`)
878
+
879
+ - Repository setup, CI/CD baseline, Docker configuration
880
+ - Development environment setup
881
+ - Base dependencies installed
882
+
883
+ ### Phase 1: Foundational (Blocking Prerequisites)
884
+
885
+ **Goal:** Core infrastructure that everything depends on
886
+ **Duration:** 2-3 weeks
887
+ **Epics:** Foundation, Data Layer (base models only)
888
+
889
+ **Characteristics:**
890
+
891
+ - ❌ NO parallelization (everything blocks on these)
892
+ - ✅ Must complete BEFORE user story implementation
893
+ - 🎯 Establish patterns for entire project
894
+
895
+ **Example Tasks:**
896
+
897
+ - [T001-T020] Database connection, ORM setup, migrations
898
+ - [T021-T040] Logging, error handling, config management
899
+ - [T041-T060] Base entity models (User, Session)
900
+
901
+ ### Phase 2-N: User Stories (Priority-Ordered)
902
+
903
+ **Goal:** Deliver business value incrementally
904
+ **Duration:** Varies per story (1-3 weeks each)
905
+ **Epics:** All business features
906
+
907
+ **Characteristics:**
908
+
909
+ - ✅ Each story is INDEPENDENTLY deployable
910
+ - ✅ High parallelization potential (2-3 devs)
911
+ - 🎯 Delivers working software each iteration
912
+
913
+ **Story Execution Order:**
914
+
915
+ 1. P0 stories (MVP-critical) → [US1], [US2], [US3]
916
+ 2. P1 stories (high value) → [US4], [US5]
917
+ 3. P2 stories (nice-to-have) → [US6], [US7]
918
+
919
+ **Example Story Tasks:**
920
+
921
+ - [T061] [US1] Write authentication tests
922
+ - [T062] [US1] Implement JWT service
923
+ - [T063] [US1] Create login endpoint
924
+ - [T064] [P] [US2] Write product catalog tests (parallel to US1)
925
+
926
+ ### Phase N: Polish & Cross-Cutting
927
+
928
+ **Goal:** Production readiness
929
+ **Duration:** 1-2 weeks
930
+ **Epics:** Operations, Testing, Performance
931
+
932
+ **Characteristics:**
933
+
934
+ - ✅ Can run after all critical stories complete
935
+ - ✅ Some parallelization (different concerns)
936
+ - 🎯 Ensures quality and operability
937
+
938
+ **Example Tasks:**
939
+
940
+ - [T200-T210] Performance optimization, caching
941
+ - [T211-T220] Security hardening, penetration testing
942
+ - [T221-T230] Monitoring, alerting, logging
943
+ - [T231-T240] Documentation finalization
944
+
945
+ ### Phase Benefits:
946
+
947
+ 1. **Incremental Delivery**: Ship user stories as they complete
948
+ 2. **Risk Mitigation**: Foundation issues caught early
949
+ 3. **Team Scaling**: Multiple stories run in parallel
950
+ 4. **Predictable Velocity**: Story points per sprint stabilize
951
+ 5. **Quality Gates**: Each phase has clear exit criteria
952
+
953
+ ---
954
+
598
955
  ## 🔗 Dependency Graph
599
956
 
600
957
  ```mermaid
@@ -625,16 +982,40 @@ Use this table to translate Story Points to time estimates:
625
982
 
626
983
  ##### Feature 1.1: Base Application Configuration • 5 SP
627
984
 
628
- ⏱️ **Est. Time:** 1-2 days • 🎯 **Priority:** P0 • 📋 **Dependencies:** None
985
+ ⏱️ **Est. Time:** 1-2 days (~8-12h total) • 🎯 **Priority:** P0 • 📋 **Dependencies:** None
986
+ 🏷️ **User Story:** [US0] As a developer, I need a robust configuration system
629
987
 
630
- **Tasks:**
988
+ **Tasks:** (Test-First, execution order, hybrid estimation)
989
+
990
+ - [ ] [T001] [P] Write unit tests for configuration service (5 tests) • 2 SP (~3-4h)
991
+ File: tests/unit/config/ConfigService.spec.ts
992
+ Tests: env var loading, validation, defaults, type conversion, missing var errors
993
+ Dependencies: None (can run parallel with other foundational tests)
994
+
995
+ - [ ] [T002] Setup configuration service/module • 2 SP (~3-4h)
996
+ File: src/config/ConfigService.ts
997
+ Implements: Load env vars, validate required fields, type-safe access
998
+ Dependencies: None
999
+
1000
+ - [ ] [T003] Configure environment variables (`.env` structure) • 1 SP (~1-2h)
1001
+ File: .env.example
1002
+ Structure: All required env vars with descriptions and example values
1003
+ Dependencies: T002 (know which vars are needed)
1004
+
1005
+ - [ ] [T004] Add validation for required env vars • 1 SP (~1-2h)
1006
+ File: src/config/ConfigService.ts (extend)
1007
+ Logic: Fail-fast on missing vars, clear error messages
1008
+ Dependencies: T002 (base service exists)
1009
+
1010
+ - [ ] [T005] [P] Create constants file for app-wide values • 1 SP (~1h)
1011
+ File: src/constants/index.ts
1012
+ Constants: App name, version, default values, enums
1013
+ Dependencies: None (can run parallel with other tasks)
631
1014
 
632
- - [ ] Configure environment variables (`.env` structure) • 1 SP
633
- - [ ] Setup configuration service/module • 2 SP
634
- - [ ] Add validation for required env vars 1 SP
635
- - [ ] Create constants file for app-wide values • 1 SP
636
- - [ ] Write unit tests for configuration service (5 tests) • 2 SP
637
- - [ ] Document configuration in `specs/configuration.md` • 1 SP
1015
+ - [ ] [T006] Document configuration in specs/configuration.md • 1 SP (~1h)
1016
+ File: specs/configuration.md
1017
+ Add: All env vars, types, defaults, validation rules
1018
+ Dependencies: T002, T003, T004 (config system complete)
638
1019
 
639
1020
  **Acceptance Criteria:**
640
1021
 
@@ -773,7 +1154,7 @@ Update this roadmap as you complete features:
773
1154
 
774
1155
  **Need to modify the roadmap?**
775
1156
 
776
- - Update documentation first (`/flow-bootstrap` or `/flow-docs-sync`)
1157
+ - Update documentation first (`/flow-build` or `/flow-docs-sync`)
777
1158
  - Re-run Phase 9 to regenerate roadmap
778
1159
 
779
1160
  ---
@@ -786,7 +1167,7 @@ Update this roadmap as you complete features:
786
1167
 
787
1168
  ```
788
1169
  ✅ Roadmap document generated
789
- ✅ Location: .ai-flow/roadmap.md
1170
+ ✅ Location: roadmap.md
790
1171
  ✅ Total: {{TOTAL_EPICS}} Epics, {{TOTAL_FEATURES}} Features, {{TOTAL_TASKS}} Tasks
791
1172
  ✅ Estimated: {{TOTAL_SP}} Story Points (~{{TOTAL_WEEKS}} weeks)
792
1173
  ```
@@ -811,7 +1192,7 @@ Update this roadmap as you complete features:
811
1192
  ✅ Estimated time: {{SOLO_WEEKS}} weeks (1 dev) | {{TWO_DEV_WEEKS}} weeks (2 devs)
812
1193
  ✅ Dependency graph: Generated
813
1194
  ✅ Execution order: Optimized for parallelization
814
- ✅ Roadmap document: .ai-flow/roadmap.md
1195
+ ✅ Roadmap document: roadmap.md
815
1196
 
816
1197
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
817
1198
  🎯 What This Roadmap Guarantees
@@ -840,14 +1221,14 @@ Update this roadmap as you complete features:
840
1221
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
841
1222
 
842
1223
  1. **Open the roadmap**
843
- └─ Open .ai-flow/roadmap.md in your editor
1224
+ └─ Open roadmap.md in your editor
844
1225
 
845
1226
  2. **Review and adjust priorities**
846
1227
  └─ Decide which features are MVP vs future phases
847
1228
  └─ Adjust P0/P1/P2/P3 priorities if needed
848
1229
 
849
1230
  3. **Commit the roadmap**
850
- └─ git add .ai-flow/roadmap.md
1231
+ └─ git add roadmap.md
851
1232
  └─ git commit -m "docs: add implementation roadmap with Story Points"
852
1233
 
853
1234
  4. **Start implementation**
@@ -879,13 +1260,13 @@ Update this roadmap as you complete features:
879
1260
  time-to-market.
880
1261
 
881
1262
  • **Re-generate:** If documentation changes significantly, run
882
- /flow-bootstrap again (Phases 0-9) to update everything.
1263
+ /flow-build again (Phases 0-9) to update everything.
883
1264
 
884
1265
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
885
1266
 
886
1267
  Ready to start building? 🚀
887
1268
 
888
- Open .ai-flow/roadmap.md and let's ship this! 💪
1269
+ Open roadmap.md and let's ship this! 💪
889
1270
 
890
1271
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
891
1272
  ```
@@ -899,10 +1280,10 @@ A) ✅ Start implementing first feature now (recommended)
899
1280
  → Will execute: /feature new "{{FIRST_FEATURE_NAME}}"
900
1281
 
901
1282
  B) 📋 Review roadmap first
902
- → Will open .ai-flow/roadmap.md
1283
+ → Will open roadmap.md
903
1284
 
904
1285
  C) ✏️ Customize roadmap
905
- → Will open .ai-flow/roadmap.md for editing
1286
+ → Will open roadmap.md for editing
906
1287
 
907
1288
  Your choice (A/B/C): __
908
1289
  ```
@@ -1021,7 +1402,7 @@ Please fix documentation and re-run Phase 9
1021
1402
 
1022
1403
  **9.5 Generate Roadmap Document:**
1023
1404
 
1024
- - [ ] Create `.ai-flow/roadmap.md`
1405
+ - [ ] Create `roadmap.md`
1025
1406
  - [ ] Include project overview
1026
1407
  - [ ] Include Story Points reference table
1027
1408
  - [ ] Include Epic overview table