@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,578 @@
1
+ # Cache Warming Strategy
2
+
3
+ > **Objective:** Reduce token waste from redundant file reads by 15-20% via strategic pre-loading.
4
+
5
+ ## Problem Statement
6
+
7
+ **Baseline (no cache warming):**
8
+
9
+ Analysis of BA session `03b76b8b-ea1c-4f1e-a636-bd46b0c33e02` shows:
10
+ ```
11
+ Total tokens (1 agent): 106,881
12
+ Cache read input tokens: 105,351 (98.5% of total)
13
+ Cache creation input tokens: 857 (0.8% of total)
14
+ ```
15
+
16
+ **Issue:** 98.5% cache read means files are being re-read multiple times, but NOT efficiently. Many reads are for the SAME files re-loaded redundantly across different agents.
17
+
18
+ **Example redundancies detected:**
19
+ - `feature-schema.json` read 7 times
20
+ - `questionnaire/01-context.md` read 3 times
21
+ - `suggestion-catalog.md` read 5 times
22
+ - `handoff-file-templates.md` read 4 times
23
+
24
+ **Root cause:** No pre-loading strategy → each agent reads files on-demand → redundant I/O operations.
25
+
26
+ ---
27
+
28
+ ## Solution: Progressive Cache Warming
29
+
30
+ **Principle:** Pre-load frequently-used static files at specific checkpoints, organize by retention policy.
31
+
32
+ ### Benefits
33
+
34
+ | Metric | Before | After | Improvement |
35
+ |--------|--------|-------|-------------|
36
+ | Schema file reads | 7× | 1× | 86% ↓ |
37
+ | Questionnaire reads | 3× | 1× | 67% ↓ |
38
+ | Template reads | 4-5× | 1× | 75-80% ↓ |
39
+ | Token waste | ~15,000 | ~3,000 | 80% ↓ |
40
+ | Overall session | 106,881 | ~90,000 | 15-20% ↓ |
41
+
42
+ ---
43
+
44
+ ## Cache Bucket Architecture
45
+
46
+ ### Bucket 1: Core Schemas (CRITICAL)
47
+
48
+ **Files:**
49
+ ```
50
+ docs/business/{app}/business-analyse/schemas/
51
+ ├── feature-schema.json (~8KB)
52
+ ├── application-schema.json (~6KB)
53
+ ├── sections/
54
+ │ ├── analysis-schema.json (~5KB)
55
+ │ ├── discovery-schema.json (~3KB)
56
+ │ ├── handoff-schema.json (~4KB)
57
+ │ ├── metadata-schema.json (~2KB)
58
+ │ ├── specification-schema.json (~7KB)
59
+ │ └── validation-schema.json (~3KB)
60
+ └── shared/
61
+ └── common-defs.json (~4KB)
62
+
63
+ Total: ~42KB, 9 files
64
+ ```
65
+
66
+ **Load at:** Step-00 (initialization)
67
+ **Retention:** Entire session (until BA completes)
68
+ **Used in:** ALL steps (validation, schema references)
69
+
70
+ **Why critical:**
71
+ - Used by every ba-writer operation for validation
72
+ - Referenced in every feature.json via `$schema` field
73
+ - Small files (42KB total) with high re-use (7× average)
74
+ - ROI: 86% reduction in schema reads
75
+
76
+ **Implementation:**
77
+ ```javascript
78
+ // Step-00 initialization
79
+ const schemaFiles = glob("docs/business/{app}/business-analyse/schemas/**/*.json");
80
+ for (const file of schemaFiles) {
81
+ read(file); // Pre-load into cache
82
+ }
83
+ // Files now cached for entire session
84
+ ```
85
+
86
+ ---
87
+
88
+ ### Bucket 2: Questionnaire Templates (HIGH)
89
+
90
+ **Files:**
91
+ ```
92
+ ~/.claude/skills/business-analyse/questionnaire/
93
+ ├── 00-application.md (~4KB)
94
+ ├── 01-context.md (~6KB)
95
+ ├── 02-stakeholders.md (~7KB)
96
+ ├── 03-scope.md (~6KB)
97
+ ├── 04-data.md (~3KB)
98
+ ├── 05-integrations.md (~3KB)
99
+ ├── 06-security.md (~2KB)
100
+ ├── 07-ui.md (~4KB)
101
+ ├── 08-performance.md (~2KB)
102
+ ├── 09-constraints.md (~1KB)
103
+ ├── 10-documentation.md (~1KB)
104
+ ├── 11-data-lifecycle.md (~3KB)
105
+ ├── 12-migration.md (~3KB)
106
+ ├── 13-cross-module.md (~3KB)
107
+ ├── 14-risk-assumptions.md (~4KB)
108
+ └── 15-success-metrics.md (~4KB)
109
+
110
+ Total: ~56KB, 16 files
111
+ ```
112
+
113
+ **Load at:** Step-00 (initialization)
114
+ **Retention:** Until step-02 (after cadrage completes)
115
+ **Used in:** Step-01 only (cadrage/framing)
116
+
117
+ **Why high priority:**
118
+ - Read 2-3× during step-01 (questionnaire selection + processing)
119
+ - Conditional loading logic re-reads files multiple times
120
+ - Moderate size (56KB) but only used in 1 step
121
+ - ROI: 67% reduction in questionnaire reads
122
+
123
+ **Implementation:**
124
+ ```javascript
125
+ // Step-00 initialization
126
+ const questionnaireFiles = glob("~/.claude/skills/business-analyse/questionnaire/*.md");
127
+ for (const file of questionnaireFiles) {
128
+ read(file);
129
+ }
130
+
131
+ // Step-02 start: Clear cache
132
+ // (Questionnaires no longer needed)
133
+ ```
134
+
135
+ **Optimization:** Only load questionnaires that will be used based on `vibe_coding` flag:
136
+ - If `vibe_coding = true`: Load only 00, 01, 02, 03, 14, 15 (core 6 files, ~31KB)
137
+ - If `vibe_coding = false`: Load all 16 files (~56KB)
138
+
139
+ ---
140
+
141
+ ### Bucket 3: Suggestion & Pattern Catalogs (HIGH)
142
+
143
+ **Files:**
144
+ ```
145
+ ~/.claude/skills/business-analyse/patterns/
146
+ └── suggestion-catalog.md (~12KB)
147
+
148
+ Total: ~12KB, 1 file
149
+ ```
150
+
151
+ **Load at:** Step-00 (initialization)
152
+ **Retention:** Until step-02 (after cadrage)
153
+ **Used in:** Step-01 (cadrage suggestions)
154
+
155
+ **Why high priority:**
156
+ - Read 5× during step-01 (suggestion generation)
157
+ - Small file (12KB) but very high re-use
158
+ - ROI: 80% reduction in suggestion reads
159
+
160
+ ---
161
+
162
+ ### Bucket 4: Module Specification References (MEDIUM)
163
+
164
+ **Files:**
165
+ ```
166
+ ~/.claude/skills/business-analyse/references/
167
+ ├── spec-auto-inference.md (~8KB)
168
+ ├── ui-resource-cards.md (~6KB)
169
+ ├── ui-dashboard-spec.md (~5KB)
170
+ └── cadrage-vibe-coding.md (~4KB)
171
+
172
+ Total: ~23KB, 4 files
173
+ ```
174
+
175
+ **Load at:** Step-03 start (before module loop)
176
+ **Retention:** Until step-04 (after all modules specified)
177
+ **Used in:** Step-03a, 03b, 03c (module specification)
178
+
179
+ **Why medium priority:**
180
+ - NOT loaded at step-00 (not used until step-03)
181
+ - Read 2-3× PER MODULE (5 modules = 10-15 reads)
182
+ - Moderate size (23KB) with high re-use during module loop
183
+ - ROI: 75% reduction in reference reads during step-03
184
+
185
+ **Implementation:**
186
+ ```javascript
187
+ // Step-03 start (before module loop)
188
+ const moduleRefs = [
189
+ "spec-auto-inference.md",
190
+ "ui-resource-cards.md",
191
+ "ui-dashboard-spec.md",
192
+ "cadrage-vibe-coding.md"
193
+ ];
194
+ for (const file of moduleRefs) {
195
+ read(`~/.claude/skills/business-analyse/references/${file}`);
196
+ }
197
+
198
+ // Step-04 start: Clear cache
199
+ ```
200
+
201
+ ---
202
+
203
+ ### Bucket 5: Handoff & Deploy Templates (LOW)
204
+
205
+ **Files:**
206
+ ```
207
+ ~/.claude/skills/business-analyse/references/
208
+ ├── handoff-file-templates.md (~15KB)
209
+ ├── handoff-mappings.md (~12KB)
210
+ ├── deploy-data-build.md (~10KB)
211
+ ├── deploy-modes.md (~8KB)
212
+ └── html-data-mapping.md (~9KB)
213
+
214
+ ~/.claude/skills/business-analyse/html/
215
+ └── ba-interactive.html (~85KB)
216
+
217
+ Total: ~139KB, 6 files
218
+ ```
219
+
220
+ **Load at:** Step-05a start (before handoff generation)
221
+ **Retention:** Until session end
222
+ **Used in:** Step-05a, 05b (handoff & deploy)
223
+
224
+ **Why LOW priority (don't pre-load at step-00):**
225
+ - Large files (139KB total), especially ba-interactive.html (85KB)
226
+ - Only used at END of BA workflow (step-05)
227
+ - Read only 1-2× each (low re-use)
228
+ - ROI: Marginal (5-10% savings) vs. upfront cost
229
+
230
+ **Implementation:**
231
+ ```javascript
232
+ // Step-05a start (NOT at step-00)
233
+ const handoffRefs = [
234
+ "handoff-file-templates.md",
235
+ "handoff-mappings.md",
236
+ "deploy-data-build.md",
237
+ "deploy-modes.md",
238
+ "html-data-mapping.md"
239
+ ];
240
+ for (const file of handoffRefs) {
241
+ read(`~/.claude/skills/business-analyse/references/${file}`);
242
+ }
243
+
244
+ const htmlTemplate = read("~/.claude/skills/business-analyse/html/ba-interactive.html");
245
+ ```
246
+
247
+ ---
248
+
249
+ ## Implementation Timeline
250
+
251
+ ### Step-00: Initialization (Load CRITICAL + HIGH)
252
+
253
+ ```javascript
254
+ // 1. Schemas (42KB, 9 files) - CRITICAL
255
+ glob("schemas/**/*.json").forEach(f => read(f));
256
+
257
+ // 2. Questionnaires (31-56KB, 6-16 files) - HIGH
258
+ // Conditional on vibe_coding flag
259
+ if (vibe_coding) {
260
+ ["00", "01", "02", "03", "14", "15"].forEach(n =>
261
+ read(`questionnaire/${n}-*.md`)
262
+ );
263
+ } else {
264
+ glob("questionnaire/*.md").forEach(f => read(f));
265
+ }
266
+
267
+ // 3. Suggestion catalog (12KB, 1 file) - HIGH
268
+ read("patterns/suggestion-catalog.md");
269
+
270
+ // Total pre-loaded: 85-110KB, 16-26 files
271
+ ```
272
+
273
+ **Cache status after step-00:**
274
+ ```
275
+ ✓ Core schemas: 9 files (42KB) - cached for session
276
+ ✓ Questionnaires: 6-16 files (31-56KB) - cached until step-02
277
+ ✓ Suggestion catalog: 1 file (12KB) - cached until step-02
278
+ Total: 16-26 files (85-110KB)
279
+ Expected hit rate: 95-100% in step-01
280
+ ```
281
+
282
+ ---
283
+
284
+ ### Step-02: Clear Questionnaires (Free Memory)
285
+
286
+ ```javascript
287
+ // After cadrage completes, questionnaires no longer needed
288
+ // Cache eviction happens automatically based on retention policy
289
+ // No explicit action needed (handled by Claude's cache system)
290
+
291
+ console.log(`
292
+ ✓ Cache eviction: questionnaires (31-56KB freed)
293
+ Retained: schemas (42KB)
294
+ `);
295
+ ```
296
+
297
+ ---
298
+
299
+ ### Step-03: Load Module Spec References
300
+
301
+ ```javascript
302
+ // Before starting module loop
303
+ const moduleRefs = [
304
+ "spec-auto-inference.md",
305
+ "ui-resource-cards.md",
306
+ "ui-dashboard-spec.md",
307
+ "cadrage-vibe-coding.md"
308
+ ];
309
+ moduleRefs.forEach(f => read(`references/${f}`));
310
+
311
+ // Total added: 23KB, 4 files
312
+ ```
313
+
314
+ **Cache status during step-03:**
315
+ ```
316
+ ✓ Core schemas: 9 files (42KB) - still cached
317
+ ✓ Module references: 4 files (23KB) - cached for module loop
318
+ Total: 13 files (65KB)
319
+ Expected hit rate: 90-95% during module loop
320
+ ```
321
+
322
+ ---
323
+
324
+ ### Step-04: Clear Module Spec References
325
+
326
+ ```javascript
327
+ // After all modules specified, references no longer needed
328
+ // Cache eviction automatic
329
+
330
+ console.log(`
331
+ ✓ Cache eviction: module references (23KB freed)
332
+ Retained: schemas (42KB)
333
+ `);
334
+ ```
335
+
336
+ ---
337
+
338
+ ### Step-05a: Load Handoff Templates
339
+
340
+ ```javascript
341
+ // Before handoff generation
342
+ const handoffRefs = [
343
+ "handoff-file-templates.md",
344
+ "handoff-mappings.md",
345
+ "deploy-data-build.md",
346
+ "deploy-modes.md",
347
+ "html-data-mapping.md"
348
+ ];
349
+ handoffRefs.forEach(f => read(`references/${f}`));
350
+
351
+ const htmlTemplate = read("html/ba-interactive.html");
352
+
353
+ // Total added: 139KB, 6 files
354
+ ```
355
+
356
+ **Cache status during step-05:**
357
+ ```
358
+ ✓ Core schemas: 9 files (42KB) - still cached
359
+ ✓ Handoff templates: 6 files (139KB) - cached for handoff/deploy
360
+ Total: 15 files (181KB)
361
+ Expected hit rate: 85-90% during handoff/deploy
362
+ ```
363
+
364
+ ---
365
+
366
+ ## Token Savings Calculation
367
+
368
+ ### Baseline (No Cache Warming)
369
+
370
+ ```
371
+ Step-01 (Cadrage):
372
+ - Schemas read: 7× × 42KB = 294KB
373
+ - Questionnaires read: 3× × 56KB = 168KB
374
+ - Suggestions read: 5× × 12KB = 60KB
375
+ Total redundant: 522KB (~15,000 tokens wasted)
376
+
377
+ Step-03 (Module Loop, 5 modules):
378
+ - Module refs read: 3× per module × 5 modules × 23KB = 345KB
379
+ Total redundant: 345KB (~10,000 tokens wasted)
380
+
381
+ Step-05 (Handoff):
382
+ - Handoff refs read: 2× × 54KB = 108KB
383
+ Total redundant: 108KB (~3,000 tokens wasted)
384
+
385
+ TOTAL WASTED: 975KB (~28,000 tokens)
386
+ ```
387
+
388
+ ### With Cache Warming
389
+
390
+ ```
391
+ Step-00: Pre-load 85-110KB (one-time cost: ~3,000 tokens)
392
+ Step-01: 0KB redundant (100% cache hits)
393
+ Step-03: Pre-load 23KB (one-time cost: ~700 tokens)
394
+ Module loop: 0KB redundant (90% cache hits, ~2,000 tokens saved)
395
+ Step-05a: Pre-load 139KB (one-time cost: ~4,000 tokens)
396
+ Handoff: 0KB redundant (85% cache hits, ~2,500 tokens saved)
397
+
398
+ TOTAL PRE-LOAD COST: 247-272KB (~7,700 tokens)
399
+ TOTAL SAVED: 28,000 - 7,700 = 20,300 tokens (72% reduction)
400
+ ```
401
+
402
+ ### ROI Analysis
403
+
404
+ | Session Type | Baseline Tokens | After Warming | Savings | % Improvement |
405
+ |--------------|----------------|---------------|---------|---------------|
406
+ | 5-module app | 106,881 | ~90,000 | 16,881 | 15.8% |
407
+ | 3-module app | 85,000 | ~72,000 | 13,000 | 15.3% |
408
+ | 1-module (simple) | 45,000 | ~40,000 | 5,000 | 11.1% |
409
+
410
+ **Average improvement: 15-20% token savings**
411
+
412
+ ---
413
+
414
+ ## Monitoring & Validation
415
+
416
+ ### Cache Hit Rate Monitoring
417
+
418
+ After each major step, verify cache efficiency:
419
+
420
+ ```javascript
421
+ // Pseudo-code for monitoring
422
+ const cacheStats = getCacheStats();
423
+ console.log(`
424
+ Step-${currentStep} cache statistics:
425
+ - Total file reads: ${cacheStats.totalReads}
426
+ - Cache hits: ${cacheStats.cacheHits} (${cacheStats.hitRate}%)
427
+ - Cache misses: ${cacheStats.cacheMisses}
428
+ - Redundant reads: ${cacheStats.redundantReads}
429
+ - Status: ${cacheStats.hitRate > 90 ? "Optimal" : "Suboptimal"}
430
+ `);
431
+ ```
432
+
433
+ **Target metrics:**
434
+ - Step-01: 95-100% hit rate (schemas + questionnaires pre-loaded)
435
+ - Step-03: 90-95% hit rate (schemas + module refs pre-loaded)
436
+ - Step-05: 85-90% hit rate (schemas + handoff refs pre-loaded)
437
+
438
+ ### Troubleshooting Poor Cache Efficiency
439
+
440
+ | Symptom | Cause | Fix |
441
+ |---------|-------|-----|
442
+ | Step-01 hit rate < 90% | Questionnaires not pre-loaded | Verify step-00 glob pattern |
443
+ | Step-03 hit rate < 80% | Module refs not loaded at step start | Add pre-load at step-03 start |
444
+ | Cache eviction too early | Retention policy too aggressive | Extend retention period |
445
+ | Memory issues | Too many files cached | Reduce bucket 2/3 sizes, prioritize bucket 1 |
446
+
447
+ ---
448
+
449
+ ## Advanced: Adaptive Cache Warming
450
+
451
+ **Concept:** Adjust pre-loading based on detected workflow patterns.
452
+
453
+ ### Detection Logic
454
+
455
+ ```javascript
456
+ // Step-00: Analyze feature_description to predict workflow
457
+ const predictions = {
458
+ willNeedQuestionnaires: !vibe_coding, // Full questionnaires if not vibe coding
459
+ willBeMultiModule: detectMultiModuleKeywords(feature_description), // "modules", "applications"
460
+ estimatedModuleCount: estimateModuleCount(feature_description) // 1-10
461
+ };
462
+
463
+ // Adaptive pre-loading
464
+ if (predictions.willBeMultiModule && predictions.estimatedModuleCount > 3) {
465
+ // Large multi-module app → pre-load module refs at step-00 (not step-03)
466
+ loadModuleReferences();
467
+ }
468
+
469
+ if (!predictions.willNeedQuestionnaires) {
470
+ // Vibe coding → only load 6 core questionnaires
471
+ loadCoreQuestionnaires();
472
+ } else {
473
+ // Full analysis → load all 16 questionnaires
474
+ loadAllQuestionnaires();
475
+ }
476
+ ```
477
+
478
+ **Benefits:**
479
+ - Further 5-10% token savings via predictive loading
480
+ - Reduced memory footprint for simple workflows
481
+
482
+ **Risks:**
483
+ - Prediction errors (over-loading or under-loading)
484
+ - Complexity increase
485
+
486
+ **Recommendation:** Start with STATIC strategy (current), add ADAPTIVE in Phase 3.
487
+
488
+ ---
489
+
490
+ ## Integration with Agent Pooling
491
+
492
+ **Synergy:** Cache warming + Agent pooling = Maximum efficiency
493
+
494
+ ### Example: Step-03 Module Loop
495
+
496
+ **Without cache warming + agent pooling:**
497
+ ```
498
+ Spawn 24 agents (4-5 per module × 5 modules)
499
+ Each agent re-reads schemas + module refs = 24 × 65KB = 1,560KB
500
+ Tokens: ~45,000
501
+ ```
502
+
503
+ **With cache warming ONLY:**
504
+ ```
505
+ Spawn 24 agents
506
+ Pre-load schemas + module refs once = 65KB
507
+ Subsequent reads cached = 24 × 0KB redundant
508
+ Tokens: ~15,000 (67% savings)
509
+ ```
510
+
511
+ **With cache warming + agent pooling:**
512
+ ```
513
+ Spawn 5 agents (1 per module)
514
+ Pre-load schemas + module refs once = 65KB
515
+ Each agent reads cached files = 5 × 0KB redundant
516
+ Tokens: ~7,000 (84% savings)
517
+ ```
518
+
519
+ **Combined effect:** 84% token reduction (vs. baseline)
520
+
521
+ ---
522
+
523
+ ## Rollout Checklist
524
+
525
+ ### Phase 2.1: Implement Core Warming (Week 1)
526
+
527
+ - [ ] Add cache warming to step-00-init.md (Bucket 1 + 2)
528
+ - [ ] Test cache hit rates in step-01
529
+ - [ ] Verify 15-20% token savings
530
+ - [ ] Document in MEMORY.md
531
+
532
+ ### Phase 2.2: Progressive Warming (Week 2)
533
+
534
+ - [ ] Add module ref warming at step-03 start (Bucket 3)
535
+ - [ ] Add handoff ref warming at step-05a start (Bucket 5)
536
+ - [ ] Test cache eviction after step-02 and step-04
537
+ - [ ] Measure token savings across full session
538
+
539
+ ### Phase 2.3: Monitoring & Validation (Week 3)
540
+
541
+ - [ ] Add cache hit rate reporting after each step
542
+ - [ ] Create troubleshooting guide for poor efficiency
543
+ - [ ] Test with 1-module, 3-module, 5-module apps
544
+ - [ ] Validate 15-20% savings across all scenarios
545
+
546
+ ### Phase 2.4: Optimization (Week 4)
547
+
548
+ - [ ] Implement adaptive warming (optional)
549
+ - [ ] Fine-tune retention policies
550
+ - [ ] Integrate with agent pooling strategy
551
+ - [ ] Document best practices
552
+
553
+ ---
554
+
555
+ ## Success Criteria
556
+
557
+ **Minimum (Phase 2.1):**
558
+ - ✓ Cache warming implemented in step-00
559
+ - ✓ Cache hit rate > 90% in step-01
560
+ - ✓ Token savings ≥ 10%
561
+
562
+ **Target (Phase 2.2):**
563
+ - ✓ Progressive warming across all steps
564
+ - ✓ Cache hit rates: step-01 (95%), step-03 (90%), step-05 (85%)
565
+ - ✓ Token savings ≥ 15%
566
+
567
+ **Optimal (Phase 2.3+):**
568
+ - ✓ Adaptive warming based on predictions
569
+ - ✓ Cache hit rates > 90% across all steps
570
+ - ✓ Token savings ≥ 20%
571
+ - ✓ Integration with agent pooling (84% combined savings)
572
+
573
+ ---
574
+
575
+ **Last Updated:** 2026-02-08
576
+ **Version:** 1.0
577
+ **Author:** SmartStack CLI Team
578
+ **Based on:** Analysis of BA session 03b76b8b-ea1c-4f1e-a636-bd46b0c33e02
@@ -0,0 +1,78 @@
1
+ # Cadrage Structure Cards
2
+
3
+ > Reference for step-01-cadrage.md — exact JSON formats for cadrage section fields.
4
+
5
+ ## stakeholders[]
6
+
7
+ ```json
8
+ {
9
+ "role": "Fleet Manager",
10
+ "function": "Manages daily fleet operations",
11
+ "involvement": "decision-maker",
12
+ "tasks": ["Monitor vehicles", "Approve repairs", "Export reports"],
13
+ "frequency": "Daily",
14
+ "painPoints": ["Manual tracking in spreadsheets", "No real-time visibility"]
15
+ }
16
+ ```
17
+ **MANDATORY fields:** `role`, `function`, `involvement`, `tasks`
18
+ **involvement values:** `approver`, `decision-maker`, `consulted`, `informed`, `end-user`
19
+ **FORBIDDEN fields:** Do NOT use `expertise`, `systemRole`, `description` (use `function` instead).
20
+
21
+ ## applicationRoles[]
22
+
23
+ ```json
24
+ {
25
+ "role": "{App} Admin",
26
+ "description": "Full access to all modules",
27
+ "level": "admin",
28
+ "permissionPattern": "business.{app}.*"
29
+ }
30
+ ```
31
+ **MANDATORY fields:** `role`, `level`, `permissionPattern`
32
+ **level values:** `admin`, `manager`, `contributor`, `viewer`
33
+ **FORBIDDEN fields:** Do NOT use `permissions` (use `permissionPattern`), `isDefault`.
34
+
35
+ ## risks[]
36
+
37
+ ```json
38
+ {
39
+ "id": "RISK-001",
40
+ "type": "business|technical|organizational",
41
+ "description": "CSV data may contain duplicates and errors",
42
+ "probability": "high|medium|low",
43
+ "impact": "high|medium|low",
44
+ "priority": "critical|medium|low",
45
+ "mitigation": "Data cleaning phase before import, detailed error reports"
46
+ }
47
+ ```
48
+ **MANDATORY fields:** `id` (pattern: RISK-NNN), `type`, `description`, `mitigation`
49
+ **FORBIDDEN fields:** Do NOT use `risk` (name), `severity`. Use `id` + `description` + `priority`.
50
+
51
+ ## acceptanceCriteria[]
52
+
53
+ ```json
54
+ { "id": "AC-001", "criterion": "All must-have features delivered and tested", "validated": false }
55
+ ```
56
+ **MANDATORY:** This section must NOT be omitted.
57
+
58
+ ## coverageMatrix[]
59
+
60
+ ```json
61
+ {
62
+ "item": "User management with CRUD",
63
+ "category": "mustHave|shouldHave|couldHave|outOfScope|implicit",
64
+ "module": "Users",
65
+ "ucRef": "UC-UM-001",
66
+ "notes": "Foundation module, must be implemented first"
67
+ }
68
+ ```
69
+ **MANDATORY fields:** `item`, `category`, `module`
70
+ **category values:** `mustHave`, `shouldHave`, `couldHave`, `outOfScope`, `implicit` (camelCase)
71
+ **FORBIDDEN fields:** Do NOT use `id`, `feature`, `priority`. Use `item` + `category`.
72
+
73
+ ## codebaseContext
74
+
75
+ Must be a string, NOT an object:
76
+ ```json
77
+ "codebaseContext": "Greenfield project, no existing entities. SmartStack 2.1.0 with Extensions DbContext."
78
+ ```