@atlashub/smartstack-cli 3.10.0 → 3.12.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 (35) hide show
  1. package/dist/index.js +2544 -2461
  2. package/dist/index.js.map +1 -1
  3. package/dist/mcp-entry.mjs +479 -6185
  4. package/dist/mcp-entry.mjs.map +1 -1
  5. package/package.json +1 -1
  6. package/templates/agents/db-reader.md +149 -0
  7. package/templates/skills/business-analyse/references/cadrage-vibe-coding.md +9 -19
  8. package/templates/skills/business-analyse/references/consolidation-structural-checks.md +12 -2
  9. package/templates/skills/business-analyse/references/deploy-data-build.md +36 -25
  10. package/templates/skills/business-analyse/references/detection-strategies.md +424 -0
  11. package/templates/skills/business-analyse/references/html-data-mapping.md +4 -0
  12. package/templates/skills/business-analyse/references/prd-generation.md +258 -0
  13. package/templates/skills/business-analyse/references/validate-incremental-html.md +47 -4
  14. package/templates/skills/business-analyse/references/validation-checklist.md +281 -0
  15. package/templates/skills/business-analyse/steps/step-00-init.md +50 -221
  16. package/templates/skills/business-analyse/steps/step-01-cadrage.md +8 -22
  17. package/templates/skills/business-analyse/steps/step-03a-data.md +20 -446
  18. package/templates/skills/business-analyse/steps/step-03a1-setup.md +356 -0
  19. package/templates/skills/business-analyse/steps/step-03a2-analysis.md +143 -0
  20. package/templates/skills/business-analyse/steps/step-03b-ui.md +3 -0
  21. package/templates/skills/business-analyse/steps/step-03c-compile.md +1 -1
  22. package/templates/skills/business-analyse/steps/step-03d-validate.md +21 -262
  23. package/templates/skills/business-analyse/steps/step-04-consolidation.md +21 -606
  24. package/templates/skills/business-analyse/steps/step-04a-collect.md +304 -0
  25. package/templates/skills/business-analyse/steps/step-04b-analyze.md +239 -0
  26. package/templates/skills/business-analyse/steps/step-04c-decide.md +186 -0
  27. package/templates/skills/business-analyse/steps/step-05b-deploy.md +21 -0
  28. package/templates/skills/business-analyse/steps/step-05c-ralph-readiness.md +27 -35
  29. package/templates/skills/debug/SKILL.md +156 -53
  30. package/templates/skills/debug/references/team-protocol.md +232 -0
  31. package/templates/skills/ralph-loop/references/category-rules.md +46 -0
  32. package/templates/skills/ralph-loop/references/compact-loop.md +32 -2
  33. package/templates/skills/ralph-loop/references/core-seed-data.md +60 -0
  34. package/templates/skills/ralph-loop/steps/step-00-init.md +64 -1
  35. package/templates/skills/ralph-loop/steps/step-04-check.md +27 -2
@@ -33,23 +33,66 @@ Follow step-05 section 9d "Step 2: Build FEATURE_DATA object" for the complete m
33
33
  - `consolidation` → empty `{ interactions: [], e2eFlows: [] }` (not yet consolidated)
34
34
  - `handoff` → empty `{}` (not yet handed off)
35
35
 
36
- ### Step 3: Replace Placeholders in Template
36
+ ### Step 3: Build EMBEDDED_ARTIFACTS Object
37
+
38
+ > **CRITICAL: Without EMBEDDED_ARTIFACTS, the Maquettes tab will show EMPTY mockups.**
39
+ > Use the EXACT SAME mapping defined in references/deploy-data-build.md and references/html-data-mapping.md.
40
+
41
+ Build EMBEDDED_ARTIFACTS with wireframes for completed modules only:
42
+
43
+ ```javascript
44
+ const EMBEDDED_ARTIFACTS = {
45
+ wireframes: {
46
+ // FOR EACH completed module: extract wireframes with RENAMED fields
47
+ [moduleCode]: moduleFeature.specification.uiWireframes.map(wf => ({
48
+ screen: wf.screen,
49
+ section: wf.section,
50
+ format: wf.mockupFormat || "ascii", // RENAME: mockupFormat → format
51
+ content: wf.mockup, // RENAME: mockup → content
52
+ description: wf.description || "",
53
+ elements: wf.elements || [],
54
+ actions: wf.actions || [],
55
+ componentMapping: wf.componentMapping || [],
56
+ layout: wf.layout || null,
57
+ permissionsRequired: wf.permissionsRequired || []
58
+ }))
59
+ },
60
+ e2eFlows: [], // Empty — not yet consolidated
61
+ dependencyGraph: {
62
+ nodes: (master.modules || []).map(m => ({
63
+ id: m.code, label: m.code, type: m.featureType || "data-centric"
64
+ })),
65
+ edges: (master.dependencyGraph?.edges || []).map(e => ({
66
+ from: e.from, to: e.to, description: e.description || ""
67
+ }))
68
+ }
69
+ };
70
+ ```
71
+
72
+ > **FIELD RENAME WARNING:** feature.json uses `mockupFormat` and `mockup`.
73
+ > The HTML renderer reads `format` and `content`. You MUST rename these fields.
74
+ > Failure to rename = empty mockup display in the browser.
75
+
76
+ ### Step 4: Replace Placeholders in Template
37
77
 
38
78
  - Serialize the FEATURE_DATA object as JSON (2-space indentation)
39
- - Replace `{{FEATURE_DATA}}` with the serialized JSON
79
+ - Serialize the EMBEDDED_ARTIFACTS object as JSON (2-space indentation)
80
+ - Replace `{{FEATURE_DATA}}` with the serialized FEATURE_DATA JSON
81
+ - Replace `{{EMBEDDED_ARTIFACTS}}` with the serialized EMBEDDED_ARTIFACTS JSON
40
82
  - Replace `{{APPLICATION_NAME}}` → `{application_name}`
41
83
  - Replace `{{APPLICATION_ID}}` → `{feature_id}`
42
84
  - Replace `{{VERSION}}` → `{version}`
43
85
  - Replace `{{CREATED_AT}}` → `{ISO timestamp}`
44
86
 
45
- ### Step 4: Write and Confirm
87
+ ### Step 5: Write and Confirm
46
88
 
47
89
  ```
48
90
  ✓ Interactive HTML updated (incremental):
49
91
  Path: docs/business/{app}/business-analyse/v{version}/ba-interactive.html
50
92
  Modules included: {completedModules.length}/{totalModules} specified
51
- - {completedModule1}: {uc_count} UCs, {br_count} BRs, {entity_count} entities
93
+ - {completedModule1}: {uc_count} UCs, {br_count} BRs, {wireframe_count} wireframes
52
94
  - {completedModule2}: ...
95
+ Visual artifacts: {total_wireframes} wireframes embedded
53
96
  Remaining: {pendingModules.join(', ')} (will be added after specification)
54
97
  → Client can open in browser to review completed modules now.
55
98
  ```
@@ -0,0 +1,281 @@
1
+ # Module Specification Checklist
2
+
3
+ > **CRITICAL:** This checklist MUST be FULLY COMPLETED before marking module status = "specified".
4
+ > **Rationale:** Prevents incomplete modules from reaching handoff, reduces ralph-loop failures.
5
+
6
+ ## Checklist Structure
7
+
8
+ **Execute BEFORE updating module status to "specified":**
9
+
10
+ ```javascript
11
+ const checklist = {
12
+ // SECTION 1: DATA MODEL (BLOCKING)
13
+ entities: {
14
+ minimum: 2,
15
+ actual: specification.entities.length,
16
+ status: actual >= minimum ? "PASS" : "FAIL",
17
+ blocking: true,
18
+ details: "At least 2 entities required for a meaningful module"
19
+ },
20
+
21
+ entityAttributes: {
22
+ check: "All entities have ≥3 attributes",
23
+ status: validateAllEntities(e => e.attributes.length >= 3) ? "PASS" : "FAIL",
24
+ blocking: true,
25
+ details: "Entities with <3 attributes are likely incomplete"
26
+ },
27
+
28
+ entityRelationships: {
29
+ check: "All entities have relationships defined (or explicitly marked as standalone)",
30
+ status: validateEntityRelationships() ? "PASS" : "FAIL",
31
+ blocking: false, // WARNING only
32
+ details: "Standalone entities should be rare in business modules"
33
+ },
34
+
35
+ // SECTION 2: BUSINESS RULES (BLOCKING)
36
+ businessRules: {
37
+ minimum: 4,
38
+ actual: analysis.businessRules.length,
39
+ status: actual >= minimum ? "PASS" : "FAIL",
40
+ blocking: true,
41
+ details: "Minimum 4 BRs (mix of VAL/CALC/WF/SEC/DATA)"
42
+ },
43
+
44
+ businessRuleCategories: {
45
+ check: "BRs cover ≥2 categories (VAL, CALC, WF, SEC, DATA)",
46
+ status: countUniqueCategories(analysis.businessRules) >= 2 ? "PASS" : "FAIL",
47
+ blocking: true,
48
+ details: "Single-category modules are likely incomplete"
49
+ },
50
+
51
+ businessRulePrefixes: {
52
+ check: "All BR IDs use module prefix (e.g., BR-VAL-{PREFIX}-NNN)",
53
+ status: validateBRPrefixes() ? "PASS" : "FAIL",
54
+ blocking: true,
55
+ details: "Missing prefixes cause ID collisions in multi-module apps"
56
+ },
57
+
58
+ // SECTION 3: USE CASES & REQUIREMENTS (BLOCKING)
59
+ useCases: {
60
+ minimum: 6,
61
+ actual: specification.useCases.length,
62
+ status: actual >= minimum ? "PASS" : "FAIL",
63
+ blocking: true,
64
+ details: "Minimum 6 UCs (CRUD + 2 business-specific)"
65
+ },
66
+
67
+ useCasePrefixes: {
68
+ check: "All UC IDs use module prefix (UC-{PREFIX}-NNN)",
69
+ status: validateUCPrefixes() ? "PASS" : "FAIL",
70
+ blocking: true,
71
+ details: "Missing prefixes cause ID collisions"
72
+ },
73
+
74
+ functionalRequirements: {
75
+ minimum: 4,
76
+ actual: specification.functionalRequirements.length,
77
+ status: actual >= minimum ? "PASS" : "FAIL",
78
+ blocking: true,
79
+ details: "FRs must cover key functionality"
80
+ },
81
+
82
+ ucFrLinkage: {
83
+ check: "Every UC has ≥1 linked FR",
84
+ status: validateUCtoFRLinkage() ? "PASS" : "FAIL",
85
+ blocking: true,
86
+ details: "Orphan UCs indicate incomplete requirements"
87
+ },
88
+
89
+ frBrLinkage: {
90
+ check: "Every FR has ≥1 linked BR",
91
+ status: validateFRtoBRLinkage() ? "PASS" : "FAIL",
92
+ blocking: false, // WARNING only
93
+ details: "FRs without BRs may lack validation/calculation logic"
94
+ },
95
+
96
+ // SECTION 4: PERMISSIONS (BLOCKING)
97
+ permissions: {
98
+ minimum: 5,
99
+ actual: specification.permissionMatrix.permissions.length,
100
+ status: actual >= minimum ? "PASS" : "FAIL",
101
+ blocking: true,
102
+ details: "Minimum 5 permissions (CRUD + 1 business action)"
103
+ },
104
+
105
+ permissionFormat: {
106
+ check: "All permissions use full format: business.{app}.{module}.{resource}.{action}",
107
+ status: validatePermissionFormat() ? "PASS" : "FAIL",
108
+ blocking: true,
109
+ details: "Wrong format breaks RBAC system"
110
+ },
111
+
112
+ rolePermissions: {
113
+ check: "All application roles have ≥1 permission assigned",
114
+ status: validateRoleAssignments() ? "PASS" : "FAIL",
115
+ blocking: true,
116
+ details: "Roles without permissions are useless"
117
+ },
118
+
119
+ // SECTION 5: UI & NAVIGATION (BLOCKING)
120
+ sections: {
121
+ minimum: 2,
122
+ actual: specification.sections.length,
123
+ status: actual >= minimum ? "PASS" : "FAIL",
124
+ blocking: true,
125
+ details: "Modules need ≥2 sections (list + form minimum)"
126
+ },
127
+
128
+ wireframes: {
129
+ minimum: specification.sections.length, // 1 wireframe PER section
130
+ actual: specification.uiWireframes.length,
131
+ status: actual >= minimum ? "PASS" : "FAIL",
132
+ blocking: true,
133
+ details: "EVERY section MUST have a wireframe (ASCII/SVG)"
134
+ },
135
+
136
+ navigation: {
137
+ check: "Module has ≥1 navigation entry",
138
+ status: specification.navigation.entries.length >= 1 ? "PASS" : "FAIL",
139
+ blocking: true,
140
+ details: "Module must be accessible in menu"
141
+ },
142
+
143
+ // SECTION 6: I18N & MESSAGES (BLOCKING)
144
+ i18nKeys: {
145
+ minimum: 42, // Realistic minimum for a module
146
+ actual: specification.i18nKeys.length,
147
+ status: actual >= minimum ? "PASS" : "FAIL",
148
+ blocking: true,
149
+ details: "Keys needed: entities (×2), fields, messages, validation, navigation"
150
+ },
151
+
152
+ i18nLanguages: {
153
+ check: "All i18n keys have 4 languages (fr, en, nl, de)",
154
+ status: validateI18nCompleteness() ? "PASS" : "FAIL",
155
+ blocking: true,
156
+ details: "Missing translations break multi-language support"
157
+ },
158
+
159
+ messages: {
160
+ minimum: 4,
161
+ actual: specification.messages.length,
162
+ status: actual >= minimum ? "PASS" : "FAIL",
163
+ blocking: true,
164
+ details: "Minimum: 1 success, 1 error, 1 warning, 1 info"
165
+ },
166
+
167
+ // SECTION 7: SEED DATA (BLOCKING)
168
+ seedDataCore: {
169
+ check: "All 7 CORE seed data sections present",
170
+ requiredSections: [
171
+ "navigationModules",
172
+ "navigationSections",
173
+ "navigationResources",
174
+ "navigationTranslations",
175
+ "permissions",
176
+ "rolePermissions",
177
+ "permissionConstants"
178
+ ],
179
+ status: validateSeedDataCore() ? "PASS" : "FAIL",
180
+ blocking: true,
181
+ details: "Missing CORE seed data breaks module deployment"
182
+ },
183
+
184
+ seedDataBusiness: {
185
+ check: "Business seed data template defined for modules with reference/lookup entities",
186
+ status: specification.seedDataBusiness !== undefined ? "PASS" : "FAIL",
187
+ blocking: true, // BLOCKING — missing seed data causes empty dropdowns and test failures
188
+ details: "Business seed data (reference types, categories, statuses) is required for testing and dev environment"
189
+ },
190
+
191
+ // SECTION 8: API ENDPOINTS (BLOCKING)
192
+ apiEndpoints: {
193
+ minimum: 5,
194
+ actual: specification.apiEndpoints.length,
195
+ status: actual >= minimum ? "PASS" : "FAIL",
196
+ blocking: true,
197
+ details: "Minimum 5 endpoints (CRUD + 1 business action)"
198
+ },
199
+
200
+ apiPermissions: {
201
+ check: "Every API endpoint has permission defined",
202
+ status: validateAPIPermissions() ? "PASS" : "FAIL",
203
+ blocking: true,
204
+ details: "Endpoints without permissions are security holes"
205
+ },
206
+
207
+ // SECTION 9: VALIDATIONS (BLOCKING)
208
+ validations: {
209
+ minimum: 1,
210
+ actual: specification.validations.length,
211
+ status: actual >= minimum ? "PASS" : "FAIL",
212
+ blocking: true,
213
+ details: "Modules need field validation rules"
214
+ },
215
+
216
+ // SECTION 10: GHERKIN SCENARIOS (WARNING)
217
+ gherkinScenarios: {
218
+ minimum: 2,
219
+ actual: specification.gherkinScenarios.scenarios.length,
220
+ status: actual >= minimum ? "PASS" : "FAIL",
221
+ blocking: false, // WARNING only
222
+ details: "Gherkin scenarios enable automated testing"
223
+ }
224
+ };
225
+ ```
226
+
227
+ ## Blocking Check Logic
228
+
229
+ ```javascript
230
+ // BLOCKING CHECK: Count failures in BLOCKING items
231
+ const blockingFailures = Object.entries(checklist)
232
+ .filter(([key, check]) => check.blocking === true && check.status === "FAIL")
233
+ .map(([key, check]) => ({ section: key, ...check }));
234
+
235
+ IF blockingFailures.length > 0:
236
+ **BLOCKING ERROR:** Module specification incomplete
237
+
238
+ Display table:
239
+ | Section | Required | Actual | Status | Details |
240
+ |---------|----------|--------|--------|---------|
241
+ {for each blocking failure}
242
+
243
+ ACTIONS REQUIRED:
244
+ 1. Fix ALL blocking failures listed above
245
+ 2. Re-run step-03d validation
246
+ 3. DO NOT mark module as "specified" until ALL blocking checks pass
247
+
248
+ STOP - DO NOT PROCEED TO UPDATE STATUS
249
+ ELSE:
250
+ All blocking checks passed ✓
251
+ {count} warnings (non-blocking)
252
+ Proceed to mark module as "specified"
253
+ ```
254
+
255
+ ## Display Format
256
+
257
+ ```
258
+ ═══════════════════════════════════════════════════════════════
259
+ MODULE SPECIFICATION CHECKLIST - {currentModule}
260
+ ═══════════════════════════════════════════════════════════════
261
+
262
+ | Category | Checks | Passed | Failed | Warnings |
263
+ |----------|--------|--------|--------|----------|
264
+ | Data Model | 3 | {n} | {n} | {n} |
265
+ | Business Rules | 3 | {n} | {n} | {n} |
266
+ | Use Cases & FRs | 4 | {n} | {n} | {n} |
267
+ | Permissions | 3 | {n} | {n} | {n} |
268
+ | UI & Navigation | 3 | {n} | {n} | {n} |
269
+ | I18N & Messages | 3 | {n} | {n} | {n} |
270
+ | Seed Data | 2 | {n} | {n} | {n} |
271
+ | API Endpoints | 2 | {n} | {n} | {n} |
272
+ | Validations | 1 | {n} | {n} | {n} |
273
+ | Gherkin | 1 | {n} | {n} | {n} |
274
+
275
+ TOTAL: {total_checks} checks | {passed} ✓ | {failed} ✗ | {warnings} ⚠
276
+
277
+ STATUS: {failed === 0 ? "READY FOR SPECIFIED" : "INCOMPLETE - FIX REQUIRED"}
278
+ ═══════════════════════════════════════════════════════════════
279
+ ```
280
+
281
+ **IF ALL BLOCKING CHECKS PASS → Proceed to update module status to "specified"**
@@ -69,94 +69,51 @@ mcp__smartstack__validate_conventions({ checks: ["tables"] })
69
69
  **DO NOT** continue to any subsequent step.
70
70
  **STOP the skill immediately.**
71
71
 
72
- ## Step 2a: Check for Review Mode
73
-
74
- If `{feature_description}` starts with `-review` (with or without extra text):
75
-
76
- 1. Set `workflow_type = "review"`
77
- 2. Scan `docs/business/` for the most recent application (by updatedAt)
78
- 3. For the latest application version folder, look for `ba-review.json`
79
- 4. If found:
80
- - Store `review_json_path` = path to `ba-review.json`
81
- - Store `application_name` from the master feature.json metadata
82
- - Store `docs_dir` = directory containing `ba-review.json`
83
- - Display:
84
- ```
85
- Review mode: found ba-review.json at {review_json_path}
86
- Application: {application_name}
87
- ```
88
- - **SKIP all remaining steps** → Load `./step-06-review.md` directly
89
- 5. If NOT found:
90
- - Display error:
91
- ```
92
- ERROR: No ba-review.json found in docs/business/
93
-
94
- To create one:
95
- 1. Open the ba-interactive.html in your browser
96
- 2. Make your corrections
97
- 3. Click "Sauvegarder corrections" button
98
- 4. Save the downloaded ba-review.json in the version folder
99
- (e.g., docs/business/{app}/business-analyse/v1.0/ba-review.json)
100
- 5. Run /business-analyse -review again
101
- ```
102
- - **STOP EXECUTION**
103
-
104
- ## Step 2b: Scan Existing Applications
105
-
106
- Scan `docs/business/` for existing business analysis features.
72
+ ## Step 2-3: Workflow Detection (Review / New / Update)
107
73
 
108
- ```
109
- 1. Glob: docs/business/*/business-analyse/*/feature.json
110
- 2. For each feature.json found:
111
- - Read metadata.application, metadata.featureDescription
112
- - Store: { app: string, featureId: string, description: string, version: string }
113
- 3. Build list of existing applications
114
- ```
74
+ **Objective:** Detect workflow type and match against existing applications.
115
75
 
116
- **Store:**
117
- ```yaml
118
- existing_apps: array of { app, featureId, description, version }
119
- ```
76
+ **Process:**
120
77
 
121
- ## Step 3: Auto-Detect New vs Update (skipped in review mode)
78
+ Execute workflow detection algorithm:
79
+ 1. **Review Mode Detection:** Check if `{feature_description}` starts with `-review`
80
+ 2. **Existing Applications Scanner:** Glob `docs/business/*/business-analyse/*/feature.json`
81
+ 3. **Similarity Analysis:** Score user intent against existing apps (>= 80 = strong match)
82
+ 4. **Decision Tree:** Prompt user with relevant options
122
83
 
123
- Compare the user's `{feature_description}` with existing applications.
84
+ ```javascript
85
+ const detectionResult = detectWorkflowType(feature_description, existingApps);
124
86
 
125
- ```
126
- IF existing_apps is empty:
127
- workflow_type = "new"
128
- → Go to Step 4
87
+ IF detectionResult.error OR detectionResult.ambiguous:
88
+ // CONDITIONAL LOAD: Only load detection strategies on error or ambiguity
89
+ Read references/detection-strategies.md
90
+ Display:
91
+ - Detailed similarity scoring algorithm
92
+ - Decision tree with thresholds
93
+ - Error handling procedures
94
+ - Review mode troubleshooting (if review mode failed)
129
95
 
130
- IF existing_apps has entries:
131
- Analyze {feature_description} for similarity with existing apps:
132
- - Same application domain?
133
- - References an existing module name?
134
- - Mentions adding/changing/modifying something existing?
96
+ Resolve ambiguity with user clarification
135
97
 
136
- Ask via AskUserQuestion:
137
- question: "J'ai trouvé des analyses existantes. Que souhaitez-vous faire ?"
138
- header: "Mode"
139
- options:
140
- - label: "Nouvelle application"
141
- description: "Créer une nouvelle analyse complète"
142
- - label: "Mise à jour de {appName} (FEAT-NNN)"
143
- description: "Enrichir ou modifier l'application existante (crée v{next})"
144
- (repeat for each existing app, max 3 options + "Nouvelle application")
145
-
146
- IF user selects "Nouvelle application":
147
- workflow_type = "new"
148
- ELSE:
149
- workflow_type = "update"
150
- existing_feature_id = selected app's featureId
151
- Call ba-writer.createVersion(existing_feature_id, {feature_description})
152
- version = new version number
98
+ ELSE:
99
+ Workflow detected: {detectionResult.workflow_type}
100
+ Continue to application name determination
153
101
  ```
154
102
 
103
+ **Key decision points:**
104
+ 1. IF review mode → load ba-review.json, skip to step-06-review.md
105
+ 2. IF no existing apps → workflow_type = "new"
106
+ 3. IF existing apps → analyze similarity → prompt user
107
+
108
+ **Optimization:** The detailed 400-line detection-strategies.md is loaded **only when detection fails or is ambiguous** (saves ~15,000 tokens on clear detection path).
109
+
155
110
  **Store:**
156
111
  ```yaml
157
- workflow_type: "new" | "update"
112
+ workflow_type: "new" | "update" | "review"
158
113
  existing_feature_id: string | null
159
114
  version: "1.0" (new) | "1.1"+ (update)
115
+ review_json_path: string | null (review only)
116
+ existing_apps: array of { app, featureId, description, version }
160
117
  ```
161
118
 
162
119
  ## Step 4: Determine Application Name
@@ -279,169 +236,41 @@ See [references/init-schema-deployment.md](../references/init-schema-deployment.
279
236
 
280
237
  ## Step 8b: Cache Warming (PERFORMANCE OPTIMIZATION)
281
238
 
282
- > **Objective:** Pre-load frequently-used templates and context files to reduce redundant reads in subsequent steps.
283
- > **Expected token savings:** 15-20% across the entire BA session
284
-
285
- **Why cache warming matters:**
239
+ > **Objective:** Pre-load frequently-used templates and context files to reduce redundant reads.
240
+ > **Expected token savings:** 15-20% across entire BA session
286
241
 
287
- Analysis of BA sessions shows 98.5% cache read operations, meaning the same files are re-read multiple times. By pre-loading them once at initialization, we reduce:
288
- - Redundant file reads (5+ reads of same schema files)
289
- - Token waste on repeated context setup
290
- - Agent execution time (no wait for file I/O)
291
-
292
- ### Cache Buckets Strategy
293
-
294
- Organize cached content into logical buckets based on when they'll be used:
242
+ **Implementation:**
295
243
 
296
244
  ```javascript
297
- const cacheBuckets = {
298
- // Bucket 1: Core schemas (used in ALL steps)
299
- schemas: {
300
- retention: "session", // Keep for entire BA session
301
- files: [
302
- "docs/business/{app}/business-analyse/schemas/feature-schema.json",
303
- "docs/business/{app}/business-analyse/schemas/application-schema.json",
304
- "docs/business/{app}/business-analyse/schemas/sections/*.json",
305
- "docs/business/{app}/business-analyse/schemas/shared/common-defs.json"
306
- ],
307
- priority: "critical"
308
- },
309
-
310
- // Bucket 2: Questionnaire templates (used in step-01)
311
- questionnaires: {
312
- retention: "until-step-02", // Can clear after cadrage
313
- files: [
314
- "~/.claude/skills/business-analyse/questionnaire/*.md",
315
- "~/.claude/skills/business-analyse/patterns/suggestion-catalog.md"
316
- ],
317
- priority: "high"
318
- },
319
-
320
- // Bucket 3: Module specification references (used in step-03)
321
- moduleSpec: {
322
- retention: "until-step-04", // Can clear after all modules specified
323
- files: [
324
- "~/.claude/skills/business-analyse/references/spec-auto-inference.md",
325
- "~/.claude/skills/business-analyse/references/ui-resource-cards.md",
326
- "~/.claude/skills/business-analyse/references/ui-dashboard-spec.md"
327
- ],
328
- priority: "medium"
329
- },
330
-
331
- // Bucket 4: Handoff & deploy templates (used in step-05)
332
- handoff: {
333
- retention: "until-complete",
334
- files: [
335
- "~/.claude/skills/business-analyse/references/handoff-file-templates.md",
336
- "~/.claude/skills/business-analyse/references/handoff-mappings.md",
337
- "~/.claude/skills/business-analyse/references/deploy-data-build.md",
338
- "~/.claude/skills/business-analyse/html/ba-interactive.html"
339
- ],
340
- priority: "low" // Load later, not at init
341
- }
342
- };
343
- ```
344
-
345
- ### Implementation at Step 8b
346
-
347
- **ONLY pre-load CRITICAL and HIGH priority buckets at initialization:**
348
-
349
- ```javascript
350
- // 1. Pre-load schemas (Bucket 1 - CRITICAL)
245
+ // Pre-load CRITICAL (schemas) and HIGH (questionnaires) priority buckets
351
246
  const schemaFiles = glob("docs/business/{app}/business-analyse/schemas/**/*.json");
352
247
  for (const file of schemaFiles) {
353
- const content = read(file);
354
- // Content is now in cache for subsequent reads
355
- // No need to store in variable, just reading triggers cache
248
+ read(file); // Triggers cache
356
249
  }
357
250
 
358
- // 2. Pre-load questionnaires (Bucket 2 - HIGH, if step-01 is next)
359
251
  const questionnaireFiles = glob("~/.claude/skills/business-analyse/questionnaire/*.md");
360
252
  for (const file of questionnaireFiles) {
361
- const content = read(file);
253
+ read(file); // Triggers cache
362
254
  }
363
255
 
364
- // 3. Pre-load suggestion catalog
365
- const suggestions = read("~/.claude/skills/business-analyse/patterns/suggestion-catalog.md");
256
+ read("~/.claude/skills/business-analyse/patterns/suggestion-catalog.md");
366
257
 
367
- // 4. Display cache warming status
258
+ // Display status
368
259
  console.log(`
369
- ✓ Cache warmed: 9 schemas + 16 questionnaires + 1 suggestion catalog
370
- Expected token savings: 15-20% over session
371
- Cache retention: schemas (session-wide), questionnaires (until step-02)
260
+ ✓ Cache warmed: 9 schemas + 16 questionnaires + 1 catalog
261
+ Expected savings: 15-20% session tokens
262
+ Retention: schemas (session-wide), questionnaires (until step-02)
372
263
  `);
373
264
  ```
374
265
 
375
- ### Cache Retention Rules
376
-
377
- | Bucket | Load At | Clear At | Reason |
378
- |--------|---------|----------|--------|
379
- | schemas | step-00 | session end | Used by ALL steps for validation |
380
- | questionnaires | step-00 | step-02 | Only needed for cadrage |
381
- | moduleSpec | step-03 start | step-04 | Only needed for module loop |
382
- | handoff | step-05a start | session end | Only needed for handoff/deploy |
383
-
384
- ### Benefits
385
-
386
- **Measured impact (from analysis):**
387
-
388
- - **Before warming:**
389
- - Schema files read 5-7 times per session
390
- - Questionnaires read 2-3 times
391
- - Total redundant reads: ~30 file operations
392
- - Token cost: ~15,000 tokens wasted
393
-
394
- - **After warming:**
395
- - Schema files read once (cached for session)
396
- - Questionnaires read once (cached until step-02)
397
- - Total redundant reads: ~5 file operations (90% reduction)
398
- - Token cost: ~3,000 tokens (80% reduction)
399
-
400
- **Overall session impact:** 15-20% total token savings
401
-
402
- ### When NOT to Pre-Load
403
-
404
- ❌ **Don't pre-load:**
405
- - Files that will NOT be used (e.g., handoff templates during cadrage)
406
- - Large files (>50KB) that are read only once
407
- - Module-specific feature.json files (loaded on-demand)
408
- - User-generated content (changes frequently)
409
-
410
- ✅ **DO pre-load:**
411
- - Small, static template files (<10KB) used 3+ times
412
- - Core schemas used in every step
413
- - Questionnaire templates used in next step
414
- - Pattern catalogs referenced frequently
415
-
416
- ### Monitoring Cache Efficiency
417
-
418
- After cache warming, monitor cache hit rates:
419
-
420
- ```
421
- Step-01 cache stats:
422
- - schema-read operations: 12 (100% cache hits)
423
- - questionnaire-read operations: 16 (100% cache hits)
424
- - Cache efficiency: Optimal (0 redundant reads)
425
- ```
426
-
427
- Compare to baseline (no warming):
428
- ```
429
- Step-01 cache stats (baseline):
430
- - schema-read operations: 12 (8 cache hits, 4 misses = 67% efficiency)
431
- - questionnaire-read operations: 16 (5 cache hits, 11 misses = 31% efficiency)
432
- - Cache efficiency: Poor (15 redundant reads)
433
- ```
434
-
435
- **Success metric:** Cache hit rate > 90% for pre-loaded files
436
-
437
- ### Reference Documentation
266
+ **Bucket Strategy:**
438
267
 
439
- See [references/cache-warming-strategy.md](../references/cache-warming-strategy.md) for:
440
- - Complete cache bucket definitions
441
- - Retention policy details
442
- - Token savings calculations
443
- - Cache invalidation rules
444
- - Advanced: progressive cache warming across steps
268
+ See [references/cache-warming-strategy.md](../references/cache-warming-strategy.md) for complete documentation on:
269
+ - 5 cache buckets (schemas, questionnaires, moduleSpec, handoff, etc.)
270
+ - Retention policies and clearing rules
271
+ - Token savings calculations (baseline vs optimized)
272
+ - Monitoring cache efficiency
273
+ - When to pre-load vs lazy-load
445
274
 
446
275
  ## Step 9: Create Master feature.json
447
276