one-code-extension 0.4.0 → 0.5.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 (419) hide show
  1. package/README.md +219 -219
  2. package/agents/general-purpose.md +2 -2
  3. package/docs/guide/README.md +2 -1
  4. package/docs/guide/bring-your-claude-code-setup.md +60 -9
  5. package/docs/guide/configuration.md +48 -14
  6. package/docs/guide/differences-from-claude-code.md +32 -23
  7. package/docs/guide/doctor.md +20 -13
  8. package/docs/guide/hooks.md +18 -3
  9. package/docs/guide/installation.md +27 -4
  10. package/docs/guide/permissions-modes-and-auto-mode.md +225 -49
  11. package/docs/guide/providers-and-models.md +137 -54
  12. package/docs/guide/reference.md +27 -15
  13. package/docs/guide/sessions-and-context.md +69 -16
  14. package/docs/guide/skills-plugins-and-mcp.md +57 -20
  15. package/docs/guide/subagents-and-workflows.md +95 -29
  16. package/docs/guide/tasks-and-background-work.md +101 -26
  17. package/docs/guide/terminal-interface.md +24 -12
  18. package/docs/guide/tools.md +46 -5
  19. package/docs/guide/troubleshooting.md +13 -9
  20. package/docs/guide/windows.md +66 -34
  21. package/extensions/artifacts/gallery.ts +227 -0
  22. package/extensions/artifacts/index.ts +288 -0
  23. package/extensions/artifacts/store.ts +570 -0
  24. package/extensions/artifacts/viewer.ts +199 -0
  25. package/extensions/ask-user/description.ts +67 -0
  26. package/extensions/ask-user/dialogs.ts +80 -0
  27. package/extensions/ask-user/index.ts +37 -33
  28. package/extensions/ask-user/questions.ts +32 -7
  29. package/extensions/ask-user/widget.ts +45 -25
  30. package/extensions/auto-mode/actions.ts +6 -0
  31. package/extensions/auto-mode/cache.ts +88 -0
  32. package/extensions/auto-mode/classifier-prompt.ts +5 -4
  33. package/extensions/auto-mode/classifier.ts +290 -65
  34. package/extensions/auto-mode/config.ts +72 -20
  35. package/extensions/auto-mode/decision-log.ts +2 -0
  36. package/extensions/auto-mode/defaults.ts +1 -1
  37. package/extensions/auto-mode/denials.ts +123 -0
  38. package/extensions/auto-mode/git-checkout-programs.ts +187 -0
  39. package/extensions/auto-mode/git-status-meta.ts +159 -0
  40. package/extensions/auto-mode/history.ts +189 -0
  41. package/extensions/auto-mode/instructions.ts +58 -52
  42. package/extensions/auto-mode/model-select.ts +159 -134
  43. package/extensions/auto-mode/paths.ts +57 -5
  44. package/extensions/auto-mode/pause.ts +57 -2
  45. package/extensions/auto-mode/prompt.ts +37 -21
  46. package/extensions/auto-mode/read-only-options.ts +724 -0
  47. package/extensions/auto-mode/resolved-paths-meta.ts +133 -0
  48. package/extensions/auto-mode/rules.ts +18 -1
  49. package/extensions/auto-mode/safety-floor.ts +361 -18
  50. package/extensions/auto-mode/setup-run.ts +20 -14
  51. package/extensions/auto-mode/shell-analysis.ts +764 -490
  52. package/extensions/auto-mode/shell-parse.ts +885 -0
  53. package/extensions/auto-mode/system-note.ts +33 -0
  54. package/extensions/auto-mode/transcript.ts +80 -51
  55. package/extensions/background/cron.ts +515 -0
  56. package/extensions/background/index.ts +514 -236
  57. package/extensions/background/loop-fire.ts +136 -0
  58. package/extensions/background/loop-preamble.ts +59 -0
  59. package/extensions/background/loop-skill.ts +163 -0
  60. package/extensions/background/monitor-batch.ts +53 -0
  61. package/extensions/background/noop-fold.ts +128 -0
  62. package/extensions/background/switch-guard.ts +52 -0
  63. package/extensions/background/wakeup.ts +159 -55
  64. package/extensions/bash/background.ts +53 -17
  65. package/extensions/bash/child.ts +7 -0
  66. package/extensions/bash/description.ts +188 -0
  67. package/extensions/bash/guards.ts +15 -67
  68. package/extensions/bash/index.ts +88 -35
  69. package/extensions/branding/compaction-keep.ts +63 -0
  70. package/extensions/branding/declined.ts +22 -0
  71. package/extensions/branding/index.ts +133 -9
  72. package/extensions/branding/prompt-editor.ts +53 -6
  73. package/extensions/branding/queued-edit.ts +31 -0
  74. package/extensions/branding/replaced-builtins.ts +68 -0
  75. package/extensions/branding/startup.ts +33 -71
  76. package/extensions/btw/index.ts +229 -71
  77. package/extensions/btw/panel.ts +228 -100
  78. package/extensions/btw/prompt.ts +41 -4
  79. package/extensions/claude-compat/index.ts +7 -11
  80. package/extensions/claude-context/index.ts +446 -58
  81. package/extensions/compaction/cut.ts +157 -0
  82. package/extensions/compaction/index.ts +216 -75
  83. package/extensions/compaction/kept-thinking.ts +62 -0
  84. package/extensions/compaction/prompt.ts +15 -12
  85. package/extensions/context-budget/index.ts +24 -5
  86. package/extensions/context-management/index.ts +25 -0
  87. package/extensions/doctor/build.ts +59 -8
  88. package/extensions/doctor/builtins.ts +84 -0
  89. package/extensions/doctor/cli.ts +7 -1
  90. package/extensions/doctor/compat.ts +88 -23
  91. package/extensions/doctor/dependencies.ts +41 -5
  92. package/extensions/doctor/fix-prompt.ts +9 -2
  93. package/extensions/doctor/index.ts +102 -58
  94. package/extensions/doctor/models.ts +102 -63
  95. package/extensions/doctor/presets.ts +42 -27
  96. package/extensions/doctor/report.ts +19 -2
  97. package/extensions/doctor/viewer.ts +49 -27
  98. package/extensions/effort/index.ts +72 -19
  99. package/extensions/effort/settings.ts +21 -0
  100. package/extensions/effort/slider.ts +24 -20
  101. package/extensions/exit/index.ts +32 -1
  102. package/extensions/file-tracker/index.ts +337 -26
  103. package/extensions/file-tracker/replay.ts +96 -10
  104. package/extensions/file-tracker/restore.ts +63 -0
  105. package/extensions/file-tracker/results.ts +66 -0
  106. package/extensions/file-tracker/shell-reads.ts +211 -0
  107. package/extensions/file-tracker/tracker.ts +32 -15
  108. package/extensions/footer/footer-line.ts +45 -24
  109. package/extensions/footer/index.ts +47 -2
  110. package/extensions/footer/pr.ts +34 -5
  111. package/extensions/hooks/compaction.ts +7 -0
  112. package/extensions/hooks/executor.ts +32 -30
  113. package/extensions/hooks/index.ts +198 -31
  114. package/extensions/hooks/matcher.ts +3 -0
  115. package/extensions/hooks/protocol.ts +41 -3
  116. package/extensions/hooks/settings.ts +50 -19
  117. package/extensions/hooks/subagent-bridge.ts +2 -0
  118. package/extensions/hooks/trust.ts +13 -5
  119. package/extensions/idle-compact/index.ts +119 -0
  120. package/extensions/idle-compact/policy.ts +143 -0
  121. package/extensions/init/index.ts +11 -10
  122. package/extensions/init/prompt.ts +25 -32
  123. package/extensions/interrupted/index.ts +13 -1
  124. package/extensions/kept-thinking/index.ts +27 -0
  125. package/extensions/lib/agent-cron.ts +130 -0
  126. package/extensions/lib/agent-loader.ts +15 -1
  127. package/extensions/lib/agent-view.ts +85 -0
  128. package/extensions/lib/anthropic-payload.ts +82 -1
  129. package/extensions/lib/anthropic-server-call.ts +230 -0
  130. package/extensions/lib/anthropic-server-tools.ts +485 -0
  131. package/extensions/lib/app-launch.mjs +94 -0
  132. package/extensions/lib/argument-hints.ts +190 -0
  133. package/extensions/lib/atomic-write.ts +6 -2
  134. package/extensions/lib/auto-memory.ts +75 -0
  135. package/extensions/lib/bash-parser.ts +84 -0
  136. package/extensions/lib/btw-fork.ts +93 -0
  137. package/extensions/lib/child-extensions.ts +42 -0
  138. package/extensions/lib/child-writes.ts +45 -0
  139. package/extensions/lib/claude-context.ts +515 -100
  140. package/extensions/lib/claude-external-includes.ts +68 -0
  141. package/extensions/lib/claude-id.ts +22 -0
  142. package/extensions/lib/claude-rules.ts +323 -0
  143. package/extensions/lib/claude-settings.ts +76 -4
  144. package/extensions/lib/compaction-boundary.ts +36 -0
  145. package/extensions/lib/compaction-keep.mjs +83 -0
  146. package/extensions/lib/config-mode.ts +112 -0
  147. package/extensions/lib/consent-dialogs.ts +63 -0
  148. package/extensions/lib/consent-preview.ts +5 -1
  149. package/extensions/lib/consent-stores.ts +48 -0
  150. package/extensions/lib/context-facts.ts +78 -0
  151. package/extensions/lib/context-stack.ts +81 -0
  152. package/extensions/lib/deferred.ts +219 -25
  153. package/extensions/lib/dock-rows.ts +60 -0
  154. package/extensions/lib/empty-tool-result.ts +27 -0
  155. package/extensions/lib/environment-block.ts +76 -0
  156. package/extensions/lib/fetch-timeout.ts +24 -6
  157. package/extensions/{system-prompt → lib}/git-status.ts +51 -13
  158. package/extensions/lib/git.ts +75 -13
  159. package/extensions/lib/grammars/LICENSE-tree-sitter-bash +21 -0
  160. package/extensions/lib/grammars/README.md +2 -0
  161. package/extensions/lib/grammars/tree-sitter-bash.wasm +0 -0
  162. package/extensions/lib/guide-docs.ts +45 -0
  163. package/extensions/lib/headless-output.ts +46 -0
  164. package/extensions/lib/hook-gate.ts +7 -7
  165. package/extensions/lib/interrupt.ts +20 -4
  166. package/extensions/lib/key-input.ts +455 -0
  167. package/extensions/lib/keys.ts +14 -1
  168. package/extensions/lib/local-command.ts +47 -13
  169. package/extensions/lib/mcp-overrides.ts +1 -1
  170. package/extensions/lib/mcp-share.ts +46 -0
  171. package/extensions/lib/memory-content.ts +146 -0
  172. package/extensions/lib/memory-index.ts +18 -0
  173. package/extensions/lib/memory.ts +134 -123
  174. package/extensions/lib/model-catalog/huggingface.json +174 -0
  175. package/extensions/lib/model-catalog/models-dev.json +18297 -0
  176. package/extensions/lib/model-catalog/openrouter.json +5252 -0
  177. package/extensions/lib/model-catalog-data.ts +513 -0
  178. package/extensions/lib/model-catalog.ts +462 -0
  179. package/extensions/lib/model-choice-warnings.ts +137 -0
  180. package/extensions/lib/model-pairings.ts +152 -0
  181. package/extensions/{auto-mode → lib}/model-picker.ts +26 -43
  182. package/extensions/lib/model-policy.ts +112 -15
  183. package/extensions/lib/model-tier.ts +283 -355
  184. package/extensions/lib/model-unusable.ts +1 -1
  185. package/extensions/lib/newer-model.ts +100 -0
  186. package/extensions/lib/notices.ts +87 -0
  187. package/extensions/lib/notifications.ts +308 -64
  188. package/extensions/lib/one-code-settings.ts +74 -8
  189. package/extensions/lib/open-browser.ts +63 -0
  190. package/extensions/lib/openrouter-generation.ts +94 -0
  191. package/extensions/lib/operation-deadline.ts +30 -0
  192. package/extensions/lib/original-command.ts +4 -4
  193. package/extensions/lib/package-version.ts +1 -1
  194. package/extensions/lib/panel-focus.ts +134 -0
  195. package/extensions/lib/paths.ts +17 -2
  196. package/extensions/lib/permission-gate.ts +72 -6
  197. package/extensions/lib/persisted-output.ts +60 -8
  198. package/extensions/lib/pi-ai-estimate.ts +19 -3
  199. package/extensions/lib/pi-version.ts +21 -2
  200. package/extensions/lib/plan-mode-channels.ts +20 -5
  201. package/extensions/lib/plugins.ts +26 -17
  202. package/extensions/lib/powershell-parse-script.ts +208 -0
  203. package/extensions/lib/powershell-parser.ts +344 -0
  204. package/extensions/lib/process-tree.ts +131 -8
  205. package/extensions/lib/prompt-options.ts +82 -0
  206. package/extensions/lib/queued-delivery.ts +44 -0
  207. package/extensions/lib/reminders.ts +364 -58
  208. package/extensions/lib/replaced-builtins.mjs +199 -0
  209. package/extensions/lib/replay-call.ts +70 -0
  210. package/extensions/lib/request-replay.ts +439 -0
  211. package/extensions/lib/scratchpad.ts +81 -14
  212. package/extensions/lib/send-now-channel.ts +7 -0
  213. package/extensions/lib/session-model-tier.ts +51 -0
  214. package/extensions/lib/session-work.ts +64 -0
  215. package/extensions/lib/settings-channels.ts +4 -4
  216. package/extensions/lib/shell-exit-semantics.ts +170 -0
  217. package/extensions/lib/shell-quote.ts +11 -0
  218. package/extensions/lib/shell-result.ts +70 -0
  219. package/extensions/lib/shell-spawn.ts +70 -6
  220. package/extensions/lib/shell-tool.ts +75 -25
  221. package/extensions/lib/side-call-cache.ts +124 -0
  222. package/extensions/lib/side-call-run.ts +96 -0
  223. package/extensions/lib/side-call-usage.ts +38 -0
  224. package/extensions/lib/side-call.ts +13 -1
  225. package/extensions/lib/single-flight.ts +18 -0
  226. package/extensions/lib/skill-body.ts +42 -0
  227. package/extensions/lib/skill-scan.ts +63 -24
  228. package/extensions/lib/spill-file.ts +140 -0
  229. package/extensions/lib/subagent-handback.ts +113 -0
  230. package/extensions/lib/system-role.ts +156 -0
  231. package/extensions/lib/terminal-text.ts +114 -0
  232. package/extensions/lib/text-width.ts +47 -16
  233. package/extensions/lib/timer-ops.ts +20 -0
  234. package/extensions/lib/tool-additions.ts +149 -0
  235. package/extensions/lib/tool-call-corruption.ts +134 -0
  236. package/extensions/lib/tool-path.ts +66 -0
  237. package/extensions/lib/tool-variants.ts +69 -0
  238. package/extensions/lib/tui-render.ts +255 -27
  239. package/extensions/lib/turn-budget-layout.ts +143 -0
  240. package/extensions/lib/update-check.mjs +15 -2
  241. package/extensions/lib/usage-bus.ts +1 -1
  242. package/extensions/lib/user-denial.ts +38 -0
  243. package/extensions/lib/workspace-channel.ts +16 -0
  244. package/extensions/lib/worktree-channel.ts +31 -3
  245. package/extensions/lib/worktree-isolation.ts +40 -10
  246. package/extensions/lsp/client.ts +8 -9
  247. package/extensions/lsp/index.ts +70 -4
  248. package/extensions/lsp/keep-alive.ts +1 -1
  249. package/extensions/lsp/trust.ts +119 -0
  250. package/extensions/lsp/watcher.ts +1 -1
  251. package/extensions/mcp/announce.ts +87 -5
  252. package/extensions/mcp/client.ts +161 -48
  253. package/extensions/mcp/config.ts +132 -8
  254. package/extensions/mcp/discovery.ts +19 -0
  255. package/extensions/mcp/index.ts +209 -71
  256. package/extensions/mcp/oauth/browser.ts +38 -17
  257. package/extensions/mcp/oauth/flow.ts +25 -17
  258. package/extensions/mcp/oauth/provider.ts +14 -8
  259. package/extensions/mcp/oauth/store.ts +34 -16
  260. package/extensions/mcp/panel/keys.ts +12 -11
  261. package/extensions/mcp/panel/render.ts +9 -6
  262. package/extensions/mcp/schema.ts +104 -5
  263. package/extensions/mcp/trust.ts +151 -67
  264. package/extensions/memory/entries.ts +23 -14
  265. package/extensions/memory/index.ts +134 -28
  266. package/extensions/memory/open-external.ts +33 -18
  267. package/extensions/memory/panel.ts +135 -26
  268. package/extensions/newer-model/index.ts +31 -0
  269. package/extensions/notebook/description.ts +18 -0
  270. package/extensions/notebook/index.ts +6 -5
  271. package/extensions/notebook/notebook.ts +1 -1
  272. package/extensions/permissions/index.ts +1300 -381
  273. package/extensions/permissions/matcher.ts +425 -74
  274. package/extensions/permissions/modes.ts +6 -4
  275. package/extensions/permissions/panel/host.ts +130 -0
  276. package/extensions/permissions/panel/keys.ts +48 -0
  277. package/extensions/permissions/panel/render.ts +450 -0
  278. package/extensions/permissions/panel/state.ts +550 -0
  279. package/extensions/permissions/powershell-cmdlets.ts +198 -0
  280. package/extensions/permissions/powershell-paths.ts +197 -0
  281. package/extensions/permissions/powershell-rules.ts +207 -280
  282. package/extensions/permissions/powershell-tree.ts +557 -0
  283. package/extensions/permissions/project-trust.ts +27 -11
  284. package/extensions/permissions/protected-paths.ts +14 -2
  285. package/extensions/permissions/session-grant.ts +6 -0
  286. package/extensions/permissions/settings.ts +166 -31
  287. package/extensions/permissions/subagent-gate.ts +25 -0
  288. package/extensions/permissions/workspace.ts +78 -0
  289. package/extensions/plan-mode/index.ts +156 -69
  290. package/extensions/plan-mode/reminder.ts +89 -21
  291. package/extensions/plan-mode/texts.ts +177 -0
  292. package/extensions/plan-mode/viewer.ts +92 -27
  293. package/extensions/plugins/counts.ts +3 -3
  294. package/extensions/plugins/index.ts +61 -46
  295. package/extensions/plugins/install/install.ts +16 -0
  296. package/extensions/plugins/marketplace/sync.ts +9 -3
  297. package/extensions/plugins/marketplace/types.ts +3 -1
  298. package/extensions/plugins/panel/keys.ts +21 -24
  299. package/extensions/plugins/panel/render.ts +12 -6
  300. package/extensions/plugins/shell-expand.ts +107 -0
  301. package/extensions/plugins/template.ts +32 -15
  302. package/extensions/powershell/child.ts +7 -0
  303. package/extensions/powershell/description.ts +38 -6
  304. package/extensions/powershell/guards.ts +1 -1
  305. package/extensions/powershell/index.ts +12 -7
  306. package/extensions/recap/index.ts +65 -60
  307. package/extensions/recap/prompt.ts +2 -2
  308. package/extensions/recap/scheduler.ts +3 -5
  309. package/extensions/search-tools/grep-merge.ts +39 -0
  310. package/extensions/search-tools/index.ts +0 -0
  311. package/extensions/send-now/chord.ts +62 -0
  312. package/extensions/send-now/index.ts +133 -0
  313. package/extensions/session-title/index.ts +3 -0
  314. package/extensions/session-title/title.ts +4 -1
  315. package/extensions/skill/code-review.ts +97 -0
  316. package/extensions/skill/index.ts +421 -101
  317. package/extensions/skill/invoke.ts +128 -18
  318. package/extensions/skill/listing.ts +133 -9
  319. package/extensions/skill/panel/keys.ts +15 -16
  320. package/extensions/skill/panel/render.ts +5 -2
  321. package/extensions/skill/panel/state.ts +12 -1
  322. package/extensions/subagents/agent-args.ts +39 -0
  323. package/extensions/subagents/agent-description.ts +132 -0
  324. package/extensions/subagents/agents.ts +116 -23
  325. package/extensions/subagents/announce.ts +69 -0
  326. package/extensions/subagents/default-model.ts +2 -3
  327. package/extensions/subagents/delegation-steer.ts +4 -4
  328. package/extensions/subagents/fork-cache.ts +76 -0
  329. package/extensions/subagents/guide-agent.ts +189 -0
  330. package/extensions/subagents/hand-back-review.ts +3 -0
  331. package/extensions/subagents/index.ts +1493 -824
  332. package/extensions/subagents/live-runs.ts +26 -6
  333. package/extensions/subagents/model-select.ts +38 -25
  334. package/extensions/subagents/outcome.ts +2 -2
  335. package/extensions/subagents/panel-keys.ts +73 -31
  336. package/extensions/subagents/panel-render.ts +120 -96
  337. package/extensions/subagents/panel-widget.ts +60 -89
  338. package/extensions/subagents/runner.ts +108 -80
  339. package/extensions/subagents/runs.ts +39 -5
  340. package/extensions/subagents/send-to-main-tool.ts +1 -1
  341. package/extensions/subagents/session-turns.ts +32 -8
  342. package/extensions/subagents/shell-panel.ts +36 -178
  343. package/extensions/subagents/tasks-dialog.ts +170 -0
  344. package/extensions/subagents/viewport-mirror.ts +95 -0
  345. package/extensions/subagents/worktree.ts +57 -13
  346. package/extensions/system-prompt/environment.ts +19 -19
  347. package/extensions/system-prompt/idle-turn.ts +65 -0
  348. package/extensions/system-prompt/index.ts +131 -47
  349. package/extensions/system-prompt/template.ts +24 -50
  350. package/extensions/system-prompt/tiers/common.ts +23 -64
  351. package/extensions/system-prompt/tiers/frontier.ts +32 -11
  352. package/extensions/system-prompt/tiers/low.ts +67 -45
  353. package/extensions/system-prompt/tiers/mid.ts +96 -38
  354. package/extensions/system-reminder/index.ts +175 -13
  355. package/extensions/tasks/descriptions.ts +190 -0
  356. package/extensions/tasks/index.ts +120 -41
  357. package/extensions/tasks/store.ts +83 -16
  358. package/extensions/tool-call-corruption/child.ts +7 -0
  359. package/extensions/tool-call-corruption/index.ts +237 -0
  360. package/extensions/tool-search/announce.ts +16 -0
  361. package/extensions/tool-search/index.ts +189 -41
  362. package/extensions/tool-style/index.ts +68 -10
  363. package/extensions/tool-style/write-description.ts +40 -0
  364. package/extensions/tool-style/write-render.ts +237 -0
  365. package/extensions/turn-duration/index.ts +7 -3
  366. package/extensions/turn-duration/line.ts +47 -4
  367. package/extensions/web/backends.ts +6 -9
  368. package/extensions/web/description.ts +50 -0
  369. package/extensions/web/index.ts +118 -53
  370. package/extensions/web/native-call.ts +15 -0
  371. package/extensions/web/native-results.ts +41 -0
  372. package/extensions/web-fetch/description.ts +42 -0
  373. package/extensions/web-fetch/extract.ts +53 -6
  374. package/extensions/web-fetch/index.ts +125 -76
  375. package/extensions/web-fetch/page-content.ts +19 -0
  376. package/extensions/web-fetch/response.ts +49 -0
  377. package/extensions/web-fetch/summarize.ts +9 -10
  378. package/extensions/workflow/agent-session.ts +105 -18
  379. package/extensions/workflow/args.ts +24 -0
  380. package/extensions/workflow/description.ts +67 -0
  381. package/extensions/workflow/globals.ts +17 -3
  382. package/extensions/workflow/index.ts +145 -162
  383. package/extensions/workflow/records.ts +1 -0
  384. package/extensions/workflow/run-manager.ts +29 -6
  385. package/extensions/workflow/saved-workflows.ts +3 -2
  386. package/extensions/workflow/types.ts +22 -1
  387. package/extensions/workflow/viewer.ts +54 -24
  388. package/extensions/workflow/widget.ts +20 -0
  389. package/extensions/worktree/descriptions.ts +91 -0
  390. package/extensions/worktree/guards.ts +316 -54
  391. package/extensions/worktree/index.ts +121 -39
  392. package/extensions/worktree/powershell-guards.ts +167 -0
  393. package/extensions/worktree/rewrite.ts +14 -16
  394. package/package.json +19 -7
  395. package/skills/artifact-design/SKILL.md +85 -0
  396. package/skills/code-review/SKILL.md +20 -20
  397. package/skills/code-review/cells/arguments-and-flags.md +19 -0
  398. package/skills/code-review/cells/high-3x5-recall-verify.md +137 -0
  399. package/skills/code-review/cells/high-8-inline.md +122 -0
  400. package/skills/code-review/cells/low-1-pass-max4.md +27 -0
  401. package/skills/code-review/cells/low-1-pass-min-files-4.md +28 -0
  402. package/skills/code-review/cells/max-5x5-verify-sweep.md +162 -0
  403. package/skills/code-review/cells/medium-3x5-verify.md +132 -0
  404. package/skills/code-review/cells/minimal-prompt.md +32 -0
  405. package/skills/code-review/cells/xhigh-10-inline-sweep.md +149 -0
  406. package/skills/code-review/cells/xhigh-5x5-verify-sweep.md +162 -0
  407. package/skills/fewer-permission-prompts/SKILL.md +1 -1
  408. package/skills/loop/SKILL.md +11 -0
  409. package/skills/security-review/SKILL.md +2 -5
  410. package/skills/simplify/SKILL.md +7 -5
  411. package/skills/workflow-authoring/SKILL.md +143 -0
  412. package/themes/onecode-light.json +1 -1
  413. package/themes/onecode.json +1 -1
  414. package/types/app.d.ts +58 -0
  415. package/types/community-packages.d.ts +26 -1
  416. package/extensions/auto-mode/recoverability.ts +0 -229
  417. package/extensions/lib/capability-index.ts +0 -466
  418. package/extensions/lib/model-facts.generated.json +0 -2675
  419. package/extensions/lib/model-facts.ts +0 -162
@@ -0,0 +1,146 @@
1
+ /**
2
+ * MEMORY.md and memory-file content: Claude Code's index load limits and
3
+ * truncation, and the frontmatter stamp written into memory files. Kept apart
4
+ * from `memory.ts`, whose path helpers most extensions import, so only the
5
+ * memory and doctor extensions load the YAML and instruction parsers.
6
+ */
7
+
8
+ import { isMap, isScalar, parseDocument, visit } from "yaml";
9
+ import { parseRule } from "./claude-rules.ts";
10
+
11
+ /**
12
+ * Claude Code loads only the first 200 lines or 25,000 characters of
13
+ * MEMORY.md, whichever comes first, and tells the model what it cut (see
14
+ * `truncateIndex`). Mirror that so an overgrown index behaves identically
15
+ * here. The limits are measured against what actually loads: YAML frontmatter
16
+ * and block-level HTML comments are stripped first, and surrounding
17
+ * whitespace does not count. Claude Code measures string length, not UTF-8
18
+ * bytes.
19
+ */
20
+ export const INDEX_MAX_LINES = 200;
21
+ export const INDEX_MAX_CHARS = 25_000;
22
+
23
+ /** The index uses Claude Code's instruction parser before applying its load limits. */
24
+ export function loadableIndexContent(content: string): string {
25
+ return parseRule(content).content;
26
+ }
27
+
28
+ /** Line and character counts of the index as the limits measure it. */
29
+ function indexSize(loadable: string): { trimmed: string; lines: number; chars: number } {
30
+ const trimmed = loadable.trim();
31
+ return { trimmed, lines: trimmed.split("\n").length, chars: trimmed.length };
32
+ }
33
+
34
+ /**
35
+ * The index as it loads. Within the limits it is the loadable content as is.
36
+ * Past either limit it is cut the way Claude Code cuts it: to the first 200
37
+ * lines, then back to the last line break within 25,000 characters, followed
38
+ * by Claude Code's warning line naming what was cut, so the model knows the
39
+ * index goes on. The result ends in a newline, so the next section of the
40
+ * context block starts on a line of its own.
41
+ */
42
+ export function truncateIndex(content: string): string {
43
+ const loadable = loadableIndexContent(content);
44
+ const { trimmed, lines, chars } = indexSize(loadable);
45
+ const overLines = lines > INDEX_MAX_LINES;
46
+ const overChars = chars > INDEX_MAX_CHARS;
47
+ if (!overLines && !overChars) return loadable;
48
+
49
+ let kept = overLines ? trimmed.split("\n").slice(0, INDEX_MAX_LINES).join("\n") : trimmed;
50
+ if (kept.length > INDEX_MAX_CHARS) {
51
+ const lastBreak = kept.lastIndexOf("\n", INDEX_MAX_CHARS);
52
+ kept = kept.slice(0, lastBreak > 0 ? lastBreak : INDEX_MAX_CHARS);
53
+ }
54
+ const keptLines = trimmed[kept.length] === "\n" ? kept.split("\n").length : 0;
55
+ const nextStart = kept.length + 1;
56
+ const nextEnd = trimmed.indexOf("\n", nextStart);
57
+ const nextLine = trimmed.slice(nextStart, nextEnd < 0 ? undefined : nextEnd).trim();
58
+ const cut =
59
+ keptLines === 0
60
+ ? `everything after the first ${kept.length} characters of line 1 was cut off`
61
+ : `${lines - keptLines} of ${lines} lines were cut off, starting at line ${keptLines + 1}${nextLine ? ` ("${shortenLine(nextLine, 80)}")` : ""}`;
62
+ const size =
63
+ overChars && !overLines
64
+ ? `${formatSize(chars)} (limit: ${formatSize(INDEX_MAX_CHARS)}) \u2014 index entries are too long`
65
+ : overLines && !overChars
66
+ ? `${lines} lines (limit: ${INDEX_MAX_LINES})`
67
+ : `${lines} lines and ${formatSize(chars)}`;
68
+ return `${kept}\n\n> WARNING: MEMORY.md is ${size}. Only part of it was loaded: ${cut}. Keep index entries to one line under ~200 chars; move detail into topic files.\n`;
69
+ }
70
+
71
+ /** A size the way Claude Code prints it: `N bytes`, else `N.NKB`/`MB` with a trailing `.0` dropped. */
72
+ function formatSize(n: number): string {
73
+ const units = ["KB", "MB", "GB"];
74
+ let value = n / 1024;
75
+ if (value < 1) return `${n} bytes`;
76
+ let unit = 0;
77
+ while (value >= 1024 && unit < units.length - 1) {
78
+ value /= 1024;
79
+ unit++;
80
+ }
81
+ return `${value.toFixed(1).replace(/\.0$/, "")}${units[unit]}`;
82
+ }
83
+
84
+ /** Claude Code's quote of the first cut line: at most `max` characters, cut at a word when that keeps over half. */
85
+ function shortenLine(text: string, max: number): string {
86
+ if (text.length <= max) return text;
87
+ const head = [...text].slice(0, max - 1).join("");
88
+ const lastSpace = head.search(/\s\S*$/);
89
+ const atWord = lastSpace === -1 ? "" : head.slice(0, lastSpace).trimEnd();
90
+ return `${atWord.length > max / 2 ? atWord : head.trimEnd()}\u2026`;
91
+ }
92
+
93
+ /**
94
+ * Where the index stands against its load limits, checked after each write so
95
+ * the model hears about an overgrown index while it can still fix it (Claude
96
+ * Code behaves the same: near-limit reminder, over-limit error — the write
97
+ * itself always succeeds).
98
+ */
99
+ export function indexLimitStatus(content: string): "ok" | "near" | "over" {
100
+ const { lines, chars } = indexSize(loadableIndexContent(content));
101
+ if (lines > INDEX_MAX_LINES || chars > INDEX_MAX_CHARS) return "over";
102
+ if (lines >= INDEX_MAX_LINES * 0.9 || chars >= INDEX_MAX_CHARS * 0.9) return "near";
103
+ return "ok";
104
+ }
105
+
106
+ export const INDEX_NEAR_LIMIT_REMINDER = `MEMORY.md is approaching its load limit (only the first ${INDEX_MAX_LINES} lines or 25KB are loaded each session). Shorten it now: keep one line per entry, move detail into topic files in the memory directory, and merge or drop stale entries.`;
107
+
108
+ export const INDEX_OVER_LIMIT_ERROR = `MEMORY.md is over its load limit (${INDEX_MAX_LINES} lines / 25KB): everything past the limit is dropped the next time it is loaded. The write succeeded, but rewrite the index now — one line per entry, move detail into topic files, merge or drop stale entries.`;
109
+
110
+ /**
111
+ * Stamp safe YAML memory headers, retaining the originating session on updates.
112
+ * Claude Code's ue/Mt preserve originSessionId; Dn declines unsafe rewrites.
113
+ * Keep comments, flow mappings, BOM/CRLF and the body; leave malformed headers,
114
+ * aliases and non-mapping metadata untouched rather than losing user content.
115
+ */
116
+ export function stampFrontmatter(content: string, sessionId: string, modifiedIso: string): string {
117
+ if (/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F]/.test(content)) return content;
118
+ const match = content.match(/^(\uFEFF?---[ \t]*\r?\n)([\s\S]*?)(\r?\n---[ \t]*(?:\r?\n|$))/);
119
+ if (!match) return content;
120
+
121
+ // Claude Code checks its permissive parser against strict delimiters before
122
+ // rewriting: a quoted value containing "---" can make the header ambiguous.
123
+ const parsedBoundary = content.replace(/^\uFEFF/, "").match(/^---\s*\n([\s\S]*?)---\s*\n?/);
124
+ if (parsedBoundary?.[1].trim() !== match[2].trim()) return content;
125
+
126
+ const document = parseDocument(match[2]);
127
+ if (document.errors.length || document.warnings.length || !isMap(document.contents)) return content;
128
+ let hasAlias = false;
129
+ visit(document, { Alias: () => { hasAlias = true; } });
130
+ if (hasAlias) return content;
131
+
132
+ if (document.get("metadata") == null) document.set("metadata", document.createNode({}));
133
+ const metadata = document.get("metadata", true);
134
+ if (!isMap(metadata)) return content;
135
+
136
+ metadata.set("node_type", "memory");
137
+ const nodeIndex = metadata.items.findIndex((pair) => isScalar(pair.key) && pair.key.value === "node_type");
138
+ metadata.items.unshift(...metadata.items.splice(nodeIndex, 1));
139
+ const origin = metadata.get("originSessionId");
140
+ if (typeof origin !== "string" || !origin) metadata.set("originSessionId", sessionId);
141
+ metadata.set("modified", modifiedIso);
142
+
143
+ let yaml = document.toString().replace(/\n$/, "");
144
+ if (match[1].endsWith("\r\n")) yaml = yaml.replaceAll("\n", "\r\n");
145
+ return match[1] + yaml + match[3] + content.slice(match[0].length);
146
+ }
@@ -0,0 +1,18 @@
1
+ /** Read the startup/compaction memory index without loading excluded or non-text files. */
2
+ import os from "node:os";
3
+ import { join } from "node:path";
4
+ import { isClaudeLocation, readFileIfPresent } from "./claude-context.ts";
5
+ import { autoMemoryEnabled } from "./auto-memory.ts";
6
+ import { claudeSourcesOn } from "./config-mode.ts";
7
+ import { projectMemoryDir } from "./memory.ts";
8
+ import { truncateIndex } from "./memory-content.ts";
9
+ import { claudeUserDir } from "./paths.ts";
10
+
11
+ export function readMemoryIndex(cwd: string, home: string = os.homedir()): { path: string; content: string } | null {
12
+ if (!autoMemoryEnabled(cwd)) return null;
13
+ const path = join(projectMemoryDir(cwd, home), "MEMORY.md");
14
+ if (!claudeSourcesOn() && isClaudeLocation(path, claudeUserDir(home))) return null;
15
+ const raw = readFileIfPresent(path);
16
+ if (!raw?.trim() || raw.includes("\0")) return null;
17
+ return { path, content: truncateIndex(raw) };
18
+ }
@@ -18,21 +18,29 @@
18
18
 
19
19
  import os from "node:os";
20
20
  import { join } from "node:path";
21
+ import { userConfigDir } from "./config-mode.ts";
21
22
  import { findProjectRoot } from "./git.ts";
22
- import { claudeUserDir } from "./paths.ts";
23
23
 
24
- /** Claude Code's project-directory slug: every char outside [A-Za-z0-9-] becomes "-". */
24
+ /** Claude Code's project-directory slug: 200 sanitized characters, then a hash for longer paths. */
25
25
  export function projectSlug(projectRoot: string): string {
26
- return projectRoot.replace(/[^A-Za-z0-9-]/g, "-");
26
+ const slug = projectRoot.replace(/[^A-Za-z0-9-]/g, "-");
27
+ if (slug.length <= 200) return slug;
28
+
29
+ let hash = 0;
30
+ for (let i = 0; i < projectRoot.length; i++) {
31
+ hash = ((hash << 5) - hash + projectRoot.charCodeAt(i)) | 0;
32
+ }
33
+ return `${slug.slice(0, 200)}-${Math.abs(hash).toString(36)}`;
27
34
  }
28
35
 
29
36
  /**
30
- * `~/.claude/projects/<slug>/memory` — the same location Claude Code uses.
37
+ * `~/.claude/projects/<slug>/memory` — the same location Claude Code uses —
38
+ * or, in independent mode (lib/config-mode.ts), `~/.onecode/projects/<slug>/memory`.
31
39
  * `projectRoot` must be the git repository root when there is one (all
32
40
  * worktrees and subdirectories share one memory directory), else the cwd.
33
41
  */
34
42
  export function memoryDir(home: string, projectRoot: string): string {
35
- return join(claudeUserDir(home), "projects", projectSlug(projectRoot), "memory");
43
+ return join(userConfigDir(home), "projects", projectSlug(projectRoot), "memory");
36
44
  }
37
45
 
38
46
  /**
@@ -46,57 +54,6 @@ export function projectMemoryDir(cwd: string, home: string = os.homedir()): stri
46
54
  return memoryDir(home, findProjectRoot(cwd) ?? cwd);
47
55
  }
48
56
 
49
- /**
50
- * Claude Code loads only the first 200 lines or 25KB of MEMORY.md, whichever
51
- * comes first; the rest is silently dropped. Mirror that so an overgrown index
52
- * behaves identically here. The limits are measured against what actually
53
- * loads: YAML frontmatter and block-level HTML comments are stripped first.
54
- */
55
- export const INDEX_MAX_LINES = 200;
56
- export const INDEX_MAX_BYTES = 25_000;
57
-
58
- /** The index content that loads: frontmatter and whole-line HTML comments removed. */
59
- export function loadableIndexContent(content: string): string {
60
- let out = content;
61
- if (out.startsWith("---\n")) {
62
- const close = out.indexOf("\n---", 3);
63
- if (close !== -1) {
64
- const lineEnd = out.indexOf("\n", close + 1 + 3);
65
- out = lineEnd === -1 ? "" : out.slice(lineEnd + 1);
66
- }
67
- }
68
- return out.replace(/^[ \t]*<!--[\s\S]*?-->[ \t]*\n?/gm, "");
69
- }
70
-
71
- export function truncateIndex(content: string): string {
72
- let out = loadableIndexContent(content).split("\n").slice(0, INDEX_MAX_LINES).join("\n");
73
- if (Buffer.byteLength(out, "utf8") > INDEX_MAX_BYTES) {
74
- out = Buffer.from(out, "utf8").subarray(0, INDEX_MAX_BYTES).toString("utf8");
75
- // A byte cut can split a multi-byte character; drop the replacement char.
76
- out = out.replace(/�+$/, "");
77
- }
78
- return out;
79
- }
80
-
81
- /**
82
- * Where the index stands against its load limits, checked after each write so
83
- * the model hears about an overgrown index while it can still fix it (Claude
84
- * Code behaves the same: near-limit reminder, over-limit error — the write
85
- * itself always succeeds).
86
- */
87
- export function indexLimitStatus(content: string): "ok" | "near" | "over" {
88
- const loadable = loadableIndexContent(content);
89
- const lines = loadable.split("\n").length;
90
- const bytes = Buffer.byteLength(loadable, "utf8");
91
- if (lines > INDEX_MAX_LINES || bytes > INDEX_MAX_BYTES) return "over";
92
- if (lines >= INDEX_MAX_LINES * 0.9 || bytes >= INDEX_MAX_BYTES * 0.9) return "near";
93
- return "ok";
94
- }
95
-
96
- export const INDEX_NEAR_LIMIT_REMINDER = `MEMORY.md is approaching its load limit (only the first ${INDEX_MAX_LINES} lines or 25KB are loaded each session). Shorten it now: keep one line per entry, move detail into topic files in the memory directory, and merge or drop stale entries.`;
97
-
98
- export const INDEX_OVER_LIMIT_ERROR = `MEMORY.md is over its load limit (${INDEX_MAX_LINES} lines / 25KB): everything past the limit is dropped the next time it is loaded. The write succeeded, but rewrite the index now — one line per entry, move detail into topic files, merge or drop stale entries.`;
99
-
100
57
  /**
101
58
  * Claude Code's soft size limit for a context file (CLAUDE.md/AGENTS.md/ONECODE.md):
102
59
  * over ~40k chars it warns at startup that the file is bloating the context, and
@@ -129,49 +86,15 @@ export function combinedLimitWarning(totalChars: number): string | null {
129
86
  return `Project instructions total ${k(totalChars)} chars, over the ${k(CLAUDE_MD_CHAR_LIMIT)}-char limit · /memory to free up context`;
130
87
  }
131
88
 
132
- /**
133
- * Claude Code stamps bookkeeping fields into a memory file's frontmatter at
134
- * write time: node_type, the writing session's id, and a modified timestamp
135
- * (observed in real memory files; `modified` is also documented). A file
136
- * without frontmatter is left untouched — Claude Code never adds frontmatter
137
- * to one, which also keeps MEMORY.md unstamped. Line-based on the template's
138
- * `metadata:` mapping; a re-stamp replaces the previous values.
139
- */
140
- export function stampFrontmatter(content: string, sessionId: string, modifiedIso: string): string {
141
- if (!content.startsWith("---\n")) return content;
142
- const close = content.indexOf("\n---", 3);
143
- if (close === -1) return content;
144
-
145
- const body = content.slice(4, close);
146
- const rest = content.slice(close);
147
- const lines = body.split("\n").filter((l) => !/^\s{2}(node_type|originSessionId|modified):/.test(l));
148
-
149
- const metaIndex = lines.findIndex((l) => /^metadata:\s*$/.test(l));
150
- const tail = [` originSessionId: ${sessionId}`, ` modified: ${modifiedIso}`];
151
- let out: string[];
152
- if (metaIndex === -1) {
153
- out = [...lines, "metadata:", " node_type: memory", ...tail];
154
- } else {
155
- let childEnd = metaIndex + 1;
156
- while (childEnd < lines.length && /^\s+\S/.test(lines[childEnd])) childEnd++;
157
- out = [
158
- ...lines.slice(0, metaIndex + 1),
159
- " node_type: memory",
160
- ...lines.slice(metaIndex + 1, childEnd),
161
- ...tail,
162
- ...lines.slice(childEnd),
163
- ];
164
- }
165
- return `---\n${out.join("\n")}${rest}`;
166
- }
167
89
 
168
90
  /**
169
- * The `# Memory` system prompt section, kept close to Claude Code's wording.
170
- * Depends only on the directory path (and the fixed `verbose` flag for a given
171
- * tier), so the prompt stays byte-stable across turns for a given cwd.
91
+ * The memory system prompt section, in Claude Code's wording with the tool
92
+ * named `write`. Depends only on the directory path (and the fixed `verbose`
93
+ * flag for a given tier), so the prompt stays byte-stable across turns for a
94
+ * given cwd.
172
95
  *
173
- * `verbose` selects the long, explicit spec (Claude Code's Haiku memory prompt,
174
- * adapted) for the workhorse/cheap/tiny tiers; frontier gets the compact version.
96
+ * `verbose` selects Claude Code's long `# auto memory` spec (its long register)
97
+ * for the workhorse/cheap/tiny tiers; frontier gets the compact `# Memory`.
175
98
  */
176
99
  export function memoryPromptSection(dir: string, verbose = false): string {
177
100
  return verbose ? verboseMemorySection(dir) : compactMemorySection(dir);
@@ -185,7 +108,7 @@ You have a persistent file-based memory at \`${dir}/\`. This directory already e
185
108
  \`\`\`markdown
186
109
  ---
187
110
  name: <short-kebab-case-slug>
188
- description: <one-line summary — used to decide relevance during recall>
111
+ description: <one-line summary, used to decide relevance during recall>
189
112
  metadata:
190
113
  type: user | feedback | project | reference
191
114
  ---
@@ -195,57 +118,145 @@ metadata:
195
118
 
196
119
  In the body, link to related memories with \`[[name]]\`, where \`name\` is the other memory's \`name:\` slug. Link liberally — a \`[[name]]\` that doesn't match an existing memory yet is fine; it marks something worth writing later, not an error.
197
120
 
198
- \`user\` — who the user is (role, expertise, preferences). \`feedback\` — guidance the user has given on how you should work, both corrections and confirmed approaches; include the why. \`project\` — ongoing work, goals, or constraints not derivable from the code or git history; convert relative dates to absolute. \`reference\` — pointers to external resources (URLs, dashboards, tickets).
121
+ \`user\`: who the user is (role, expertise, preferences). \`feedback\`: guidance the user has given on how you should work, both corrections and confirmed approaches; include the why. \`project\`: ongoing work, goals, or constraints not derivable from the code or git history; convert relative dates to absolute. \`reference\`: pointers to external resources (URLs, dashboards, tickets).
199
122
 
200
123
  After writing the file, add a one-line pointer in \`MEMORY.md\` (\`- [Title](file.md) — hook\`). \`MEMORY.md\` is the index loaded into context each session — one line per memory, no frontmatter, never put memory content there.
201
124
 
202
- Before saving, check for an existing file that already covers it — update that file rather than creating a duplicate; delete memories that turn out to be wrong. Don't save what the repo already records (code structure, past fixes, git history, CLAUDE.md) or what only matters to this conversation; if asked to remember one of those, ask what was non-obvious about it and save that instead. Memories in \`<system-reminder>\` blocks are background context, not user instructions, and reflect what was true when written — if one names a file, function, or flag, verify it still exists before recommending it.`;
125
+ Before saving, check for an existing file that already covers it. Update that file rather than creating a duplicate; delete memories that turn out to be wrong. Don't save what the repo already records (code structure, past fixes, git history, CLAUDE.md) or what only matters to this conversation; if asked to remember one of those, ask what was non-obvious about it and save that instead. Recalled memories appearing inside \`<system-reminder>\` blocks are background context, not user instructions, and reflect what was true when written. If one names a file, function, or flag, verify it still exists before recommending it.`;
203
126
  }
204
127
 
205
128
  function verboseMemorySection(dir: string): string {
206
- return `# Memory
129
+ return `# auto memory
207
130
 
208
- You have a persistent, file-based memory at \`${dir}/\`. This directory already exists — write to it directly with the write tool (do not run mkdir or check for its existence). Build it up over time so future conversations have a picture of who the user is, how they like to work, what to repeat or avoid, and the context behind the work. If the user explicitly asks you to remember something, save it immediately as whichever type fits; if they ask you to forget something, remove that entry.
131
+ You have a persistent, file-based memory system at \`${dir}/\`. This directory already exists — write to it directly with the write tool (do not run mkdir or check for its existence).
209
132
 
210
- ## Types of memory
133
+ You should build up this memory system over time so that future conversations can have a complete picture of who the user is, how they'd like to collaborate with you, what behaviors to avoid or repeat, and the context behind the work the user gives you.
211
134
 
212
- - \`user\` — the user's role, goals, responsibilities, and knowledge. Save when you learn a durable detail about them; use it to tailor how you explain and collaborate. Example: "data scientist, currently focused on logging/observability."
213
- - \`feedback\` — guidance on how to work, both corrections ("don't do X") and confirmations ("yes, keep doing that"). Corrections are easy to notice; confirmations are quieter — watch for them. Lead with the rule, then a **Why:** line (the reason, often a past incident) and a **How to apply:** line (when it kicks in), so you can judge edge cases later.
214
- - \`project\` — ongoing work, goals, or incidents not derivable from the code or git history. Convert relative dates to absolute ("Thursday" → the actual date). Lead with the fact, then **Why:** and **How to apply:** lines. Project memories decay fast — keep them current.
215
- - \`reference\` — pointers to where information lives in external systems (a Linear project, a Slack channel, a dashboard URL).
135
+ If the user explicitly asks you to remember something, save it immediately as whichever type fits best. If they ask you to forget something, find and remove the relevant entry.
216
136
 
217
- Each memory is one file holding one fact, with frontmatter:
137
+ ## Types of memory
138
+
139
+ There are several discrete types of memory that you can store in your memory system:
140
+
141
+ <types>
142
+ <type>
143
+ <name>user</name>
144
+ <description>Contain information about the user's role, goals, responsibilities, and knowledge. Great user memories help you tailor your future behavior to the user's preferences and perspective. Your goal in reading and writing these memories is to build up an understanding of who the user is and how you can be most helpful to them specifically. For example, you should collaborate with a senior software engineer differently than a student who is coding for the very first time. Keep in mind, that the aim here is to be helpful to the user. Avoid writing memories about the user that could be viewed as a negative judgement or that are not relevant to the work you're trying to accomplish together.</description>
145
+ <when_to_save>When you learn any details about the user's role, preferences, responsibilities, or knowledge</when_to_save>
146
+ <how_to_use>When your work should be informed by the user's profile or perspective. For example, if the user is asking you to explain a part of the code, you should answer that question in a way that is tailored to the specific details that they will find most valuable or that helps them build their mental model in relation to domain knowledge they already have.</how_to_use>
147
+ <examples>
148
+ user: I'm a data scientist investigating what logging we have in place
149
+ assistant: [saves user memory: user is a data scientist, currently focused on observability/logging]
150
+
151
+ user: I've been writing Go for ten years but this is my first time touching the React side of this repo
152
+ assistant: [saves user memory: deep Go expertise, new to React and this project's frontend — frame frontend explanations in terms of backend analogues]
153
+ </examples>
154
+ </type>
155
+ <type>
156
+ <name>feedback</name>
157
+ <description>Guidance the user has given you about how to approach work — both what to avoid and what to keep doing. These are a very important type of memory to read and write as they allow you to remain coherent and responsive to the way you should approach work in the project. Record from failure AND success: if you only save corrections, you will avoid past mistakes but drift away from approaches the user has already validated, and may grow overly cautious.</description>
158
+ <when_to_save>Any time the user corrects your approach ("no not that", "don't", "stop doing X") OR confirms a non-obvious approach worked ("yes exactly", "perfect, keep doing that", accepting an unusual choice without pushback). Corrections are easy to notice; confirmations are quieter — watch for them. In both cases, save what is applicable to future conversations, especially if surprising or not obvious from the code. Include *why* so you can judge edge cases later.</when_to_save>
159
+ <how_to_use>Let these memories guide your behavior so that the user does not need to offer the same guidance twice.</how_to_use>
160
+ <body_structure>Lead with the rule itself, then a **Why:** line (the reason the user gave — often a past incident or strong preference) and a **How to apply:** line (when/where this guidance kicks in). Knowing *why* lets you judge edge cases instead of blindly following the rule.</body_structure>
161
+ <examples>
162
+ user: don't mock the database in these tests — we got burned last quarter when mocked tests passed but the prod migration failed
163
+ assistant: [saves feedback memory: integration tests must hit a real database, not mocks. Reason: prior incident where mock/prod divergence masked a broken migration]
164
+
165
+ user: stop summarizing what you just did at the end of every response, I can read the diff
166
+ assistant: [saves feedback memory: this user wants terse responses with no trailing summaries]
167
+
168
+ user: yeah the single bundled PR was the right call here, splitting this one would've just been churn
169
+ assistant: [saves feedback memory: for refactors in this area, user prefers one bundled PR over many small ones. Confirmed after I chose this approach — a validated judgment call, not a correction]
170
+ </examples>
171
+ </type>
172
+ <type>
173
+ <name>project</name>
174
+ <description>Information that you learn about ongoing work, goals, initiatives, bugs, or incidents within the project that is not otherwise derivable from the code or git history. Project memories help you understand the broader context and motivation behind the work the user is doing within this working directory.</description>
175
+ <when_to_save>When you learn who is doing what, why, or by when. These states change relatively quickly so try to keep your understanding of this up to date. Always convert relative dates in user messages to absolute dates when saving (e.g., "Thursday" → "2026-03-05"), so the memory remains interpretable after time passes.</when_to_save>
176
+ <how_to_use>Use these memories to more fully understand the details and nuance behind the user's request and make better informed suggestions.</how_to_use>
177
+ <body_structure>Lead with the fact or decision, then a **Why:** line (the motivation — often a constraint, deadline, or stakeholder ask) and a **How to apply:** line (how this should shape your suggestions). Project memories decay fast, so the why helps future-you judge whether the memory is still load-bearing.</body_structure>
178
+ <examples>
179
+ user: we're freezing all non-critical merges after Thursday — mobile team is cutting a release branch
180
+ assistant: [saves project memory: merge freeze begins 2026-03-05 for mobile release cut. Flag any non-critical PR work scheduled after that date]
181
+
182
+ user: the reason we're ripping out the old auth middleware is that legal flagged it for storing session tokens in a way that doesn't meet the new compliance requirements
183
+ assistant: [saves project memory: auth middleware rewrite is driven by legal/compliance requirements around session token storage, not tech-debt cleanup — scope decisions should favor compliance over ergonomics]
184
+ </examples>
185
+ </type>
186
+ <type>
187
+ <name>reference</name>
188
+ <description>Stores pointers to where information can be found in external systems. These memories allow you to remember where to look to find up-to-date information outside of the project directory.</description>
189
+ <when_to_save>When you learn about resources in external systems and their purpose. For example, that bugs are tracked in a specific project in Linear or that feedback can be found in a specific Slack channel.</when_to_save>
190
+ <how_to_use>When the user references an external system or information that may be in an external system.</how_to_use>
191
+ <examples>
192
+ user: check the Linear project "INGEST" if you want context on these tickets, that's where we track all pipeline bugs
193
+ assistant: [saves reference memory: pipeline bugs are tracked in Linear project "INGEST"]
194
+
195
+ user: the Grafana board at grafana.internal/d/api-latency is what oncall watches — if you're touching request handling, that's the thing that'll page someone
196
+ assistant: [saves reference memory: grafana.internal/d/api-latency is the oncall latency dashboard — check it when editing request-path code]
197
+ </examples>
198
+ </type>
199
+ </types>
200
+
201
+ ## What NOT to save in memory
202
+
203
+ - Code patterns, conventions, architecture, file paths, or project structure — these can be derived by reading the current project state.
204
+ - Git history, recent changes, or who-changed-what — \`git log\` / \`git blame\` are authoritative.
205
+ - Debugging solutions or fix recipes — the fix is in the code; the commit message has the context.
206
+ - Anything already documented in CLAUDE.md files.
207
+ - Ephemeral task details: in-progress work, temporary state, current conversation context.
208
+
209
+ These exclusions apply even when the user explicitly asks you to save. If they ask you to save a PR list or activity summary, ask what was *surprising* or *non-obvious* about it — that is the part worth keeping.
210
+
211
+ ## How to save memories
212
+
213
+ Saving a memory is a two-step process:
214
+
215
+ **Step 1** — write the memory to its own file (e.g., \`user_role.md\`, \`feedback_testing.md\`) using this frontmatter format:
218
216
 
219
217
  \`\`\`markdown
220
218
  ---
221
- name: <short-kebab-case-slug>
222
- description: <one-line summary — used to decide relevance during recall>
219
+ name: {{short-kebab-case-slug}}
220
+ description: {{one-line summary, used to decide relevance in future conversations, so be specific}}
223
221
  metadata:
224
- type: user | feedback | project | reference
222
+ type: {{user, feedback, project, reference}}
225
223
  ---
226
224
 
227
- <the fact; for feedback/project, follow with **Why:** and **How to apply:** lines.>
225
+ {{memory content — for feedback/project types, structure as: rule/fact, then **Why:** and **How to apply:** lines. Link related memories with [[their-name]].}}
228
226
  \`\`\`
229
227
 
230
- In the body, link to related memories with \`[[name]]\`, where \`name\` is the other memory's \`name:\` slug. Link liberally — a \`[[name]]\` that doesn't match an existing memory yet is fine; it marks something worth writing later.
228
+ In the body, link to related memories with \`[[name]]\`, where \`name\` is the other memory's \`name:\` slug. Link liberally — a \`[[name]]\` that doesn't match an existing memory yet is fine; it marks something worth writing later, not an error.
229
+
230
+ **Step 2** — add a pointer to that file in \`MEMORY.md\`. \`MEMORY.md\` is an index, not a memory — each entry should be one line, under ~150 characters: \`- [Title](file.md) — one-line hook\`. It has no frontmatter. Never write memory content directly into \`MEMORY.md\`.
231
+
232
+ - \`MEMORY.md\` is always loaded into your conversation context — lines after 200 will be truncated, so keep the index concise
233
+ - Keep the name, description, and type fields in memory files up-to-date with the content
234
+ - Organize memory semantically by topic, not chronologically
235
+ - Update or remove memories that turn out to be wrong or outdated
236
+ - Do not write duplicate memories. First check if there is an existing memory you can update before writing a new one.
231
237
 
232
- ## What NOT to save
238
+ ## When to access memories
239
+ - When memories seem relevant, or the user references prior-conversation work.
240
+ - You MUST access memory when the user explicitly asks you to check, recall, or remember.
241
+ - If the user says to *ignore* or *not use* memory: Do not apply remembered facts, cite, compare against, or mention memory content.
242
+ - Memory records can become stale over time. Use memory as context for what was true at a given point in time. Before answering the user or building assumptions based solely on information in memory records, verify that the memory is still correct and up-to-date by reading the current state of the files or resources. If a recalled memory conflicts with current information, trust what you observe now — and update or remove the stale memory rather than acting on it.
233
243
 
234
- - Code patterns, conventions, architecture, file paths, or project structure — read the current project state instead.
235
- - Git history or who-changed-what — \`git log\`/\`git blame\` are authoritative.
236
- - Debugging fixes — the fix is in the code; the commit message has the context.
237
- - Anything already in a CLAUDE.md file, or details that only matter to this conversation.
244
+ ## Before recommending from memory
238
245
 
239
- These exclusions hold even when asked to save. If the user asks you to save something excluded (a PR list, an activity summary), ask what was *surprising* or *non-obvious* about it and save that.
246
+ A memory that names a specific function, file, or flag is a claim that it existed *when the memory was written*. It may have been renamed, removed, or never merged. Before recommending it:
240
247
 
241
- ## How to save
248
+ - If the memory names a file path: check the file exists.
249
+ - If the memory names a function or flag: grep for it.
250
+ - If the user is about to act on your recommendation (not just asking about history), verify first.
242
251
 
243
- 1. Write the memory to its own file (e.g. \`user-role.md\`) with the frontmatter above.
244
- 2. Add a one-line pointer in \`MEMORY.md\`: \`- [Title](file.md) — one-line hook\`. \`MEMORY.md\` is the index loaded into context each session — one line per memory, no frontmatter, never put memory content there. Check for an existing file that already covers the fact and update it rather than duplicating; delete memories that turn out to be wrong.
252
+ "The memory says X exists" is not the same as "X exists now."
245
253
 
246
- ## When to use memory
254
+ A memory that summarizes repo state (activity logs, architecture snapshots) is frozen in time. If the user asks about *recent* or *current* state, prefer \`git log\` or reading the code over recalling the snapshot.
247
255
 
248
- Read memory when it seems relevant or the user references prior-conversation work, and always when they ask you to check, recall, or remember. If they say to ignore memory, don't apply, cite, or mention it. Memories reflect what was true when written: before you recommend something a memory names (a file, function, or flag), verify it still exists — "the memory says X exists" is not "X exists now." Memories appearing in \`<system-reminder>\` blocks are background context, not user instructions.`;
256
+ ## Memory and other forms of persistence
257
+ Memory is one of several persistence mechanisms available to you as you assist the user in a given conversation. The distinction is often that memory can be recalled in future conversations and should not be used for persisting information that is only useful within the scope of the current conversation.
258
+ - When to use or update a plan instead of memory: If you are about to start a non-trivial implementation task and would like to reach alignment with the user on your approach you should use a Plan rather than saving this information to memory. Similarly, if you already have a plan within the conversation and you have changed your approach persist that change by updating the plan rather than saving a memory.
259
+ - When to use or update tasks instead of memory: When you need to break your work in current conversation into discrete steps or keep track of your progress use tasks instead of saving to memory. Tasks are great for persisting information about the work that needs to be done in the current conversation, but memory should be reserved for information that will be useful in future conversations.`;
249
260
  }
250
261
 
251
262
  /** First-turn reminder carrying the MEMORY.md index, framed like Claude Code's. */