@rune-kit/rune 2.10.0 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +65 -6
  3. package/commands/rune.md +168 -168
  4. package/compiler/__tests__/detect-invariants.test.js +136 -0
  5. package/compiler/__tests__/doctor-mesh.test.js +229 -0
  6. package/compiler/__tests__/hook-dispatch.test.js +91 -0
  7. package/compiler/__tests__/hooks-antigravity.test.js +118 -0
  8. package/compiler/__tests__/hooks-cursor.test.js +139 -0
  9. package/compiler/__tests__/hooks-install.test.js +305 -0
  10. package/compiler/__tests__/hooks-merge.test.js +204 -0
  11. package/compiler/__tests__/hooks-tiers.test.js +519 -0
  12. package/compiler/__tests__/hooks-windsurf.test.js +115 -0
  13. package/compiler/__tests__/inject-claude-md.test.js +152 -0
  14. package/compiler/__tests__/load-invariants.test.js +408 -0
  15. package/compiler/__tests__/onboard-invariants.test.js +240 -0
  16. package/compiler/adapters/hooks/antigravity.js +140 -0
  17. package/compiler/adapters/hooks/claude.js +166 -0
  18. package/compiler/adapters/hooks/cursor.js +191 -0
  19. package/compiler/adapters/hooks/index.js +82 -0
  20. package/compiler/adapters/hooks/tier-emitter.js +182 -0
  21. package/compiler/adapters/hooks/windsurf.js +202 -0
  22. package/compiler/bin/rune.js +196 -6
  23. package/compiler/commands/hook-dispatch.js +87 -0
  24. package/compiler/commands/hooks/install.js +120 -0
  25. package/compiler/commands/hooks/merge.js +211 -0
  26. package/compiler/commands/hooks/presets.js +116 -0
  27. package/compiler/commands/hooks/status.js +112 -0
  28. package/compiler/commands/hooks/tiers.js +221 -0
  29. package/compiler/commands/hooks/uninstall.js +94 -0
  30. package/compiler/doctor.js +236 -0
  31. package/contexts/dev.md +34 -34
  32. package/contexts/research.md +43 -43
  33. package/contexts/review.md +55 -55
  34. package/extensions/ai-ml/PACK.md +88 -88
  35. package/extensions/ai-ml/skills/ai-agents.md +172 -172
  36. package/extensions/ai-ml/skills/code-sandbox.md +187 -187
  37. package/extensions/ai-ml/skills/deep-research.md +146 -146
  38. package/extensions/ai-ml/skills/embedding-search.md +66 -66
  39. package/extensions/ai-ml/skills/fine-tuning-guide.md +74 -74
  40. package/extensions/ai-ml/skills/llm-architect.md +125 -125
  41. package/extensions/ai-ml/skills/llm-integration.md +64 -64
  42. package/extensions/ai-ml/skills/prompt-patterns.md +72 -72
  43. package/extensions/ai-ml/skills/rag-patterns.md +66 -66
  44. package/extensions/ai-ml/skills/web-extraction.md +114 -114
  45. package/extensions/analytics/PACK.md +92 -92
  46. package/extensions/analytics/skills/ab-testing.md +72 -72
  47. package/extensions/analytics/skills/dashboard-patterns.md +83 -83
  48. package/extensions/analytics/skills/data-validation.md +68 -68
  49. package/extensions/analytics/skills/funnel-analysis.md +81 -81
  50. package/extensions/analytics/skills/sql-patterns.md +57 -57
  51. package/extensions/analytics/skills/statistical-analysis.md +79 -79
  52. package/extensions/analytics/skills/tracking-setup.md +71 -71
  53. package/extensions/backend/PACK.md +104 -104
  54. package/extensions/backend/skills/api-patterns.md +84 -84
  55. package/extensions/backend/skills/async-pipeline.md +193 -193
  56. package/extensions/backend/skills/auth-patterns.md +97 -97
  57. package/extensions/backend/skills/background-jobs.md +133 -133
  58. package/extensions/backend/skills/caching-patterns.md +108 -108
  59. package/extensions/backend/skills/cli-generation.md +133 -133
  60. package/extensions/backend/skills/database-patterns.md +87 -87
  61. package/extensions/backend/skills/middleware-patterns.md +104 -104
  62. package/extensions/chrome-ext/PACK.md +93 -93
  63. package/extensions/chrome-ext/skills/cws-preflight.md +143 -143
  64. package/extensions/chrome-ext/skills/cws-publish.md +104 -104
  65. package/extensions/chrome-ext/skills/ext-ai-integration.md +251 -251
  66. package/extensions/chrome-ext/skills/ext-messaging.md +139 -139
  67. package/extensions/chrome-ext/skills/ext-storage.md +133 -133
  68. package/extensions/chrome-ext/skills/mv3-scaffold.md +164 -164
  69. package/extensions/content/PACK.md +96 -96
  70. package/extensions/content/skills/blog-patterns.md +88 -88
  71. package/extensions/content/skills/cms-integration.md +131 -131
  72. package/extensions/content/skills/content-scoring.md +107 -107
  73. package/extensions/content/skills/i18n.md +83 -83
  74. package/extensions/content/skills/mdx-authoring.md +137 -137
  75. package/extensions/content/skills/reference.md +1014 -1014
  76. package/extensions/content/skills/seo-patterns.md +67 -67
  77. package/extensions/content/skills/video-repurpose.md +153 -153
  78. package/extensions/devops/PACK.md +101 -101
  79. package/extensions/devops/skills/chaos-testing.md +67 -67
  80. package/extensions/devops/skills/ci-cd.md +75 -75
  81. package/extensions/devops/skills/docker.md +58 -58
  82. package/extensions/devops/skills/edge-serverless.md +163 -163
  83. package/extensions/devops/skills/infra-as-code.md +158 -158
  84. package/extensions/devops/skills/kubernetes.md +110 -110
  85. package/extensions/devops/skills/monitoring.md +57 -57
  86. package/extensions/devops/skills/server-setup.md +64 -64
  87. package/extensions/devops/skills/ssl-domain.md +42 -42
  88. package/extensions/ecommerce/PACK.md +116 -116
  89. package/extensions/ecommerce/skills/cart-system.md +79 -79
  90. package/extensions/ecommerce/skills/inventory-mgmt.md +102 -102
  91. package/extensions/ecommerce/skills/order-management.md +126 -126
  92. package/extensions/ecommerce/skills/payment-integration.md +472 -472
  93. package/extensions/ecommerce/skills/shopify-dev.md +69 -69
  94. package/extensions/ecommerce/skills/subscription-billing.md +93 -93
  95. package/extensions/ecommerce/skills/tax-compliance.md +117 -117
  96. package/extensions/gamedev/PACK.md +142 -142
  97. package/extensions/gamedev/skills/asset-pipeline.md +74 -74
  98. package/extensions/gamedev/skills/audio-system.md +129 -129
  99. package/extensions/gamedev/skills/camera-system.md +87 -87
  100. package/extensions/gamedev/skills/ecs.md +98 -98
  101. package/extensions/gamedev/skills/game-loops.md +72 -72
  102. package/extensions/gamedev/skills/input-system.md +199 -199
  103. package/extensions/gamedev/skills/multiplayer.md +180 -180
  104. package/extensions/gamedev/skills/particles.md +105 -105
  105. package/extensions/gamedev/skills/physics-engine.md +89 -89
  106. package/extensions/gamedev/skills/scene-management.md +146 -146
  107. package/extensions/gamedev/skills/threejs-patterns.md +90 -90
  108. package/extensions/gamedev/skills/webgl.md +71 -71
  109. package/extensions/mobile/PACK.md +106 -106
  110. package/extensions/mobile/skills/app-store-connect.md +152 -152
  111. package/extensions/mobile/skills/app-store-prep.md +66 -66
  112. package/extensions/mobile/skills/deep-linking.md +109 -109
  113. package/extensions/mobile/skills/flutter.md +60 -60
  114. package/extensions/mobile/skills/ios-build-pipeline.md +142 -142
  115. package/extensions/mobile/skills/native-bridge.md +66 -66
  116. package/extensions/mobile/skills/ota-updates.md +97 -97
  117. package/extensions/mobile/skills/push-notifications.md +111 -111
  118. package/extensions/mobile/skills/react-native.md +82 -82
  119. package/extensions/saas/PACK.md +116 -116
  120. package/extensions/saas/skills/billing-integration.md +200 -200
  121. package/extensions/saas/skills/feature-flags.md +130 -130
  122. package/extensions/saas/skills/multi-tenant.md +103 -103
  123. package/extensions/saas/skills/onboarding-flow.md +139 -139
  124. package/extensions/saas/skills/subscription-flow.md +95 -95
  125. package/extensions/saas/skills/team-management.md +144 -144
  126. package/extensions/security/PACK.md +99 -99
  127. package/extensions/security/skills/api-security.md +140 -140
  128. package/extensions/security/skills/compliance.md +68 -68
  129. package/extensions/security/skills/owasp-audit.md +64 -64
  130. package/extensions/security/skills/pentest-patterns.md +77 -77
  131. package/extensions/security/skills/secret-mgmt.md +65 -65
  132. package/extensions/security/skills/supply-chain.md +65 -65
  133. package/extensions/trading/PACK.md +80 -80
  134. package/extensions/trading/skills/chart-components.md +55 -55
  135. package/extensions/trading/skills/experiment-loop.md +125 -125
  136. package/extensions/trading/skills/fintech-patterns.md +47 -47
  137. package/extensions/trading/skills/indicator-library.md +58 -58
  138. package/extensions/trading/skills/quant-analysis.md +111 -111
  139. package/extensions/trading/skills/realtime-data.md +58 -58
  140. package/extensions/trading/skills/trade-logic.md +104 -104
  141. package/extensions/ui/PACK.md +130 -130
  142. package/extensions/ui/skills/a11y-audit.md +91 -91
  143. package/extensions/ui/skills/animation-patterns.md +127 -127
  144. package/extensions/ui/skills/component-patterns.md +100 -100
  145. package/extensions/ui/skills/design-decision.md +108 -108
  146. package/extensions/ui/skills/design-system.md +68 -68
  147. package/extensions/ui/skills/landing-patterns.md +155 -155
  148. package/extensions/ui/skills/palette-picker.md +173 -173
  149. package/extensions/ui/skills/react-health.md +90 -90
  150. package/extensions/ui/skills/type-system.md +125 -125
  151. package/extensions/ui/skills/web-vitals.md +153 -153
  152. package/extensions/zalo/PACK.md +145 -145
  153. package/extensions/zalo/skills/zalo-oa-mcp.md +317 -317
  154. package/extensions/zalo/skills/zalo-oa-messaging.md +429 -429
  155. package/extensions/zalo/skills/zalo-oa-setup.md +236 -236
  156. package/extensions/zalo/skills/zalo-oa-webhook.md +189 -189
  157. package/extensions/zalo/skills/zalo-personal-messaging.md +194 -194
  158. package/extensions/zalo/skills/zalo-personal-setup.md +153 -153
  159. package/extensions/zalo/skills/zalo-rate-guard.md +219 -219
  160. package/hooks/auto-format/index.cjs +48 -48
  161. package/hooks/hooks.json +111 -111
  162. package/hooks/post-session-reflect/index.cjs +189 -189
  163. package/hooks/pre-compact/index.cjs +95 -95
  164. package/hooks/run-hook.cmd +1 -1
  165. package/hooks/secrets-scan/index.cjs +100 -100
  166. package/hooks/session-start/index.cjs +71 -71
  167. package/hooks/typecheck/index.cjs +65 -65
  168. package/package.json +63 -63
  169. package/references/ui-pro-max-data/LICENSE-UI-PRO-MAX +21 -21
  170. package/references/ui-pro-max-data/charts.csv +26 -26
  171. package/references/ui-pro-max-data/colors.csv +161 -161
  172. package/references/ui-pro-max-data/styles.csv +68 -68
  173. package/references/ui-pro-max-data/typography.csv +74 -74
  174. package/references/ui-pro-max-data/ui-reasoning.csv +162 -162
  175. package/references/ui-pro-max-data/ux-guidelines.csv +99 -99
  176. package/skills/adversary/SKILL.md +283 -283
  177. package/skills/asset-creator/SKILL.md +157 -157
  178. package/skills/audit/SKILL.md +147 -2
  179. package/skills/autopsy/SKILL.md +335 -335
  180. package/skills/ba/SKILL.md +85 -1
  181. package/skills/brainstorm/SKILL.md +380 -342
  182. package/skills/browser-pilot/SKILL.md +169 -168
  183. package/skills/constraint-check/SKILL.md +165 -165
  184. package/skills/context-engine/SKILL.md +408 -404
  185. package/skills/cook/SKILL.md +917 -863
  186. package/skills/db/SKILL.md +273 -273
  187. package/skills/debug/SKILL.md +465 -465
  188. package/skills/dependency-doctor/SKILL.md +265 -235
  189. package/skills/deploy/SKILL.md +274 -231
  190. package/skills/design/DESIGN-REFERENCE.md +365 -365
  191. package/skills/design/SKILL.md +590 -589
  192. package/skills/doc-processor/SKILL.md +254 -254
  193. package/skills/docs/SKILL.md +374 -374
  194. package/skills/docs-seeker/SKILL.md +178 -177
  195. package/skills/fix/SKILL.md +332 -330
  196. package/skills/git/SKILL.md +339 -339
  197. package/skills/hallucination-guard/SKILL.md +220 -219
  198. package/skills/incident/SKILL.md +254 -253
  199. package/skills/integrity-check/SKILL.md +169 -169
  200. package/skills/journal/SKILL.md +241 -240
  201. package/skills/launch/SKILL.md +344 -344
  202. package/skills/logic-guardian/SKILL.md +269 -251
  203. package/skills/marketing/SKILL.md +351 -289
  204. package/skills/mcp-builder/SKILL.md +425 -425
  205. package/skills/neural-memory/SKILL.md +359 -362
  206. package/skills/onboard/SKILL.md +432 -403
  207. package/skills/onboard/references/invariants-template.md +76 -0
  208. package/skills/onboard/scripts/detect-invariants.js +439 -0
  209. package/skills/onboard/scripts/inject-claude-md.js +150 -0
  210. package/skills/onboard/scripts/onboard-invariants.js +194 -0
  211. package/skills/perf/SKILL.md +347 -346
  212. package/skills/plan/SKILL.md +435 -428
  213. package/skills/preflight/SKILL.md +415 -415
  214. package/skills/problem-solver/SKILL.md +380 -284
  215. package/skills/rescue/SKILL.md +474 -474
  216. package/skills/research/SKILL.md +4 -0
  217. package/skills/retro/SKILL.md +3 -1
  218. package/skills/review/SKILL.md +614 -588
  219. package/skills/review-intake/SKILL.md +249 -249
  220. package/skills/safeguard/SKILL.md +200 -200
  221. package/skills/sast/SKILL.md +190 -190
  222. package/skills/scaffold/SKILL.md +328 -287
  223. package/skills/scope-guard/SKILL.md +183 -180
  224. package/skills/scout/SKILL.md +269 -263
  225. package/skills/sentinel/SKILL.md +384 -381
  226. package/skills/sentinel-env/SKILL.md +254 -254
  227. package/skills/sequential-thinking/SKILL.md +234 -234
  228. package/skills/session-bridge/SKILL.md +595 -543
  229. package/skills/session-bridge/scripts/load-invariants.js +397 -0
  230. package/skills/skill-forge/SKILL.md +581 -581
  231. package/skills/skill-router/SKILL.md +3 -0
  232. package/skills/slides/SKILL.md +19 -0
  233. package/skills/surgeon/SKILL.md +215 -215
  234. package/skills/team/SKILL.md +557 -537
  235. package/skills/test/SKILL.md +620 -614
  236. package/skills/trend-scout/SKILL.md +145 -145
  237. package/skills/verification/SKILL.md +334 -326
  238. package/skills/video-creator/SKILL.md +201 -201
  239. package/skills/watchdog/SKILL.md +168 -168
  240. package/skills/worktree/SKILL.md +140 -140
@@ -1,543 +1,595 @@
1
- ---
2
- name: session-bridge
3
- description: Universal context persistence across sessions. Auto-saves decisions, conventions, and progress to .rune/ files. Loads state at session start. Use when any skill makes architectural decisions or establishes patterns that must survive session boundaries.
4
- metadata:
5
- author: runedev
6
- version: "0.6.0"
7
- layer: L3
8
- model: haiku
9
- group: state
10
- tools: "Read, Write, Edit, Glob, Grep"
11
- listen: phase.complete, checkpoint.request
12
- ---
13
-
14
- # session-bridge
15
-
16
- ## Purpose
17
-
18
- Solve the #1 developer complaint: context loss across sessions. Session-bridge auto-saves critical context to `.rune/` files in the project directory, and loads them at session start. Every new session knows exactly where the last one left off.
19
-
20
- ## Triggers
21
-
22
- - Auto-trigger: when an architectural decision is made
23
- - Auto-trigger: when a convention/pattern is established
24
- - Auto-trigger: before context compaction
25
- - Auto-trigger: at session end (stop hook)
26
- - Signal: `checkpoint.request` explicit checkpoint from cook/team mid-phase
27
- - `/checkpoint` — manual checkpoint (save exact resume point)
28
- - `/rune status` — manual state check
29
-
30
- ## Calls (outbound)
31
-
32
- # Exception: L3→L3 coordination (same pattern as hallucination-guard → research)
33
- - `integrity-check` (L3): verify .rune/ file integrity before loading state
34
-
35
- ## Called By (inbound)
36
-
37
- - `cook` (L1): auto-save decisions during feature implementation
38
- - `rescue` (L1): state management throughout refactoring
39
- - `context-engine` (L3): save state before compaction
40
-
41
- ## State Files Managed
42
-
43
- ```
44
- .rune/
45
- ├── decisions.md — Architectural decisions log
46
- ├── conventions.md — Established patterns & style
47
- ├── progress.md — Task progress tracker
48
- ├── session-log.md Brief log of each session
49
- ├── instincts.md Learned project-specific patterns (trigger→action)
50
- ├── cumulative-notes.md Living project understanding (profile, themes, relationships)
51
- ├── learnings.jsonl Structured learning log (append-only, queryable)
52
- └── checkpoint.md Exact resume point for cross-session continuity
53
- ```
54
-
55
- ## Execution
56
-
57
- ### Save Mode (end of session or pre-compaction)
58
-
59
- #### Step 1 — Gather state
60
-
61
- Collect from the current session:
62
- - All architectural or technology choices made (language, library, approach)
63
- - Conventions established (naming patterns, file structure, coding style)
64
- - Tasks completed, in-progress, and blocked
65
- - A one-paragraph summary of what this session accomplished
66
-
67
- **Python project context** (if `pyproject.toml` or `setup.py` detected):
68
- - Python version (from `.python-version`, `pyproject.toml` `requires-python`, or `python --version`)
69
- - Virtual environment path and type (venv, poetry, uv, conda)
70
- - Installed optional dependency groups (e.g., `[dev]`, `[test]`, `[embeddings]`)
71
- - Last mypy error count (from most recent verification run, if available)
72
- - Last test coverage percentage (from most recent test run, if available)
73
- - DB migration version (if alembic, django migrations, or similar detected)
74
-
75
- #### Step 2 Update .rune/decisions.md
76
-
77
- Use `Glob` to check if `.rune/decisions.md` exists. If not, use `Write` to create it with a `# Decisions Log` header.
78
-
79
- For each architectural decision from this session, use `Edit` to append to `.rune/decisions.md`:
80
-
81
- ```markdown
82
- ## [YYYY-MM-DD HH:MM] Decision: <title>
83
-
84
- **Context:** Why this decision was needed
85
- **Decision:** What was decided
86
- **Rationale:** Why this approach over alternatives
87
- **Impact:** What files/modules are affected
88
- ```
89
-
90
- #### Step 3 Update .rune/conventions.md
91
-
92
- Use `Glob` to check if `.rune/conventions.md` exists. If not, use `Write` to create it with a `# Conventions` header.
93
-
94
- For each pattern or convention established, use `Edit` to append to `.rune/conventions.md`:
95
-
96
- ```markdown
97
- ## [YYYY-MM-DD] Convention: <title>
98
-
99
- **Pattern:** Description of the convention
100
- **Example:** Code example showing the pattern
101
- **Applies to:** Where this convention should be followed
102
- ```
103
-
104
- Python example:
105
- ```markdown
106
- ## [YYYY-MM-DD] Convention: Async-First I/O
107
-
108
- **Pattern:** All I/O functions use `async def`; blocking calls (`requests`, `open`, `time.sleep`) are forbidden in async modules
109
- **Example:** `async def fetch_data(): async with httpx.AsyncClient() as client: ...`
110
- **Applies to:** All modules in `src/` — sync wrappers only in CLI entry points
111
- ```
112
-
113
- #### Step 4Update .rune/progress.md
114
-
115
- Use `Glob` to check if `.rune/progress.md` exists. If not, use `Write` to create it with a `# Progress` header.
116
-
117
- Use `Edit` to append the current task status to `.rune/progress.md`:
118
-
119
- ```markdown
120
- ## [YYYY-MM-DD HH:MM] Session Summary
121
-
122
- **Completed:**
123
- - [x] Task description
124
-
125
- **In Progress:**
126
- - [ ] Task description (step X/Y)
127
-
128
- **Blocked:**
129
- - [ ] Task description reason
130
-
131
- **Next Session Should:**
132
- - Start with X
133
- - Continue Y from step Z
134
-
135
- **Python Context** (if Python project):
136
- - Python: [version] ([venv type])
137
- - Installed extras: [list of optional dependency groups]
138
- - mypy: [error count] ([strict/normal])
139
- - Coverage: [percentage]%
140
- - Migration: [version or N/A]
141
- ```
142
-
143
- #### Step 5 Update .rune/session-log.md
144
-
145
- Use `Glob` to check if `.rune/session-log.md` exists. If not, use `Write` to create it with a `# Session Log` header.
146
-
147
- Use `Edit` to append a one-line entry to `.rune/session-log.md`:
148
-
149
- ```
150
- [YYYY-MM-DD HH:MM] [brief description of session accomplishments]
151
- ```
152
-
153
- #### Step 5.5 Autonomous Loop Notes (when inside team or headless)
154
-
155
- When session-bridge is invoked by `cook` running inside `team` or in autonomous mode (`claude -p`), persist iteration state to `.rune/task-notes.md`:
156
-
157
- ```markdown
158
- # Task Notes: [task name]
159
- ## What Worked (with evidence)
160
- - [approach]: [outcome, test output, or file path as proof]
161
-
162
- ## What Failed
163
- - [approach]: [why it failed, error message]
164
-
165
- ## What's Left
166
- - [ ] [remaining task with specific next step]
167
-
168
- ## Key Context for Next Iteration
169
- - [critical info that would be lost on context reset]
170
- ```
171
-
172
- **Why**: In autonomous loops, each `claude -p` invocation starts with zero context. Without this file, the next iteration repeats failed approaches and loses progress. The notes bridge the gap between independent invocations.
173
-
174
- **Rules**: Agent reads `.rune/task-notes.md` at start (Step 1 of Load Mode), updates at end. Keep concise — max 50 lines. Prune completed items.
175
-
176
- #### Step 5.7 — Instinct Extraction (Project-Scoped Learning)
177
-
178
- Extract atomic "instincts" — learned trigger→action patterns — from this session and persist to `.rune/instincts.md`. Instincts are project-scoped by default to prevent cross-project contamination.
179
-
180
- **Instinct format:**
181
-
182
- ```markdown
183
- ## [YYYY-MM-DD] Instinct: <short name>
184
-
185
- **Trigger:** <when this pattern applies — specific condition>
186
- **Action:** <what to do — specific behavior>
187
- **Confidence:** <0.3–0.9>
188
- **Evidence:** <what happened that taught this file, error, outcome>
189
- ```
190
-
191
- **Extraction rules:**
192
-
193
- | Signal | Example | Confidence |
194
- |--------|---------|------------|
195
- | Repeated manual correction by user | "Don't use X, use Y here" (2+ times) | 0.7–0.9 |
196
- | Failed approach → successful pivot | Tried approach A, failed, approach B worked | 0.5–0.7 |
197
- | Project-specific convention discovered | "This codebase uses X pattern for Y" | 0.4–0.6 |
198
- | One-off preference (may not generalize) | User chose a specific library once | 0.3–0.4 |
199
-
200
- **Promotion to global**: When the same instinct (matching trigger+action) appears in `.rune/instincts.md` across 2+ projects at confidence ≥0.8, promote it to Neural Memory via Step 6 with tag `[cross-project, instinct]`. Until then, it stays project-local.
201
-
202
- **Pruning**: At session start (Load Mode Step 1), review instincts older than 30 days with confidence <0.5 — remove them. Instincts that conflict with current conventions should be removed immediately.
203
-
204
- **Max instincts**: Keep `.rune/instincts.md` under 20 entries. When full, evict the lowest-confidence entry.
205
-
206
- #### Step 5.8 — Learnings Log (Structured JSONL)
207
-
208
- Append structured learning entries to `.rune/learnings.jsonl` — an append-only log that captures decisions, insights, and error resolutions in a machine-queryable format. Unlike markdown state files (which are for human reading), JSONL enables fast filtering and "latest winner" lookups.
209
-
210
- **Entry schema** — one JSON object per line:
211
-
212
- ```json
213
- {"ts":"2026-04-04T14:30:00Z","skill":"cook","type":"decision","key":"state-lib","insight":"Chose Zustand over Redux fewer re-renders in dashboard with 50+ real-time widgets","confidence":0.8,"files":["src/store/index.ts"]}
214
- ```
215
-
216
- | Field | Type | Description |
217
- |-------|------|-------------|
218
- | `ts` | ISO 8601 | When the learning was captured |
219
- | `skill` | string | Which skill produced this learning |
220
- | `type` | enum | `decision` · `error` · `insight` · `convention` · `performance` |
221
- | `key` | string | Dedup key latest entry per key+type wins on read |
222
- | `insight` | string | 1-2 sentences, causal language ("Chose X because Y", "Root cause was X") |
223
- | `confidence` | 0.1–1.0 | How certain this learning is (0.3=hunch, 0.7=validated, 0.9=battle-tested) |
224
- | `files` | string[] | Optionalaffected file paths |
225
-
226
- **Write rules:**
227
- - Append only never edit or delete lines in the JSONL file
228
- - Max 1-3 entries per session (only genuinely transferable learnings)
229
- - Use causal/comparative language, not flat facts
230
- - Key must be kebab-case, descriptive (e.g., `auth-lib`, `db-migration-strategy`, `react-hook-pitfall`)
231
-
232
- **Read rules (latest-winner):**
233
- - When loading learnings, group by `key+type` and take the entry with the latest `ts`
234
- - This means updating a learning = just append a new entry with the same key+type
235
- - No dedup needed on write — dedup happens on read
236
-
237
- **Query patterns** (for other skills or session-start):
238
- - All learnings: read `.rune/learnings.jsonl`, parse line-by-line
239
- - By type: filter `type === "error"` to surface past mistakes before coding
240
- - By skill: filter `skill === "cook"` to see cook-specific learnings
241
- - By recency: sort by `ts` descending, take top N
242
- - Surface top 5 learnings at session start if file has 10+ entries
243
-
244
- **Pruning**: When file exceeds 100 entries, compact by keeping only the latest-winner per key+type. Write compacted entries to a new file, replace original.
245
-
246
- **Why**: Markdown state files (decisions.md, conventions.md) are great for human reading but hard to query programmatically. JSONL enables structured recall — "show me all errors from last week" or "what did we decide about auth?" — without parsing markdown headers.
247
-
248
- #### Step 5.9 — Cumulative Project Notes (Structured Memory)
249
-
250
- Maintain a running **cumulative notes** file at `.rune/cumulative-notes.md` that evolves across sessions. Unlike `progress.md` (which tracks tasks) or `decisions.md` (which logs choices), cumulative notes capture the **living understanding** of the project — patterns learned, relationships discovered, recurring themes, and open threads.
251
-
252
- **Format** — use these fixed sections (add content, never remove prior entries):
253
-
254
- ```markdown
255
- # Cumulative Project Notes
256
-
257
- ## Project Profile
258
- - [Core purpose of the project — 1 sentence]
259
- - [Primary users/audience]
260
- - [Key technical constraints — e.g., "must run offline", "latency-critical", "multi-tenant"]
261
-
262
- ## Architecture Map
263
- - [Key modules and their responsibilities discovered over sessions]
264
- - [Critical data flows — e.g., "user input → validation → API → DB → cache invalidation"]
265
- - [Integration points — external APIs, services, databases]
266
-
267
- ## Recurring Themes
268
- - [Patterns that keep coming up across sessions e.g., "auth edge cases", "migration complexity"]
269
- - [Common failure modes — what breaks and why]
270
- - [Technical debt hotspots — areas that repeatedly cause issues]
271
-
272
- ## Active Topics
273
- - [What's currently being worked on updated each session]
274
- - [Open questions that haven't been resolved yet]
275
- - [Experiments in progress]
276
-
277
- ## Relationship Map
278
- - [Key files and their dependencies — "changing X requires updating Y"]
279
- - [People and their areas — "Alice owns auth, Bob owns payments"]
280
- - [External service dependencies — "Stripe webhook → order.complete handler"]
281
-
282
- ## Follow-Up Items
283
- - [ ] [Things noted but not yet addressed — carry forward until done]
284
- - [ ] [Ideas that came up during work but were out of scope]
285
-
286
- ## Attention Points
287
- - [Things the next session should be aware of fragile areas, pending PRs, deadlines]
288
- - [Temporary workarounds that need proper fixes]
289
- ```
290
-
291
- **Update rules:**
292
- - **Create** the file on first session-bridge save if it doesn't exist
293
- - **Append** to existing sections — never overwrite prior entries (they represent accumulated knowledge)
294
- - **Prune** entries older than 60 days in Recurring Themes and Relationship Map — these may be stale
295
- - **Move** completed Follow-Up Items to a `## Resolved` section at the bottom (keep last 10)
296
- - **Keep under 200 lines**if approaching limit, summarize older entries in each section
297
-
298
- **Why**: Individual state files (decisions.md, progress.md) capture discrete events. Cumulative notes capture the **emergent understanding** that develops over many sessions the kind of knowledge that's lost when context resets. This is the project's "institutional memory."
299
-
300
- #### Step 6 — Cross-Project Knowledge Extraction (Neural Memory Bridge)
301
-
302
- Before committing, extract generalizable patterns from this session for cross-project reuse:
303
-
304
- 1. Review the session's decisions, conventions, and completed tasks
305
- 2. Identify 1-3 patterns that are NOT project-specific but would help in OTHER projects:
306
- - Technology choices with reasoning ("Chose Redis over Memcached because X")
307
- - Architecture patterns ("Fan-out queue pattern solved Y")
308
- - Failure modes discovered ("React 19 useEffect cleanup breaks when Z")
309
- - Performance insights ("N+1 query pattern in Prisma solved by include")
310
- 3. For each generalizable pattern, save to Neural Memory:
311
- - Use `nmem_remember` with rich cognitive language (causal, comparative, decisional)
312
- - Tags: `[cross-project, <technology>, <pattern-type>]`
313
- - Priority: 6-7 (important enough to surface in other projects)
314
- 4. Skip if session was purely project-specific (config changes, bug fixes with no transferable insight)
315
-
316
- **Why**: This turns every project session into learning that compounds across ALL projects. A pattern discovered in Project A auto-surfaces when Project B faces a similar problem.
317
-
318
- #### Step 7 — Commit
319
-
320
- Stage and commit all updated state files:
321
-
322
- ```bash
323
- git add .rune/ && git commit -m "chore: update rune session state"
324
- ```
325
-
326
- If git is not available or the directory is not a repo, skip the commit and emit a warning.
327
-
328
- ---
329
-
330
- ### Load Mode (start of session)
331
-
332
- #### Step 1 — Check existence
333
-
334
- Use `Glob` to check for `.rune/` directory:
335
-
336
- ```
337
- Glob pattern: .rune/*.md
338
- ```
339
-
340
- If no files found: suggest running `/rune onboard` to initialize the project. Exit load mode.
341
-
342
- #### Step 1.5 — Integrity verification
343
-
344
- Before loading state files, invoke `integrity-check` (L3) to verify `.rune/` files haven't been tampered:
345
-
346
- ```
347
- REQUIRED SUB-SKILL: rune:integrity-check
348
- → Invoke integrity-check on all .rune/*.md files found in Step 1.
349
- → Capture: status (CLEAN | SUSPICIOUS | TAINTED), findings list.
350
- ```
351
-
352
- Handle results:
353
- - `CLEAN` → proceed to Step 2 (load files)
354
- - `SUSPICIOUS` → present warning to user with specific findings. Ask: "Suspicious patterns detected in .rune/ files. Load anyway?" If user approves → proceed. If not → exit load mode.
355
- - `TAINTED` → **BLOCK load**. Report: ".rune/ integrity check FAILED — possible poisoning detected. Run `/rune integrity` for details."
356
-
357
- #### Step 2 Load files
358
-
359
- Use `Read` on all four state files in parallel:
360
-
361
- ```
362
- Read: .rune/decisions.md
363
- Read: .rune/conventions.md
364
- Read: .rune/progress.md
365
- Read: .rune/session-log.md
366
- Read: .rune/cumulative-notes.md
367
- ```
368
-
369
- #### Step 3 Summarize
370
-
371
- Present the loaded context to the agent in a structured summary:
372
-
373
- > "Here's what happened in previous sessions:"
374
- > - Last session: [last line from session-log.md]
375
- > - Key decisions: [last 3 entries from decisions.md]
376
- > - Active conventions: [count from conventions.md]
377
- > - Current progress: [in-progress and blocked items from progress.md]
378
- > - Project understanding: [Active Topics + Attention Points from cumulative-notes.md]
379
- > - Next task: [first item under "Next Session Should" from progress.md]
380
-
381
- #### Step 4Resume
382
-
383
- Identify the next concrete task from `progress.md` → "Next Session Should" section. Present it as the recommended starting point to the calling orchestrator.
384
-
385
- ### Checkpoint Mode (explicit save-and-resume point)
386
-
387
- Unlike Save Mode (which captures session state broadly), Checkpoint Mode creates an **exact resume point** — a single file that tells the next session precisely where to pick up, what's in-flight, and what decisions are load-bearing.
388
-
389
- **Trigger**: User says `/checkpoint`, or `cook`/`team` emits `checkpoint.request` signal when pausing mid-phase.
390
-
391
- #### Step 1 Capture resume state
392
-
393
- Collect into a structured checkpoint:
394
-
395
- ```markdown
396
- # Checkpoint — [YYYY-MM-DD HH:MM]
397
-
398
- ## What I Was Doing
399
- [1-2 sentences: the exact task and sub-step in progress]
400
-
401
- ## Current Git State
402
- - Branch: [branch name]
403
- - Last commit: [short hash + message]
404
- - Uncommitted changes: [list of modified/untracked files, or "clean"]
405
- - Stashed: [yes/no if yes, stash message]
406
-
407
- ## Decisions Made This Session (Load-Bearing)
408
- [Only decisions that affect the remaining work not all decisions]
409
- - [Decision 1]: [choice + why]
410
- - [Decision 2]: [choice + why]
411
-
412
- ## What's Left (Ordered)
413
- 1. [Next immediate step — be specific: file, function, what to change]
414
- 2. [Step after that]
415
- 3. [Remaining steps...]
416
-
417
- ## Context the Next Session Needs
418
- [Critical info that's NOT in the code or git history — mental model, gotchas discovered, things tried and failed]
419
- - [Item 1]
420
- - [Item 2]
421
-
422
- ## Resume Command
423
- [Exact instruction for the next session to pick up — e.g., "Continue Phase 2 Task 3: implement the retry logic in src/api/client.ts, the happy path is done, need error handling"]
424
- ```
425
-
426
- #### Step 2 Write checkpoint file
427
-
428
- Write to `.rune/checkpoint.md` (overwrite only one active checkpoint at a time).
429
-
430
- #### Step 3 Confirm to user
431
-
432
- ```
433
- ## Checkpoint Saved
434
- - **Resume point**: [1-line summary of what to continue]
435
- - **Git state**: [branch] @ [commit hash] — [clean/N uncommitted files]
436
- - **Remaining tasks**: [count]
437
- - Next session will auto-detect this checkpoint and offer to resume.
438
- ```
439
-
440
- #### Checkpoint Resume (in Load Mode)
441
-
442
- At Load Mode Step 1, after checking `.rune/*.md` existence, also check for `.rune/checkpoint.md`:
443
-
444
- - If checkpoint exists, read it FIRST (before other state files)
445
- - Present the resume point prominently:
446
- ```
447
- ## Checkpoint Detected — [date]
448
- **Resume**: [Resume Command from checkpoint]
449
- **Git state**: [branch] @ [commit] — [clean/dirty]
450
- **Tasks remaining**: [count]
451
- ```
452
- - After successful resume (user confirms they've picked up where they left off), rename checkpoint:
453
- ```bash
454
- mv .rune/checkpoint.md .rune/checkpoint-[date].resolved.md
455
- ```
456
- - Keep last 3 resolved checkpoints for history, delete older ones
457
-
458
- **Why**: Save Mode captures everything broadly. Checkpoint captures the **exact needle position** — like a bookmark in a book vs. a summary of chapters read. The next session doesn't need to scan all state files to figure out what to do; the checkpoint tells it directly.
459
-
460
- ## Output Format
461
-
462
- ### Save Mode
463
- ```
464
- ## Session BridgeSaved
465
- - **decisions.md**: [N] decisions appended
466
- - **conventions.md**: [N] conventions appended
467
- - **progress.md**: updated (completed/in-progress/blocked counts)
468
- - **session-log.md**: 1 entry appended
469
- - **Git commit**: [hash] | skipped (no git)
470
- ```
471
-
472
- ### Load Mode
473
- ```
474
- ## Session BridgeLoaded
475
- - **Last session**: [date and summary]
476
- - **Checkpoint**: [detected — resume point] | [none]
477
- - **Decisions on file**: [count]
478
- - **Conventions on file**: [count]
479
- - **Learnings on file**: [count] (top 5 surfaced if 10+)
480
- - **Next task**: [task description]
481
- ```
482
-
483
- ### Checkpoint Mode
484
- ```
485
- ## Checkpoint Saved
486
- - **Resume point**: [1-line summary]
487
- - **Git state**: [branch] @ [hash] — [clean/N files]
488
- - **Remaining tasks**: [count]
489
- ```
490
-
491
- ## Constraints
492
-
493
- 1. MUST save decisions, conventions, and progress not just a status line
494
- 2. MUST verify saved context can be loaded in a fresh session — test the round-trip
495
- 3. MUST NOT overwrite existing bridge data without merging
496
-
497
- ## Sharp Edges
498
-
499
- Known failure modes for this skill. Check these before declaring done.
500
-
501
- | Failure Mode | Severity | Mitigation |
502
- |---|---|---|
503
- | Overwriting existing .rune/ files instead of appending | HIGH | Constraint 3: use Edit to append entries — never Write to overwrite existing state |
504
- | Saving only a status line, missing decisions/conventions | HIGH | Constraint 1: all three files (decisions, conventions, progress) must be updated |
505
- | Load mode presenting stale context without age marker | MEDIUM | Mark each loaded entry with its session date — caller knows how fresh it is |
506
- | Silent failure when git unavailable | MEDIUM | Note "no git available" in report — do not fail silently or skip without logging |
507
- | Loading poisoned .rune/ files without verification | CRITICAL | Step 1.5 integrity-check MUST run before loading TAINTED = block load |
508
- | Learnings JSONL grows unbounded | MEDIUM | Auto-compact at 100 entries — keep only latest-winner per key+type |
509
- | Checkpoint stale after code changes | MEDIUM | Checkpoint includes git state if branch/commit differ at resume, warn user that checkpoint may be outdated |
510
- | Multiple checkpoints overwrite each other | LOW | By design — only one active checkpoint. Resolved ones archived with date suffix |
511
-
512
- ## Done When (Save Mode)
513
-
514
- - decisions.md updated with all architectural decisions made this session
515
- - conventions.md updated with all new patterns established
516
- - progress.md updated with completed/in-progress/blocked task status
517
- - session-log.md appended with one-line session summary
518
- - learnings.jsonl appended with 1-3 structured entries (if transferable learnings exist)
519
- - Git commit made (or "no git" noted in report)
520
- - Session Bridge Saved report emitted
521
-
522
- ## Done When (Load Mode)
523
-
524
- - .rune/*.md files found and read
525
- - Checkpoint detected and presented (if exists)
526
- - Learnings surfaced (top 5 if 10+ entries)
527
- - Last session summary presented
528
- - Current in-progress and blocked tasks identified
529
- - Next task recommendation from progress.md (or checkpoint resume command)
530
- - Session Bridge Loaded report emitted
531
-
532
- ## Done When (Checkpoint Mode)
533
-
534
- - Git state captured (branch, commit, uncommitted files)
535
- - Load-bearing decisions documented
536
- - Remaining tasks listed in execution order
537
- - Resume command written (specific enough for a fresh session to act on)
538
- - checkpoint.md written to .rune/
539
- - Checkpoint Saved report emitted
540
-
541
- ## Cost Profile
542
-
543
- ~100-300 tokens per save. ~500-1000 tokens per load. Always haiku. Negligible cost.
1
+ ---
2
+ name: session-bridge
3
+ description: Universal context persistence across sessions. Auto-saves decisions, conventions, and progress to .rune/ files. Loads state at session start. Use when any skill makes architectural decisions or establishes patterns that must survive session boundaries.
4
+ metadata:
5
+ author: runedev
6
+ version: "0.7.0"
7
+ layer: L3
8
+ model: haiku
9
+ group: state
10
+ tools: "Read, Write, Edit, Glob, Grep"
11
+ listen: phase.complete, checkpoint.request
12
+ emit: invariants.loaded
13
+ ---
14
+
15
+ # session-bridge
16
+
17
+ ## Purpose
18
+
19
+ Solve the #1 developer complaint: context loss across sessions. Session-bridge auto-saves critical context to `.rune/` files in the project directory, and loads them at session start. Every new session knows exactly where the last one left off.
20
+
21
+ ## Triggers
22
+
23
+ - Auto-trigger: when an architectural decision is made
24
+ - Auto-trigger: when a convention/pattern is established
25
+ - Auto-trigger: before context compaction
26
+ - Auto-trigger: at session end (stop hook)
27
+ - Signal: `checkpoint.request` — explicit checkpoint from cook/team mid-phase
28
+ - `/checkpoint` — manual checkpoint (save exact resume point)
29
+ - `/rune status` — manual state check
30
+
31
+ ## Calls (outbound)
32
+
33
+ # Exception: L3→L3 coordination (same pattern as hallucination-guard research)
34
+ - `integrity-check` (L3): verify .rune/ file integrity before loading state
35
+
36
+ ## Called By (inbound)
37
+
38
+ - `cook` (L1): auto-save decisions during feature implementation
39
+ - `rescue` (L1): state management throughout refactoring
40
+ - `context-engine` (L3): save state before compaction
41
+ - `context-pack` (L3): coordinate state for sub-agent handoff
42
+ - `neural-memory` (L3): sync key decisions back to `.rune/` files after Capture Mode
43
+
44
+ ## State Files Managed
45
+
46
+ ```
47
+ .rune/
48
+ ├── decisions.md Architectural decisions log
49
+ ├── conventions.md Established patterns & style
50
+ ├── progress.md Task progress tracker
51
+ ├── session-log.md Brief log of each session
52
+ ├── instincts.md Learned project-specific patterns (trigger→action)
53
+ ├── cumulative-notes.md — Living project understanding (profile, themes, relationships)
54
+ ├── learnings.jsonl — Structured learning log (append-only, queryable)
55
+ └── checkpoint.md — Exact resume point for cross-session continuity
56
+ ```
57
+
58
+ ## Execution
59
+
60
+ ### Save Mode (end of session or pre-compaction)
61
+
62
+ #### Step 1 Gather state
63
+
64
+ Collect from the current session:
65
+ - All architectural or technology choices made (language, library, approach)
66
+ - Conventions established (naming patterns, file structure, coding style)
67
+ - Tasks completed, in-progress, and blocked
68
+ - A one-paragraph summary of what this session accomplished
69
+
70
+ **Python project context** (if `pyproject.toml` or `setup.py` detected):
71
+ - Python version (from `.python-version`, `pyproject.toml` `requires-python`, or `python --version`)
72
+ - Virtual environment path and type (venv, poetry, uv, conda)
73
+ - Installed optional dependency groups (e.g., `[dev]`, `[test]`, `[embeddings]`)
74
+ - Last mypy error count (from most recent verification run, if available)
75
+ - Last test coverage percentage (from most recent test run, if available)
76
+ - DB migration version (if alembic, django migrations, or similar detected)
77
+
78
+ #### Step 2 — Update .rune/decisions.md
79
+
80
+ Use `Glob` to check if `.rune/decisions.md` exists. If not, use `Write` to create it with a `# Decisions Log` header.
81
+
82
+ For each architectural decision from this session, use `Edit` to append to `.rune/decisions.md`:
83
+
84
+ ```markdown
85
+ ## [YYYY-MM-DD HH:MM] Decision: <title>
86
+
87
+ **Context:** Why this decision was needed
88
+ **Decision:** What was decided
89
+ **Rationale:** Why this approach over alternatives
90
+ **Impact:** What files/modules are affected
91
+ ```
92
+
93
+ #### Step 3 — Update .rune/conventions.md
94
+
95
+ Use `Glob` to check if `.rune/conventions.md` exists. If not, use `Write` to create it with a `# Conventions` header.
96
+
97
+ For each pattern or convention established, use `Edit` to append to `.rune/conventions.md`:
98
+
99
+ ```markdown
100
+ ## [YYYY-MM-DD] Convention: <title>
101
+
102
+ **Pattern:** Description of the convention
103
+ **Example:** Code example showing the pattern
104
+ **Applies to:** Where this convention should be followed
105
+ ```
106
+
107
+ Python example:
108
+ ```markdown
109
+ ## [YYYY-MM-DD] Convention: Async-First I/O
110
+
111
+ **Pattern:** All I/O functions use `async def`; blocking calls (`requests`, `open`, `time.sleep`) are forbidden in async modules
112
+ **Example:** `async def fetch_data(): async with httpx.AsyncClient() as client: ...`
113
+ **Applies to:** All modules in `src/` sync wrappers only in CLI entry points
114
+ ```
115
+
116
+ #### Step 4 — Update .rune/progress.md
117
+
118
+ Use `Glob` to check if `.rune/progress.md` exists. If not, use `Write` to create it with a `# Progress` header.
119
+
120
+ Use `Edit` to append the current task status to `.rune/progress.md`:
121
+
122
+ ```markdown
123
+ ## [YYYY-MM-DD HH:MM] Session Summary
124
+
125
+ **Completed:**
126
+ - [x] Task description
127
+
128
+ **In Progress:**
129
+ - [ ] Task description (step X/Y)
130
+
131
+ **Blocked:**
132
+ - [ ] Task description — reason
133
+
134
+ **Next Session Should:**
135
+ - Start with X
136
+ - Continue Y from step Z
137
+
138
+ **Python Context** (if Python project):
139
+ - Python: [version] ([venv type])
140
+ - Installed extras: [list of optional dependency groups]
141
+ - mypy: [error count] ([strict/normal])
142
+ - Coverage: [percentage]%
143
+ - Migration: [version or N/A]
144
+ ```
145
+
146
+ #### Step 5 — Update .rune/session-log.md
147
+
148
+ Use `Glob` to check if `.rune/session-log.md` exists. If not, use `Write` to create it with a `# Session Log` header.
149
+
150
+ Use `Edit` to append a one-line entry to `.rune/session-log.md`:
151
+
152
+ ```
153
+ [YYYY-MM-DD HH:MM][brief description of session accomplishments]
154
+ ```
155
+
156
+ #### Step 5.5 — Autonomous Loop Notes (when inside team or headless)
157
+
158
+ When session-bridge is invoked by `cook` running inside `team` or in autonomous mode (`claude -p`), persist iteration state to `.rune/task-notes.md`:
159
+
160
+ ```markdown
161
+ # Task Notes: [task name]
162
+ ## What Worked (with evidence)
163
+ - [approach]: [outcome, test output, or file path as proof]
164
+
165
+ ## What Failed
166
+ - [approach]: [why it failed, error message]
167
+
168
+ ## What's Left
169
+ - [ ] [remaining task with specific next step]
170
+
171
+ ## Key Context for Next Iteration
172
+ - [critical info that would be lost on context reset]
173
+ ```
174
+
175
+ **Why**: In autonomous loops, each `claude -p` invocation starts with zero context. Without this file, the next iteration repeats failed approaches and loses progress. The notes bridge the gap between independent invocations.
176
+
177
+ **Rules**: Agent reads `.rune/task-notes.md` at start (Step 1 of Load Mode), updates at end. Keep concise — max 50 lines. Prune completed items.
178
+
179
+ #### Step 5.7 — Instinct Extraction (Project-Scoped Learning)
180
+
181
+ Extract atomic "instincts" — learned trigger→action patterns — from this session and persist to `.rune/instincts.md`. Instincts are project-scoped by default to prevent cross-project contamination.
182
+
183
+ **Instinct format:**
184
+
185
+ ```markdown
186
+ ## [YYYY-MM-DD] Instinct: <short name>
187
+
188
+ **Trigger:** <when this pattern appliesspecific condition>
189
+ **Action:** <what to do — specific behavior>
190
+ **Confidence:** <0.3–0.9>
191
+ **Evidence:** <what happened that taught this — file, error, outcome>
192
+ ```
193
+
194
+ **Extraction rules:**
195
+
196
+ | Signal | Example | Confidence |
197
+ |--------|---------|------------|
198
+ | Repeated manual correction by user | "Don't use X, use Y here" (2+ times) | 0.7–0.9 |
199
+ | Failed approach → successful pivot | Tried approach A, failed, approach B worked | 0.5–0.7 |
200
+ | Project-specific convention discovered | "This codebase uses X pattern for Y" | 0.4–0.6 |
201
+ | One-off preference (may not generalize) | User chose a specific library once | 0.3–0.4 |
202
+
203
+ **Promotion to global**: When the same instinct (matching trigger+action) appears in `.rune/instincts.md` across 2+ projects at confidence ≥0.8, promote it to Neural Memory via Step 6 with tag `[cross-project, instinct]`. Until then, it stays project-local.
204
+
205
+ **Pruning**: At session start (Load Mode Step 1), review instincts older than 30 days with confidence <0.5 — remove them. Instincts that conflict with current conventions should be removed immediately.
206
+
207
+ **Max instincts**: Keep `.rune/instincts.md` under 20 entries. When full, evict the lowest-confidence entry.
208
+
209
+ #### Step 5.8 — Learnings Log (Structured JSONL)
210
+
211
+ Append structured learning entries to `.rune/learnings.jsonl` — an append-only log that captures decisions, insights, and error resolutions in a machine-queryable format. Unlike markdown state files (which are for human reading), JSONL enables fast filtering and "latest winner" lookups.
212
+
213
+ **Entry schema**one JSON object per line:
214
+
215
+ ```json
216
+ {"ts":"2026-04-04T14:30:00Z","skill":"cook","type":"decision","key":"state-lib","insight":"Chose Zustand over Redux fewer re-renders in dashboard with 50+ real-time widgets","confidence":0.8,"files":["src/store/index.ts"]}
217
+ ```
218
+
219
+ | Field | Type | Description |
220
+ |-------|------|-------------|
221
+ | `ts` | ISO 8601 | When the learning was captured |
222
+ | `skill` | string | Which skill produced this learning |
223
+ | `type` | enum | `decision` · `error` · `insight` · `convention` · `performance` |
224
+ | `key` | string | Dedup key latest entry per key+type wins on read |
225
+ | `insight` | string | 1-2 sentences, causal language ("Chose X because Y", "Root cause was X") |
226
+ | `confidence` | 0.1–1.0 | How certain this learning is (0.3=hunch, 0.7=validated, 0.9=battle-tested) |
227
+ | `files` | string[] | Optional affected file paths |
228
+
229
+ **Write rules:**
230
+ - Append only never edit or delete lines in the JSONL file
231
+ - Max 1-3 entries per session (only genuinely transferable learnings)
232
+ - Use causal/comparative language, not flat facts
233
+ - Key must be kebab-case, descriptive (e.g., `auth-lib`, `db-migration-strategy`, `react-hook-pitfall`)
234
+
235
+ **Read rules (latest-winner):**
236
+ - When loading learnings, group by `key+type` and take the entry with the latest `ts`
237
+ - This means updating a learning = just append a new entry with the same key+type
238
+ - No dedup needed on write — dedup happens on read
239
+
240
+ **Query patterns** (for other skills or session-start):
241
+ - All learnings: read `.rune/learnings.jsonl`, parse line-by-line
242
+ - By type: filter `type === "error"` to surface past mistakes before coding
243
+ - By skill: filter `skill === "cook"` to see cook-specific learnings
244
+ - By recency: sort by `ts` descending, take top N
245
+ - Surface top 5 learnings at session start if file has 10+ entries
246
+
247
+ **Pruning**: When file exceeds 100 entries, compact by keeping only the latest-winner per key+type. Write compacted entries to a new file, replace original.
248
+
249
+ **Why**: Markdown state files (decisions.md, conventions.md) are great for human reading but hard to query programmatically. JSONL enables structured recall — "show me all errors from last week" or "what did we decide about auth?" — without parsing markdown headers.
250
+
251
+ #### Step 5.9 — Cumulative Project Notes (Structured Memory)
252
+
253
+ Maintain a running **cumulative notes** file at `.rune/cumulative-notes.md` that evolves across sessions. Unlike `progress.md` (which tracks tasks) or `decisions.md` (which logs choices), cumulative notes capture the **living understanding** of the project — patterns learned, relationships discovered, recurring themes, and open threads.
254
+
255
+ **Format** use these fixed sections (add content, never remove prior entries):
256
+
257
+ ```markdown
258
+ # Cumulative Project Notes
259
+
260
+ ## Project Profile
261
+ - [Core purpose of the project — 1 sentence]
262
+ - [Primary users/audience]
263
+ - [Key technical constraints e.g., "must run offline", "latency-critical", "multi-tenant"]
264
+
265
+ ## Architecture Map
266
+ - [Key modules and their responsibilities — discovered over sessions]
267
+ - [Critical data flows — e.g., "user input → validation → API → DB → cache invalidation"]
268
+ - [Integration pointsexternal APIs, services, databases]
269
+
270
+ ## Recurring Themes
271
+ - [Patterns that keep coming up across sessions — e.g., "auth edge cases", "migration complexity"]
272
+ - [Common failure modes — what breaks and why]
273
+ - [Technical debt hotspots areas that repeatedly cause issues]
274
+
275
+ ## Active Topics
276
+ - [What's currently being worked on — updated each session]
277
+ - [Open questions that haven't been resolved yet]
278
+ - [Experiments in progress]
279
+
280
+ ## Relationship Map
281
+ - [Key files and their dependencies — "changing X requires updating Y"]
282
+ - [People and their areas — "Alice owns auth, Bob owns payments"]
283
+ - [External service dependencies "Stripe webhook order.complete handler"]
284
+
285
+ ## Follow-Up Items
286
+ - [ ] [Things noted but not yet addressed — carry forward until done]
287
+ - [ ] [Ideas that came up during work but were out of scope]
288
+
289
+ ## Attention Points
290
+ - [Things the next session should be aware of — fragile areas, pending PRs, deadlines]
291
+ - [Temporary workarounds that need proper fixes]
292
+ ```
293
+
294
+ **Update rules:**
295
+ - **Create** the file on first session-bridge save if it doesn't exist
296
+ - **Append** to existing sectionsnever overwrite prior entries (they represent accumulated knowledge)
297
+ - **Prune** entries older than 60 days in Recurring Themes and Relationship Map — these may be stale
298
+ - **Move** completed Follow-Up Items to a `## Resolved` section at the bottom (keep last 10)
299
+ - **Keep under 200 lines** — if approaching limit, summarize older entries in each section
300
+
301
+ **Why**: Individual state files (decisions.md, progress.md) capture discrete events. Cumulative notes capture the **emergent understanding** that develops over many sessions — the kind of knowledge that's lost when context resets. This is the project's "institutional memory."
302
+
303
+ #### Step 6 — Cross-Project Knowledge Extraction (Neural Memory Bridge)
304
+
305
+ Before committing, extract generalizable patterns from this session for cross-project reuse:
306
+
307
+ 1. Review the session's decisions, conventions, and completed tasks
308
+ 2. Identify 1-3 patterns that are NOT project-specific but would help in OTHER projects:
309
+ - Technology choices with reasoning ("Chose Redis over Memcached because X")
310
+ - Architecture patterns ("Fan-out queue pattern solved Y")
311
+ - Failure modes discovered ("React 19 useEffect cleanup breaks when Z")
312
+ - Performance insights ("N+1 query pattern in Prisma solved by include")
313
+ 3. For each generalizable pattern, save to Neural Memory:
314
+ - Use `nmem_remember` with rich cognitive language (causal, comparative, decisional)
315
+ - Tags: `[cross-project, <technology>, <pattern-type>]`
316
+ - Priority: 6-7 (important enough to surface in other projects)
317
+ 4. Skip if session was purely project-specific (config changes, bug fixes with no transferable insight)
318
+
319
+ **Why**: This turns every project session into learning that compounds across ALL projects. A pattern discovered in Project A auto-surfaces when Project B faces a similar problem.
320
+
321
+ #### Step 7 — Commit
322
+
323
+ Stage and commit all updated state files:
324
+
325
+ ```bash
326
+ git add .rune/ && git commit -m "chore: update rune session state"
327
+ ```
328
+
329
+ If git is not available or the directory is not a repo, skip the commit and emit a warning.
330
+
331
+ ---
332
+
333
+ ### Load Mode (start of session)
334
+
335
+ #### Step 1 — Check existence
336
+
337
+ Use `Glob` to check for `.rune/` directory:
338
+
339
+ ```
340
+ Glob pattern: .rune/*.md
341
+ ```
342
+
343
+ If no files found: suggest running `/rune onboard` to initialize the project. Exit load mode.
344
+
345
+ #### Step 1.5 — Integrity verification
346
+
347
+ Before loading state files, invoke `integrity-check` (L3) to verify `.rune/` files haven't been tampered:
348
+
349
+ ```
350
+ REQUIRED SUB-SKILL: rune:integrity-check
351
+ → Invoke integrity-check on all .rune/*.md files found in Step 1.
352
+ Capture: status (CLEAN | SUSPICIOUS | TAINTED), findings list.
353
+ ```
354
+
355
+ Handle results:
356
+ - `CLEAN` → proceed to Step 2 (load files)
357
+ - `SUSPICIOUS` present warning to user with specific findings. Ask: "Suspicious patterns detected in .rune/ files. Load anyway?" If user approves → proceed. If not → exit load mode.
358
+ - `TAINTED` → **BLOCK load**. Report: ".rune/ integrity check FAILED — possible poisoning detected. Run `/rune integrity` for details."
359
+
360
+ #### Step 1.7 — Load invariants (auto-discipline)
361
+
362
+ Before loading the usual state files, run the invariants loader so the agent sees active discipline rules without being told to look:
363
+
364
+ ```
365
+ Execute: node skills/session-bridge/scripts/load-invariants.js --root <project-root> --json
366
+ ```
367
+
368
+ The loader:
369
+ - Reads `.rune/INVARIANTS.md` (silent no-op if missing)
370
+ - Strips the `## Archived` section (retired rules don't re-activate)
371
+ - Parses active rules into `{ section, title, what, where, why }`
372
+ - Returns a token-budgeted preview (≤ 500 tokens by default)
373
+ - Flags staleness when mtime > 30 days
374
+
375
+ **Emit signal**: `invariants.loaded` with payload `{ loaded, count, rules, stats, stale, overflow, path }` where:
376
+ - `loaded` (boolean) whether any active rules were parsed
377
+ - `count` (number) total active rules (convenience alias for `stats.total`)
378
+ - `rules` (array) — full rule objects `[{ section, title, what, where: string[], why }]` consumers cache these for glob matching
379
+ - `stats` `{ danger, critical, state, cross, total, archivedSkipped }`
380
+ - `stale` (boolean) — mtime > 30 days
381
+ - `overflow` (number)rules present but not shown in preview (budget overflow)
382
+ - `path` (string) — absolute path to `.rune/INVARIANTS.md`
383
+
384
+ Downstream listeners (`logic-guardian`, Pro `autopilot`) consume `rules[]` directly — no second file read needed.
385
+
386
+ **Present to agent** (injected verbatim into the Load Mode summary):
387
+
388
+ ```
389
+ 📎 Active Invariants (.rune/INVARIANTS.md)
390
+ ⚠ skills/skill-router/** — L0 router, never bypass
391
+ 🔒 compiler/parser.js IR schema is the adapter contract
392
+ 🔁 compiler/hooks/dispatch.js — phase order is pre → run → post
393
+ 🔗 .claude-plugin/marketplace.json mirrors plugin.json
394
+ …+2 more rules in .rune/INVARIANTS.md
395
+ ```
396
+
397
+ **Staleness warning** (emit ONCE per session, not per tool call):
398
+
399
+ ```
400
+ ⚠ Invariants file is stale (> 30 days since last onboard). Consider `rune onboard --refresh`.
401
+ ```
402
+
403
+ **Failure modes**:
404
+ - Missing file silent no-op (no preview, no error). Don't nag fresh repos.
405
+ - Malformed file → `loaded: false, rules: []`. Log a single-line warning, continue.
406
+ - File fails `integrity-check` in Step 1.5 → this step is skipped entirely (load already blocked).
407
+
408
+ #### Step 2Load files
409
+
410
+ Use `Read` on all four state files in parallel:
411
+
412
+ ```
413
+ Read: .rune/decisions.md
414
+ Read: .rune/conventions.md
415
+ Read: .rune/progress.md
416
+ Read: .rune/session-log.md
417
+ Read: .rune/cumulative-notes.md
418
+ ```
419
+
420
+ #### Step 3 — Summarize
421
+
422
+ Present the loaded context to the agent in a structured summary:
423
+
424
+ > "Here's what happened in previous sessions:"
425
+ > - Last session: [last line from session-log.md]
426
+ > - Key decisions: [last 3 entries from decisions.md]
427
+ > - Active conventions: [count from conventions.md]
428
+ > - Current progress: [in-progress and blocked items from progress.md]
429
+ > - Project understanding: [Active Topics + Attention Points from cumulative-notes.md]
430
+ > - Next task: [first item under "Next Session Should" from progress.md]
431
+
432
+ #### Step 4 — Resume
433
+
434
+ Identify the next concrete task from `progress.md` → "Next Session Should" section. Present it as the recommended starting point to the calling orchestrator.
435
+
436
+ ### Checkpoint Mode (explicit save-and-resume point)
437
+
438
+ Unlike Save Mode (which captures session state broadly), Checkpoint Mode creates an **exact resume point** — a single file that tells the next session precisely where to pick up, what's in-flight, and what decisions are load-bearing.
439
+
440
+ **Trigger**: User says `/checkpoint`, or `cook`/`team` emits `checkpoint.request` signal when pausing mid-phase.
441
+
442
+ #### Step 1 Capture resume state
443
+
444
+ Collect into a structured checkpoint:
445
+
446
+ ```markdown
447
+ # Checkpoint — [YYYY-MM-DD HH:MM]
448
+
449
+ ## What I Was Doing
450
+ [1-2 sentences: the exact task and sub-step in progress]
451
+
452
+ ## Current Git State
453
+ - Branch: [branch name]
454
+ - Last commit: [short hash + message]
455
+ - Uncommitted changes: [list of modified/untracked files, or "clean"]
456
+ - Stashed: [yes/no if yes, stash message]
457
+
458
+ ## Decisions Made This Session (Load-Bearing)
459
+ [Only decisions that affect the remaining work — not all decisions]
460
+ - [Decision 1]: [choice + why]
461
+ - [Decision 2]: [choice + why]
462
+
463
+ ## What's Left (Ordered)
464
+ 1. [Next immediate step be specific: file, function, what to change]
465
+ 2. [Step after that]
466
+ 3. [Remaining steps...]
467
+
468
+ ## Context the Next Session Needs
469
+ [Critical info that's NOT in the code or git history — mental model, gotchas discovered, things tried and failed]
470
+ - [Item 1]
471
+ - [Item 2]
472
+
473
+ ## Resume Command
474
+ [Exact instruction for the next session to pick up e.g., "Continue Phase 2 Task 3: implement the retry logic in src/api/client.ts, the happy path is done, need error handling"]
475
+ ```
476
+
477
+ #### Step 2 — Write checkpoint file
478
+
479
+ Write to `.rune/checkpoint.md` (overwrite only one active checkpoint at a time).
480
+
481
+ #### Step 3 — Confirm to user
482
+
483
+ ```
484
+ ## Checkpoint Saved
485
+ - **Resume point**: [1-line summary of what to continue]
486
+ - **Git state**: [branch] @ [commit hash] — [clean/N uncommitted files]
487
+ - **Remaining tasks**: [count]
488
+ - Next session will auto-detect this checkpoint and offer to resume.
489
+ ```
490
+
491
+ #### Checkpoint Resume (in Load Mode)
492
+
493
+ At Load Mode Step 1, after checking `.rune/*.md` existence, also check for `.rune/checkpoint.md`:
494
+
495
+ - If checkpoint exists, read it FIRST (before other state files)
496
+ - Present the resume point prominently:
497
+ ```
498
+ ## Checkpoint Detected — [date]
499
+ **Resume**: [Resume Command from checkpoint]
500
+ **Git state**: [branch] @ [commit] — [clean/dirty]
501
+ **Tasks remaining**: [count]
502
+ ```
503
+ - After successful resume (user confirms they've picked up where they left off), rename checkpoint:
504
+ ```bash
505
+ mv .rune/checkpoint.md .rune/checkpoint-[date].resolved.md
506
+ ```
507
+ - Keep last 3 resolved checkpoints for history, delete older ones
508
+
509
+ **Why**: Save Mode captures everything broadly. Checkpoint captures the **exact needle position** like a bookmark in a book vs. a summary of chapters read. The next session doesn't need to scan all state files to figure out what to do; the checkpoint tells it directly.
510
+
511
+ ## Output Format
512
+
513
+ ### Save Mode
514
+ ```
515
+ ## Session Bridge Saved
516
+ - **decisions.md**: [N] decisions appended
517
+ - **conventions.md**: [N] conventions appended
518
+ - **progress.md**: updated (completed/in-progress/blocked counts)
519
+ - **session-log.md**: 1 entry appended
520
+ - **Git commit**: [hash] | skipped (no git)
521
+ ```
522
+
523
+ ### Load Mode
524
+ ```
525
+ ## Session Bridge Loaded
526
+ - **Last session**: [date and summary]
527
+ - **Checkpoint**: [detected resume point] | [none]
528
+ - **Invariants**: [N loaded from .rune/INVARIANTS.md] | [none] | [stale — run rune onboard --refresh]
529
+ - **Decisions on file**: [count]
530
+ - **Conventions on file**: [count]
531
+ - **Learnings on file**: [count] (top 5 surfaced if 10+)
532
+ - **Next task**: [task description]
533
+ ```
534
+
535
+ ### Checkpoint Mode
536
+ ```
537
+ ## Checkpoint Saved
538
+ - **Resume point**: [1-line summary]
539
+ - **Git state**: [branch] @ [hash] — [clean/N files]
540
+ - **Remaining tasks**: [count]
541
+ ```
542
+
543
+ ## Constraints
544
+
545
+ 1. MUST save decisions, conventions, and progress — not just a status line
546
+ 2. MUST verify saved context can be loaded in a fresh session — test the round-trip
547
+ 3. MUST NOT overwrite existing bridge data without merging
548
+
549
+ ## Sharp Edges
550
+
551
+ Known failure modes for this skill. Check these before declaring done.
552
+
553
+ | Failure Mode | Severity | Mitigation |
554
+ |---|---|---|
555
+ | Overwriting existing .rune/ files instead of appending | HIGH | Constraint 3: use Edit to append entries — never Write to overwrite existing state |
556
+ | Saving only a status line, missing decisions/conventions | HIGH | Constraint 1: all three files (decisions, conventions, progress) must be updated |
557
+ | Load mode presenting stale context without age marker | MEDIUM | Mark each loaded entry with its session date — caller knows how fresh it is |
558
+ | Silent failure when git unavailable | MEDIUM | Note "no git available" in report — do not fail silently or skip without logging |
559
+ | Loading poisoned .rune/ files without verification | CRITICAL | Step 1.5 integrity-check MUST run before loading — TAINTED = block load |
560
+ | Learnings JSONL grows unbounded | MEDIUM | Auto-compact at 100 entries — keep only latest-winner per key+type |
561
+ | Checkpoint stale after code changes | MEDIUM | Checkpoint includes git state — if branch/commit differ at resume, warn user that checkpoint may be outdated |
562
+ | Multiple checkpoints overwrite each other | LOW | By design — only one active checkpoint. Resolved ones archived with date suffix |
563
+
564
+ ## Done When (Save Mode)
565
+
566
+ - decisions.md updated with all architectural decisions made this session
567
+ - conventions.md updated with all new patterns established
568
+ - progress.md updated with completed/in-progress/blocked task status
569
+ - session-log.md appended with one-line session summary
570
+ - learnings.jsonl appended with 1-3 structured entries (if transferable learnings exist)
571
+ - Git commit made (or "no git" noted in report)
572
+ - Session Bridge Saved report emitted
573
+
574
+ ## Done When (Load Mode)
575
+
576
+ - .rune/*.md files found and read
577
+ - Checkpoint detected and presented (if exists)
578
+ - Learnings surfaced (top 5 if 10+ entries)
579
+ - Last session summary presented
580
+ - Current in-progress and blocked tasks identified
581
+ - Next task recommendation from progress.md (or checkpoint resume command)
582
+ - Session Bridge Loaded report emitted
583
+
584
+ ## Done When (Checkpoint Mode)
585
+
586
+ - Git state captured (branch, commit, uncommitted files)
587
+ - Load-bearing decisions documented
588
+ - Remaining tasks listed in execution order
589
+ - Resume command written (specific enough for a fresh session to act on)
590
+ - checkpoint.md written to .rune/
591
+ - Checkpoint Saved report emitted
592
+
593
+ ## Cost Profile
594
+
595
+ ~100-300 tokens per save. ~500-1000 tokens per load. Always haiku. Negligible cost.