@atlashub/smartstack-cli 3.8.0 → 3.10.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 (130) hide show
  1. package/dist/index.js +365 -2
  2. package/dist/index.js.map +1 -1
  3. package/package.json +2 -1
  4. package/templates/agents/action.md +1 -0
  5. package/templates/agents/ba-writer.md +211 -0
  6. package/templates/agents/explore-codebase.md +1 -0
  7. package/templates/agents/explore-docs.md +1 -0
  8. package/templates/agents/fix-grammar.md +1 -0
  9. package/templates/agents/snipper.md +1 -0
  10. package/templates/skills/admin/SKILL.md +6 -0
  11. package/templates/skills/ai-prompt/SKILL.md +32 -136
  12. package/templates/skills/ai-prompt/steps/step-01-implementation.md +122 -0
  13. package/templates/skills/apex/SKILL.md +120 -0
  14. package/templates/skills/apex/_shared.md +86 -0
  15. package/templates/skills/apex/references/agent-teams-protocol.md +164 -0
  16. package/templates/skills/apex/references/smartstack-layers.md +173 -0
  17. package/templates/skills/apex/steps/step-00-init.md +156 -0
  18. package/templates/skills/apex/steps/step-01-analyze.md +169 -0
  19. package/templates/skills/apex/steps/step-02-plan.md +160 -0
  20. package/templates/skills/apex/steps/step-03-execute.md +166 -0
  21. package/templates/skills/apex/steps/step-04-validate.md +138 -0
  22. package/templates/skills/apex/steps/step-05-examine.md +124 -0
  23. package/templates/skills/apex/steps/step-06-resolve.md +105 -0
  24. package/templates/skills/apex/steps/step-07-tests.md +130 -0
  25. package/templates/skills/apex/steps/step-08-run-tests.md +115 -0
  26. package/templates/skills/application/SKILL.md +10 -0
  27. package/templates/skills/application/references/application-roles-template.md +227 -0
  28. package/templates/skills/application/references/backend-controller-hierarchy.md +58 -0
  29. package/templates/skills/application/references/backend-entity-seeding.md +72 -0
  30. package/templates/skills/application/references/backend-verification.md +88 -0
  31. package/templates/skills/application/references/frontend-verification.md +111 -0
  32. package/templates/skills/application/references/nav-fallback-procedure.md +200 -0
  33. package/templates/skills/application/references/provider-template.md +158 -0
  34. package/templates/skills/application/references/test-frontend.md +73 -0
  35. package/templates/skills/application/references/test-prerequisites.md +72 -0
  36. package/templates/skills/application/steps/step-01-navigation.md +7 -198
  37. package/templates/skills/application/steps/step-03-roles.md +45 -7
  38. package/templates/skills/application/steps/step-03b-provider.md +15 -132
  39. package/templates/skills/application/steps/step-04-backend.md +20 -350
  40. package/templates/skills/application/steps/step-05-frontend.md +12 -101
  41. package/templates/skills/application/steps/step-07-tests.md +12 -132
  42. package/templates/skills/business-analyse/SKILL.md +67 -6
  43. package/templates/skills/business-analyse/html/ba-interactive.html +176 -14
  44. package/templates/skills/business-analyse/html/src/scripts/01-data-init.js +1 -0
  45. package/templates/skills/business-analyse/html/src/scripts/05-render-specs.js +16 -4
  46. package/templates/skills/business-analyse/html/src/scripts/06-render-consolidation.js +7 -2
  47. package/templates/skills/business-analyse/html/src/scripts/09-export.js +103 -0
  48. package/templates/skills/business-analyse/html/src/scripts/10-comments.js +12 -6
  49. package/templates/skills/business-analyse/html/src/scripts/11-review-panel.js +24 -2
  50. package/templates/skills/business-analyse/html/src/styles/08-review-panel.css +12 -0
  51. package/templates/skills/business-analyse/html/src/template.html +1 -0
  52. package/templates/skills/business-analyse/references/agent-pooling-best-practices.md +477 -0
  53. package/templates/skills/business-analyse/references/cache-warming-strategy.md +578 -0
  54. package/templates/skills/business-analyse/references/cadrage-structure-cards.md +78 -0
  55. package/templates/skills/business-analyse/references/cadrage-vibe-coding.md +97 -0
  56. package/templates/skills/business-analyse/references/consolidation-structural-checks.md +92 -0
  57. package/templates/skills/business-analyse/references/deploy-data-build.md +121 -0
  58. package/templates/skills/business-analyse/references/deploy-modes.md +49 -0
  59. package/templates/skills/business-analyse/references/handoff-file-templates.md +119 -0
  60. package/templates/skills/business-analyse/references/handoff-mappings.md +81 -0
  61. package/templates/skills/business-analyse/references/html-data-mapping.md +10 -2
  62. package/templates/skills/business-analyse/references/init-schema-deployment.md +65 -0
  63. package/templates/skills/business-analyse/references/review-data-mapping.md +363 -0
  64. package/templates/skills/business-analyse/references/robustness-checks.md +538 -0
  65. package/templates/skills/business-analyse/references/spec-auto-inference.md +57 -0
  66. package/templates/skills/business-analyse/references/ui-dashboard-spec.md +85 -0
  67. package/templates/skills/business-analyse/references/ui-resource-cards.md +110 -0
  68. package/templates/skills/business-analyse/references/validate-incremental-html.md +55 -0
  69. package/templates/skills/business-analyse/schemas/sections/specification-schema.json +33 -1
  70. package/templates/skills/business-analyse/steps/step-00-init.md +186 -53
  71. package/templates/skills/business-analyse/steps/step-01-cadrage.md +5 -194
  72. package/templates/skills/business-analyse/steps/step-03a-data.md +42 -49
  73. package/templates/skills/business-analyse/steps/step-03b-ui.md +12 -178
  74. package/templates/skills/business-analyse/steps/step-03c-compile.md +71 -2
  75. package/templates/skills/business-analyse/steps/step-03d-validate.md +277 -48
  76. package/templates/skills/business-analyse/steps/step-04-consolidation.md +175 -104
  77. package/templates/skills/business-analyse/steps/step-05a-handoff.md +66 -438
  78. package/templates/skills/business-analyse/steps/step-05b-deploy.md +35 -184
  79. package/templates/skills/business-analyse/steps/step-05c-ralph-readiness.md +526 -0
  80. package/templates/skills/business-analyse/steps/step-06-review.md +277 -0
  81. package/templates/skills/cc-agent/references/agent-behavior-patterns.md +95 -0
  82. package/templates/skills/cc-agent/steps/step-02-generate.md +5 -78
  83. package/templates/skills/check-version/SKILL.md +7 -0
  84. package/templates/skills/controller/references/controller-code-templates.md +159 -0
  85. package/templates/skills/controller/references/permission-sync-templates.md +152 -0
  86. package/templates/skills/controller/steps/step-03-generate.md +166 -158
  87. package/templates/skills/controller/steps/step-04-perms.md +5 -144
  88. package/templates/skills/controller/templates.md +11 -2
  89. package/templates/skills/debug/SKILL.md +7 -0
  90. package/templates/skills/explore/SKILL.md +6 -0
  91. package/templates/skills/feature-full/SKILL.md +39 -142
  92. package/templates/skills/feature-full/steps/step-01-implementation.md +120 -0
  93. package/templates/skills/gitflow/references/init-config-template.md +135 -0
  94. package/templates/skills/gitflow/references/init-name-normalization.md +103 -0
  95. package/templates/skills/gitflow/references/plan-template.md +69 -0
  96. package/templates/skills/gitflow/references/start-efcore-preflight.md +70 -0
  97. package/templates/skills/gitflow/references/start-local-config.md +110 -0
  98. package/templates/skills/gitflow/steps/step-init.md +18 -289
  99. package/templates/skills/gitflow/steps/step-plan.md +6 -63
  100. package/templates/skills/gitflow/steps/step-start.md +16 -126
  101. package/templates/skills/mcp/SKILL.md +9 -213
  102. package/templates/skills/mcp/steps/step-01-healthcheck.md +108 -0
  103. package/templates/skills/mcp/steps/step-02-tools.md +73 -0
  104. package/templates/skills/notification/SKILL.md +7 -0
  105. package/templates/skills/quick-search/SKILL.md +5 -0
  106. package/templates/skills/ralph-loop/SKILL.md +99 -381
  107. package/templates/skills/ralph-loop/references/category-rules.md +259 -0
  108. package/templates/skills/ralph-loop/references/compact-loop.md +182 -0
  109. package/templates/skills/ralph-loop/references/core-seed-data.md +173 -21
  110. package/templates/skills/ralph-loop/references/task-transform-legacy.md +259 -0
  111. package/templates/skills/ralph-loop/references/team-orchestration.md +189 -0
  112. package/templates/skills/ralph-loop/steps/step-00-init.md +111 -383
  113. package/templates/skills/ralph-loop/steps/step-01-task.md +79 -896
  114. package/templates/skills/ralph-loop/steps/step-02-execute.md +68 -680
  115. package/templates/skills/ralph-loop/steps/step-03-commit.md +47 -277
  116. package/templates/skills/ralph-loop/steps/step-04-check.md +124 -607
  117. package/templates/skills/ralph-loop/steps/step-05-report.md +68 -367
  118. package/templates/skills/refactor/SKILL.md +12 -176
  119. package/templates/skills/refactor/steps/step-01-discover.md +60 -0
  120. package/templates/skills/refactor/steps/step-02-execute.md +67 -0
  121. package/templates/skills/review-code/SKILL.md +19 -257
  122. package/templates/skills/review-code/steps/step-01-smartstack.md +96 -0
  123. package/templates/skills/review-code/steps/step-02-detailed-review.md +80 -0
  124. package/templates/skills/review-code/steps/step-03-react.md +44 -0
  125. package/templates/skills/ui-components/SKILL.md +7 -0
  126. package/templates/skills/utils/SKILL.md +6 -0
  127. package/templates/skills/validate/SKILL.md +6 -0
  128. package/templates/skills/validate-feature/SKILL.md +8 -0
  129. package/templates/skills/workflow/SKILL.md +40 -118
  130. package/templates/skills/workflow/steps/step-01-implementation.md +84 -0
@@ -0,0 +1,110 @@
1
+ # UI: Resource Structure Cards
2
+
3
+ > Reference for step-03b-ui.md — exact JSON formats for section resources (SmartTable, SmartForm) and wireframes.
4
+
5
+ ## specification.sections[] (with resources)
6
+
7
+ ```json
8
+ {
9
+ "code": "list",
10
+ "labels": { "fr": "Liste", "en": "List", "it": "Elenco", "de": "Liste" },
11
+ "route": "/business/{app}/{module}/list",
12
+ "icon": "list",
13
+ "permission": "business.{app}.{module}.read",
14
+ "wireframe": "{module}-list",
15
+ "useCases": ["UC-{PREFIX}-001", "UC-{PREFIX}-002"],
16
+ "businessRules": ["BR-VAL-{PREFIX}-001"],
17
+ "resources": [
18
+ {
19
+ "code": "{module}-grid",
20
+ "type": "SmartTable",
21
+ "entity": "{MainEntity}",
22
+ "permission": "business.{app}.{module}.read",
23
+ "columns": ["name", "status", "createdAt"],
24
+ "columnDefs": [
25
+ { "field": "code", "label": {"fr": "Code", "en": "Code"}, "format": "text", "sortable": true, "filterable": true, "clickAction": "navigate:detail" },
26
+ { "field": "name", "label": {"fr": "Nom", "en": "Name"}, "format": "text", "sortable": true, "filterable": true },
27
+ { "field": "status", "label": {"fr": "Statut", "en": "Status"}, "format": "badge", "sortable": true, "filterable": true, "colorMap": "stateMachine:{Entity}" },
28
+ { "field": "createdAt", "label": {"fr": "Créé le", "en": "Created"}, "format": "date-relative", "sortable": true }
29
+ ],
30
+ "actions": ["view", "edit", "delete"],
31
+ "rowActions": [
32
+ { "action": "view", "icon": "eye", "permission": "business.{app}.{module}.read" },
33
+ { "action": "edit", "icon": "edit", "permission": "business.{app}.{module}.update", "showWhen": {"status": ["draft"]} },
34
+ { "action": "delete", "icon": "trash", "permission": "business.{app}.{module}.delete", "confirm": true }
35
+ ],
36
+ "filters": ["status", "dateRange"],
37
+ "defaultSort": { "field": "createdAt", "direction": "desc" },
38
+ "defaultPageSize": 20,
39
+ "emptyState": { "icon": "inbox", "message": {"fr": "Aucun enregistrement", "en": "No records"}, "createAction": true }
40
+ }
41
+ ]
42
+ }
43
+ ```
44
+
45
+ **MANDATORY for SmartTable:** `columnDefs`, `rowActions`, `defaultSort`, `emptyState`
46
+
47
+ ## SmartForm resource (for create/edit sections)
48
+
49
+ ```json
50
+ {
51
+ "code": "{module}-form",
52
+ "type": "SmartForm",
53
+ "entity": "{MainEntity}",
54
+ "permission": "business.{app}.{module}.create",
55
+ "fields": [
56
+ { "name": "code", "component": "Input", "required": true, "validation": "Unique, auto-generated" },
57
+ { "name": "name", "component": "Input", "required": true },
58
+ { "name": "type", "component": "Select", "required": true, "source": "EntityTypeEnum" },
59
+ { "name": "description", "component": "TextArea", "required": false },
60
+ { "name": "parentId", "component": "EntitySelect", "source": "ParentEntity", "required": true },
61
+ { "name": "startDate", "component": "DatePicker", "required": true },
62
+ { "name": "isActive", "component": "Toggle", "default": true }
63
+ ],
64
+ "formLayout": {
65
+ "type": "tabs",
66
+ "tabs": [
67
+ { "code": "general", "label": {"fr": "Général", "en": "General"}, "fields": ["code", "name", "type", "description"] },
68
+ { "code": "details", "label": {"fr": "Détails", "en": "Details"}, "fields": ["parentId", "startDate", "isActive"] }
69
+ ]
70
+ }
71
+ }
72
+ ```
73
+
74
+ **MANDATORY for SmartForm:** `fields` with `component` type, `formLayout`
75
+
76
+ ## specification.uiWireframes[]
77
+
78
+ ```json
79
+ {
80
+ "screen": "{module}-{section}",
81
+ "section": "{section}",
82
+ "description": "Description of the screen",
83
+ "mockupFormat": "ascii",
84
+ "mockup": "╔═══...",
85
+ "elements": ["DataGrid", "FilterBar", "Pagination", "CreateButton"],
86
+ "actions": ["filter", "sort", "create", "view-detail"],
87
+ "permissionsRequired": ["business.{app}.{module}.read"],
88
+ "componentMapping": [
89
+ { "wireframeElement": "DataGrid", "reactComponent": "SmartTable" },
90
+ { "wireframeElement": "FilterBar", "reactComponent": "SmartFilter" },
91
+ { "wireframeElement": "CreateButton", "reactComponent": "Button" }
92
+ ],
93
+ "layout": {
94
+ "type": "page",
95
+ "regions": [
96
+ { "id": "toolbar", "position": "top", "components": [
97
+ { "type": "FilterBar", "resourceRef": "{module}-filters" },
98
+ { "type": "ActionMenu", "resourceRef": "{module}-actions", "permission": "business.{app}.{module}.create" }
99
+ ]},
100
+ { "id": "content", "position": "main", "span": 12, "components": [
101
+ { "type": "SmartTable", "resourceRef": "{module}-grid" }
102
+ ]}
103
+ ]
104
+ }
105
+ }
106
+ ```
107
+
108
+ **REQUIRED fields:** `screen`, `mockup`, `elements`, `section`, `componentMapping`, `layout` are ALL mandatory.
109
+ A wireframe without `componentMapping` or `layout` will FAIL validation in step 9.
110
+ **layout.regions[].components[].resourceRef** MUST match a `sections[].resources[].code`.
@@ -0,0 +1,55 @@
1
+ # Validate: Incremental Interactive HTML Deployment
2
+
3
+ > Reference for step-03d-validate.md — section 11-bis incremental HTML deploy after each module.
4
+
5
+ ## Why Incremental?
6
+
7
+ The client doesn't have to wait until handoff to start reviewing.
8
+ While module 2 is being specified, the client can already give feedback on module 1.
9
+ Each incremental deployment OVERWRITES the previous HTML (latest state always).
10
+ The FINAL deployment at step-05 (handoff) will include consolidation and handoff data.
11
+
12
+ ## Deployment Steps
13
+
14
+ **Source:** `html/ba-interactive.html` (relative to skill root = `~/.claude/skills/business-analyse/html/`)
15
+
16
+ **Destination:** `docs/business/{app}/business-analyse/v{version}/ba-interactive.html`
17
+
18
+ ### Step 1: Read Sources
19
+
20
+ - Read the HTML template from skill directory
21
+ - Read the master feature.json (application level — now updated with current module status)
22
+ - Read EACH completed module's feature.json (including the one just specified)
23
+
24
+ ### Step 2: Build FEATURE_DATA Object
25
+
26
+ > **Use the EXACT SAME mapping defined in step-05b-deploy.md and references/html-data-mapping.md.**
27
+ > The mapping is identical — the only difference is that `moduleSpecs` only includes completed modules.
28
+ > Modules not yet specified will NOT appear in `moduleSpecs` (their entry in `modules[]` will show `status: "pending"`).
29
+
30
+ Follow step-05 section 9d "Step 2: Build FEATURE_DATA object" for the complete mapping pseudocode:
31
+ - `metadata`, `cadrage`, `modules[]`, `dependencies[]` → from master feature.json
32
+ - `moduleSpecs[moduleCode]` → only for modules with status "specified" (completed so far)
33
+ - `consolidation` → empty `{ interactions: [], e2eFlows: [] }` (not yet consolidated)
34
+ - `handoff` → empty `{}` (not yet handed off)
35
+
36
+ ### Step 3: Replace Placeholders in Template
37
+
38
+ - Serialize the FEATURE_DATA object as JSON (2-space indentation)
39
+ - Replace `{{FEATURE_DATA}}` with the serialized JSON
40
+ - Replace `{{APPLICATION_NAME}}` → `{application_name}`
41
+ - Replace `{{APPLICATION_ID}}` → `{feature_id}`
42
+ - Replace `{{VERSION}}` → `{version}`
43
+ - Replace `{{CREATED_AT}}` → `{ISO timestamp}`
44
+
45
+ ### Step 4: Write and Confirm
46
+
47
+ ```
48
+ ✓ Interactive HTML updated (incremental):
49
+ Path: docs/business/{app}/business-analyse/v{version}/ba-interactive.html
50
+ Modules included: {completedModules.length}/{totalModules} specified
51
+ - {completedModule1}: {uc_count} UCs, {br_count} BRs, {entity_count} entities
52
+ - {completedModule2}: ...
53
+ Remaining: {pendingModules.join(', ')} (will be added after specification)
54
+ → Client can open in browser to review completed modules now.
55
+ ```
@@ -382,7 +382,7 @@
382
382
  },
383
383
  "seedDataCore": {
384
384
  "type": "object",
385
- "description": "5 mandatory SmartStack core SeedData definitions",
385
+ "description": "7 mandatory SmartStack core SeedData definitions (modules, sections, resources, translations, permissions, rolePermissions, permissionConstants)",
386
386
  "properties": {
387
387
  "navigationModules": {
388
388
  "type": "array",
@@ -399,6 +399,38 @@
399
399
  }
400
400
  }
401
401
  },
402
+ "navigationSections": {
403
+ "type": "array",
404
+ "description": "Level 4 (Section) navigation entries for core.nav_Sections table. Derived from specification.sections[].",
405
+ "items": {
406
+ "type": "object",
407
+ "required": ["code", "label", "icon", "route", "parentCode", "permission"],
408
+ "properties": {
409
+ "code": { "type": "string", "description": "Section code (list, detail, create, dashboard)" },
410
+ "label": { "type": "string", "description": "Section label in default language (fr)" },
411
+ "icon": { "type": "string", "description": "Lucide icon name" },
412
+ "route": { "type": "string", "description": "Full route path" },
413
+ "parentCode": { "type": "string", "description": "Parent module code" },
414
+ "permission": { "type": "string", "description": "Required permission path" },
415
+ "sort": { "type": "integer", "description": "Display order within module" }
416
+ }
417
+ }
418
+ },
419
+ "navigationResources": {
420
+ "type": "array",
421
+ "description": "Level 5 (Resource) navigation entries for core.nav_Resources table. Derived from specification.sections[].resources[].",
422
+ "items": {
423
+ "type": "object",
424
+ "required": ["code", "type", "parentCode"],
425
+ "properties": {
426
+ "code": { "type": "string", "description": "Resource code (kebab-case)" },
427
+ "type": { "type": "string", "description": "SmartStack component type (SmartTable, SmartForm, DetailCard, KpiCard, Chart, etc.)" },
428
+ "entity": { "type": "string", "description": "Primary entity this resource operates on" },
429
+ "parentCode": { "type": "string", "description": "Parent section code" },
430
+ "permission": { "type": "string", "description": "Required permission path (optional if inherited from section)" }
431
+ }
432
+ }
433
+ },
402
434
  "navigationTranslations": {
403
435
  "type": "array",
404
436
  "items": {
@@ -69,7 +69,39 @@ 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 2: Scan Existing Applications
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
73
105
 
74
106
  Scan `docs/business/` for existing business analysis features.
75
107
 
@@ -86,7 +118,7 @@ Scan `docs/business/` for existing business analysis features.
86
118
  existing_apps: array of { app, featureId, description, version }
87
119
  ```
88
120
 
89
- ## Step 3: Auto-Detect New vs Update
121
+ ## Step 3: Auto-Detect New vs Update (skipped in review mode)
90
122
 
91
123
  Compare the user's `{feature_description}` with existing applications.
92
124
 
@@ -243,72 +275,173 @@ docs_dir: "docs/business/{app}/business-analyse/v{version}"
243
275
  > **The JSON Schemas MUST be present in the project alongside the generated feature.json files.**
244
276
  > Without schemas, feature.json files cannot be validated and have no structural reference.
245
277
 
246
- **Performance optimization:** Use cache file to avoid redundant deployments.
278
+ See [references/init-schema-deployment.md](../references/init-schema-deployment.md) for cache-based deployment logic (9 schema files, version-checked via `.schema-cache.json`).
247
279
 
248
- ### Cache-based deployment logic:
280
+ ## Step 8b: Cache Warming (PERFORMANCE OPTIMIZATION)
249
281
 
250
- **Step 1: Check deployment cache**
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
251
284
 
252
- Cache file location: `docs/business/{app}/business-analyse/.schema-cache.json`
285
+ **Why cache warming matters:**
253
286
 
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:
295
+
296
+ ```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
+ };
254
343
  ```
255
- IF EXISTS docs/business/{app}/business-analyse/.schema-cache.json:
256
- Read cache file
257
- IF cache.version == "{CLI_VERSION}" (from package.json):
258
- Display: "Schemas already deployed ({CLI_VERSION}) - skipping"
259
- SKIP deployment (trust cache)
260
- → Go to Step 9
261
- ELSE:
262
- Display: "Schema version mismatch (cache: {cache.version}, current: {CLI_VERSION})"
263
- Proceed to deployment
264
- ELSE:
265
- Display: "Deploying schemas (first time)..."
266
- Proceed to deployment
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)
351
+ const schemaFiles = glob("docs/business/{app}/business-analyse/schemas/**/*.json");
352
+ 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
356
+ }
357
+
358
+ // 2. Pre-load questionnaires (Bucket 2 - HIGH, if step-01 is next)
359
+ const questionnaireFiles = glob("~/.claude/skills/business-analyse/questionnaire/*.md");
360
+ for (const file of questionnaireFiles) {
361
+ const content = read(file);
362
+ }
363
+
364
+ // 3. Pre-load suggestion catalog
365
+ const suggestions = read("~/.claude/skills/business-analyse/patterns/suggestion-catalog.md");
366
+
367
+ // 4. Display cache warming status
368
+ 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)
372
+ `);
267
373
  ```
268
374
 
269
- **Step 2: Deploy schemas (if needed)**
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
270
403
 
271
- Source: `schemas/` (relative to skill root = `~/.claude/skills/business-analyse/schemas/`)
272
- Destination: `docs/business/{app}/business-analyse/schemas/`
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:
273
419
 
274
420
  ```
275
- Read and Write each file (preserving directory structure):
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
+ ```
276
426
 
277
- docs/business/{app}/business-analyse/schemas/
278
- ├── feature-schema.json
279
- ├── application-schema.json
280
- ├── sections/
281
- │ ├── metadata-schema.json
282
- │ ├── discovery-schema.json
283
- │ ├── analysis-schema.json
284
- │ ├── specification-schema.json
285
- │ ├── validation-schema.json
286
- │ └── handoff-schema.json
287
- └── shared/
288
- └── common-defs.json
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)
289
433
  ```
290
434
 
291
- **Total: 9 files to deploy.**
435
+ **Success metric:** Cache hit rate > 90% for pre-loaded files
292
436
 
293
- **Step 3: Write cache file (after successful deployment)**
437
+ ### Reference Documentation
294
438
 
295
- ```json
296
- {
297
- "version": "{CLI_VERSION}",
298
- "deployedAt": "{ISO timestamp}",
299
- "schemas": [
300
- "feature-schema.json",
301
- "application-schema.json",
302
- "sections/metadata-schema.json",
303
- "sections/discovery-schema.json",
304
- "sections/analysis-schema.json",
305
- "sections/specification-schema.json",
306
- "sections/validation-schema.json",
307
- "sections/handoff-schema.json",
308
- "shared/common-defs.json"
309
- ]
310
- }
311
- ```
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
312
445
 
313
446
  ## Step 9: Create Master feature.json
314
447