@atlashub/smartstack-cli 4.31.0 → 4.33.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 (41) hide show
  1. package/.documentation/commands.html +952 -116
  2. package/.documentation/index.html +2 -2
  3. package/.documentation/init.html +358 -174
  4. package/dist/mcp-entry.mjs +271 -44
  5. package/dist/mcp-entry.mjs.map +1 -1
  6. package/package.json +1 -1
  7. package/templates/mcp-scaffolding/controller.cs.hbs +54 -128
  8. package/templates/project/README.md +19 -0
  9. package/templates/skills/apex/SKILL.md +16 -10
  10. package/templates/skills/apex/_shared.md +1 -1
  11. package/templates/skills/apex/references/checks/architecture-checks.sh +154 -0
  12. package/templates/skills/apex/references/checks/backend-checks.sh +194 -0
  13. package/templates/skills/apex/references/checks/frontend-checks.sh +448 -0
  14. package/templates/skills/apex/references/checks/infrastructure-checks.sh +255 -0
  15. package/templates/skills/apex/references/checks/security-checks.sh +153 -0
  16. package/templates/skills/apex/references/checks/seed-checks.sh +536 -0
  17. package/templates/skills/apex/references/frontend-route-wiring-app-tsx.md +49 -192
  18. package/templates/skills/apex/references/parallel-execution.md +18 -5
  19. package/templates/skills/apex/references/post-checks.md +124 -2156
  20. package/templates/skills/apex/references/smartstack-api.md +160 -957
  21. package/templates/skills/apex/references/smartstack-frontend-compliance.md +23 -1
  22. package/templates/skills/apex/references/smartstack-frontend.md +134 -1022
  23. package/templates/skills/apex/references/smartstack-layers.md +12 -6
  24. package/templates/skills/apex/steps/step-00-init.md +81 -238
  25. package/templates/skills/apex/steps/step-03-execute.md +25 -751
  26. package/templates/skills/apex/steps/step-03a-layer0-domain.md +118 -0
  27. package/templates/skills/apex/steps/step-03b-layer1-seed.md +91 -0
  28. package/templates/skills/apex/steps/step-03c-layer2-backend.md +240 -0
  29. package/templates/skills/apex/steps/step-03d-layer3-frontend.md +300 -0
  30. package/templates/skills/apex/steps/step-03e-layer4-devdata.md +44 -0
  31. package/templates/skills/apex/steps/step-04-examine.md +70 -150
  32. package/templates/skills/application/references/frontend-i18n-and-output.md +2 -2
  33. package/templates/skills/application/references/frontend-route-naming.md +5 -1
  34. package/templates/skills/application/references/frontend-route-wiring-app-tsx.md +49 -198
  35. package/templates/skills/application/references/frontend-verification.md +11 -11
  36. package/templates/skills/application/steps/step-05-frontend.md +26 -15
  37. package/templates/skills/application/templates-frontend.md +4 -0
  38. package/templates/skills/cli-app-sync/SKILL.md +2 -2
  39. package/templates/skills/cli-app-sync/references/comparison-map.md +1 -1
  40. package/templates/skills/controller/references/controller-code-templates.md +70 -67
  41. package/templates/skills/controller/references/mcp-scaffold-workflow.md +5 -1
@@ -277,7 +277,7 @@ var sectionRoute = $"{moduleRoute}/{ToKebabCase(sectionCode)}";
277
277
  | Action | Tool |
278
278
  |--------|------|
279
279
  | API client | MCP `scaffold_api_client` |
280
- | Routes | MCP `scaffold_routes` (outputFormat: `applicationRoutes`) |
280
+ | Routes | MCP `scaffold_routes` (outputFormat: `componentRegistry`) |
281
281
  | Complex pages | /ui-components skill + `smartstack-frontend.md` patterns |
282
282
  | Validate routes | MCP `validate_frontend_routes` |
283
283
 
@@ -312,6 +312,9 @@ const [loading, setLoading] = useState(true);
312
312
 
313
313
  ### RULE — Frontend Route Ordering
314
314
 
315
+ > **Note (v3.7+):** Route ordering is handled automatically by DynamicRouter.
316
+ > The ordering rules below apply only to legacy Pattern A/B projects.
317
+
315
318
  > **CRITICAL:** React Router matches routes top-to-bottom. Dynamic routes (`:id`, `:id/edit`) placed BEFORE static routes (`dashboard`, `create`) will swallow the static paths — e.g., `/employees/dashboard` matches `:id` with `id="dashboard"` → 404.
316
319
 
317
320
  **Order (MANDATORY):**
@@ -346,12 +349,15 @@ POST-CHECK C49 detects this anti-pattern and BLOCKS.
346
349
 
347
350
  ### Section Routes (when module has sections)
348
351
 
349
- If the module defines `{sections}`, generate frontend routes for EACH section as children of the application route.
352
+ > **Note (v3.7+):** With DynamicRouter, section routes are resolved automatically from navigation
353
+ > seed data + PageRegistry. The manual wiring below applies only to legacy Pattern A/B projects.
354
+
355
+ If the module defines `{sections}`, ensure navigation seed data has ComponentKey matching PageRegistry keys.
356
+ ComponentKey convention: `{app_code}.{module_code}.{section_code}` (dot-separated, lowercase).
357
+ DynamicRouter generates the URL paths from seed data Route field.
350
358
 
351
- > **CRITICAL Module Segment Required:** Route paths in `applicationRoutes['{app}']` are RELATIVE to the application root.
352
- > They MUST include the module segment: `{module-kebab}/{section-kebab}`, NOT just `{section-kebab}`.
353
- > Without the module segment, the route resolves to `/{app}/{section}` instead of `/{app}/{module}/{section}`,
354
- > causing a mismatch with backend navigation seed data routes → nav links produce 404s.
359
+ Legacy (Pattern A/B): generate frontend routes for EACH section as children of the application route.
360
+ Route paths MUST include the module segment: `{module-kebab}/{section-kebab}`.
355
361
 
356
362
  ```tsx
357
363
  // Routes in applicationRoutes['human-resources'] — RELATIVE paths include module segment
@@ -23,103 +23,48 @@ Read `_shared.md` for SmartStack detection patterns and MCP tools reference.
23
23
 
24
24
  ## 1. Parse Flags
25
25
 
26
- Extract flags from the raw input:
26
+ Extract flags from input: `-a, -x, -s, -e, -r, -pr, -d {path}, --foundation`
27
27
 
28
- ```
29
- Input: "{raw_input}"
30
-
31
- Flags to detect: -a, -x, -s, -e, -r, -pr, -d {path}, --foundation
32
- Remaining text after flag removal = {task_description}
33
- ```
34
-
35
- **Defaults:**
36
-
37
- ```yaml
38
- auto_mode: false
39
- examine_mode: false
40
- save_mode: false
41
- economy_mode: false
42
- pr_mode: false
43
- resume_mode: false
44
- delegate_mode: false
45
- delegate_prd_path: null
46
- foundation_mode: false
47
- ```
48
-
49
- **If `-d {path}` detected:** set `delegate_mode = true`, `delegate_prd_path = {path}`, force `auto_mode = true`, `economy_mode = true`.
28
+ | Flag | Sets | Force |
29
+ |------|------|-------|
30
+ | `-a` | auto_mode | — |
31
+ | `-x` | examine_mode | |
32
+ | `-s` | save_mode | |
33
+ | `-e` | economy_mode | — |
34
+ | `-r` | resume_mode | — |
35
+ | `-pr` | pr_mode | — |
36
+ | `-d {path}` | delegate_mode, delegate_prd_path | auto_mode, economy_mode |
37
+ | `--foundation` | foundation_mode | auto_mode |
50
38
 
51
- **If `--foundation` detected:** set `foundation_mode = true`, force `auto_mode = true`. Foundation mode generates ONLY entities + EF configs + migration (domain + infrastructure layers). Skip application/api/frontend/tests.
39
+ **Special behaviors:** `-d {path}` enables delegate mode (extract context from PRD). `--foundation` generates ONLY entities + EF configs + migration (domain + infrastructure layers only).
52
40
 
53
41
  ---
54
42
 
55
43
  ## 1b. Delegate Mode Fast Path (if -d)
56
44
 
57
- > **When `/ralph-loop` invokes `/apex -d {prd_path}`, all context is extracted from the PRD file.**
58
- > Skip interactive sections (hierarchy definition, challenge questions).
45
+ When `-d {prd_path}` is used, extract all context from PRD file and skip sections 2, 4, 5:
59
46
 
60
- ```
61
- IF delegate_mode:
62
- Read prd.json from {delegate_prd_path}
63
-
64
- Extract context:
65
- {app_name} = prd.project.application (e.g., "HumanResources")
66
- {module_code} = prd.project.module (e.g., "EmployeeManagement")
67
- {prd_path} = {delegate_prd_path}
68
- {feature_path} = prd.source.feature_json_path (if exists)
69
-
70
- Extract sections from infrastructure tasks with _seedDataMeta:
71
- Find task where _seedDataMeta.coreSeedData.navigationSections exists
72
- {sections} = _seedDataMeta.coreSeedData.navigationSections[]
73
- → map to: { code, label, description, route, displayOrder, navigation }
74
-
75
- Extract entities from domain tasks:
76
- {entities} = prd.tasks.filter(t => t.category == 'domain').map(t => entity name from t.description)
77
-
78
- Extract code patterns from feature.json (if available):
79
- IF {feature_path} exists:
80
- Read feature.json → for each entity with codePattern defined:
81
- {code_patterns}[] += { entity, strategy, prefix, digits, includeTenantSlug, separator }
82
- ELSE:
83
- {code_patterns} = [] # will use heuristic fallback in analysis-methods.md
84
-
85
- Extract complexity:
86
- {module_complexity} = heuristic from task count:
87
- <= 10 tasks → "simple-crud"
88
- <= 20 tasks → "crud-rules"
89
- <= 30 tasks → "crud-workflow"
90
- > 30 tasks → "complex"
91
-
92
- Set needs:
93
- {needs_seed_data} = prd.tasks.some(t => t.category == 'seedData' || t.category == 'infrastructure')
94
- {needs_migration} = prd.tasks.some(t => t._migrationMeta != null)
95
- {has_dependencies} = prd.tasks.some(t => t.dependencies.length > 0) ? "references" : "none"
96
- {key_properties} = [] (extracted during step-01 from feature.json if available)
97
-
98
- SKIP sections 2 (detect application), 4 (hierarchy), 5 (challenge questions)
99
- Jump to section 3 (MCP verify) → then section 6 (determine needs, already set) → section 9 (summary)
100
- ```
47
+ **Extract from prd.json:**
48
+ - `{app_name}` = prd.project.application
49
+ - `{module_code}` = prd.project.module
50
+ - `{sections}` = infrastructure tasks → _seedDataMeta.coreSeedData.navigationSections (map to code/label/description/route/displayOrder/navigation)
51
+ - `{entities}` = domain tasks → extract entity names from descriptions
52
+ - `{code_patterns}` = feature.json entity patterns (or [] for heuristic fallback)
53
+ - `{module_complexity}` = heuristic from task count (≤10→"simple-crud", ≤20→"crud-rules", ≤30→"crud-workflow", >30→"complex")
54
+ - `{needs_seed_data}` = any seedData/infrastructure tasks exist
55
+ - `{needs_migration}` = any tasks with _migrationMeta
56
+ - `{has_dependencies}` = prd.tasks.some(t => t.dependencies.length > 0) ? "references" : "none"
57
+
58
+ **Jump to:** section 3 (MCP verify) → section 6 (determine needs) → section 9 (summary)
101
59
 
102
60
  ---
103
61
 
104
62
  ## 2. Detect SmartStack Application
105
63
 
106
- Scan the project to identify the SmartStack hierarchy:
107
-
108
- ```
109
- 1. Glob("*.sln") → confirm .NET project
110
- 2. Glob("docs/business/**/*") → list existing BA artifacts
111
- 3. Glob(".ralph/prd-*.json") → list existing PRDs
112
- 4. Glob("src/pages/**/*.tsx") → confirm frontend exists
113
- ```
64
+ Scan project: Glob("*.sln"), Glob("docs/business/**/*"), Glob(".ralph/prd-*.json"), Glob("src/pages/**/*.tsx")
114
65
 
115
- **From task description, infer:**
116
- - `{app_name}`: application name
117
- - `{module_code}`: target module
118
- - `{sections}`: sections being added/modified
119
-
120
- **From existing artifacts:**
121
- - `{prd_path}`: `.ralph/prd-{module_code}.json` if exists
122
- - `{feature_path}`: `docs/business/{app}/{module}/business-analyse/*/feature.json` if exists
66
+ **Infer from task description:** {app_name}, {module_code}, {sections}
67
+ **From artifacts:** {prd_path} = `.ralph/prd-{module_code}.json` (if exists), {feature_path} = `docs/business/{app}/{module}/business-analyse/*/feature.json` (if exists)
123
68
 
124
69
  If hierarchy cannot be inferred → load application question from `references/challenge-questions.md`.
125
70
 
@@ -136,200 +81,104 @@ IF failure → warn user, continue in degraded mode (manual tools only)
136
81
 
137
82
  ---
138
83
 
139
- ## 4. Define Navigation Hierarchy (4 Levels)
140
-
141
- > **Reference:** Load `references/challenge-questions.md` for hierarchy rules and challenge questions:
142
- > - 4-level hierarchy structure (Application → Module → Section → Resource)
143
- > - Challenge questions (4a: Application, 4b: Module, 4c: Sections, 5a: Entities, 5b: Dependencies, 5c: Code Generation)
144
- > - Validation rules (sections MUST have at least one entry)
145
- > - Storage format for each level
146
- > - Delegate mode skip (if -d)
147
-
148
- ### 4d. Resources (Optional)
149
-
150
- If the task or feature.json mentions specific resources (export, import, bulk actions):
151
- ```
152
- For each section, check if resources are needed.
153
- Resources are OPTIONAL — only define if explicitly mentioned or inferred.
154
- ```
84
+ ## 4. Define Navigation Hierarchy
155
85
 
156
- ### 4e. Hierarchy Summary
86
+ Reference `references/challenge-questions.md` for 4-level structure (Application → Module → Section → Resource), validation rules, and challenge questions 4a-4c.
157
87
 
158
- Display before proceeding:
159
-
160
- ```
161
- {app_name} ({app_code}) → {module_code} → [{sections[].code}]
88
+ **Hierarchy Summary:** {app_name} ({app_code}) → {module_code} → [{sections[].code}]
162
89
  Routes: /{app-kebab}/{module-kebab}/{section-kebab}
163
- ```
164
90
 
165
- ---
91
+ **Resources:** OPTIONAL — only define if explicitly mentioned or inferred from task/feature.json (export, import, bulk actions).
166
92
 
167
- ## 5. Challenge the Need
93
+ ### 4f. Naming Derivation Rules (DETERMINISTIC)
168
94
 
169
- > **Objective:** Even without a formal Business Analysis (`/business-analyse`), the need MUST be challenged to avoid obvious gaps. This is a rapid scope validation — 3-4 targeted questions to ensure the developer has thought through the fundamentals.
95
+ All naming variants are derived from {app_name}, {module_code}, {sections}. Do NOT invent names.
170
96
 
171
- ### 5a. Entity Scope & Relationships
97
+ | Source | Derivation | Example |
98
+ |--------|-----------|---------|
99
+ | {app_name} | kebab: lowercase, hyphen-separated | `human-resources` |
100
+ | {app_name} | PascalCase | `HumanResources` |
101
+ | {module_code} | already kebab | `employee-management` |
102
+ | {module_code} | PascalCase: remove hyphens, capitalize | `EmployeeManagement` |
103
+ | {sections[].code} | already kebab | `employees` |
104
+ | {sections[].code} | PascalCase | `Employees` |
105
+ | NavRoute | `{app_name_kebab}.{module_code}.{section_code}` (dots) | `human-resources.employee-management.employees` |
106
+ | API route | resolved dynamically by [NavRoute] from DB | N/A |
107
+ | Permission | `{app_name_kebab}.{module_code}.{section_code}.{action}` | `human-resources.employee-management.employees.read` |
172
108
 
173
- Load and execute entity questions from `references/challenge-questions.md` section 5a.
109
+ Call `mcp__smartstack__validate_conventions` after computing derivations. Fix any errors BEFORE step-01.
174
110
 
175
- ### 5b. Dependencies & Key Properties
176
-
177
- Load and execute dependency questions from `references/challenge-questions.md` section 5b.
178
-
179
- ### 5c. Code Generation Strategy
111
+ ---
180
112
 
181
- Load and execute code generation questions from `references/challenge-questions.md` section 5c.
113
+ ## 5. Challenge the Need
182
114
 
183
- **Skip if:**
184
- - `delegate_mode` is true (PRD defines code patterns)
185
- - `foundation_mode` is true (code strategy comes later)
186
- - `feature.json` exists AND all entities in `{entities}` have `codePattern` defined
115
+ Rapid scope validation — load and execute questions from `references/challenge-questions.md`:
116
+ - **5a:** Entity scope & relationships
117
+ - **5b:** Dependencies & key properties
118
+ - **5c:** Code generation strategy
187
119
 
188
- **If feature.json covers SOME but not all entities:**
189
- Only ask for entities without `codePattern` in feature.json
190
- Merge feature.json patterns + user answers into `{code_patterns}`
120
+ **Skip 5c if:**
121
+ - `delegate_mode = true` (PRD defines patterns)
122
+ - `foundation_mode = true` (code strategy later)
123
+ - `feature.json` exists AND all entities have `codePattern` defined
191
124
 
192
- ### 5d. Store Responses
125
+ **If feature.json covers SOME entities:** Only ask for entities without `codePattern`, merge responses.
193
126
 
194
- ```yaml
195
- {entities}: string[] # Main entities to manage
196
- {module_complexity}: string # "simple-crud" | "crud-rules" | "crud-workflow" | "complex"
197
- {has_dependencies}: string # "none" | "references" | "unknown"
198
- {key_properties}: string[] # Key business properties mentioned by user
199
- {code_patterns}: object[] # Per-entity code generation config (from 5c or feature.json)
127
+ **Store responses:**
200
128
  ```
201
-
202
- These values are propagated to:
203
- - **step-01 (Analyze):** Guide code exploration focus + code pattern detection (uses `{code_patterns}` as Priority 1)
204
- - **step-02 (Plan):** Inform layer mapping (e.g., workflow → needs /workflow skill)
205
- - **step-03 (Execute):** Entity scaffolding with correct properties, relationships, and code generation strategy
129
+ {entities}, {module_complexity}, {has_dependencies}, {key_properties}, {code_patterns}
130
+ ```
131
+ Propagated to: step-01 (code focus), step-02 (layer mapping), step-03 (scaffolding)
206
132
 
207
133
  ---
208
134
 
209
135
  ## 5e. Scope Complexity Guard
210
136
 
211
- > **Root cause (test-apex-007):** `/apex` was invoked with 3 applications and 7 entities.
212
- > The model's context window saturated, causing: incomplete migrations, lost conventions,
213
- > missing pages, unregistered i18n, forgotten DI registrations.
214
- >
215
- > `/apex` is designed for **incremental** development (1 module at a time).
216
- > Multi-module projects should use `/ralph-loop` which calls `/apex -d` per module.
217
-
218
- ### Scope Detection
137
+ **Design:** `/apex` handles 1 module at a time. Use `/ralph-loop` for multi-module projects.
219
138
 
139
+ **Calculate:**
220
140
  ```
221
- entity_count = {entities}.length
222
- section_count = {sections}.length
223
- app_count = number of DISTINCT applications detected in {task_description}
224
- (heuristics: "application X et application Y", "module X, module Y, module Z"
225
- with different app names, "3 apps", etc.)
226
-
227
141
  scope_score = entity_count + (section_count * 0.5) + (app_count * 3)
228
142
  ```
229
143
 
230
- ### Guard Rules
231
-
232
- ```
233
- IF delegate_mode (-d flag):
234
- SKIP guard (ralph-loop already handles scope per module)
235
-
236
- ELSE IF app_count > 1:
237
- → Warning: "Multiple applications detected ({app_count} apps, {entity_count} entities).
238
- /apex handles 1 module at a time. For multi-module projects, use:
239
- - /ralph-loop (automated: reads PRD, generates all modules sequentially)
240
- - Multiple /apex calls (manual: one /apex per module)
241
-
242
- To proceed, split your request:
243
- /apex -e add HR employee management
244
- /apex -e add CRM client management
245
- /apex -e add Project management"
246
-
247
- ELSE IF entity_count > 6:
248
- → BLOCKING: "Too many entities ({entity_count}) for a single /apex invocation.
249
- Context window saturation causes: incomplete migrations, lost conventions,
250
- missing pages, unregistered i18n, forgotten DI registrations.
251
- Maximum: 6 entities without delegate mode (-d).
252
-
253
- Solutions:
254
- /ralph-loop (automated multi-module orchestration)
255
- /apex -d {prd_path} (delegate mode, called per module by ralph-loop)
256
- Split manually: /apex add {first 3-4 entities} → then /apex add {remaining}"
257
- → STOP execution
258
-
259
- ELSE IF scope_score > 8:
260
- → WARNING: "Large scope detected ({entity_count} entities, {section_count} sections).
261
- /apex works best with ≤ 4 entities per invocation.
262
- Consider splitting into smaller iterations."
263
-
264
- AskUserQuestion:
265
- header: "Scope"
266
- question: "Le périmètre est large ({entity_count} entités). Réduire le scope ou continuer ?"
267
- options:
268
- - label: "Continue anyway"
269
- description: "Proceed with full scope (higher risk of omissions)"
270
- - label: "Split into iterations"
271
- description: "Focus on the first module/app, then run /apex again for the rest"
272
- - label: "Use /ralph-loop"
273
- description: "Switch to /ralph-loop for automated multi-module orchestration"
274
-
275
- IF "Split" → ask user which module to focus on first, update {entities}/{sections}
276
- IF "/ralph-loop" → display command to run, STOP execution
277
-
278
- ELSE:
279
- → PASS (scope is manageable)
280
- ```
281
-
282
- ### Recommended Scope per /apex Invocation
144
+ **Rules:**
145
+ - `delegate_mode (-d)` → SKIP guard (ralph-loop handles scope per module)
146
+ - `app_count > 1` → Warning: use `/ralph-loop` or split requests
147
+ - `entity_count > 6` → BLOCKING: max 6 entities. Solutions: `/ralph-loop`, `/apex -d`, or split manually
148
+ - `scope_score > 8` WARNING: ask user to split or use `/ralph-loop`
283
149
 
150
+ **Recommended Scope:**
284
151
  | Metric | Safe | Warning | Blocking |
285
152
  |--------|------|---------|----------|
286
- | Applications | 1 | 1 (large) | >1 |
153
+ | Applications | 1 | 1 | >1 |
287
154
  | Entities | 1-4 | 5-6 | >6 without -d |
288
155
  | Sections | 1-3 | 4-5 | >5 without -d |
289
- | Sub-resources | 0-2 | 3-4 | >4 without -d |
290
156
 
291
157
  ---
292
158
 
293
159
  ## 6. Determine Needs
294
160
 
295
161
  ```
296
- needs_seed_data = {sections}.length > 0 OR task mentions navigation/permissions/roles/seed
297
- needs_migration = {entities}.length > 0 OR task mentions entity/field/table/column/migration
298
- needs_workflow = {module_complexity} == "crud-workflow" OR task mentions workflow/email/approval
299
- needs_notification = {module_complexity} in ["crud-workflow","complex"] OR task mentions notification/alert
162
+ needs_seed_data = {sections}.length > 0 OR mentions navigation/permissions/roles/seed
163
+ needs_migration = {entities}.length > 0 OR mentions entity/field/table/column/migration
164
+ needs_workflow = {module_complexity} == "crud-workflow" OR mentions workflow/email/approval
165
+ needs_notification = {module_complexity} in ["crud-workflow","complex"] OR mentions notification/alert
300
166
  ```
301
167
 
302
168
  ---
303
169
 
304
170
  ## 7. Resume Mode (if -r)
305
171
 
306
- ```
307
- IF resume_mode:
308
- Read .claude/output/apex/ find latest task directory (by timestamp)
309
-
310
- IF state.json exists:
311
- → Read state.json for precise layer-level resume:
312
- completed_layers, completed_entities, files_created, build_gates, commits
313
- → Resume step-03 at NEXT uncompleted layer (skip completed layers entirely)
314
- → Re-derive remaining state variables from existing files + git log
315
-
316
- ELSE IF 00-context.md exists:
317
- → Restore state from 00-context.md (step-00 output only)
318
- → Re-derive post-step-00 state from git history + existing files
319
-
320
- ELSE:
321
- → Full re-derive from git history + existing files (slowest path)
322
- ```
172
+ Read latest task directory in `.claude/output/apex/`:
173
+ - **If state.json exists:** resume step-03 at next uncompleted layer (skip completed)
174
+ - **Else if 00-context.md exists:** restore step-00 state, re-derive post-step-00 from git + files
175
+ - **Else:** full re-derive from git history + files
323
176
 
324
177
  ---
325
178
 
326
179
  ## 8. Save Mode Setup (if -s)
327
180
 
328
- ```
329
- IF save_mode:
330
- Generate task_id → create .claude/output/apex/{task_id}/ → write 00-context.md
331
- (timestamp, state variables, flags, hierarchy, challenge responses)
332
- ```
181
+ Generate task_id → create `.claude/output/apex/{task_id}/` → write `00-context.md` with timestamp, state, flags, hierarchy, responses
333
182
 
334
183
  ---
335
184
 
@@ -340,14 +189,8 @@ APEX INIT COMPLETE — v{{SMARTSTACK_VERSION}}
340
189
  Task: {task_description}
341
190
  Hierarchy: {app_name} → {module_code} → {sections[].code}
342
191
  Entities: {entities} | Complexity: {module_complexity} | Deps: {has_dependencies}
343
- Code: {code_patterns summary e.g., "Employee:sequential(emp), Contract:year-seq(ctr)" or "all manual" or "none"}
344
- PRD: {prd_path||none} | Feature: {feature_path||none} | Flags: {active_flags}
345
- MCP: {available|degraded} | Needs: migration/seed/workflow/notification = {yes|no}
192
+ Code: {code_patterns summary} | PRD: {prd_path||none} | Feature: {feature_path||none}
193
+ Flags: {active_flags} | MCP: {available|degraded} | Needs: {migration/seed/workflow/notification}
346
194
  NEXT STEP: step-01-analyze
347
195
  ```
348
196
 
349
- ---
350
-
351
- ## NEXT STEP
352
-
353
- Load `steps/step-01-analyze.md`