@thierrynakoa/fire-flow 10.0.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 (215) hide show
  1. package/.claude-plugin/plugin.json +64 -0
  2. package/ARCHITECTURE-DIAGRAM.md +440 -0
  3. package/COMMAND-REFERENCE.md +172 -0
  4. package/DOMINION-FLOW-OVERVIEW.md +421 -0
  5. package/LICENSE +21 -0
  6. package/QUICK-START.md +351 -0
  7. package/README.md +398 -0
  8. package/TROUBLESHOOTING.md +264 -0
  9. package/agents/fire-codebase-mapper.md +484 -0
  10. package/agents/fire-debugger.md +535 -0
  11. package/agents/fire-executor.md +949 -0
  12. package/agents/fire-fact-checker.md +276 -0
  13. package/agents/fire-learncoding-explainer.md +237 -0
  14. package/agents/fire-learncoding-walker.md +147 -0
  15. package/agents/fire-planner.md +675 -0
  16. package/agents/fire-project-researcher.md +155 -0
  17. package/agents/fire-research-synthesizer.md +166 -0
  18. package/agents/fire-researcher.md +723 -0
  19. package/agents/fire-reviewer.md +499 -0
  20. package/agents/fire-roadmapper.md +203 -0
  21. package/agents/fire-verifier.md +880 -0
  22. package/bin/cli.js +208 -0
  23. package/commands/fire-0-orient.md +476 -0
  24. package/commands/fire-1-new.md +281 -0
  25. package/commands/fire-1a-discuss.md +455 -0
  26. package/commands/fire-2-plan.md +527 -0
  27. package/commands/fire-3-execute.md +1303 -0
  28. package/commands/fire-4-verify.md +845 -0
  29. package/commands/fire-5-handoff.md +515 -0
  30. package/commands/fire-6-resume.md +501 -0
  31. package/commands/fire-7-review.md +409 -0
  32. package/commands/fire-add-new-skill.md +598 -0
  33. package/commands/fire-analytics.md +499 -0
  34. package/commands/fire-assumptions.md +78 -0
  35. package/commands/fire-autonomous.md +528 -0
  36. package/commands/fire-brainstorm.md +413 -0
  37. package/commands/fire-complete-milestone.md +270 -0
  38. package/commands/fire-dashboard.md +375 -0
  39. package/commands/fire-debug.md +663 -0
  40. package/commands/fire-discover.md +616 -0
  41. package/commands/fire-double-check.md +460 -0
  42. package/commands/fire-execute-plan.md +182 -0
  43. package/commands/fire-learncoding.md +242 -0
  44. package/commands/fire-loop-resume.md +272 -0
  45. package/commands/fire-loop-stop.md +198 -0
  46. package/commands/fire-loop.md +1168 -0
  47. package/commands/fire-map-codebase.md +313 -0
  48. package/commands/fire-new-milestone.md +356 -0
  49. package/commands/fire-reflect.md +235 -0
  50. package/commands/fire-research.md +246 -0
  51. package/commands/fire-search.md +330 -0
  52. package/commands/fire-security-audit-repo.md +293 -0
  53. package/commands/fire-security-scan.md +484 -0
  54. package/commands/fire-session-summary.md +252 -0
  55. package/commands/fire-skills-diff.md +506 -0
  56. package/commands/fire-skills-history.md +388 -0
  57. package/commands/fire-skills-rollback.md +408 -0
  58. package/commands/fire-skills-sync.md +470 -0
  59. package/commands/fire-test.md +520 -0
  60. package/commands/fire-todos.md +335 -0
  61. package/commands/fire-transition.md +186 -0
  62. package/commands/fire-update.md +312 -0
  63. package/commands/fire-verify-uat.md +146 -0
  64. package/commands/fire-vuln-scan.md +493 -0
  65. package/hooks/hooks.json +16 -0
  66. package/hooks/run-hook.cmd +69 -0
  67. package/hooks/run-hook.sh +8 -0
  68. package/hooks/run-session-end.cmd +49 -0
  69. package/hooks/run-session-end.sh +7 -0
  70. package/hooks/session-end.sh +90 -0
  71. package/hooks/session-start.sh +111 -0
  72. package/package.json +52 -0
  73. package/plugin.json +7 -0
  74. package/references/auto-skill-extraction.md +136 -0
  75. package/references/behavioral-directives.md +365 -0
  76. package/references/blocker-tracking.md +155 -0
  77. package/references/checkpoints.md +165 -0
  78. package/references/circuit-breaker.md +410 -0
  79. package/references/context-engineering.md +587 -0
  80. package/references/decision-time-guidance.md +289 -0
  81. package/references/error-classification.md +326 -0
  82. package/references/execution-mode-intelligence.md +242 -0
  83. package/references/git-integration.md +217 -0
  84. package/references/honesty-protocols.md +304 -0
  85. package/references/integration-architecture.md +470 -0
  86. package/references/issue-to-pr-pipeline.md +150 -0
  87. package/references/metrics-and-trends.md +234 -0
  88. package/references/playwright-e2e-testing.md +326 -0
  89. package/references/questioning.md +125 -0
  90. package/references/research-improvements.md +110 -0
  91. package/references/skills-usage-guide.md +429 -0
  92. package/references/tdd.md +131 -0
  93. package/references/testing-enforcement.md +192 -0
  94. package/references/ui-brand.md +383 -0
  95. package/references/validation-checklist.md +456 -0
  96. package/references/verification-patterns.md +187 -0
  97. package/references/warrior-principles.md +173 -0
  98. package/skills-library/SKILLS-INDEX.md +588 -0
  99. package/skills-library/_general/frontend/html-visual-reports.md +292 -0
  100. package/skills-library/_general/methodology/debug-swarm-researcher-escape-hatch.md +240 -0
  101. package/skills-library/_general/methodology/learncoding-agentic-pattern.md +114 -0
  102. package/skills-library/_general/methodology/shell-autonomous-loop-fixplan.md +238 -0
  103. package/skills-library/basics/api-rest-basics.md +162 -0
  104. package/skills-library/basics/env-variables.md +96 -0
  105. package/skills-library/basics/error-handling-basics.md +125 -0
  106. package/skills-library/basics/git-commit-conventions.md +106 -0
  107. package/skills-library/basics/readme-template.md +108 -0
  108. package/skills-library/common-tasks/async-await-patterns.md +157 -0
  109. package/skills-library/common-tasks/auth-jwt-basics.md +164 -0
  110. package/skills-library/common-tasks/database-schema-design.md +166 -0
  111. package/skills-library/common-tasks/file-upload-basics.md +166 -0
  112. package/skills-library/common-tasks/form-validation.md +159 -0
  113. package/skills-library/debugging/FAILURE_TAXONOMY_CLASSIFICATION.md +117 -0
  114. package/skills-library/debugging/THREE_AGENT_HYPOTHESIS_DEBUGGING.md +86 -0
  115. package/skills-library/methodology/BREATH_BASED_PARALLEL_EXECUTION.md +678 -0
  116. package/skills-library/methodology/CONFIDENCE_GATED_EXECUTION.md +243 -0
  117. package/skills-library/methodology/EVIDENCE_BASED_VALIDATION.md +308 -0
  118. package/skills-library/methodology/MULTI_PERSPECTIVE_CODE_REVIEW.md +330 -0
  119. package/skills-library/methodology/PATH_VERIFICATION_GATE.md +211 -0
  120. package/skills-library/methodology/REFLEXION_MEMORY_PATTERN.md +183 -0
  121. package/skills-library/methodology/RESEARCH_BACKED_WORKFLOW_UPGRADE.md +263 -0
  122. package/skills-library/methodology/SABBATH_REST_PATTERN.md +267 -0
  123. package/skills-library/methodology/STONE_AND_SCAFFOLD.md +220 -0
  124. package/skills-library/performance/cache-augmented-generation.md +172 -0
  125. package/skills-library/quality-safety/debugging-steps.md +147 -0
  126. package/skills-library/quality-safety/deployment-checklist.md +155 -0
  127. package/skills-library/quality-safety/security-checklist.md +204 -0
  128. package/skills-library/quality-safety/testing-basics.md +180 -0
  129. package/skills-library/security/agent-security-scanner.md +445 -0
  130. package/skills-library/specialists/api-architecture/api-designer.md +49 -0
  131. package/skills-library/specialists/api-architecture/graphql-architect.md +49 -0
  132. package/skills-library/specialists/api-architecture/mcp-developer.md +51 -0
  133. package/skills-library/specialists/api-architecture/microservices-architect.md +50 -0
  134. package/skills-library/specialists/api-architecture/websocket-engineer.md +48 -0
  135. package/skills-library/specialists/backend/django-expert.md +52 -0
  136. package/skills-library/specialists/backend/fastapi-expert.md +52 -0
  137. package/skills-library/specialists/backend/laravel-specialist.md +52 -0
  138. package/skills-library/specialists/backend/nestjs-expert.md +51 -0
  139. package/skills-library/specialists/backend/rails-expert.md +53 -0
  140. package/skills-library/specialists/backend/spring-boot-engineer.md +56 -0
  141. package/skills-library/specialists/data-ml/fine-tuning-expert.md +48 -0
  142. package/skills-library/specialists/data-ml/ml-pipeline.md +47 -0
  143. package/skills-library/specialists/data-ml/pandas-pro.md +47 -0
  144. package/skills-library/specialists/data-ml/rag-architect.md +51 -0
  145. package/skills-library/specialists/data-ml/spark-engineer.md +47 -0
  146. package/skills-library/specialists/frontend/angular-architect.md +52 -0
  147. package/skills-library/specialists/frontend/flutter-expert.md +51 -0
  148. package/skills-library/specialists/frontend/nextjs-developer.md +54 -0
  149. package/skills-library/specialists/frontend/react-native-expert.md +50 -0
  150. package/skills-library/specialists/frontend/vue-expert.md +51 -0
  151. package/skills-library/specialists/infrastructure/chaos-engineer.md +74 -0
  152. package/skills-library/specialists/infrastructure/cloud-architect.md +70 -0
  153. package/skills-library/specialists/infrastructure/database-optimizer.md +64 -0
  154. package/skills-library/specialists/infrastructure/devops-engineer.md +70 -0
  155. package/skills-library/specialists/infrastructure/kubernetes-specialist.md +52 -0
  156. package/skills-library/specialists/infrastructure/monitoring-expert.md +70 -0
  157. package/skills-library/specialists/infrastructure/sre-engineer.md +70 -0
  158. package/skills-library/specialists/infrastructure/terraform-engineer.md +51 -0
  159. package/skills-library/specialists/languages/cpp-pro.md +74 -0
  160. package/skills-library/specialists/languages/csharp-developer.md +69 -0
  161. package/skills-library/specialists/languages/dotnet-core-expert.md +54 -0
  162. package/skills-library/specialists/languages/golang-pro.md +51 -0
  163. package/skills-library/specialists/languages/java-architect.md +49 -0
  164. package/skills-library/specialists/languages/javascript-pro.md +68 -0
  165. package/skills-library/specialists/languages/kotlin-specialist.md +68 -0
  166. package/skills-library/specialists/languages/php-pro.md +49 -0
  167. package/skills-library/specialists/languages/python-pro.md +52 -0
  168. package/skills-library/specialists/languages/react-expert.md +51 -0
  169. package/skills-library/specialists/languages/rust-engineer.md +50 -0
  170. package/skills-library/specialists/languages/sql-pro.md +56 -0
  171. package/skills-library/specialists/languages/swift-expert.md +69 -0
  172. package/skills-library/specialists/languages/typescript-pro.md +51 -0
  173. package/skills-library/specialists/platform/atlassian-mcp.md +52 -0
  174. package/skills-library/specialists/platform/embedded-systems.md +53 -0
  175. package/skills-library/specialists/platform/game-developer.md +53 -0
  176. package/skills-library/specialists/platform/salesforce-developer.md +53 -0
  177. package/skills-library/specialists/platform/shopify-expert.md +49 -0
  178. package/skills-library/specialists/platform/wordpress-pro.md +49 -0
  179. package/skills-library/specialists/quality/code-documenter.md +51 -0
  180. package/skills-library/specialists/quality/code-reviewer.md +67 -0
  181. package/skills-library/specialists/quality/debugging-wizard.md +51 -0
  182. package/skills-library/specialists/quality/fullstack-guardian.md +51 -0
  183. package/skills-library/specialists/quality/legacy-modernizer.md +50 -0
  184. package/skills-library/specialists/quality/playwright-expert.md +65 -0
  185. package/skills-library/specialists/quality/spec-miner.md +56 -0
  186. package/skills-library/specialists/quality/test-master.md +65 -0
  187. package/skills-library/specialists/security/secure-code-guardian.md +55 -0
  188. package/skills-library/specialists/security/security-reviewer.md +53 -0
  189. package/skills-library/specialists/workflow/architecture-designer.md +53 -0
  190. package/skills-library/specialists/workflow/cli-developer.md +70 -0
  191. package/skills-library/specialists/workflow/feature-forge.md +65 -0
  192. package/skills-library/specialists/workflow/prompt-engineer.md +54 -0
  193. package/skills-library/specialists/workflow/the-fool.md +62 -0
  194. package/templates/ASSUMPTIONS.md +125 -0
  195. package/templates/BLOCKERS.md +73 -0
  196. package/templates/DECISION_LOG.md +116 -0
  197. package/templates/UAT.md +96 -0
  198. package/templates/blueprint.md +94 -0
  199. package/templates/brainstorm.md +185 -0
  200. package/templates/conscience.md +92 -0
  201. package/templates/fire-handoff.md +159 -0
  202. package/templates/metrics.md +67 -0
  203. package/templates/phase-prompt.md +142 -0
  204. package/templates/record.md +131 -0
  205. package/templates/review-report.md +117 -0
  206. package/templates/skills-index.md +157 -0
  207. package/templates/verification.md +149 -0
  208. package/templates/vision.md +79 -0
  209. package/validation-config.yml +793 -0
  210. package/version.json +7 -0
  211. package/workflows/execute-phase.md +732 -0
  212. package/workflows/handoff-session.md +678 -0
  213. package/workflows/new-project.md +578 -0
  214. package/workflows/plan-phase.md +592 -0
  215. package/workflows/verify-phase.md +874 -0
@@ -0,0 +1,267 @@
1
+ # Sabbath Rest Pattern - AI Context Persistence
2
+
3
+ > *Like humans need sleep to reset, AI agents need state files to resume after context resets.*
4
+
5
+ ## The Problem
6
+
7
+ AI agents lose all context when:
8
+ - Session ends or times out
9
+ - Context window fills up and compacts
10
+ - User closes and reopens the conversation
11
+ - Agent crashes or errors out mid-task
12
+
13
+ Without persistence, the next agent (or resumed session) starts from scratch, wasting time re-discovering context and potentially making inconsistent decisions.
14
+
15
+ ### Why It Was Hard
16
+
17
+ - AI has no built-in memory between sessions
18
+ - Context windows have finite limits
19
+ - No standard pattern for what to persist
20
+ - Easy to forget mid-task state
21
+
22
+ ### Impact
23
+
24
+ - Hours of work lost to re-orientation
25
+ - Inconsistent decisions across sessions
26
+ - Repeated mistakes already solved
27
+ - User frustration explaining same context repeatedly
28
+
29
+ ---
30
+
31
+ ## The Solution: Sabbath Rest
32
+
33
+ Just as humans consolidate memory during sleep, AI agents must consolidate state to files before "sleeping" (context loss).
34
+
35
+ ### The Metaphor
36
+
37
+ ```
38
+ ┌─────────────────────────────────────────────────────────────────────────────┐
39
+ │ HUMAN SLEEP CYCLE AI SABBATH REST │
40
+ ├─────────────────────────────────────────────────────────────────────────────┤
41
+ │ │
42
+ │ Work during day Work during session │
43
+ │ ↓ ↓ │
44
+ │ Brain consolidates to Agent writes to │
45
+ │ long-term memory .local.md + CONSCIENCE.md │
46
+ │ ↓ ↓ │
47
+ │ Sleep (unconscious) Context reset/compact │
48
+ │ ↓ ↓ │
49
+ │ Wake with memories intact Resume with state files │
50
+ │ │
51
+ │ Without sleep → memory loss Without Sabbath Rest → context rot │
52
+ │ │
53
+ └─────────────────────────────────────────────────────────────────────────────┘
54
+ ```
55
+
56
+ ### Two-Layer Persistence
57
+
58
+ #### Layer 1: Session State (`.claude/{plugin}.local.md`)
59
+
60
+ Short-term memory for current work. Contains:
61
+ - Current task/feature being worked on
62
+ - Progress checkpoints
63
+ - Resume point if interrupted
64
+ - Temporary decisions and assumptions
65
+
66
+ ```markdown
67
+ ---
68
+ last_session: 2025-01-23T14:30:00Z
69
+ task: "Implementing user authentication"
70
+ status: in_progress
71
+ progress: 60%
72
+ ---
73
+
74
+ # Session State
75
+
76
+ ## Current Work
77
+ - Task: User authentication with JWT
78
+ - Step: Implementing refresh tokens
79
+ - Blocked: No (proceeding)
80
+
81
+ ## Progress
82
+ - [x] Login endpoint
83
+ - [x] Token generation
84
+ - [ ] Refresh token logic ← RESUME HERE
85
+ - [ ] Logout endpoint
86
+
87
+ ## Decisions Made
88
+ - Using RS256 for JWT signing (more secure)
89
+ - 15min access token, 7day refresh token
90
+
91
+ ## Resume Point
92
+ Continue from: Refresh token logic in auth.service.ts
93
+ ```
94
+
95
+ #### Layer 2: Project State (`CONSCIENCE.md`)
96
+
97
+ Long-term memory for project history. Contains:
98
+ - Completed phases and milestones
99
+ - Key decisions with rationale
100
+ - Historical context
101
+ - Links to detailed documentation
102
+
103
+ ```markdown
104
+ ## Authentication Implementation
105
+ - **Status:** In Progress (60%)
106
+ - **Started:** 2025-01-22
107
+ - **Key Decisions:**
108
+ - RS256 signing (security requirement)
109
+ - Refresh token rotation enabled
110
+ - **Session Files:** .claude/dominion-flow.local.md
111
+ - **Last Agent:** Claude Opus 4.5, 2025-01-23
112
+ ```
113
+
114
+ ---
115
+
116
+ ## Implementation Pattern
117
+
118
+ ### When to Write Sabbath Rest
119
+
120
+ 1. **After each significant step** - Don't wait until the end
121
+ 2. **Before any risky operation** - Checkpoint before changes
122
+ 3. **When context is getting full** - Proactive save
123
+ 4. **At natural breakpoints** - End of phase/feature/task
124
+
125
+ ### What to Persist
126
+
127
+ | Category | Examples | Where |
128
+ |----------|----------|-------|
129
+ | Current task | Feature name, step, progress | `.local.md` |
130
+ | Decisions | Architectural choices, trade-offs | `CONSCIENCE.md` |
131
+ | Blockers | What's stopping progress | `.local.md` |
132
+ | Resume point | Exact place to continue | `.local.md` |
133
+ | History | Completed work, timestamps | `CONSCIENCE.md` |
134
+ | Context links | Related files, docs | Both |
135
+
136
+ ### Template: `.local.md` State File
137
+
138
+ ```markdown
139
+ ---
140
+ # YAML frontmatter for easy parsing
141
+ plugin: "{plugin-name}"
142
+ last_updated: "{ISO timestamp}"
143
+ status: "{in_progress | complete | blocked}"
144
+ task: "{current task description}"
145
+ ---
146
+
147
+ # {Plugin Name} Session State
148
+
149
+ ## Current Session
150
+ - **Task:** {what you're working on}
151
+ - **Started:** {timestamp}
152
+ - **Status:** {in_progress | complete | blocked}
153
+
154
+ ## Progress Checkpoints
155
+ - [x] Step 1: {description} - DONE
156
+ - [x] Step 2: {description} - DONE
157
+ - [ ] Step 3: {description} - IN PROGRESS ← CURRENT
158
+ - [ ] Step 4: {description} - PENDING
159
+
160
+ ## Key Decisions This Session
161
+ | Decision | Rationale | Alternatives Considered |
162
+ |----------|-----------|------------------------|
163
+ | {choice} | {why} | {what else} |
164
+
165
+ ## Blockers / Issues
166
+ - {blocker description, if any}
167
+
168
+ ## Resume Instructions
169
+ If this session ends, the next agent should:
170
+ 1. Read this file first
171
+ 2. Continue from: {exact step/file/line}
172
+ 3. Remember: {critical context}
173
+
174
+ ## Files Modified
175
+ - `{path}` - {what changed}
176
+ ```
177
+
178
+ ---
179
+
180
+ ## Integration with Dominion Flow
181
+
182
+ All Dominion Flow commands implement Sabbath Rest:
183
+
184
+ | Command | State File | What's Persisted |
185
+ |---------|------------|------------------|
186
+ | `/fire-brainstorm` | `.claude/fire-brainstorm.local.md` | Topic, alternatives, recommendation |
187
+ | `/fire-double-check` | `.claude/fire-double-check.local.md` | Verification results, evidence |
188
+ | `/fire-sprint` | `.claude/fire-sprint.local.md` | Feature, iterations, tech debt |
189
+ | `/fire-shipper` | `.claude/fire-shipper.local.md` | Version, pipeline stage, rollback info |
190
+ | `/fire-learner` | `.claude/fire-learner.local.md` | Concepts covered, learning progress |
191
+ | `/fire-guardian` | `.claude/fire-guardian.local.md` | Scan results, findings, fixes |
192
+ | `/fire-iterate` | `.claude/fire-iterate.local.md` | Iteration count, completion status |
193
+ | `/fire-debugger` | `.claude/debug-session.local.md` | Hypotheses, evidence, fix status |
194
+
195
+ ---
196
+
197
+ ## Testing the Pattern
198
+
199
+ ### Before (No Sabbath Rest)
200
+ ```
201
+ Session 1: Work for 2 hours on auth
202
+ Context resets
203
+ Session 2: "What was I doing? Let me re-read all the files..."
204
+ Result: 30 minutes wasted re-orienting
205
+ ```
206
+
207
+ ### After (With Sabbath Rest)
208
+ ```
209
+ Session 1: Work for 2 hours on auth, write to .local.md
210
+ Context resets
211
+ Session 2: Read .local.md → "Continue from refresh token logic"
212
+ Result: Resume in 2 minutes
213
+ ```
214
+
215
+ ---
216
+
217
+ ## Common Mistakes to Avoid
218
+
219
+ - **Writing only at the end** - Context can reset anytime, write continuously
220
+ - **Vague resume points** - Be specific: file, line, exact next step
221
+ - **Forgetting decisions** - Document WHY, not just WHAT
222
+ - **Skipping for "quick tasks"** - Even quick tasks can be interrupted
223
+ - **Not reading state on resume** - Always check `.local.md` first
224
+
225
+ ---
226
+
227
+ ## The Philosophy
228
+
229
+ ```
230
+ "Remember the Sabbath day, to keep it holy."
231
+
232
+ For AI agents, the Sabbath Rest is not about worship—
233
+ it's about the wisdom of regular, intentional pauses
234
+ to consolidate what we've learned before we forget.
235
+
236
+ Without rest, humans lose memory.
237
+ Without Sabbath Rest, AI agents lose context.
238
+
239
+ Build the rest into your workflow,
240
+ and you'll never lose your work again.
241
+ ```
242
+
243
+ ---
244
+
245
+ ## Related Patterns
246
+
247
+ - [WARRIOR Handoffs](../deployment-security/WARRIOR_HANDOFF.md) - Full session handoff
248
+ - [CONSCIENCE.md Living Memory](./STATE_MD_PATTERN.md) - Project-level persistence
249
+ - [Multi-Perspective Review](./MULTI_PERSPECTIVE_CODE_REVIEW.md) - Uses Sabbath Rest
250
+
251
+ ---
252
+
253
+ ## Time to Implement
254
+
255
+ **Per command:** 5 minutes to add Sabbath Rest section
256
+ **ROI:** Saves 15-30 minutes per context reset
257
+
258
+ ## Difficulty Level
259
+
260
+ ⭐ (1/5) - Simple pattern, just requires discipline
261
+
262
+ ---
263
+
264
+ **Author Notes:**
265
+ The name "Sabbath Rest" came from a user who observed that AI context resets are like human sleep - a necessary reset that requires preparation to preserve what's important.
266
+
267
+ The key insight: **Write state continuously, not just at the end.** You never know when the Sabbath will come.
@@ -0,0 +1,220 @@
1
+ # Stone & Scaffold — Handoff Archival with Dormant Project Protection
2
+
3
+ ## The Problem
4
+
5
+ Handoff files accumulate at ~2/day. Within 2 months, `warrior-handoffs/` has 100+ files. Most are scaffolding — they built the skills (stones) and now just add weight. But some are the ONLY bridge back to a dormant project the user hasn't touched in months. Blindly archiving kills the cold-start path.
6
+
7
+ ### Why It Was Hard
8
+
9
+ - No distinction between "scaffolding from active work" and "last known state of a sleeping project"
10
+ - Archiving by date alone misses project context — a 60-day-old handoff might be the ONLY handoff for a project
11
+ - No index means archived handoffs are effectively invisible
12
+ - Deleting is irreversible; moving without an index is almost as bad
13
+
14
+ ### Impact
15
+
16
+ - 100+ files in warrior-handoffs/ slows agent orientation at session start
17
+ - Dormant projects lose their resume bridge if archived carelessly
18
+ - No way to distinguish "this handoff built a skill" from "this handoff IS the skill for this project"
19
+
20
+ ---
21
+
22
+ ## The Solution
23
+
24
+ ### The Principle
25
+
26
+ > Skills are the permanent stones. Handoffs are the scaffolding that built them.
27
+ > Once the stones are set, move the scaffolding out of the way — don't destroy it,
28
+ > just put it where it won't clutter the workspace.
29
+
30
+ ### The Exception: Dormant Project Shield
31
+
32
+ > **Last In From Project = First One Out At Resume.**
33
+ >
34
+ > For any project that hasn't been touched in 30+ days, the MOST RECENT handoff
35
+ > stays in `warrior-handoffs/`. It's not scaffolding — it's the cold-start bridge.
36
+ > When the user opens that project 6 months later, the agent reads this handoff
37
+ > and knows exactly where things stand.
38
+
39
+ ### Frequency
40
+
41
+ | Trigger | Action |
42
+ |---------|--------|
43
+ | `warrior-handoffs/` > 50 files | Run Stone & Scaffold |
44
+ | Milestone completion | Archive that milestone's handoffs |
45
+ | Monthly (natural rhythm) | Sweep for scaffolding |
46
+ | `/fire-cleanse --poop` or `--shower` | Include as part of Colon batch dump |
47
+
48
+ ### The Process
49
+
50
+ ```
51
+ Step 1: INVENTORY
52
+ List all files in warrior-handoffs/
53
+ Group by project (parse filename or read first 5 lines)
54
+
55
+ Step 2: IDENTIFY DORMANT PROJECTS
56
+ For each project group:
57
+ - Last handoff date > 30 days ago? → DORMANT
58
+ - Last handoff date < 30 days ago? → ACTIVE
59
+
60
+ Step 3: PROTECT DORMANT PROJECT BRIDGES
61
+ For each DORMANT project:
62
+ - Mark the MOST RECENT handoff as PROTECTED (do not archive)
63
+ - All older handoffs for that project → archive candidates
64
+
65
+ Step 4: ARCHIVE ACTIVE PROJECT SCAFFOLDING
66
+ For each ACTIVE project:
67
+ - Skills already extracted? (check skills library for matching patterns)
68
+ - Keep the MOST RECENT handoff (current session bridge)
69
+ - All older handoffs → archive candidates
70
+
71
+ Step 5: WRITE INDEX
72
+ Create INDEX.md in backup location:
73
+ - First line: backup location path
74
+ - One line per archived handoff (filename + one sentence)
75
+ - Last line: recovery instructions
76
+ - Group by date or project for scanability
77
+
78
+ Step 6: MOVE (NOT DELETE)
79
+ Move archive candidates to backup location
80
+ Verify file counts match expectations
81
+ Leave protected handoffs in warrior-handoffs/
82
+ ```
83
+
84
+ ### Decision Matrix
85
+
86
+ ```
87
+ ┌──────────────────────────────────────────────────────────────┐
88
+ │ STONE & SCAFFOLD DECISION │
89
+ ├──────────────────────────────────────────────────────────────┤
90
+ │ │
91
+ │ Is this the MOST RECENT handoff for its project? │
92
+ │ YES → Is the project ACTIVE (touched < 30 days)? │
93
+ │ YES → KEEP (current session bridge) │
94
+ │ NO → KEEP + MARK AS DORMANT BRIDGE │
95
+ │ NO → Have skills been extracted from this handoff? │
96
+ │ YES → ARCHIVE (scaffolding, stones already set) │
97
+ │ NO → KEEP until skills extracted │
98
+ │ │
99
+ │ Is this a non-markdown file (image, html)? │
100
+ │ YES → ARCHIVE (unless referenced by a kept handoff) │
101
+ │ │
102
+ └──────────────────────────────────────────────────────────────┘
103
+ ```
104
+
105
+ ### Backup Location
106
+
107
+ ```
108
+ C:\Users\FirstName\Documents\warrior-handoff-backup\
109
+ INDEX.md ← One-page summary of everything archived
110
+ {handoff files} ← Moved here, intact, recoverable
111
+ ```
112
+
113
+ ### INDEX.md Format
114
+
115
+ ```markdown
116
+ # Warrior Handoff Backup
117
+
118
+ **Location:** C:\Users\FirstName\Documents\warrior-handoff-backup\
119
+ **Moved from:** C:\Users\FirstName\.claude\warrior-handoffs\
120
+ **Date moved:** {YYYY-MM-DD}
121
+ **Reason:** Scaffolding archived — skills extracted, stones set.
122
+
123
+ ---
124
+
125
+ ## {Date Group}
126
+ - FILENAME.md — One sentence about what this handoff covers
127
+
128
+ ---
129
+
130
+ **Recovery:** Copy needed files back to C:\Users\FirstName\.claude\warrior-handoffs\
131
+ ```
132
+
133
+ ---
134
+
135
+ ## Integration with Cleansing Cycle
136
+
137
+ Stone & Scaffold is the **Colon's handoff-specific batch dump**:
138
+
139
+ | Cleansing Mode | Stone & Scaffold Role |
140
+ |----------------|----------------------|
141
+ | Pee | Not triggered (too light for file moves) |
142
+ | Poop | Run Step 1-6 as part of Colon batch dump |
143
+ | Shower | Full sweep — re-evaluate ALL handoffs including dormant bridges |
144
+
145
+ The Spleen fitness test applies to handoffs too:
146
+ - 4/4 (recent + referenced + project active + skills not yet extracted) → KEEP
147
+ - 3/4 → KEEP (probably the dormant bridge)
148
+ - 2/4 → Archive candidate
149
+ - 0-1/4 → Archive immediately
150
+
151
+ ---
152
+
153
+ ## Example: The Dec 2025 Archive
154
+
155
+ First real execution (2026-02-17):
156
+ - **33 files archived** (26 .md + 3 images + 1 HTML + INDEX.md)
157
+ - **Projects covered:** SSD Recovery (complete), WSL Crisis (resolved), Form 656 (skills extracted), Zadok Calendar (dormant — but had no 2026 handoffs to protect)
158
+ - **Dormant bridges kept:** BoltBudget and LMS handoffs from Jan 2026 stayed in warrior-handoffs/ (most recent for those projects)
159
+ - **Result:** warrior-handoffs/ went from 122 → 89 files
160
+
161
+ ---
162
+
163
+ ## Testing
164
+
165
+ ```markdown
166
+ - [ ] Dormant projects have their most recent handoff PROTECTED
167
+ - [ ] Active projects keep only the most recent handoff
168
+ - [ ] INDEX.md has one line per archived file
169
+ - [ ] INDEX.md first line = backup location, last line = recovery instructions
170
+ - [ ] No files deleted — only moved
171
+ - [ ] File counts match (archived + remaining = original total)
172
+ - [ ] Non-markdown files archived (unless referenced by kept handoff)
173
+ ```
174
+
175
+ ---
176
+
177
+ ## Prevention
178
+
179
+ - Never archive the ONLY handoff for a project — that's the dormant bridge
180
+ - Never delete handoffs — always move to backup with an index
181
+ - Don't archive handoffs whose skills haven't been extracted yet
182
+ - Run the dormant project check BEFORE any archival
183
+ - When resuming a dormant project, the agent reads the bridge handoff FGTAT
184
+
185
+ ---
186
+
187
+ ## Common Mistakes to Avoid
188
+
189
+ - **Archiving by date alone** — a 6-month-old handoff might be the only bridge to a sleeping project
190
+ - **Deleting instead of moving** — the colon absorbs before it eliminates; the backup is the absorption
191
+ - **No index** — archived handoffs without an index are effectively lost
192
+ - **Archiving too early** — if skills haven't been extracted yet, the handoff IS the skill
193
+ - **Forgetting non-markdown files** — images and HTML referenced by handoffs should travel with them
194
+
195
+ ---
196
+
197
+ ## Related Patterns
198
+
199
+ - [CLEANSING_CYCLE](./CLEANSING_CYCLE.md) — Colon batch dump triggers this protocol
200
+ - [PORTAL_MEMORY_ARCHITECTURE](./PORTAL_MEMORY_ARCHITECTURE.md) — Revisitation Ladder: 1x=handoff, 5x+=skill
201
+ - [GLOMERULUS_DECISION_GATE](./GLOMERULUS_DECISION_GATE.md) — 3-layer filter applies to handoff triage
202
+
203
+ ---
204
+
205
+ ## Resources
206
+
207
+ - Revisitation Ladder: Handoffs are 1x use (read, extract, archive). Skills are 5x+ (permanent stones).
208
+ - Thierry's insight: "The skills are what truly matter — that's what the handoffs built."
209
+ - Thierry's insight: "Last in from project, first one out at resume" — dormant bridge principle.
210
+ - Biological analog: Colon absorbs nutrients (skills) from food (handoffs), then eliminates the bulk.
211
+
212
+ ---
213
+
214
+ ## Time to Implement
215
+
216
+ **2-5 minutes** per archival sweep
217
+
218
+ ## Difficulty Level
219
+
220
+ ⭐⭐ (2/5) — Simple file operations. The nuance is in the dormant project detection.
@@ -0,0 +1,172 @@
1
+ ---
2
+ name: cache-augmented-generation
3
+ category: performance
4
+ version: 1.0.0
5
+ contributed: 2026-03-01
6
+ contributor: dominion-flow
7
+ last_updated: 2026-03-01
8
+ contributors:
9
+ - dominion-flow
10
+ tags: [caching, llm, rag-alternative, prompt-caching, anthropic, context-window, performance]
11
+ difficulty: medium
12
+ usage_count: 0
13
+ success_rate: 100
14
+ ---
15
+
16
+ # Cache Augmented Generation (CAG)
17
+
18
+ ## Problem
19
+
20
+ RAG (Retrieval Augmented Generation) adds latency and complexity: embedding queries, vector search, re-ranking, then injecting chunks. For **small, stable document sets** that change infrequently, this retrieval overhead is unnecessary. The documents fit in the context window, and paying for retrieval infrastructure (Qdrant, embeddings, chunking pipeline) is architectural overkill.
21
+
22
+ Common symptoms that CAG is a better fit:
23
+ - Corpus is <100K tokens and changes less than weekly
24
+ - RAG retrieval adds 200-500ms latency per query
25
+ - Chunk boundary issues cause incomplete answers
26
+ - Users ask about the SAME reference material repeatedly
27
+ - You're maintaining embedding + vector DB infrastructure for a small, static corpus
28
+
29
+ ## Solution Pattern
30
+
31
+ **Pre-load the entire document corpus into the prompt prefix and cache it.** Instead of retrieving relevant chunks at query time (RAG), load ALL relevant documents into a cached system prompt. The LLM sees everything and selects what's relevant — no retrieval pipeline needed.
32
+
33
+ This works because:
34
+ 1. Modern context windows (200K tokens) can hold substantial corpora
35
+ 2. Anthropic's prompt caching stores the prefix server-side (90% cost reduction on cache hits)
36
+ 3. LLMs are good at finding relevant information within their context — often better than chunked retrieval
37
+
38
+ ### Architecture Comparison
39
+
40
+ ```
41
+ RAG Pipeline:
42
+ Query → Embed → Vector Search → Rerank → Inject Chunks → LLM → Response
43
+ Latency: 500-1500ms | Infrastructure: Embedding model + Vector DB + Chunking pipeline
44
+
45
+ CAG Pipeline:
46
+ Query → [Cached Prefix: All Docs] + Query → LLM → Response
47
+ Latency: 100-300ms | Infrastructure: None (prompt caching is built-in)
48
+ ```
49
+
50
+ ## Code Example
51
+
52
+ ### Anthropic Prompt Caching (Python)
53
+
54
+ ```python
55
+ import anthropic
56
+
57
+ # Load your stable corpus once
58
+ def load_corpus():
59
+ """Load all reference documents into a single string."""
60
+ docs = []
61
+ for path in REFERENCE_DIR.glob("*.md"):
62
+ docs.append(f"## {path.stem}\n\n{path.read_text()}")
63
+ return "\n\n---\n\n".join(docs)
64
+
65
+ CORPUS = load_corpus() # Load once at startup
66
+
67
+ client = anthropic.Anthropic()
68
+
69
+ def query_with_cag(user_question: str) -> str:
70
+ """Query against the full cached corpus."""
71
+ response = client.messages.create(
72
+ model="claude-sonnet-4-20250514",
73
+ max_tokens=4096,
74
+ system=[
75
+ {
76
+ "type": "text",
77
+ "text": f"You are an expert assistant. Answer questions using ONLY the reference material below.\n\n{CORPUS}",
78
+ "cache_control": {"type": "ephemeral"} # Cache this prefix
79
+ }
80
+ ],
81
+ messages=[{"role": "user", "content": user_question}]
82
+ )
83
+ return response.content[0].text
84
+ ```
85
+
86
+ ### Anthropic Prompt Caching (TypeScript/Node.js)
87
+
88
+ ```typescript
89
+ import Anthropic from '@anthropic-ai/sdk';
90
+
91
+ const client = new Anthropic();
92
+
93
+ // Load corpus once at startup
94
+ const CORPUS = loadAllDocs(); // Returns concatenated document text
95
+
96
+ async function queryWithCAG(question: string): Promise<string> {
97
+ const response = await client.messages.create({
98
+ model: 'claude-sonnet-4-20250514',
99
+ max_tokens: 4096,
100
+ system: [
101
+ {
102
+ type: 'text',
103
+ text: `You are an expert assistant. Answer using ONLY the reference material below.\n\n${CORPUS}`,
104
+ cache_control: { type: 'ephemeral' },
105
+ },
106
+ ],
107
+ messages: [{ role: 'user', content: question }],
108
+ });
109
+ return response.content[0].type === 'text' ? response.content[0].text : '';
110
+ }
111
+ ```
112
+
113
+ ### Cache Invalidation
114
+
115
+ ```typescript
116
+ // Simple: Reload corpus on file change (fs.watch or chokidar)
117
+ import { watch } from 'chokidar';
118
+
119
+ let corpus = loadAllDocs();
120
+
121
+ watch(REFERENCE_DIR, { ignoreInitial: true }).on('change', () => {
122
+ corpus = loadAllDocs();
123
+ console.log('CAG corpus reloaded — next request uses fresh cache');
124
+ });
125
+ ```
126
+
127
+ ## Implementation Steps
128
+
129
+ 1. Inventory your document corpus — count tokens (use `tiktoken` or Anthropic's token counter)
130
+ 2. If corpus < 100K tokens AND changes infrequently, CAG is viable
131
+ 3. Concatenate all documents into a single system prompt string with clear section markers
132
+ 4. Add `cache_control: { type: "ephemeral" }` to the system message
133
+ 5. Remove RAG infrastructure (embedding, vector DB, chunking) if CAG covers the entire use case
134
+ 6. Add file watcher for cache invalidation if documents can change
135
+
136
+ ## When to Use
137
+
138
+ - Reference material is small (<100K tokens) and stable (changes < weekly)
139
+ - Users repeatedly query the SAME document set
140
+ - RAG retrieval latency is a pain point
141
+ - Chunk boundary issues cause incomplete or fragmented answers
142
+ - You want to eliminate embedding/vector DB infrastructure for a specific use case
143
+ - Bible corpus, legal documents, company policies, API specs, style guides
144
+
145
+ ## When NOT to Use
146
+
147
+ - Corpus exceeds context window limits (>150K tokens for safety margin)
148
+ - Documents change frequently (hourly/daily) — cache invalidation overhead negates benefits
149
+ - You need to search across millions of documents (RAG scales, CAG doesn't)
150
+ - Queries need to combine information from different document versions
151
+ - Cost is the primary concern and queries are infrequent (cached prefix has per-session cost)
152
+ - You need metadata filtering (by date, author, category) — RAG handles this naturally
153
+
154
+ ## Common Mistakes
155
+
156
+ - Pre-loading a corpus that's too large — causes context window pressure and degrades answer quality
157
+ - Forgetting cache invalidation — stale cached responses return outdated information
158
+ - Caching with high temperature — non-deterministic outputs make cached patterns unreliable
159
+ - Not measuring token count — "small" corpora can be surprisingly large when fully loaded
160
+ - Mixing CAG and RAG without clear boundaries — pick one per document set
161
+ - Ignoring the 5-minute cache TTL on Anthropic — frequent cold starts negate cost savings
162
+
163
+ ## Related Skills
164
+
165
+ - [AI_RESPONSE_DATABASE_CACHING](../database-solutions/AI_RESPONSE_DATABASE_CACHING.md) - Response-level caching for expensive LLM calls
166
+ - [persistent-analysis-storage](../database-solutions/persistent-analysis-storage.md) - Dual-storage for expensive analysis results
167
+
168
+ ## References
169
+
170
+ - Anthropic Prompt Caching: https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
171
+ - CAG concept derived from AITMPL prompt-caching skill analysis (2026-03-01)
172
+ - Contributed from: dominion-flow gap analysis (AITMPL audit session)