@atlashub/smartstack-cli 4.17.1 → 4.19.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 (167) hide show
  1. package/package.json +1 -1
  2. package/templates/agents/ba-reader.md +86 -80
  3. package/templates/agents/ba-writer.md +321 -413
  4. package/templates/agents/docs-context-reader.md +3 -3
  5. package/templates/mcp-scaffolding/frontend/nav-routes.ts.hbs +133 -0
  6. package/templates/mcp-scaffolding/frontend/routes.tsx.hbs +126 -0
  7. package/templates/skills/apex/SKILL.md +29 -16
  8. package/templates/skills/apex/_shared.md +62 -9
  9. package/templates/skills/apex/references/analysis-methods.md +8 -6
  10. package/templates/skills/apex/references/challenge-questions.md +5 -5
  11. package/templates/skills/apex/references/core-seed-data.md +68 -45
  12. package/templates/skills/apex/references/frontend-route-wiring-app-tsx.md +26 -21
  13. package/templates/skills/apex/references/parallel-execution.md +156 -0
  14. package/templates/skills/apex/references/person-extension-pattern.md +12 -12
  15. package/templates/skills/apex/references/post-checks.md +1748 -1726
  16. package/templates/skills/apex/references/smartstack-api.md +63 -57
  17. package/templates/skills/apex/references/smartstack-frontend-compliance.md +594 -0
  18. package/templates/skills/apex/references/smartstack-frontend.md +1246 -1842
  19. package/templates/skills/apex/references/smartstack-layers.md +98 -145
  20. package/templates/skills/apex/steps/step-00-init.md +30 -6
  21. package/templates/skills/apex/steps/step-01-analyze.md +27 -23
  22. package/templates/skills/apex/steps/step-02-plan.md +12 -12
  23. package/templates/skills/apex/steps/step-03-execute.md +198 -143
  24. package/templates/skills/apex/steps/step-04-examine.md +24 -93
  25. package/templates/skills/apex/steps/step-05-deep-review.md +16 -16
  26. package/templates/skills/apex/steps/step-06-resolve.md +9 -9
  27. package/templates/skills/apex/steps/step-07-tests.md +3 -1
  28. package/templates/skills/apex/steps/step-08-run-tests.md +1 -1
  29. package/templates/skills/business-analyse/SKILL.md +182 -301
  30. package/templates/skills/business-analyse/_shared.md +119 -336
  31. package/templates/skills/business-analyse/html/ba-interactive.html +703 -82
  32. package/templates/skills/business-analyse/html/build-html.js +41 -3
  33. package/templates/skills/business-analyse/html/src/partials/cadrage-context.html +34 -0
  34. package/templates/skills/business-analyse/html/src/partials/cadrage-risks.html +48 -0
  35. package/templates/skills/business-analyse/html/src/partials/cadrage-scope.html +49 -0
  36. package/templates/skills/business-analyse/html/src/partials/cadrage-stakeholders.html +55 -0
  37. package/templates/skills/business-analyse/html/src/partials/cadrage-success.html +34 -0
  38. package/templates/skills/business-analyse/html/src/partials/consol-datamodel.html +8 -0
  39. package/templates/skills/business-analyse/html/src/partials/consol-flows.html +29 -0
  40. package/templates/skills/business-analyse/html/src/partials/consol-interactions.html +8 -0
  41. package/templates/skills/business-analyse/html/src/partials/consol-permissions.html +8 -0
  42. package/templates/skills/business-analyse/html/src/partials/decomp-dependencies.html +38 -0
  43. package/templates/skills/business-analyse/html/src/partials/decomp-modules.html +51 -0
  44. package/templates/skills/business-analyse/html/src/partials/handoff-summary.html +24 -0
  45. package/templates/skills/business-analyse/html/src/partials/module-spec-container.html +4 -0
  46. package/templates/skills/business-analyse/html/src/scripts/01-data-init.js +17 -1
  47. package/templates/skills/business-analyse/html/src/scripts/02-navigation.js +31 -5
  48. package/templates/skills/business-analyse/html/src/scripts/05-render-specs.js +100 -63
  49. package/templates/skills/business-analyse/html/src/scripts/06-render-mockups.js +372 -0
  50. package/templates/skills/business-analyse/html/src/scripts/10-comments.js +41 -13
  51. package/templates/skills/business-analyse/html/src/styles/09-mockups-html.css +136 -0
  52. package/templates/skills/business-analyse/patterns/suggestion-catalog.md +7 -5
  53. package/templates/skills/business-analyse/questionnaire/02-stakeholders-scope.md +142 -0
  54. package/templates/skills/business-analyse/questionnaire/03-data-ui.md +94 -0
  55. package/templates/skills/business-analyse/questionnaire/04-risks-metrics.md +150 -0
  56. package/templates/skills/business-analyse/questionnaire/05-cross-module.md +69 -0
  57. package/templates/skills/business-analyse/questionnaire.md +23 -280
  58. package/templates/skills/business-analyse/react/application-viewer.md +2 -2
  59. package/templates/skills/business-analyse/react/components.md +4 -4
  60. package/templates/skills/business-analyse/react/i18n-template.md +1 -1
  61. package/templates/skills/business-analyse/react/schema.md +14 -14
  62. package/templates/skills/business-analyse/references/acceptance-criteria.md +25 -25
  63. package/templates/skills/business-analyse/references/analysis-semantic-checks.md +3 -3
  64. package/templates/skills/business-analyse/references/compilation-structure-cards.md +1 -1
  65. package/templates/skills/business-analyse/references/consolidation-structural-checks.md +7 -7
  66. package/templates/skills/business-analyse/references/deploy-data-build.md +14 -12
  67. package/templates/skills/business-analyse/references/deploy-modes.md +10 -10
  68. package/templates/skills/business-analyse/references/detection-strategies.md +6 -6
  69. package/templates/skills/business-analyse/references/html-data-mapping.md +15 -15
  70. package/templates/skills/business-analyse/references/naming-conventions.md +4 -4
  71. package/templates/skills/business-analyse/references/review-data-mapping.md +29 -29
  72. package/templates/skills/business-analyse/references/robustness-checks.md +36 -33
  73. package/templates/skills/business-analyse/references/spec-auto-inference.md +2 -2
  74. package/templates/skills/business-analyse/references/ui-dashboard-spec.md +1 -1
  75. package/templates/skills/business-analyse/references/ui-resource-cards.md +1 -1
  76. package/templates/skills/business-analyse/references/validation-checklist.md +9 -6
  77. package/templates/skills/business-analyse/references/wireframe-svg-style-guide.md +2 -2
  78. package/templates/skills/business-analyse/schemas/application-schema.json +8 -8
  79. package/templates/skills/business-analyse/schemas/feature-schema.json +3 -3
  80. package/templates/skills/business-analyse/schemas/index-schema.json +47 -0
  81. package/templates/skills/business-analyse/schemas/project-schema.json +6 -6
  82. package/templates/skills/business-analyse/schemas/sections/analysis-schema.json +1 -1
  83. package/templates/skills/business-analyse/schemas/sections/handoff-schema.json +5 -3
  84. package/templates/skills/business-analyse/schemas/sections/metadata-schema.json +4 -4
  85. package/templates/skills/business-analyse/schemas/sections/specification-schema.json +1 -1
  86. package/templates/skills/business-analyse/schemas/shared/common-defs.json +4 -3
  87. package/templates/skills/business-analyse/steps/step-00-init.md +93 -134
  88. package/templates/skills/business-analyse/steps/step-01-cadrage.md +136 -172
  89. package/templates/skills/business-analyse/steps/step-02-structure.md +175 -0
  90. package/templates/skills/business-analyse/steps/step-03-specify.md +198 -0
  91. package/templates/skills/business-analyse/steps/step-04-consolidate.md +478 -0
  92. package/templates/skills/business-analyse/steps/step-05-deploy.md +220 -0
  93. package/templates/skills/business-analyse/steps/step-06-review.md +51 -69
  94. package/templates/skills/business-analyse/templates/tpl-frd.md +1 -1
  95. package/templates/skills/business-analyse/templates/tpl-handoff.md +20 -17
  96. package/templates/skills/business-analyse/templates/tpl-launch-displays.md +2 -2
  97. package/templates/skills/business-analyse/templates-react.md +2 -2
  98. package/templates/skills/derive-prd/SKILL.md +92 -0
  99. package/templates/skills/derive-prd/references/acceptance-criteria.md +169 -0
  100. package/templates/skills/derive-prd/references/entity-domain-mapping.md +115 -0
  101. package/templates/skills/{business-analyse → derive-prd}/references/handoff-file-templates.md +131 -120
  102. package/templates/skills/{business-analyse → derive-prd}/references/handoff-mappings.md +95 -95
  103. package/templates/skills/{business-analyse → derive-prd}/references/handoff-seeddata-generation.md +312 -312
  104. package/templates/skills/{business-analyse → derive-prd}/references/prd-generation.md +262 -258
  105. package/templates/skills/derive-prd/references/readiness-scoring.md +104 -0
  106. package/templates/skills/derive-prd/schemas/handoff-schema.json +95 -0
  107. package/templates/skills/derive-prd/steps/step-00-validate.md +130 -0
  108. package/templates/skills/derive-prd/steps/step-01-transform.md +206 -0
  109. package/templates/skills/derive-prd/steps/step-02-export.md +181 -0
  110. package/templates/skills/{business-analyse → derive-prd}/templates/tpl-progress.md +172 -172
  111. package/templates/skills/ralph-loop/SKILL.md +10 -4
  112. package/templates/skills/ralph-loop/references/category-completeness.md +20 -4
  113. package/templates/skills/ralph-loop/references/compact-loop.md +80 -48
  114. package/templates/skills/ralph-loop/references/init-resume-recovery.md +4 -2
  115. package/templates/skills/ralph-loop/references/parallel-execution.md +27 -27
  116. package/templates/skills/ralph-loop/steps/step-00-init.md +19 -9
  117. package/templates/skills/ralph-loop/steps/step-01-task.md +12 -4
  118. package/templates/skills/ralph-loop/steps/step-02-execute.md +9 -4
  119. package/templates/skills/ralph-loop/steps/step-03-commit.md +1 -1
  120. package/templates/skills/ralph-loop/steps/step-04-check.md +5 -21
  121. package/templates/skills/ralph-loop/steps/step-05-report.md +6 -1
  122. package/templates/skills/apex/references/agent-teams-protocol.md +0 -203
  123. package/templates/skills/business-analyse/_architecture.md +0 -124
  124. package/templates/skills/business-analyse/_elicitation.md +0 -206
  125. package/templates/skills/business-analyse/_module-loop.md +0 -115
  126. package/templates/skills/business-analyse/_suggestions.md +0 -34
  127. package/templates/skills/business-analyse/questionnaire/00-application.md +0 -160
  128. package/templates/skills/business-analyse/questionnaire/00b-project.md +0 -85
  129. package/templates/skills/business-analyse/questionnaire/02-stakeholders.md +0 -189
  130. package/templates/skills/business-analyse/questionnaire/03-scope.md +0 -164
  131. package/templates/skills/business-analyse/questionnaire/04-data.md +0 -88
  132. package/templates/skills/business-analyse/questionnaire/05-integrations.md +0 -58
  133. package/templates/skills/business-analyse/questionnaire/06-security.md +0 -68
  134. package/templates/skills/business-analyse/questionnaire/07-ui.md +0 -76
  135. package/templates/skills/business-analyse/questionnaire/08-performance.md +0 -42
  136. package/templates/skills/business-analyse/questionnaire/09-constraints.md +0 -45
  137. package/templates/skills/business-analyse/questionnaire/10-documentation.md +0 -43
  138. package/templates/skills/business-analyse/questionnaire/11-data-lifecycle.md +0 -59
  139. package/templates/skills/business-analyse/questionnaire/12-migration.md +0 -58
  140. package/templates/skills/business-analyse/questionnaire/13-cross-module.md +0 -69
  141. package/templates/skills/business-analyse/questionnaire/14-risk-assumptions.md +0 -135
  142. package/templates/skills/business-analyse/questionnaire/15-success-metrics.md +0 -136
  143. package/templates/skills/business-analyse/references/agent-module-prompt.md +0 -362
  144. package/templates/skills/business-analyse/references/agent-pooling-best-practices.md +0 -557
  145. package/templates/skills/business-analyse/references/cache-warming-strategy.md +0 -566
  146. package/templates/skills/business-analyse/references/cadrage-challenge-patterns.md +0 -41
  147. package/templates/skills/business-analyse/references/cadrage-coverage-matrix.md +0 -74
  148. package/templates/skills/business-analyse/references/cadrage-pre-analysis.md +0 -115
  149. package/templates/skills/business-analyse/references/cadrage-shared-modules.md +0 -68
  150. package/templates/skills/business-analyse/references/cadrage-structure-cards.md +0 -85
  151. package/templates/skills/business-analyse/references/team-orchestration.md +0 -1022
  152. package/templates/skills/business-analyse/references/validate-incremental-html.md +0 -121
  153. package/templates/skills/business-analyse/steps/step-01b-applications.md +0 -419
  154. package/templates/skills/business-analyse/steps/step-02-decomposition.md +0 -387
  155. package/templates/skills/business-analyse/steps/step-03a-data.md +0 -16
  156. package/templates/skills/business-analyse/steps/step-03a1-setup.md +0 -506
  157. package/templates/skills/business-analyse/steps/step-03a2-analysis.md +0 -301
  158. package/templates/skills/business-analyse/steps/step-03b-ui.md +0 -425
  159. package/templates/skills/business-analyse/steps/step-03c-compile.md +0 -611
  160. package/templates/skills/business-analyse/steps/step-03d-validate.md +0 -783
  161. package/templates/skills/business-analyse/steps/step-04-consolidation.md +0 -17
  162. package/templates/skills/business-analyse/steps/step-04a-collect.md +0 -415
  163. package/templates/skills/business-analyse/steps/step-04b-analyze.md +0 -163
  164. package/templates/skills/business-analyse/steps/step-04c-decide.md +0 -186
  165. package/templates/skills/business-analyse/steps/step-05a-handoff.md +0 -840
  166. package/templates/skills/business-analyse/steps/step-05b-deploy.md +0 -522
  167. package/templates/skills/business-analyse/steps/step-05c-ralph-readiness.md +0 -703
@@ -8,16 +8,17 @@ next_step: steps/step-04-examine.md
8
8
 
9
9
  # Step 3: Execute
10
10
 
11
- **CRITICAL PRINCIPLE: /apex ORCHESTRATES. It NEVER writes SmartStack code directly.**
11
+ /apex ORCHESTRATES. It does not write SmartStack code directly.
12
12
  All code goes through skills (/controller, /application, /ui-components, /efcore) or MCP tools.
13
13
 
14
14
  ## LOAD CONDITIONALLY
15
15
 
16
- > **CONTEXT REUSE:** `smartstack-api.md` (loaded in step-01) and `smartstack-layers.md` (loaded in step-02) are already in context. Do NOT re-read them.
16
+ > CONTEXT REUSE: `smartstack-api.md` (loaded in step-01) and `smartstack-layers.md` (loaded in step-02) are already in context. Do not re-read them.
17
17
 
18
- - **ALWAYS** read `references/smartstack-frontend.md` — lazy loading, i18n, page structure, CSS variables, EntityLookup, compliance gates (sections 1-9)
19
- - **ALWAYS** read `references/core-seed-data.md` — comprehensive seed data templates (Layer 1)
20
- - If NOT `{economy_mode}` AND a layer has multi-entity work: read `references/agent-teams-protocol.md`
18
+ - Read `references/core-seed-data.md` — comprehensive seed data templates (needed for Layer 1, released after)
19
+ - Defer `references/smartstack-frontend.md` until Layer 3 lazy loading, i18n, page structure, CSS variables, EntityLookup (sections 1-6)
20
+ - Defer `references/smartstack-frontend-compliance.md` until Layer 3 documentation, form testing, compliance gates (sections 7-9)
21
+ - If NOT `{economy_mode}` AND a layer has multi-entity work: read `references/parallel-execution.md`
21
22
  - If build failure during execution: read `references/error-classification.md` — error diagnosis categories A-F
22
23
 
23
24
  ---
@@ -29,7 +30,7 @@ All code goes through skills (/controller, /application, /ui-components, /efcore
29
30
  This is a foundation-only execution (called by ralph-loop Phase 0). Execute ONLY:
30
31
  - Layer 0: Domain entities + EF configs + Migration
31
32
 
32
- **SKIP ALL OTHER LAYERS:**
33
+ Skip all other layers:
33
34
  - Layer 1: Seed Data → SKIP
34
35
  - Layer 2: Backend → SKIP
35
36
  - Layer 3: Frontend → SKIP
@@ -41,7 +42,33 @@ After Layer 0 completes and builds successfully:
41
42
  - End execution
42
43
 
43
44
  **IF `{foundation_mode}` == false:**
44
- Execute ALL layers normally (Layer 0 → Layer 1 → Layer 2 → Layer 3 → Layer 4).
45
+ Execute all layers (Layer 0 → Layer 1 → Layer 2 → Layer 3 → Layer 4).
46
+
47
+ ---
48
+
49
+ ## Context Recovery Protocol
50
+
51
+ > **Run this check BEFORE each layer** to survive context compression.
52
+
53
+ ```
54
+ BEFORE starting Layer N:
55
+ Verify these variables are still accessible:
56
+ {app_name}, {module_code}, {sections}, {entities}, {code_patterns}
57
+
58
+ IF any variable is missing or empty:
59
+ 1. Read .claude/output/apex/{task_id}/state.json (if exists)
60
+ → Restore: completed_layers, completed_entities, files_created
61
+ 2. IF state.json missing:
62
+ → Re-derive from filesystem:
63
+ - {app_name}: Glob("docs/business/*/") → first directory name
64
+ - {module_code}: Glob("src/**/Domain/Entities/*/") → target module directory
65
+ - {entities}: Glob("src/**/Domain/Entities/{module_code}/*.cs") → entity names
66
+ - {sections}: Glob("src/**/Seeding/Data/{module_code}/*NavigationSeedData.cs") → parse GetSectionEntries
67
+ 3. IF Layer N-1 was already completed (check state.json or git log):
68
+ → Skip to Layer N directly
69
+
70
+ Cost: ~5 tool calls. Only triggered if context was compressed.
71
+ ```
45
72
 
46
73
  ---
47
74
 
@@ -64,46 +91,42 @@ For each entity to create/modify:
64
91
 
65
92
  ### Person Extension Detection
66
93
 
94
+ **If entity has personRoleConfig (mandatory or optional UserId link):**
95
+ See `references/person-extension-pattern.md` for full entity, EF config, service, DTO, and frontend patterns.
96
+
67
97
  ```
68
- IF entity has personRoleConfig (from PRD or feature.json):
69
- LOAD references/person-extension-pattern.md
70
- Apply variant: mandatory or optional (from personRoleConfig.userLinkMode)
71
- scaffold_extension with options: { isPersonRole: true, userLinkMode: '{variant}' }
72
- VERIFY: UserId FK present, no duplicate person fields (mandatory)
73
- → VERIFY: EF config has unique index on (TenantId, UserId)
74
- → VERIFY (mandatory): entity has ZERO person fields (FirstName, LastName, Email, PhoneNumber)
75
- → VERIFY (optional): entity has own person fields + computed Display* properties
98
+ 1. scaffold_extension with options: { isPersonRole: true, userLinkMode: 'mandatory' | 'optional' }
99
+ 2. Verify: EF config has unique index on (TenantId, UserId)
100
+ Mandatory variant: plain .IsUnique()
101
+ Optional variant: .IsUnique().HasFilter("[UserId] IS NOT NULL")
102
+ 3. Verify all build checks pass before continuing
76
103
  ```
77
104
 
78
105
  ### EF Core Configurations
79
106
 
80
107
  ```
81
108
  For each entity:
82
- MCP scaffold_extension (type: "configuration", target: entity_name)
109
+ Create IEntityTypeConfiguration<T> manually per smartstack-api.md patterns
83
110
  → Verify: table name, relationships, indexes
84
111
  → Register DbSet in ExtensionsDbContext if new entity
85
112
  ```
86
113
 
87
- ### Migration (BLOCKING)
114
+ ### Migration
88
115
 
89
- > **CRITICAL — Migration must cover ALL entities, not just the first batch.**
90
- > Root cause (test-apex-007): Migration was created once for 3 entities, then 4 more entities
91
- > were added later without re-running migration → 4 entities had no database tables.
92
- > **RULE:** Create/update migration AFTER ALL entities and EF configs are registered in DbContext.
93
- > If entities are added incrementally, create a NEW migration for each batch.
116
+ > Migration must cover ALL entities. Root cause (test-apex-007): Migration was created once for 3 entities, then 4 more entities were added later without re-running → 4 entities had no tables. Create/update migration AFTER ALL entities and EF configs are registered in DbContext. If entities are added incrementally, create a new migration for each batch.
94
117
 
95
118
  ```
96
- 1. Verify ALL entities have been added as DbSet in ExtensionsDbContext
97
- 2. Verify ALL EF configurations are registered (ApplyConfigurationsFromAssembly or individual)
119
+ 1. Verify all entities have been added as DbSet in ExtensionsDbContext
120
+ 2. Verify all EF configurations are registered (ApplyConfigurationsFromAssembly or individual)
98
121
  3. MCP suggest_migration → get standardized name
99
122
  4. dotnet ef migrations add {Name} --project src/{Infra}.csproj --startup-project src/{Api}.csproj -o Persistence/Migrations
100
123
  5. dotnet ef database update (if local DB)
101
- 6. dotnet build → MUST PASS
102
- 7. Verify: dotnet ef migrations has-pending-model-changes → MUST report "No pending model changes"
124
+ 6. dotnet build
125
+ 7. Verify: dotnet ef migrations has-pending-model-changes → must report "No pending model changes"
103
126
  ```
104
127
 
105
- **BLOCKING:** If build fails after migration, fix EF configs before proceeding.
106
- **BLOCKING:** If `has-pending-model-changes` reports pending changes, entities are missing from the migration — create a new migration.
128
+ If build fails after migration, fix EF configs before proceeding.
129
+ If `has-pending-model-changes` reports pending changes, entities are missing from the migration — create a new migration.
107
130
 
108
131
  ### Post-Layer 0 Build Gate
109
132
 
@@ -112,7 +135,7 @@ dotnet build
112
135
  # Note: WSL bin\Debug cleanup handled by PostToolUse hook (wsl-dotnet-cleanup.sh)
113
136
  ```
114
137
 
115
- **MUST PASS before Layer 1. If NuGet error, run `dotnet restore` first. If file lock (MSB3021), use `--output /tmp/{project}_build`.**
138
+ Must pass before Layer 1. If NuGet error, run `dotnet restore` first. If file lock (MSB3021), use `--output /tmp/{project}_build`.
116
139
 
117
140
  TaskUpdate(taskId: layer0_task_id, status: "completed",
118
141
  metadata: { build_gate: "pass" })
@@ -133,21 +156,17 @@ TaskUpdate(taskId: progress_tracker_id,
133
156
  description: "Module: {module_code}. Current: step-03 (Execute), Layer 1",
134
157
  activeForm: "Executing Layer 1")
135
158
 
136
- > **This layer is DEDICATED and MANDATORY.** Seed data makes modules visible in the UI.
137
- > Without seed data, the module exists in code but is invisible to users.
138
- > Reference: `references/core-seed-data.md` (loaded above) for complete C# templates.
159
+ > This layer is required. Seed data makes modules visible in the UI. Without it, the module exists in code but is invisible to users. Reference: `references/core-seed-data.md` (loaded above) for complete C# templates.
139
160
 
140
161
  ### Application-Level Seed Data (ONCE per application)
141
162
 
142
163
  ```
143
164
  1. NavigationApplicationSeedData.cs
144
165
  → Application-level navigation entry (MUST be first)
145
- → Random GUID via Guid.NewGuid()
146
166
  → 4 language translations (fr, en, it, de)
147
167
 
148
168
  2. ApplicationRolesSeedData.cs
149
169
  → 4 roles: admin, manager, contributor, viewer
150
- → Random GUIDs (Guid.NewGuid())
151
170
  → References NavigationApplicationSeedData.ApplicationId
152
171
  ```
153
172
 
@@ -155,8 +174,7 @@ TaskUpdate(taskId: progress_tracker_id,
155
174
 
156
175
  ```
157
176
  3. NavigationModuleSeedData.cs
158
- Random GUIDs (Guid.NewGuid()), 4 languages (fr, en, it, de)
159
- → GetModuleEntry() + GetTranslationEntries()
177
+ → 4 languages (fr, en, it, de), GetModuleEntry() + GetTranslationEntries()
160
178
  → If sections defined: GetSectionEntries() + GetSectionTranslationEntries()
161
179
  → If resources defined: GetResourceEntries() + resource translations
162
180
  → Query actual parent from DB for FK (NOT deterministic GUID)
@@ -172,7 +190,7 @@ TaskUpdate(taskId: progress_tracker_id,
172
190
 
173
191
  6. RolesSeedData.cs
174
192
  → Admin=wildcard(*), Manager=CRU, Contributor=CR, Viewer=R
175
- → Code-based role mapping (NEVER deterministic GUIDs for roles)
193
+ → Code-based role mapping (not deterministic GUIDs for roles)
176
194
  → Look up roles by Code at runtime
177
195
  ```
178
196
 
@@ -194,7 +212,7 @@ TaskUpdate(taskId: progress_tracker_id,
194
212
  dotnet build
195
213
  ```
196
214
 
197
- **MUST PASS before Layer 2.**
215
+ Must pass before Layer 2.
198
216
 
199
217
  TaskUpdate(taskId: layer1_task_id, status: "completed",
200
218
  metadata: { build_gate: "pass" })
@@ -205,6 +223,8 @@ TaskUpdate(taskId: layer1_task_id, status: "completed",
205
223
  feat({module}): [seed] navigation, permissions, roles
206
224
  ```
207
225
 
226
+ > **Context release:** `references/core-seed-data.md` is no longer needed after Layer 1. Its templates have been consumed. Do not reference it in Layer 2+.
227
+
208
228
  ---
209
229
 
210
230
  ## Layer 2 — Backend (Services + Controllers)
@@ -224,9 +244,9 @@ TaskUpdate(taskId: progress_tracker_id,
224
244
 
225
245
  ### Backend Tasks (sequential or parallel within layer)
226
246
 
227
- - **Services/DTOs:** MCP scaffold_extension
228
- - **Controllers:** use /controller skill for complex, MCP scaffold_extension for simple
229
- - **IMPORTANT:** ALL GetAll endpoints MUST support `?search=` query parameter (enables EntityLookup on frontend)
247
+ - Services/DTOs: MCP scaffold_extension
248
+ - Controllers: use /controller skill for complex, MCP scaffold_extension for simple
249
+ - Important: All GetAll endpoints must support `?search=` query parameter (enables EntityLookup on frontend)
230
250
 
231
251
  ### Skill Delegation
232
252
 
@@ -239,40 +259,36 @@ TaskUpdate(taskId: progress_tracker_id,
239
259
  | /notification | In-app or email notifications | trigger, recipients, template |
240
260
  | /workflow | Automated workflows | trigger, steps, conditions |
241
261
 
242
- ### If NOT economy_mode AND multiple entities: Agent Teams (parallel within layer)
262
+ ### If NOT economy_mode AND multiple entities: Parallel Agents (within layer)
243
263
 
244
- > **Protocol:** See `references/agent-teams-protocol.md`
264
+ > **Protocol:** See `references/parallel-execution.md`
245
265
 
246
266
  ```
247
- TeamCreate("apex-layer2", description: "Execute Layer 2 backend in parallel")
248
-
249
- Spawn 1 teammate per entity (Opus, full tools):
250
-
251
- For each entity:
252
- Task: "Execute Layer 2 backend for entity {EntityName}:
253
- - Application service/DTO: MCP scaffold_extension
254
- - Controller: /controller skill or MCP scaffold_extension
255
- - IMPORTANT: GetAll endpoint MUST support ?search= parameter
256
- - Validators: FluentValidation + DI registration
267
+ IF NOT economy_mode AND entities.length > 1:
268
+ For each entity, launch in parallel (single message):
269
+ Agent(subagent_type='Snipper', model='opus',
270
+ prompt='Execute Layer 2 backend for {EntityName}:
271
+ - Application service/DTO: MCP scaffold_extension
272
+ - Controller: /controller skill or MCP scaffold_extension
273
+ - IMPORTANT: GetAll endpoint MUST support ?search= parameter
274
+ - Validators: FluentValidation + DI registration
275
+ - Your task ID is {task_id}. Call TaskUpdate(status: "in_progress") before starting.
276
+ - Call TaskUpdate(status: "completed", metadata: { files_created: [...] }) when done.')
277
+ # All agents launched in parallel
257
278
 
258
- After ALL tasks done:
259
- SendMessage(type:'message', recipient:'team-lead', content:'ENTITY_COMPLETE: {EntityName}', summary:'{EntityName} backend done')"
260
-
261
- Wait for all teammates to report completion.
262
- shutdown_request → shutdown_response → TeamDelete("apex-layer2")
279
+ ELSE:
280
+ # Agent principal handles all entities sequentially
263
281
  ```
264
282
 
265
- ### Agent Teams + TaskCreate Integration
283
+ ### Parallel Agents + TaskCreate Integration
266
284
 
267
- When spawning teammates for multi-entity layers:
268
- - Each teammate receives its task ID and metadata context in the prompt
269
- - Teammate MUST call TaskUpdate(status: "in_progress") before starting
270
- - Teammate MUST call TaskUpdate(status: "completed", metadata: { files_created: [...] }) after SendMessage("ENTITY_COMPLETE")
271
- - Lead monitors via TaskList() between teammate completions
272
- - Lead updates activeForm after each entity completion:
285
+ When launching agents for multi-entity layers:
286
+ - Each agent receives its task ID and metadata context in the prompt
287
+ - Agent must call TaskUpdate(status: "in_progress") before starting
288
+ - Agent must call TaskUpdate(status: "completed", metadata: { files_created: [...] }) when done
289
+ - Agent principal monitors via TaskList() after all agents complete
290
+ - Agent principal updates activeForm after each entity completion:
273
291
  `TaskUpdate(taskId: layer2_task_id, activeForm: "Building {EntityName} backend (2/5 entities)")`
274
- - Lead updates metadata after each MCP scaffold:
275
- `TaskUpdate(taskId: layer_task_id, metadata: { files_created: [...previous, "new_file.cs"] })`
276
292
 
277
293
  ### Post-Layer 2 Build Gate
278
294
 
@@ -280,7 +296,7 @@ When spawning teammates for multi-entity layers:
280
296
  dotnet build
281
297
  ```
282
298
 
283
- **MUST PASS before backend tests.**
299
+ Must pass before backend tests.
284
300
 
285
301
  TaskUpdate(taskId: layer2_task_id, status: "completed",
286
302
  metadata: { build_gate: "pass" })
@@ -319,10 +335,17 @@ feat({module}): [app+api] {short description}
319
335
  test({module}): backend unit and integration tests
320
336
  ```
321
337
 
338
+ > **Context release:** `references/smartstack-api.md` entity patterns and `references/smartstack-layers.md` Layer 2 rules have been consumed. Layer 3 only needs their frontend sections (already covered by `smartstack-frontend.md`).
339
+
322
340
  ---
323
341
 
324
342
  ## Layer 3 — Frontend (Pages + I18n + Documentation)
325
343
 
344
+ ### Load Frontend References (deferred from top of step)
345
+
346
+ - Read `references/smartstack-frontend.md` now — lazy loading, i18n, page structure, CSS variables, EntityLookup (sections 1-6)
347
+ - Read `references/smartstack-frontend-compliance.md` now — documentation, form testing, compliance gates (sections 7-9)
348
+
326
349
  ### Task Progress
327
350
  TaskUpdate(taskId: layer3_task_id, status: "in_progress")
328
351
  TaskUpdate(taskId: progress_tracker_id,
@@ -334,7 +357,7 @@ TaskUpdate(taskId: progress_tracker_id,
334
357
  > - Route scaffolding (MCP scaffold_routes) — section 1 + 3b
335
358
  > - Page types (ListPage, DetailPage, CreatePage, EditPage) — section 3
336
359
  > - FK field handling (EntityLookup component) — section 6
337
- > - Form structure (ZERO modals — all full pages) — section 3b
360
+ > - Form structure (no modals — all full pages) — section 3b
338
361
  > - Detail page tabs (local state only) — section 3 "Tab Behavior Rules"
339
362
  > - Testing patterns (co-located form tests) — section 8
340
363
  > - Section-level routes and permissions — section 3b
@@ -344,50 +367,56 @@ TaskUpdate(taskId: progress_tracker_id,
344
367
  ### Frontend Tasks (sequential or parallel within layer)
345
368
 
346
369
  For each module:
347
- - **API client:** MCP scaffold_api_client
348
- - **Routes:** MCP scaffold_routes (outputFormat: 'applicationRoutes') → generates lazy imports + Suspense
349
- - **Wire Routes to App.tsx (BLOCKING):** After scaffold_routes, routes MUST be wired into App.tsx:
370
+ - API client: MCP scaffold_api_client
371
+ - Routes: MCP scaffold_routes (outputFormat: 'applicationRoutes') → generates lazy imports + Suspense
372
+ - Wire Routes to App.tsx: After scaffold_routes, routes must be wired into App.tsx:
350
373
  → Read App.tsx and detect the routing pattern
351
- **Pattern A** (`applicationRoutes: ApplicationRouteExtensions`): add routes to `applicationRoutes['{application_kebab}'][]` with RELATIVE paths
352
- **Pattern B** (JSX `<Route>`): nest routes inside `<Route path="/{application}" element={<AppLayout />}>` + duplicate in tenant block
353
- **FORBIDDEN:** Adding business routes to `clientRoutes[]` — it is ONLY for non-app routes (`/about`, `/pricing`)
354
- ALL business applications use `<AppLayout />` as layout wrapper
374
+ → Pattern A (`applicationRoutes: ApplicationRouteExtensions`): add routes to `applicationRoutes['{application_kebab}'][]` with RELATIVE paths
375
+ → Pattern B (JSX `<Route>`): nest routes inside `<Route path="/{application}" element={<AppLayout />}>` + duplicate in tenant block
376
+ Do not add business routes to `clientRoutes[]` — it is only for non-app routes (`/about`, `/pricing`)
377
+ All business applications use `<AppLayout />` as layout wrapper
355
378
  → See `references/frontend-route-wiring-app-tsx.md` for full Pattern A/B detection and examples
356
379
  → Verify: `mcp__smartstack__validate_frontend_routes (scope: 'routes')`
357
- - **Pages:** use /ui-components skill — MUST follow smartstack-frontend.md patterns:
380
+ - Pages: use /ui-components skill — follow smartstack-frontend.md patterns:
358
381
  → React.lazy() for all page imports (named export wrapping)
359
382
  → `<Suspense fallback={<PageLoader />}>` around all lazy components
360
383
  → Page structure: hooks → useEffect(load) → loading → error → content
361
384
  → CSS variables only: bg-[var(--bg-card)], text-[var(--text-primary)]
362
- → DataTable/EntityCard (NEVER raw HTML `<table>`)
385
+ → DataTable/EntityCard (not raw HTML `<table>`)
363
386
  → If entity has FK Guid fields: generate EntityLookup component in @/components/ui/EntityLookup (see smartstack-frontend.md section 6)
364
387
  → Dashboard pages: generate StatCard + ChartCard locally (see ui-components patterns/dashboard-chart.md)
365
- - **FORM PAGES (CRITICAL):** Create/Edit forms are FULL PAGES with own routes:
388
+ - Form pages: Create/Edit forms are full pages with own routes:
366
389
  → EntityCreatePage.tsx with route /{module}/create
367
390
  → EntityEditPage.tsx with route /{module}/:id/edit
368
- ZERO modals/popups/drawers/dialogs for forms
391
+ Zero modals/popups/drawers/dialogs for forms
369
392
  → Back button with navigate(-1) on every form page
370
393
  → See smartstack-frontend.md section 3b for templates
371
- - **TABS ON DETAIL PAGES (CRITICAL):** Tabs MUST switch content LOCALLY:
372
- → Tab click handler: setActiveTab(tabKey) ONLYNEVER navigate() to another page
394
+ - Tabs on detail pages: Tabs must switch content locally:
395
+ → Tab click handler: setActiveTab(tabKey) onlydo not navigate() to another page
373
396
  → Tab content: render inline with {activeTab === 'tabKey' && <TabContent />}
374
397
  → Sub-resource data: fetch via API filtered by parent ID, display in tab panel
375
- FORBIDDEN: navigate('../leaves?employee=${id}') in tab handler
398
+ Do not use navigate('../leaves?employee=${id}') in tab handler
376
399
  → See smartstack-frontend.md section 3 'Tab Behavior Rules'
377
- - **FK FIELDS (CRITICAL):** Foreign key Guid fields (e.g., EmployeeId) MUST use EntityLookup:
378
- NEVER render FK fields as `<input>` — users cannot type GUIDs
379
- NEVER render FK fields as `<select>` — even with API-loaded options, `<select>` is NOT acceptable
380
- ONLY use `<EntityLookup />` from @/components/ui/EntityLookup for searchable selection
400
+ - FK fields: Foreign key Guid fields (e.g., EmployeeId) must use EntityLookup:
401
+ Do not render FK fields as `<input>` — users cannot type GUIDs
402
+ Do not render FK fields as `<select>` — even with API-loaded options, `<select>` is not acceptable
403
+ Only use `<EntityLookup />` from @/components/ui/EntityLookup for searchable selection
381
404
  → Each FK field needs: apiEndpoint, mapOption (display name), search support on backend
382
- FORBIDDEN: `<select value={formData.departmentId}>`, `<option value={dept.id}>`, `e.target.value` for FK fields
405
+ Do not use `<select value={formData.departmentId}>`, `<option value={dept.id}>`, `e.target.value` for FK fields
383
406
  → See smartstack-frontend.md section 6 for the full EntityLookup pattern
384
- - **I18n:** Generate 4 JSON files per module namespace (fr, en, it, de)
407
+ - I18n: Generate 4 JSON files per module namespace (fr, en, it, de)
385
408
  → Follow JSON template from smartstack-frontend.md
386
409
  → Keys: actions, labels, errors, validation, columns, form, messages, empty
387
- ALL t() calls MUST use namespace prefix + fallback: t('ns:key', 'Default text')
388
- - **PERMISSIONS:** Call MCP generate_permissions for the module permission root (2 segments: {app}.{module}),
389
- then also call MCP generate_permissions for EACH section (3 segments: {app}.{module}.{section}).
390
- - **SECTION ROUTES:** Add section child routes to the module's children array.
410
+ All t() calls must use namespace prefix + fallback: t('ns:key', 'Default text')
411
+ **Register namespace in i18n config** (critical POST-CHECK C39 catches this, but fix it now):
412
+ 1. Find i18n config: `Glob("src/**/i18n/config.ts")` or `index.ts` or `i18n.ts`
413
+ 2. Read the config find the resources/ns registration pattern
414
+ 3. Add the new namespace import + registration for all 4 languages
415
+ 4. If config uses dynamic imports: add namespace to the `ns` array
416
+ 5. Verify: `grep -q "{module_namespace}" src/**/i18n/config.ts` → must match
417
+ - Permissions: Call MCP generate_permissions for the module permission root (2 segments: {app}.{module}),
418
+ then also call MCP generate_permissions for each section (3 segments: {app}.{module}.{section}).
419
+ - Section routes: Add section child routes to the module's children array.
391
420
  Wire PermissionGuard for section routes with section-level permissions.
392
421
  - MUST use src/pages/{App}/{Module}/ hierarchy (NOT flat)
393
422
 
@@ -411,63 +440,55 @@ This generates:
411
440
  - Import: `import { DocToggleButton } from '@/components/docs/DocToggleButton';`
412
441
  - Placement: inside the header actions area (see `smartstack-frontend.md` section 7)
413
442
 
414
- ### If NOT economy_mode AND multiple entities: Agent Teams (parallel within layer)
415
-
416
- > **Protocol:** See `references/agent-teams-protocol.md`
417
-
418
- ```
419
- TeamCreate("apex-layer3", description: "Execute Layer 3 frontend in parallel")
420
-
421
- Spawn 1 teammate per entity (Opus, full tools):
422
-
423
- For each entity:
424
- Task: "Execute Layer 3 frontend for entity {EntityName}:
425
- **MANDATORY: Read references/smartstack-frontend.md FIRST**
426
- - API client: MCP scaffold_api_client
427
- - Routes: MCP scaffold_routes (outputFormat: 'applicationRoutes')
428
- - Wire Routes to App.tsx (BLOCKING): After scaffold_routes, wire into App.tsx:
429
- Read App.tsx, detect Pattern A (applicationRoutes) or Pattern B (JSX Route)
430
- Pattern A: add to applicationRoutes['{application_kebab}'][] with RELATIVE paths
431
- Pattern B: nest inside <Route path='/{application}' element={<AppLayout />}> + tenant block
432
- FORBIDDEN: Adding business routes to clientRoutes[] (ONLY for /about, /pricing)
433
- See references/frontend-route-wiring-app-tsx.md for full patterns
434
- Verify: mcp__smartstack__validate_frontend_routes (scope: 'routes')
435
- - Pages: /ui-components skill (ALL 4 types: List, Detail, Create, Edit)
436
- - I18n: 4 JSON files (fr, en, it, de)
437
- - FORM PAGES: Full pages with own routes (ZERO modals)
438
- - FK FIELDS: EntityLookup for all FK Guid fields
439
- - TABS: Local state only (NEVER navigate())
440
- - FORM TESTS: Co-located .test.tsx for Create and Edit pages
441
-
442
- After ALL tasks done:
443
- SendMessage(type:'message', recipient:'team-lead', content:'ENTITY_COMPLETE: {EntityName}', summary:'{EntityName} frontend done')"
444
-
445
- Wait for all teammates to report completion.
446
- shutdown_request shutdown_response TeamDelete("apex-layer3")
447
- ```
448
-
449
- ### Agent Teams + TaskCreate Integration
450
-
451
- When spawning teammates for multi-entity layers:
452
- - Each teammate receives its task ID and metadata context in the prompt
453
- - Teammate MUST call TaskUpdate(status: "in_progress") before starting
454
- - Teammate MUST call TaskUpdate(status: "completed", metadata: { files_created: [...] }) after SendMessage("ENTITY_COMPLETE")
455
- - Lead monitors via TaskList() between teammate completions
456
- - Lead updates activeForm after each entity completion:
443
+ ### If NOT economy_mode AND multiple entities: Parallel Agents (within layer)
444
+
445
+ > **Protocol:** See `references/parallel-execution.md`
446
+
447
+ ```
448
+ IF NOT economy_mode AND entities.length > 1:
449
+ For each entity, launch in parallel (single message):
450
+ Agent(subagent_type='Snipper', model='opus',
451
+ prompt='Execute Layer 3 frontend for {EntityName}:
452
+ **MANDATORY: Read references/smartstack-frontend.md FIRST**
453
+ - API client: MCP scaffold_api_client
454
+ - Routes: MCP scaffold_routes (outputFormat: "applicationRoutes")
455
+ - Wire Routes to App.tsx (BLOCKING): detect Pattern A/B, wire accordingly
456
+ See references/frontend-route-wiring-app-tsx.md for full patterns
457
+ Verify: mcp__smartstack__validate_frontend_routes (scope: "routes")
458
+ - Pages: /ui-components skill (ALL 4 types: List, Detail, Create, Edit)
459
+ - I18n: 4 JSON files (fr, en, it, de) + REGISTER namespace in i18n config
460
+ - FORM PAGES: Full pages with own routes (no modals)
461
+ - FK FIELDS: EntityLookup for all FK Guid fields
462
+ - TABS: Local state only (NEVER navigate())
463
+ - FORM TESTS: Co-located .test.tsx for Create and Edit pages
464
+ - Your task ID is {task_id}. Call TaskUpdate(status: "in_progress") before starting.
465
+ - Call TaskUpdate(status: "completed", metadata: { files_created: [...] }) when done.')
466
+ # All agents launched in parallel
467
+
468
+ ELSE:
469
+ # Agent principal handles all entities sequentially
470
+ ```
471
+
472
+ ### Parallel Agents + TaskCreate Integration
473
+
474
+ When launching agents for multi-entity layers:
475
+ - Each agent receives its task ID and metadata context in the prompt
476
+ - Agent must call TaskUpdate(status: "in_progress") before starting
477
+ - Agent must call TaskUpdate(status: "completed", metadata: { files_created: [...] }) when done
478
+ - Agent principal monitors via TaskList() after all agents complete
479
+ - Agent principal updates activeForm after each entity completion:
457
480
  `TaskUpdate(taskId: layer3_task_id, activeForm: "Building {EntityName} frontend (2/5 entities)")`
458
- - Lead updates metadata after each MCP scaffold:
459
- `TaskUpdate(taskId: layer_task_id, metadata: { files_created: [...previous, "NewPage.tsx"] })`
460
481
 
461
- ### FRONTEND COMPLIANCE GATE (MANDATORY before commit)
482
+ ### Frontend Compliance Gate
462
483
 
463
- > **Reference:** See `references/smartstack-frontend.md` section 9 "Compliance Gates" for all 5 mandatory checks:
484
+ > See `references/smartstack-frontend.md` section 9 "Compliance Gates" for all 5 required checks:
464
485
  > 1. CSS Variables (theme system)
465
- > 2. Forms as Pages (ZERO modals/drawers/slide-overs)
486
+ > 2. Forms as Pages (zero modals/drawers/slide-overs)
466
487
  > 3. I18n File Structure (4 languages, separate JSON files)
467
488
  > 4. Lazy Loading (React.lazy() — no static imports)
468
489
  > 5. useTranslation in Pages (all text translated)
469
490
 
470
- **BLOCKING:** Do NOT commit frontend changes until ALL 5 gates pass.
491
+ Do not commit frontend changes until all 5 gates pass.
471
492
 
472
493
  When delegating to `/ui-components` skill, include explicit instructions:
473
494
  - "CSS: Use CSS variables ONLY — `bg-[var(--bg-card)]`, `text-[var(--text-primary)]`."
@@ -510,7 +531,7 @@ When delegating to `/ui-components` skill, include explicit instructions:
510
531
  npm run typecheck
511
532
  ```
512
533
 
513
- **MUST PASS before commit.**
534
+ Must pass before commit.
514
535
 
515
536
  TaskUpdate(taskId: layer3_task_id, status: "completed",
516
537
  metadata: { build_gate: "pass" })
@@ -595,6 +616,40 @@ Layer 4: feat({module}): [devdata] test data for development # if applicable
595
616
 
596
617
  ---
597
618
 
619
+ ## State Auto-Save (after each layer)
620
+
621
+ > **Automatic** — not dependent on `-s` flag. Enables reliable resume after context loss.
622
+
623
+ After each layer's build gate passes, write state to `.claude/output/apex/{task_id}/state.json`:
624
+
625
+ ```json
626
+ {
627
+ "step": 3,
628
+ "layer": 2,
629
+ "completed_layers": [0, 1, 2],
630
+ "completed_entities": ["Employee", "Department"],
631
+ "files_created": ["Employee.cs", "EmployeeConfiguration.cs", "..."],
632
+ "build_gates": { "layer0": "pass", "layer1": "pass", "layer2": "pass" },
633
+ "commits": ["abc1234", "def5678", "ghi9012"],
634
+ "timestamp": "2026-03-06T14:30:00Z"
635
+ }
636
+ ```
637
+
638
+ ```
639
+ IF .claude/output/apex/{task_id}/ does not exist:
640
+ Generate {task_id} from timestamp (e.g., "20260306-143000")
641
+ Create directory
642
+
643
+ After EACH layer build gate passes:
644
+ Read existing state.json (or create new)
645
+ Update: layer, completed_layers, completed_entities, files_created, build_gates, commits
646
+ Write back to state.json
647
+ ```
648
+
649
+ This file is consumed by resume mode (`-r`) to skip completed layers instead of re-deriving from git.
650
+
651
+ ---
652
+
598
653
  ## Save Output (if save_mode)
599
654
 
600
655
  Write to `{output_dir}/03-execute.md` with execution log per layer.