@atlashub/smartstack-cli 2.2.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/.documentation/business-analyse.html +1503 -1058
  2. package/.documentation/cli-commands.html +1 -1
  3. package/.documentation/init.html +1 -1
  4. package/.documentation/installation.html +1 -1
  5. package/dist/index.js +76 -47
  6. package/dist/index.js.map +1 -1
  7. package/package.json +10 -7
  8. package/templates/agents/ba-reader.md +114 -9
  9. package/templates/agents/ba-writer.md +108 -27
  10. package/templates/agents/mcp-healthcheck.md +1 -1
  11. package/templates/ralph/README.md +1 -1
  12. package/templates/ralph/ralph.config.yaml +1 -1
  13. package/templates/skills/_shared.md +60 -0
  14. package/templates/skills/application/steps/step-00-init.md +32 -8
  15. package/templates/skills/business-analyse/SKILL.md +65 -42
  16. package/templates/skills/business-analyse/_shared.md +161 -51
  17. package/templates/skills/business-analyse/questionnaire/00-application.md +166 -0
  18. package/templates/skills/business-analyse/questionnaire/03-scope.md +7 -7
  19. package/templates/skills/business-analyse/questionnaire/12-migration.md +1 -1
  20. package/templates/skills/business-analyse/questionnaire.md +63 -19
  21. package/templates/skills/business-analyse/react/application-viewer.md +242 -0
  22. package/templates/skills/business-analyse/react/components.md +60 -8
  23. package/templates/skills/business-analyse/react/schema.md +413 -34
  24. package/templates/skills/business-analyse/schemas/application-schema.json +389 -0
  25. package/templates/skills/business-analyse/schemas/feature-schema.json +287 -46
  26. package/templates/skills/business-analyse/steps/step-00-init.md +110 -44
  27. package/templates/skills/business-analyse/steps/step-01-cadrage.md +259 -0
  28. package/templates/skills/business-analyse/steps/step-02-decomposition.md +282 -0
  29. package/templates/skills/business-analyse/steps/step-03-specify.md +489 -0
  30. package/templates/skills/business-analyse/steps/step-04-consolidation.md +336 -0
  31. package/templates/skills/business-analyse/steps/step-05-handoff.md +1119 -0
  32. package/templates/skills/business-analyse/templates/tpl-handoff.md +11 -2
  33. package/templates/skills/mcp/SKILL.md +2 -2
  34. package/templates/skills/business-analyse/steps/step-01-analyse.md +0 -505
  35. package/templates/skills/business-analyse/steps/step-02-specify.md +0 -833
  36. package/templates/skills/business-analyse/steps/step-03-validate.md +0 -862
  37. package/templates/skills/business-analyse/steps/step-04-handoff.md +0 -1593
@@ -0,0 +1,1119 @@
1
+ ---
2
+ name: step-05-handoff
3
+ description: Development handoff - file mapping, BR-to-code, API endpoints, prd.json, progress tracker
4
+ model: sonnet
5
+ next_step: null
6
+ ---
7
+
8
+ # Step 5: Handoff
9
+
10
+ ## MANDATORY EXECUTION RULES
11
+
12
+ - **ALWAYS** verify status = "consolidated" before proceeding
13
+ - **ALWAYS** ask user for implementation strategy preference (multi-module only)
14
+ - **ALWAYS** derive prd.json from feature.json (NEVER independently)
15
+ - **NEVER** invent entities/FRs/BRs not in feature.json
16
+ - **ALL** API routes from specification.apiEndpoints (exact copy)
17
+ - **Permission** paths from specification.permissionMatrix (full format)
18
+ - **ALWAYS** generate 5 CORE SeedData task entries per module
19
+
20
+ ## YOUR TASK
21
+
22
+ Generate the development handoff package: file mapping, BR-to-code mapping, API endpoint summary, prd.json, and progress tracker. For multi-module applications, support both per-module and consolidated handoff approaches.
23
+
24
+ ---
25
+
26
+ ## EXECUTION SEQUENCE
27
+
28
+ ### 1. Verify Consolidation Passed
29
+
30
+ Use ba-reader to locate the feature and verify consolidation status:
31
+
32
+ ```
33
+ ba-reader.findFeature({feature_id})
34
+ → Check status = "consolidated"
35
+ ```
36
+
37
+ **IF** status ≠ "consolidated" → **STOP**. Return to step-04-consolidation.md.
38
+
39
+ Display validation summary:
40
+
41
+ ```
42
+ ✓ Consolidation: APPROVED
43
+ ✓ Modules: {count} specified and validated
44
+ ✓ Cross-module: interactions mapped
45
+ ✓ Permissions: coherent
46
+ → Proceeding to handoff...
47
+ ```
48
+
49
+ Include:
50
+ - Number of modules
51
+ - Number of entities across all modules
52
+ - Number of use cases across all modules
53
+ - Number of business rules across all modules
54
+ - Cross-module interaction count
55
+
56
+ ---
57
+
58
+ ### 2. Implementation Strategy Choice (Multi-Module)
59
+
60
+ **IF** more than 1 module defined in feature.json:
61
+
62
+ Ask via AskUserQuestion:
63
+
64
+ ```
65
+ question: "Quelle stratégie d'implémentation préférez-vous ?"
66
+ header: "Stratégie d'implémentation"
67
+ options:
68
+ - label: "Module par module (Recommandé)"
69
+ description: "Implémenter chaque module complètement avant de passer au suivant. Suit l'ordre topologique des dépendances."
70
+ - label: "Couche par couche"
71
+ description: "Implémenter toutes les entités, puis tous les services, puis tous les contrôleurs, etc. Plus de parallélisation possible mais plus complexe."
72
+ - label: "Hybride"
73
+ description: "Modules fondation en premier (couche par couche), puis modules dépendants (module par module)"
74
+ ```
75
+
76
+ Store the chosen strategy in `handoff.implementationStrategy`.
77
+
78
+ **IF** only 1 module → default to "Module par module" (no choice needed).
79
+
80
+ ---
81
+
82
+ ### 3. Calculate Complexity
83
+
84
+ For each module in feature.json.modules[], calculate:
85
+
86
+ ```json
87
+ {
88
+ "complexity": "simple|medium|complex",
89
+ "complexityDetails": {
90
+ "entities": {count},
91
+ "useCases": {count},
92
+ "businessRules": {count},
93
+ "calculated": "{level} (≤X entities, ≤Y UCs, ≤Z BRs)"
94
+ }
95
+ }
96
+ ```
97
+
98
+ | Criteria | Simple | Medium | Complex |
99
+ |----------|--------|--------|---------|
100
+ | Entities | ≤3 | ≤6 | >6 |
101
+ | Use Cases | ≤5 | ≤12 | >12 |
102
+ | Business Rules | ≤10 | ≤20 | >20 |
103
+
104
+ **Global complexity** = highest complexity across all modules.
105
+
106
+ Example:
107
+ - Module A: 4 entities, 6 use cases, 8 BRs → **simple**
108
+ - Module B: 8 entities, 15 use cases, 25 BRs → **complex**
109
+ - Overall: **complex**
110
+
111
+ ---
112
+
113
+ ### 4. Map Specification to Files
114
+
115
+ > **IMPORTANT:** Generate `handoff.filesToCreate` as structured object with 7 categories.
116
+ > Each file entry is `{path, type, linkedFRs, linkedUCs, module}`. NO free text.
117
+ > Read `.smartstack/config.json` to extract baseNamespace for project namespace.
118
+
119
+ **Order by topological dependency** (modules with no deps first, then dependents).
120
+
121
+ For **EACH module** in topological order:
122
+
123
+ #### 4.1 Domain Files
124
+
125
+ From `analysis.entities[]` of the module:
126
+
127
+ ```json
128
+ "domain": [
129
+ {
130
+ "path": "src/Domain/Entities/{ModuleName}/{EntityName}.cs",
131
+ "type": "Entity",
132
+ "linkedFRs": ["FR-001", "FR-002"],
133
+ "linkedUCs": ["UC-001"],
134
+ "module": "{moduleCode}"
135
+ }
136
+ ]
137
+ ```
138
+
139
+ Include:
140
+ - Value objects referenced by entities
141
+ - Enums used in domain
142
+ - Domain exceptions specific to module
143
+
144
+ #### 4.2 Application Files
145
+
146
+ From `analysis.useCases[]` of the module:
147
+
148
+ ```json
149
+ "application": [
150
+ {
151
+ "path": "src/Application/Services/{ModuleName}/{ServiceName}Service.cs",
152
+ "type": "Service",
153
+ "linkedFRs": ["FR-001"],
154
+ "linkedUCs": ["UC-001", "UC-002"],
155
+ "module": "{moduleCode}"
156
+ },
157
+ {
158
+ "path": "src/Application/DTOs/{ModuleName}/{DtoName}Dto.cs",
159
+ "type": "Dto",
160
+ "linkedUCs": ["UC-001"],
161
+ "module": "{moduleCode}"
162
+ },
163
+ {
164
+ "path": "src/Application/Validators/{ModuleName}/{ValidatorName}Validator.cs",
165
+ "type": "Validator",
166
+ "linkedFRs": ["FR-001"],
167
+ "module": "{moduleCode}"
168
+ }
169
+ ]
170
+ ```
171
+
172
+ Include:
173
+ - Service per use case cluster (or per domain entity if applicable)
174
+ - DTOs for API contracts
175
+ - Validators for FluentValidation
176
+ - Query handlers
177
+
178
+ #### 4.3 Infrastructure Files
179
+
180
+ From `analysis.entities[]` of the module:
181
+
182
+ ```json
183
+ "infrastructure": [
184
+ {
185
+ "path": "src/Infrastructure/Repositories/{ModuleName}/{EntityName}Repository.cs",
186
+ "type": "Repository",
187
+ "linkedFRs": ["FR-001"],
188
+ "module": "{moduleCode}"
189
+ },
190
+ {
191
+ "path": "src/Infrastructure/Persistence/{ModuleName}DbContext.cs",
192
+ "type": "DbContext",
193
+ "linkedFRs": ["FR-001", "FR-002"],
194
+ "module": "{moduleCode}"
195
+ }
196
+ ]
197
+ ```
198
+
199
+ Include:
200
+ - Repository per entity
201
+ - DbContext configuration (if module-specific)
202
+ - Unit of Work pattern if applicable
203
+ - Specifications if complex queries
204
+
205
+ #### 4.4 API Files
206
+
207
+ From `specification.apiEndpoints[]` of the module:
208
+
209
+ ```json
210
+ "api": [
211
+ {
212
+ "path": "src/API/Controllers/{ModuleName}Controller.cs",
213
+ "type": "ApiController",
214
+ "linkedUCs": ["UC-001", "UC-002"],
215
+ "linkedFRs": ["FR-001"],
216
+ "module": "{moduleCode}"
217
+ }
218
+ ]
219
+ ```
220
+
221
+ Include:
222
+ - One controller per domain aggregate root (or logical grouping)
223
+ - Include all HTTP methods (GET, POST, PUT, DELETE, PATCH)
224
+ - Error handling and validation responses
225
+
226
+ #### 4.5 Frontend Files
227
+
228
+ From `specification.wireframes[]` and `analysis.useCases[]` of the module:
229
+
230
+ ```json
231
+ "frontend": [
232
+ {
233
+ "path": "src/pages/{ModuleName}/{PageName}Page.tsx",
234
+ "type": "Page",
235
+ "linkedUCs": ["UC-001", "UC-002"],
236
+ "module": "{moduleCode}"
237
+ },
238
+ {
239
+ "path": "src/components/{ModuleName}/{ComponentName}.tsx",
240
+ "type": "Component",
241
+ "linkedUCs": ["UC-001"],
242
+ "module": "{moduleCode}"
243
+ },
244
+ {
245
+ "path": "src/hooks/use{ModuleName}{Hook}.ts",
246
+ "type": "Hook",
247
+ "linkedUCs": ["UC-001", "UC-002"],
248
+ "module": "{moduleCode}"
249
+ }
250
+ ]
251
+ ```
252
+
253
+ Include:
254
+ - Pages for major use cases
255
+ - Components for reusable UI elements
256
+ - Custom hooks for business logic
257
+ - Forms for data entry
258
+ - List/Detail views
259
+
260
+ #### 4.6 SeedData Files
261
+
262
+ **OBLIGATORY:** 5 CORE SeedData entries per module + business seed data:
263
+
264
+ ```json
265
+ "seedData": [
266
+ {
267
+ "path": "src/Infrastructure/Data/SeedData/{ModuleName}/NavigationModuleConfiguration.cs",
268
+ "type": "HasData",
269
+ "category": "core",
270
+ "source": "specification.seedDataCore.navigationModules",
271
+ "module": "{moduleCode}"
272
+ },
273
+ {
274
+ "path": "src/Infrastructure/Data/SeedData/{ModuleName}/PermissionsConfiguration.cs",
275
+ "type": "HasData",
276
+ "category": "core",
277
+ "source": "specification.seedDataCore.permissions",
278
+ "module": "{moduleCode}"
279
+ },
280
+ {
281
+ "path": "src/Infrastructure/Data/SeedData/{ModuleName}/RolesConfiguration.cs",
282
+ "type": "HasData",
283
+ "category": "core",
284
+ "source": "specification.seedDataCore.roles",
285
+ "module": "{moduleCode}"
286
+ },
287
+ {
288
+ "path": "src/Infrastructure/Data/SeedData/{ModuleName}/TenantConfiguration.cs",
289
+ "type": "HasData",
290
+ "category": "core",
291
+ "source": "specification.seedDataCore.tenants",
292
+ "module": "{moduleCode}"
293
+ },
294
+ {
295
+ "path": "src/Infrastructure/Data/SeedData/{ModuleName}/UserConfiguration.cs",
296
+ "type": "HasData",
297
+ "category": "core",
298
+ "source": "specification.seedDataCore.users",
299
+ "module": "{moduleCode}"
300
+ },
301
+ {
302
+ "path": "src/Infrastructure/Data/SeedData/{ModuleName}/{Entity}SeedData.cs",
303
+ "type": "HasData",
304
+ "category": "business",
305
+ "source": "specification.seedDataBusiness.{module}",
306
+ "module": "{moduleCode}"
307
+ }
308
+ ]
309
+ ```
310
+
311
+ Core categories (ALWAYS 5):
312
+ 1. NavigationModuleConfiguration (navigation items for module)
313
+ 2. PermissionsConfiguration (RBAC permissions)
314
+ 3. RolesConfiguration (roles using permissions)
315
+ 4. TenantConfiguration (test tenants)
316
+ 5. UserConfiguration (test users)
317
+
318
+ Business categories (from specification.seedDataBusiness):
319
+ - Domain-specific reference data
320
+ - Test data fixtures
321
+ - Lookup tables (statuses, categories, etc.)
322
+
323
+ #### 4.7 Test Files
324
+
325
+ ```json
326
+ "tests": [
327
+ {
328
+ "path": "src/Tests/Unit/Domain/{ModuleName}/{Entity}Tests.cs",
329
+ "type": "UnitTests",
330
+ "linkedFRs": ["FR-001"],
331
+ "module": "{moduleCode}"
332
+ },
333
+ {
334
+ "path": "src/Tests/Unit/Application/{ModuleName}/{ServiceName}ServiceTests.cs",
335
+ "type": "UnitTests",
336
+ "linkedFRs": ["FR-001"],
337
+ "linkedUCs": ["UC-001"],
338
+ "module": "{moduleCode}"
339
+ },
340
+ {
341
+ "path": "src/Tests/Integration/{ModuleName}/{ApiControllerName}ControllerTests.cs",
342
+ "type": "IntegrationTests",
343
+ "linkedUCs": ["UC-001"],
344
+ "module": "{moduleCode}"
345
+ },
346
+ {
347
+ "path": "src/Tests/Security/{ModuleName}/{ModuleName}SecurityTests.cs",
348
+ "type": "SecurityTests",
349
+ "linkedFRs": ["FR-001"],
350
+ "module": "{moduleCode}"
351
+ }
352
+ ]
353
+ ```
354
+
355
+ Test files:
356
+ - Unit tests for domain entities and value objects
357
+ - Unit tests for services and validators
358
+ - Integration tests for API endpoints
359
+ - Security tests for authorization and tenant isolation
360
+ - E2E tests for critical user flows
361
+
362
+ ---
363
+
364
+ ### 5. Map Business Rules to Code
365
+
366
+ Derive from `analysis.businessRules[]` of **EACH module**.
367
+
368
+ Generate complete mapping for each BR:
369
+
370
+ ```json
371
+ {
372
+ "brToCodeMapping": [
373
+ {
374
+ "ruleId": "BR-VAL-001",
375
+ "title": "Order total must equal sum of item prices",
376
+ "module": "{moduleCode}",
377
+ "severity": "critical",
378
+ "implementationPoints": [
379
+ {
380
+ "layer": "Domain",
381
+ "component": "Order.cs",
382
+ "method": "CalculateTotal()",
383
+ "implementation": "Validate sum equals sum of OrderItems.Price"
384
+ },
385
+ {
386
+ "layer": "Application",
387
+ "component": "CreateOrderService.cs",
388
+ "method": "Handle()",
389
+ "implementation": "Calculate total before persisting"
390
+ },
391
+ {
392
+ "layer": "API",
393
+ "component": "OrdersController.cs",
394
+ "method": "CreateOrder()",
395
+ "implementation": "Return validation error if total mismatch"
396
+ },
397
+ {
398
+ "layer": "Frontend",
399
+ "component": "OrderForm.tsx",
400
+ "method": "calculateTotal()",
401
+ "implementation": "Real-time calculation on item change"
402
+ }
403
+ ]
404
+ },
405
+ {
406
+ "ruleId": "BR-SEC-002",
407
+ "title": "User can only view orders from their tenant",
408
+ "module": "{moduleCode}",
409
+ "severity": "critical",
410
+ "implementationPoints": [
411
+ {
412
+ "layer": "Domain",
413
+ "component": "Order.cs",
414
+ "method": "Validate()",
415
+ "implementation": "Check TenantId matches user context"
416
+ },
417
+ {
418
+ "layer": "Infrastructure",
419
+ "component": "OrderRepository.cs",
420
+ "method": "GetUserOrders()",
421
+ "implementation": "Filter by TenantId in WHERE clause"
422
+ },
423
+ {
424
+ "layer": "API",
425
+ "component": "OrdersController.cs",
426
+ "method": "GetOrders()",
427
+ "implementation": "Enforce permission check + tenant filter"
428
+ }
429
+ ]
430
+ }
431
+ ]
432
+ }
433
+ ```
434
+
435
+ For each BR include:
436
+ - **ruleId**: Reference to analysis.businessRules[].id
437
+ - **title**: The rule statement
438
+ - **module**: Which module it belongs to
439
+ - **severity**: "critical", "high", "medium", "low"
440
+ - **implementationPoints**: Array of {layer, component, method, implementation}
441
+
442
+ Layers: Domain, Application, Infrastructure, API, Frontend
443
+
444
+ ---
445
+
446
+ ### 6. API Endpoint Summary
447
+
448
+ > **ABSOLUTE RULE:** Copy **EXACTLY** from `specification.apiEndpoints[]`. **NEVER** reinvent routes.
449
+
450
+ Generate summary with full details:
451
+
452
+ ```json
453
+ {
454
+ "apiEndpointSummary": [
455
+ {
456
+ "operation": "ListOrders",
457
+ "method": "GET",
458
+ "route": "/api/business/orders",
459
+ "linkedUC": "UC-001",
460
+ "linkedFR": "FR-001",
461
+ "permissions": ["business.orders.read"],
462
+ "requestSchema": { "type": "query", "params": ["pageNumber", "pageSize", "status"] },
463
+ "responseSchema": { "type": "PaginatedOrderDto[]" },
464
+ "errorCodes": [401, 403, 400, 500],
465
+ "module": "{moduleCode}"
466
+ },
467
+ {
468
+ "operation": "CreateOrder",
469
+ "method": "POST",
470
+ "route": "/api/business/orders",
471
+ "linkedUC": "UC-002",
472
+ "linkedFR": "FR-002",
473
+ "permissions": ["business.orders.create"],
474
+ "requestSchema": { "type": "body", "schema": "CreateOrderDto" },
475
+ "responseSchema": { "type": "OrderDto" },
476
+ "errorCodes": [400, 401, 403, 422, 500],
477
+ "module": "{moduleCode}"
478
+ }
479
+ ]
480
+ }
481
+ ```
482
+
483
+ For each endpoint:
484
+ - **operation**: Use case name or operation name
485
+ - **method**: HTTP method (GET, POST, PUT, DELETE, PATCH)
486
+ - **route**: Full API path from specification
487
+ - **linkedUC**: Use case ID(s) this endpoint implements
488
+ - **linkedFR**: Feature requirement ID(s)
489
+ - **permissions**: Array of exact permission paths
490
+ - **requestSchema**: Input contract (query params or body)
491
+ - **responseSchema**: Output contract
492
+ - **errorCodes**: Expected HTTP error codes
493
+ - **module**: Which module
494
+
495
+ Total endpoints = count of specification.apiEndpoints[] across all modules.
496
+
497
+ ---
498
+
499
+ ### 7. Generate prd.json
500
+
501
+ > **FUNDAMENTAL RULE:** prd.json is **DERIVED** from feature.json, **NEVER** generated independently.
502
+
503
+ **For multi-module, ask user:**
504
+
505
+ ```
506
+ question: "Comment souhaitez-vous structurer le prd.json ?"
507
+ header: "Structure PRD"
508
+ options:
509
+ - label: "Un par module (Recommandé)"
510
+ description: "Chaque module a son propre prd.json (.ralph/prd-{module}.json). Plus facile à suivre individuellement."
511
+ - label: "Consolidé"
512
+ description: "Un seul prd.json (.ralph/prd.json) avec tous les modules. Vue d'ensemble unique."
513
+ ```
514
+
515
+ **For single-module**, default to single prd.json at `.ralph/prd.json`.
516
+
517
+ **prd.json structure (per module or consolidated):**
518
+
519
+ ```json
520
+ {
521
+ "prd": {
522
+ "version": "2.0.0",
523
+ "source": {
524
+ "type": "ba-handoff",
525
+ "feature_json": "path/to/feature.json",
526
+ "step": "step-05-handoff",
527
+ "timestamp": "2026-02-02T14:30:00Z"
528
+ },
529
+ "metadata": {
530
+ "title": "Product Requirements Document - {application} {module}",
531
+ "status": "handed-off",
532
+ "createdBy": "business-analyse skill v4.0",
533
+ "createdAt": "2026-02-02T14:30:00Z"
534
+ },
535
+ "project": {
536
+ "name": "...",
537
+ "application": "...",
538
+ "module": "... (or omit for consolidated)",
539
+ "namespace": "From .smartstack/config.json.baseNamespace"
540
+ },
541
+ "overview": {
542
+ "summary": "From feature.json.specification.overview.summary",
543
+ "businessGoals": ["Goal 1", "Goal 2"],
544
+ "stakeholders": ["Stakeholder 1"],
545
+ "constraints": "From feature.json.specification.overview.constraints"
546
+ },
547
+ "requirements": {
548
+ "functional": {
549
+ "useCases": [
550
+ {
551
+ "id": "UC-001",
552
+ "title": "...",
553
+ "description": "...",
554
+ "actors": ["..."],
555
+ "steps": "...step 1, step 2...",
556
+ "postconditions": "..."
557
+ }
558
+ ],
559
+ "features": [
560
+ {
561
+ "id": "FR-001",
562
+ "title": "...",
563
+ "description": "...",
564
+ "priority": "must | should | could",
565
+ "linkedUCs": ["UC-001"]
566
+ }
567
+ ]
568
+ },
569
+ "nonFunctional": {
570
+ "performance": "...",
571
+ "security": "...",
572
+ "scalability": "...",
573
+ "usability": "..."
574
+ }
575
+ },
576
+ "businessRules": [
577
+ {
578
+ "id": "BR-VAL-001",
579
+ "title": "...",
580
+ "description": "...",
581
+ "type": "validation | constraint | calculation | security",
582
+ "severity": "critical | high | medium | low",
583
+ "implementedIn": ["Domain.Order", "API.OrdersController"]
584
+ }
585
+ ],
586
+ "architecture": {
587
+ "entities": [
588
+ {
589
+ "name": "...",
590
+ "description": "...",
591
+ "properties": ["prop1: string", "prop2: int"],
592
+ "relationships": ["Order → Customer", "Order → OrderItems"],
593
+ "linkedFR": "FR-001"
594
+ }
595
+ ],
596
+ "apiEndpoints": [
597
+ {
598
+ "method": "GET",
599
+ "route": "/api/business/orders",
600
+ "operation": "ListOrders",
601
+ "permissions": ["business.orders.read"],
602
+ "linkedUC": "UC-001"
603
+ }
604
+ ],
605
+ "permissionMatrix": [
606
+ {
607
+ "role": "OrderManager",
608
+ "permissions": ["business.orders.read", "business.orders.create"],
609
+ "description": "Can view and create orders"
610
+ }
611
+ ],
612
+ "dataModels": "From specification.dataModels"
613
+ },
614
+ "implementation": {
615
+ "strategy": "module-by-module | layer-by-layer | hybrid",
616
+ "moduleOrder": ["Module1", "Module2", "Module3"],
617
+ "dependencyOrder": "Topologically ordered based on feature.json.modules[].dependencies",
618
+ "taskBreakdown": {
619
+ "domain": "X tasks across entities, value objects, domain logic",
620
+ "application": "Y tasks across services, DTOs, validators",
621
+ "infrastructure": "Z tasks across repositories, persistence",
622
+ "api": "A tasks across controllers, error handling",
623
+ "frontend": "B tasks across pages, components, hooks",
624
+ "seedData": "5 CORE + C business seed data tasks",
625
+ "tests": "D unit + E integration + F security tests",
626
+ "i18n": "G i18n key implementations"
627
+ },
628
+ "totalTasks": "X + Y + Z + A + B + (5 + C) + (D + E + F) + G",
629
+ "fileMapping": "See handoff.filesToCreate structured object"
630
+ },
631
+ "testing": {
632
+ "unitTests": [
633
+ {
634
+ "component": "Domain.Order",
635
+ "scenarios": ["Valid order creation", "Invalid total rejection"],
636
+ "coverage": "95%"
637
+ }
638
+ ],
639
+ "integrationTests": [
640
+ {
641
+ "endpoint": "POST /api/business/orders",
642
+ "scenarios": ["Happy path", "Validation failure", "Authorization failure"],
643
+ "coverage": "90%"
644
+ }
645
+ ],
646
+ "e2eTests": [
647
+ {
648
+ "userFlow": "Create Order → View Details → Update Status",
649
+ "coverage": "End-to-end"
650
+ }
651
+ ],
652
+ "testStrategy": "From specification.testing"
653
+ },
654
+ "i18n": {
655
+ "keys": [
656
+ {
657
+ "key": "orders.list.title",
658
+ "defaultValue": "Orders",
659
+ "usedIn": ["OrdersPage.tsx"],
660
+ "linkedUC": "UC-001"
661
+ }
662
+ ],
663
+ "locales": ["fr", "en", "it", "de"],
664
+ "translationStatus": "From specification.i18n.locales"
665
+ },
666
+ "seedData": {
667
+ "core": {
668
+ "navigationModules": "Module navigation structure",
669
+ "permissions": "Role-based permissions",
670
+ "roles": "Predefined roles",
671
+ "tenants": "Test tenants",
672
+ "users": "Test users"
673
+ },
674
+ "business": [
675
+ {
676
+ "entity": "OrderStatus",
677
+ "samples": ["Pending", "Confirmed", "Shipped", "Delivered"],
678
+ "source": "specification.seedDataBusiness"
679
+ }
680
+ ]
681
+ },
682
+ "risks": "From feature.json.risks (if present)",
683
+ "schedule": "Estimated based on complexity and strategy"
684
+ }
685
+ }
686
+ ```
687
+
688
+ **Key rules for prd.json:**
689
+ - Source MUST reference feature.json (traceability)
690
+ - All use cases, features, and business rules come from feature.json
691
+ - API endpoints are EXACT copy from specification.apiEndpoints
692
+ - Module order follows topological dependency order
693
+ - Task breakdown based on filesToCreate count
694
+ - Everything is **derived**, not invented
695
+
696
+ ---
697
+
698
+ ### 8. Initialize Progress Tracker
699
+
700
+ Generate `.ralph/progress.txt` as main task tracker:
701
+
702
+ ```
703
+ ═════════════════════════════════════════════════════════════════
704
+ SMARTSTACK RALPH LOOP - PROGRESS TRACKER
705
+ Project: {project_name} | Application: {app_name}
706
+ Modules: {count} ({moduleOrder.join(', ')})
707
+ Strategy: {implementation_strategy}
708
+ Created: {timestamp}
709
+ Status: HANDED-OFF
710
+ ═════════════════════════════════════════════════════════════════
711
+
712
+ {For each module in topological order:}
713
+ [MODULE: {module_name}] ({complexity})
714
+ Status: NOT STARTED
715
+ Dependencies: {list of module dependencies or "FOUNDATION"}
716
+
717
+ [DOMAIN] Entity & Value Object Definitions
718
+ □ Define {Entity1} entity with properties and validation
719
+ □ Define {Entity2} entity with relationships
720
+ □ Define {ValueObject1} value object
721
+ □ Define domain exceptions
722
+ □ Total: X tasks
723
+
724
+ [SEEDDATA-CORE] Core Configuration (MANDATORY)
725
+ □ NavigationModuleConfiguration - Module navigation structure
726
+ □ PermissionsConfiguration - RBAC permissions setup
727
+ □ RolesConfiguration - Predefined roles
728
+ □ TenantConfiguration - Test tenants
729
+ □ UserConfiguration - Test users
730
+ Total: 5 CORE tasks
731
+
732
+ [SEEDDATA] Business Reference Data
733
+ □ Seed {Entity1} reference data
734
+ □ Seed {Entity2} lookup values
735
+ □ Total: Y business seed tasks
736
+
737
+ [APPLICATION] Services & Business Logic
738
+ □ Create {ServiceName}Service for {UC1}
739
+ □ Create {DtoName}Dto for API contracts
740
+ □ Create {ValidatorName}Validator for input validation
741
+ □ Implement query handlers
742
+ Total: Z tasks
743
+
744
+ [INFRASTRUCTURE] Repositories & Persistence
745
+ □ Create {Entity1}Repository with CRUD + custom queries
746
+ □ Create {Entity2}Repository
747
+ □ Configure DbContext for module
748
+ □ Setup specifications for complex queries
749
+ Total: A tasks
750
+
751
+ [API] REST Endpoints & Controllers
752
+ □ Create {ModuleNameController} GET endpoints (List, GetById)
753
+ □ Create {ModuleNameController} POST endpoint (Create)
754
+ □ Create {ModuleNameController} PUT endpoint (Update)
755
+ □ Create {ModuleNameController} DELETE endpoint (Delete)
756
+ □ Implement error handling and validation responses
757
+ Total: B tasks
758
+
759
+ [FRONTEND] UI Components & Pages
760
+ □ Create {ModuleName}Page for listing
761
+ □ Create {ModuleName}DetailPage for viewing
762
+ □ Create {ModuleName}Form component for creation/edit
763
+ □ Create custom hook use{ModuleName}
764
+ □ Implement pagination, filtering, sorting
765
+ Total: C tasks
766
+
767
+ [I18N] Internationalization Keys
768
+ □ Define i18n keys for {Module} UI labels
769
+ □ Setup translations for locales: fr, en, it, de
770
+ Total: D keys
771
+
772
+ [TESTS] Unit & Integration Tests
773
+ □ Unit tests for {Entity} domain logic
774
+ □ Unit tests for {ServiceName}Service
775
+ □ Integration tests for {ModuleNameController}
776
+ □ Security tests for authorization & tenant isolation
777
+ □ E2E tests for critical user flows
778
+ Total: E unit + F integration + G security = H tests
779
+
780
+ [QA] Quality Assurance
781
+ □ Code review against SmartStack conventions
782
+ □ Test coverage minimum 80%
783
+ □ Security scan for OWASP vulnerabilities
784
+ □ Performance testing under load
785
+ Total: 4 QA tasks
786
+
787
+ Module Total: X + 5 + Y + Z + A + B + C + D + H + 4 = {module_total} tasks
788
+ Estimated Effort: {simple/medium/complex} - {1-3/3-8/8-15} days
789
+
790
+ {If multi-module:}
791
+ [CROSS-MODULE] Integration Tasks
792
+ Status: NOT STARTED
793
+ Dependencies: All modules COMPLETED
794
+
795
+ □ Verify cross-module entity relationships
796
+ □ Test cross-module API dependencies
797
+ □ Validate permission matrix across modules
798
+ □ E2E flow tests spanning multiple modules
799
+ □ Cross-module data consistency checks
800
+ □ Integration test suite for module interactions
801
+ Total: 6 CROSS-MODULE tasks
802
+
803
+ ═════════════════════════════════════════════════════════════════
804
+ SUMMARY
805
+ ═════════════════════════════════════════════════════════════════
806
+ Total Modules: {count}
807
+ Total Tasks: {total_count}
808
+ - CORE SeedData: {count} × 5 = {total_core}
809
+ - Business Tasks: {total_biz}
810
+ - Development: {total_dev}
811
+ - Tests: {total_tests}
812
+ - QA: {total_qa}
813
+ - Cross-Module: {cross_module_count or 0}
814
+
815
+ Strategy: {strategy}
816
+ Module Order: {topological order with dependencies noted}
817
+
818
+ Complexity Distribution:
819
+ Simple: {count} modules ({estimate} days each)
820
+ Medium: {count} modules ({estimate} days each)
821
+ Complex: {count} modules ({estimate} days each)
822
+
823
+ Total Effort Estimate: {total_days} days ({total_hours} hours)
824
+ Per Developer (2): {total_days / 2} days
825
+ Parallel Potential: {strategy_efficiency_percent}%
826
+
827
+ ═════════════════════════════════════════════════════════════════
828
+ LEGEND
829
+ ═════════════════════════════════════════════════════════════════
830
+ □ = Task not started
831
+ ✓ = Task completed
832
+ ⚠ = Task in progress
833
+ ✗ = Task failed / blocked
834
+
835
+ COLORS:
836
+ [DOMAIN] = Domain Model & Business Logic
837
+ [SEEDDATA-CORE] = MANDATORY core configuration (5 entries)
838
+ [SEEDDATA] = Business reference & lookup data
839
+ [APPLICATION] = Services, DTOs, Validators
840
+ [INFRASTRUCTURE] = Repositories, DbContext, ORM
841
+ [API] = REST controllers & endpoints
842
+ [FRONTEND] = React pages, components, hooks
843
+ [I18N] = Internationalization
844
+ [TESTS] = Unit, Integration, Security, E2E
845
+ [QA] = Code quality, coverage, security
846
+ [CROSS-MODULE] = Multi-module integration (if applicable)
847
+
848
+ ═════════════════════════════════════════════════════════════════
849
+ ```
850
+
851
+ **Progress Tracker Rules:**
852
+ - One section per module, in topological order (dependencies first)
853
+ - CORE SeedData ALWAYS 5 entries (mandatory)
854
+ - Business SeedData varies by module
855
+ - Hierarchical task structure (module → layer → tasks)
856
+ - Each task is independent, assignable checkbox
857
+ - Effort estimate per module (simple/medium/complex)
858
+ - Summary with totals across all modules
859
+ - Identified dependencies for parallel execution
860
+ - Cross-module tasks only if multi-module
861
+
862
+ ---
863
+
864
+ ### 9. Write Handoff to Feature.json
865
+
866
+ Update feature.json with handoff data via ba-writer.
867
+
868
+ **Application-level (master/root feature):**
869
+
870
+ ```
871
+ ba-writer.enrichSection({
872
+ featureId: {feature_id},
873
+ section: "handoff",
874
+ data: {
875
+ status: "handed-off",
876
+ complexity: "{simple|medium|complex}",
877
+ implementationStrategy: "{strategy}",
878
+ moduleCount: {count},
879
+ moduleOrder: [...],
880
+ totalFilesToCreate: {count},
881
+ totalTasks: {count},
882
+ prdStructure: "per-module | consolidated",
883
+ prdFiles: [
884
+ { module: "Orders", path: ".ralph/prd-orders.json" },
885
+ { module: "Customers", path: ".ralph/prd-customers.json" }
886
+ ],
887
+ progressTrackerPath: ".ralph/progress.txt",
888
+ handedOffAt: "2026-02-02T14:30:00Z"
889
+ }
890
+ })
891
+ ```
892
+
893
+ **Module-level (each feature.json in modules[] with corresponding module feature):**
894
+
895
+ ```
896
+ ba-writer.enrichSection({
897
+ featureId: {module_feature_id},
898
+ section: "handoff",
899
+ data: {
900
+ status: "handed-off",
901
+ complexity: "{simple|medium|complex}",
902
+ filesToCreate: {...}, // Full 7-category structure from step 4
903
+ brToCodeMapping: [...], // Full mapping from step 5
904
+ apiEndpointSummary: [...], // Full summary from step 6
905
+ prdFile: ".ralph/prd-{module}.json | .ralph/prd.json (if consolidated)",
906
+ totalFiles: {count},
907
+ totalTasks: {count},
908
+ handedOffAt: "2026-02-02T14:30:00Z"
909
+ }
910
+ })
911
+ ```
912
+
913
+ **Update status:**
914
+
915
+ ```
916
+ ba-writer.updateStatus({
917
+ featureId: {feature_id},
918
+ status: "handed-off"
919
+ })
920
+ ```
921
+
922
+ Status journey: analyze → consolidate → **handed-off**
923
+
924
+ ---
925
+
926
+ ### 10. User Choice: Next Agent
927
+
928
+ Present development options after successful handoff:
929
+
930
+ ```
931
+ ═══════════════════════════════════════════════════════════════
932
+ ✓ HANDOFF COMPLETE - {application_name}
933
+ ═══════════════════════════════════════════════════════════════
934
+
935
+ Modules: {count} ({names})
936
+ Strategy: {strategy}
937
+ Files: {total files across all modules}
938
+ Tasks: {total tasks} ({core_count} CORE + {biz_count} business + {dev_count} development)
939
+ Complexity: {complexity}
940
+ Effort: {total_days} days ({total_hours} hours)
941
+
942
+ Generated Artifacts:
943
+ ✓ feature.json (master + per-module) - enhanced with handoff section
944
+ ✓ .ralph/prd.json or .ralph/prd-{module}.json - derived from feature.json
945
+ ✓ .ralph/progress.txt - comprehensive task tracker
946
+ ✓ Implementation strategy selected: {strategy}
947
+
948
+ Next: Choose development approach
949
+ ═══════════════════════════════════════════════════════════════
950
+ ```
951
+
952
+ Ask via AskUserQuestion:
953
+
954
+ ```
955
+ question: "Quelle approche de développement souhaitez-vous utiliser ?"
956
+ header: "Approche de développement"
957
+ options:
958
+ - label: "Feature Full (Recommandé)"
959
+ description: "Génération parallèle rapide (code + tests). Couverture 70-80%. ~{hours/3} heures."
960
+ - label: "Ralph Loop"
961
+ description: "Développement task-driven séquentiel. Couverture 95-100%. ~{hours} heures."
962
+ - label: "Terminer le BA"
963
+ description: "Finir l'analyse, développement manuel par l'équipe."
964
+ ```
965
+
966
+ **Recommendations by complexity:**
967
+ - **Simple:** Feature Full (1-3 days) or Ralph Loop (2-4 days)
968
+ - **Medium:** Ralph Loop recommended (5-10 days), Feature Full possible (3-6 days)
969
+ - **Complex:** Ralph Loop strongly recommended (10-20 days), Feature Full (8-12 days)
970
+
971
+ ---
972
+
973
+ ## MODE SUPPORT
974
+
975
+ ### Standard Mode
976
+
977
+ Full handoff with all implementation details:
978
+ - All 7 file categories
979
+ - Complete BR-to-code mapping
980
+ - Full API endpoint summary
981
+ - Detailed prd.json
982
+ - Comprehensive progress tracker
983
+
984
+ ### Micro Mode (use_case = micro)
985
+
986
+ Simplified handoff with minimal scope:
987
+ - Only essential CRUD entity + controller
988
+ - 3 core SeedData entries (omit some optional ones)
989
+ - Basic prd.json with simplified sections
990
+ - Lightweight progress.txt
991
+ - Auto-suggest Feature Full for rapid development
992
+
993
+ ### Delta Mode (use_case = refactoring)
994
+
995
+ Focused handoff for changes:
996
+ - Only affected modules listed
997
+ - Reuse existing implementation patterns
998
+ - Highlight what changed vs baseline
999
+ - Update only affected prd.json sections
1000
+ - Progress tracker shows only delta tasks
1001
+
1002
+ ---
1003
+
1004
+ ## OUTPUT
1005
+
1006
+ > **FORBIDDEN:** Do NOT generate separate JSON files (specification.json, analysis.json, etc.).
1007
+ > **ONLY:** feature.json is the mandatory JSON deliverable.
1008
+ > **PLUS:** prd.json and progress.txt are additional working files.
1009
+
1010
+ This step enriches **feature.json** (master + per-module) with:
1011
+ - **handoff** section: complexity, implementationStrategy, moduleOrder, filesToCreate (7 categories), brToCodeMapping, apiEndpointSummary, prdFiles
1012
+ - **status:** "handed-off"
1013
+
1014
+ Also generates two working files:
1015
+ - **.ralph/prd.json** (or .ralph/prd-{module}.json per module structure)
1016
+ - Derived entirely from feature.json
1017
+ - Single source of truth for development team
1018
+ - Includes all entities, use cases, business rules, API endpoints
1019
+ - Task breakdown and implementation sequence
1020
+
1021
+ - **.ralph/progress.txt**
1022
+ - Main development task tracker
1023
+ - Hierarchical structure (module → layer → tasks)
1024
+ - Checkboxes for progress tracking
1025
+ - Effort estimates per module
1026
+ - Cross-module integration tasks (if multi-module)
1027
+
1028
+ Next agent selection via user question:
1029
+ 1. **Feature Full** - Parallel rapid code generation (70-80% coverage)
1030
+ 2. **Ralph Loop** - Sequential task-driven development (95-100% coverage)
1031
+ 3. **End BA** - Manual development by team
1032
+
1033
+ ---
1034
+
1035
+ ## EXAMPLES & TEMPLATES
1036
+
1037
+ ### Example: Simple Single Module (Orders)
1038
+
1039
+ **Feature:** Order Management
1040
+ **Module:** Orders (1 entity, 2 use cases, 3 BRs)
1041
+
1042
+ **Output:**
1043
+ - feature.json with handoff section
1044
+ - .ralph/prd.json (single consolidated file)
1045
+ - .ralph/progress.txt (~150 lines, 20-30 tasks)
1046
+
1047
+ Strategy: Module by module (only 1 module)
1048
+
1049
+ ### Example: Medium Multi-Module (E-Commerce)
1050
+
1051
+ **Feature:** E-Commerce Platform
1052
+ **Modules:** Customers (4 entities), Products (6 entities), Orders (8 entities), Invoices (3 entities)
1053
+
1054
+ **Dependencies:**
1055
+ - Customers: Foundation (no deps)
1056
+ - Products: Foundation (no deps)
1057
+ - Orders: Depends on Customers + Products
1058
+ - Invoices: Depends on Orders
1059
+
1060
+ **Output:**
1061
+ - feature.json (master + 4 module features) with handoff sections
1062
+ - User chooses: per-module prd (.ralph/prd-customers.json, .ralph/prd-products.json, etc.) or consolidated (.ralph/prd.json)
1063
+ - .ralph/progress.txt (~400 lines, 100+ tasks)
1064
+ - Module order: Customers, Products → Orders → Invoices (topological)
1065
+
1066
+ Strategy options: Module by module (recommended), Layer by layer, Hybrid
1067
+
1068
+ ### Example: Complex Multi-Module (ERP)
1069
+
1070
+ **Feature:** Enterprise Resource Planning
1071
+ **Modules:** Accounting, Sales, Purchasing, Inventory, HR, Finance (20+ entities total, 50+ use cases, 100+ BRs)
1072
+
1073
+ **Output:**
1074
+ - feature.json (master + 6 module features) with handoff sections
1075
+ - Per-module prd.json (recommended for complexity management)
1076
+ - .ralph/progress.txt (~800+ lines, 200+ tasks)
1077
+
1078
+ Complexity: Complex (highest across all modules)
1079
+ Strategy: Hybrid recommended (Foundation modules layer-by-layer, then dependent modules module-by-module)
1080
+
1081
+ ---
1082
+
1083
+ ## VALIDATION CHECKLIST
1084
+
1085
+ Before presenting handoff to user:
1086
+
1087
+ - [ ] Status verified: "consolidated"
1088
+ - [ ] Implementation strategy selected or defaulted
1089
+ - [ ] Complexity calculated for each module and overall
1090
+ - [ ] filesToCreate: 7 categories complete, no free text
1091
+ - [ ] brToCodeMapping: All business rules from analysis.businessRules[] mapped
1092
+ - [ ] apiEndpointSummary: Exact copy from specification.apiEndpoints[]
1093
+ - [ ] prd.json: Derived from feature.json, not independently generated
1094
+ - [ ] prd.json: Includes all UCs, FRs, BRs, entities, API endpoints from source
1095
+ - [ ] progress.txt: Hierarchical, all modules in topological order, 5 CORE SeedData per module
1096
+ - [ ] Module order: Follows topological dependency graph
1097
+ - [ ] feature.json updated: handoff section + status "handed-off"
1098
+ - [ ] All paths use project namespace from .smartstack/config.json
1099
+ - [ ] No invented requirements (everything traced to feature.json)
1100
+ - [ ] User ready for next agent selection
1101
+
1102
+ ---
1103
+
1104
+ ## TROUBLESHOOTING
1105
+
1106
+ | Issue | Resolution |
1107
+ |-------|-----------|
1108
+ | Status ≠ "consolidated" | Stop. Return to step-04-consolidation.md. |
1109
+ | No specification section | Cannot generate handoff without specification. Return to step-02-specify.md. |
1110
+ | Missing apiEndpoints | Copy exact routes from specification.apiEndpoints[] (absolute rule). |
1111
+ | BR not in analysis | Do not invent. Update feature.json analysis section. |
1112
+ | Circular dependencies | Reorder modules or break circular dependency. Notify user. |
1113
+ | prd.json too large | Use per-module structure instead of consolidated (multi-module). |
1114
+ | Progress.txt tasks unclear | Ensure each task is atomic and independently assignable. |
1115
+ | Module complexity unclear | Recalculate using entity count, UC count, BR count against thresholds. |
1116
+
1117
+ ---
1118
+
1119
+ END OF STEP 5: HANDOFF