@kinqs/brainrouter-mcp-server 0.3.4

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 (337) hide show
  1. package/.env.example +144 -0
  2. package/README.md +56 -0
  3. package/agents/README.md +120 -0
  4. package/agents/code-reviewer.md +97 -0
  5. package/agents/security-auditor.md +101 -0
  6. package/agents/test-engineer.md +95 -0
  7. package/dist/__tests__/agent_mode.test.d.ts +1 -0
  8. package/dist/__tests__/api-routes.test.d.ts +1 -0
  9. package/dist/__tests__/api-routes.test.js +170 -0
  10. package/dist/__tests__/crypto.test.d.ts +1 -0
  11. package/dist/__tests__/crypto.test.js +28 -0
  12. package/dist/__tests__/host-integrations.test.d.ts +1 -0
  13. package/dist/__tests__/host-integrations.test.js +82 -0
  14. package/dist/__tests__/integration.test.d.ts +1 -0
  15. package/dist/__tests__/integration.test.js +50 -0
  16. package/dist/__tests__/loader.test.d.ts +1 -0
  17. package/dist/__tests__/loader.test.js +89 -0
  18. package/dist/__tests__/neural-spark.test.d.ts +1 -0
  19. package/dist/__tests__/neural-spark.test.js +112 -0
  20. package/dist/__tests__/pagination.test.d.ts +1 -0
  21. package/dist/__tests__/pagination.test.js +23 -0
  22. package/dist/__tests__/redaction.test.d.ts +1 -0
  23. package/dist/__tests__/redaction.test.js +17 -0
  24. package/dist/__tests__/registry.test.d.ts +1 -0
  25. package/dist/__tests__/registry.test.js +56 -0
  26. package/dist/__tests__/retry.test.d.ts +1 -0
  27. package/dist/__tests__/retry.test.js +30 -0
  28. package/dist/__tests__/skill-activation.test.d.ts +1 -0
  29. package/dist/__tests__/skill-activation.test.js +112 -0
  30. package/dist/__tests__/working-memory.test.d.ts +1 -0
  31. package/dist/__tests__/working-memory.test.js +200 -0
  32. package/dist/__tests__/workspace-paths.test.d.ts +1 -0
  33. package/dist/__tests__/workspace-paths.test.js +56 -0
  34. package/dist/__tests__/writer.test.d.ts +1 -0
  35. package/dist/__tests__/writer.test.js +94 -0
  36. package/dist/api/auth/crypto.d.ts +4 -0
  37. package/dist/api/auth/crypto.js +54 -0
  38. package/dist/api/middleware/auth.d.ts +12 -0
  39. package/dist/api/middleware/auth.js +90 -0
  40. package/dist/api/pagination.d.ts +18 -0
  41. package/dist/api/pagination.js +32 -0
  42. package/dist/api/routes/auth.d.ts +1 -0
  43. package/dist/api/routes/auth.js +130 -0
  44. package/dist/api/routes/chat-completions.d.ts +7 -0
  45. package/dist/api/routes/chat-completions.js +474 -0
  46. package/dist/api/routes/contradictions.d.ts +1 -0
  47. package/dist/api/routes/contradictions.js +28 -0
  48. package/dist/api/routes/evidence.d.ts +1 -0
  49. package/dist/api/routes/evidence.js +59 -0
  50. package/dist/api/routes/governance.d.ts +1 -0
  51. package/dist/api/routes/governance.js +95 -0
  52. package/dist/api/routes/graph.d.ts +1 -0
  53. package/dist/api/routes/graph.js +25 -0
  54. package/dist/api/routes/hooks.d.ts +1 -0
  55. package/dist/api/routes/hooks.js +88 -0
  56. package/dist/api/routes/memories.d.ts +1 -0
  57. package/dist/api/routes/memories.js +92 -0
  58. package/dist/api/routes/persona.d.ts +1 -0
  59. package/dist/api/routes/persona.js +9 -0
  60. package/dist/api/routes/scenes.d.ts +1 -0
  61. package/dist/api/routes/scenes.js +35 -0
  62. package/dist/api/routes/skills.d.ts +1 -0
  63. package/dist/api/routes/skills.js +14 -0
  64. package/dist/api/routes/stats.d.ts +1 -0
  65. package/dist/api/routes/stats.js +8 -0
  66. package/dist/api/routes/users.d.ts +1 -0
  67. package/dist/api/routes/users.js +82 -0
  68. package/dist/api/routes/working.d.ts +1 -0
  69. package/dist/api/routes/working.js +88 -0
  70. package/dist/index.d.ts +2 -0
  71. package/dist/index.js +492 -0
  72. package/dist/integrations/claude-code.d.ts +12 -0
  73. package/dist/integrations/claude-code.js +35 -0
  74. package/dist/integrations/codex.d.ts +12 -0
  75. package/dist/integrations/codex.js +34 -0
  76. package/dist/integrations/generic-mcp.d.ts +52 -0
  77. package/dist/integrations/generic-mcp.js +118 -0
  78. package/dist/loader.d.ts +29 -0
  79. package/dist/loader.js +200 -0
  80. package/dist/memory/capture.d.ts +35 -0
  81. package/dist/memory/capture.js +230 -0
  82. package/dist/memory/config.d.ts +2 -0
  83. package/dist/memory/config.js +3 -0
  84. package/dist/memory/engine.d.ts +203 -0
  85. package/dist/memory/engine.js +626 -0
  86. package/dist/memory/llm-semaphore.d.ts +41 -0
  87. package/dist/memory/llm-semaphore.js +81 -0
  88. package/dist/memory/memory-type-config.d.ts +11 -0
  89. package/dist/memory/memory-type-config.js +65 -0
  90. package/dist/memory/pipeline/cognitive-contradiction.d.ts +7 -0
  91. package/dist/memory/pipeline/cognitive-contradiction.js +59 -0
  92. package/dist/memory/pipeline/cognitive-dedup.d.ts +23 -0
  93. package/dist/memory/pipeline/cognitive-dedup.js +38 -0
  94. package/dist/memory/pipeline/cognitive-extractor.d.ts +21 -0
  95. package/dist/memory/pipeline/cognitive-extractor.js +183 -0
  96. package/dist/memory/pipeline/contextual-focus-builder.d.ts +13 -0
  97. package/dist/memory/pipeline/contextual-focus-builder.js +135 -0
  98. package/dist/memory/pipeline/focus-direction-shift.d.ts +10 -0
  99. package/dist/memory/pipeline/focus-direction-shift.js +27 -0
  100. package/dist/memory/pipeline/graph-builder.d.ts +11 -0
  101. package/dist/memory/pipeline/graph-builder.js +88 -0
  102. package/dist/memory/pipeline/graph-recall.d.ts +13 -0
  103. package/dist/memory/pipeline/graph-recall.js +55 -0
  104. package/dist/memory/pipeline/identity-distiller.d.ts +15 -0
  105. package/dist/memory/pipeline/identity-distiller.js +40 -0
  106. package/dist/memory/pipeline/l1-contradiction.d.ts +7 -0
  107. package/dist/memory/pipeline/l1-contradiction.js +66 -0
  108. package/dist/memory/pipeline/l1-dedup.d.ts +23 -0
  109. package/dist/memory/pipeline/l1-dedup.js +39 -0
  110. package/dist/memory/pipeline/l1-extractor.d.ts +21 -0
  111. package/dist/memory/pipeline/l1-extractor.js +180 -0
  112. package/dist/memory/pipeline/l2-direction-shift.d.ts +10 -0
  113. package/dist/memory/pipeline/l2-direction-shift.js +27 -0
  114. package/dist/memory/pipeline/l2-scene.d.ts +15 -0
  115. package/dist/memory/pipeline/l2-scene.js +140 -0
  116. package/dist/memory/pipeline/l3-distiller.d.ts +15 -0
  117. package/dist/memory/pipeline/l3-distiller.js +40 -0
  118. package/dist/memory/pipeline/neural-spark.d.ts +27 -0
  119. package/dist/memory/pipeline/neural-spark.js +78 -0
  120. package/dist/memory/pipeline/skill-prewarm.d.ts +63 -0
  121. package/dist/memory/pipeline/skill-prewarm.js +127 -0
  122. package/dist/memory/pipeline/task-queue.d.ts +54 -0
  123. package/dist/memory/pipeline/task-queue.js +117 -0
  124. package/dist/memory/prompts/cognitive-contradiction.d.ts +1 -0
  125. package/dist/memory/prompts/cognitive-contradiction.js +25 -0
  126. package/dist/memory/prompts/cognitive-extraction.d.ts +10 -0
  127. package/dist/memory/prompts/cognitive-extraction.js +114 -0
  128. package/dist/memory/prompts/core-identity.d.ts +6 -0
  129. package/dist/memory/prompts/core-identity.js +60 -0
  130. package/dist/memory/prompts/focus-direction-shift.d.ts +5 -0
  131. package/dist/memory/prompts/focus-direction-shift.js +32 -0
  132. package/dist/memory/prompts/focus-scene-cluster.d.ts +2 -0
  133. package/dist/memory/prompts/focus-scene-cluster.js +33 -0
  134. package/dist/memory/prompts/focus-scene.d.ts +7 -0
  135. package/dist/memory/prompts/focus-scene.js +40 -0
  136. package/dist/memory/prompts/graph-extraction-batch.d.ts +14 -0
  137. package/dist/memory/prompts/graph-extraction-batch.js +54 -0
  138. package/dist/memory/prompts/graph-extraction.d.ts +2 -0
  139. package/dist/memory/prompts/graph-extraction.js +53 -0
  140. package/dist/memory/prompts/l1-contradiction-batch.d.ts +16 -0
  141. package/dist/memory/prompts/l1-contradiction-batch.js +47 -0
  142. package/dist/memory/prompts/l1-contradiction.d.ts +1 -0
  143. package/dist/memory/prompts/l1-contradiction.js +25 -0
  144. package/dist/memory/prompts/l1-extraction.d.ts +10 -0
  145. package/dist/memory/prompts/l1-extraction.js +114 -0
  146. package/dist/memory/prompts/l2-direction-shift.d.ts +5 -0
  147. package/dist/memory/prompts/l2-direction-shift.js +32 -0
  148. package/dist/memory/prompts/l2-scene-cluster.d.ts +2 -0
  149. package/dist/memory/prompts/l2-scene-cluster.js +33 -0
  150. package/dist/memory/prompts/l2-scene.d.ts +7 -0
  151. package/dist/memory/prompts/l2-scene.js +40 -0
  152. package/dist/memory/prompts/l3-persona.d.ts +6 -0
  153. package/dist/memory/prompts/l3-persona.js +60 -0
  154. package/dist/memory/recall.d.ts +47 -0
  155. package/dist/memory/recall.js +427 -0
  156. package/dist/memory/redaction.d.ts +1 -0
  157. package/dist/memory/redaction.js +24 -0
  158. package/dist/memory/retry.d.ts +13 -0
  159. package/dist/memory/retry.js +53 -0
  160. package/dist/memory/scheduler.d.ts +9 -0
  161. package/dist/memory/scheduler.js +16 -0
  162. package/dist/memory/skill-hints-loader.d.ts +30 -0
  163. package/dist/memory/skill-hints-loader.js +100 -0
  164. package/dist/memory/store/embedding.d.ts +16 -0
  165. package/dist/memory/store/embedding.js +68 -0
  166. package/dist/memory/store/reranker.d.ts +24 -0
  167. package/dist/memory/store/reranker.js +83 -0
  168. package/dist/memory/store/sqlite.d.ts +167 -0
  169. package/dist/memory/store/sqlite.js +1816 -0
  170. package/dist/memory/store/types.d.ts +101 -0
  171. package/dist/memory/store/types.js +1 -0
  172. package/dist/memory/types.d.ts +207 -0
  173. package/dist/memory/types.js +7 -0
  174. package/dist/memory/validation.d.ts +441 -0
  175. package/dist/memory/validation.js +129 -0
  176. package/dist/memory/working/canvas.d.ts +5 -0
  177. package/dist/memory/working/canvas.js +43 -0
  178. package/dist/memory/working/offload.d.ts +71 -0
  179. package/dist/memory/working/offload.js +211 -0
  180. package/dist/memory/working/step-log.d.ts +16 -0
  181. package/dist/memory/working/step-log.js +35 -0
  182. package/dist/registry.d.ts +34 -0
  183. package/dist/registry.js +305 -0
  184. package/dist/resolver.d.ts +17 -0
  185. package/dist/resolver.js +126 -0
  186. package/dist/scripts/validate-foreign-workspace-path.d.ts +1 -0
  187. package/dist/scripts/validate-foreign-workspace-path.js +39 -0
  188. package/dist/tools/agent_memory_tools.d.ts +485 -0
  189. package/dist/tools/agent_memory_tools.js +793 -0
  190. package/dist/tools/create_skill.d.ts +46 -0
  191. package/dist/tools/create_skill.js +46 -0
  192. package/dist/tools/get_doc.d.ts +21 -0
  193. package/dist/tools/get_doc.js +24 -0
  194. package/dist/tools/get_persona.d.ts +15 -0
  195. package/dist/tools/get_persona.js +20 -0
  196. package/dist/tools/get_reference.d.ts +15 -0
  197. package/dist/tools/get_reference.js +20 -0
  198. package/dist/tools/get_skill.d.ts +34 -0
  199. package/dist/tools/get_skill.js +65 -0
  200. package/dist/tools/get_template_doc.d.ts +21 -0
  201. package/dist/tools/get_template_doc.js +24 -0
  202. package/dist/tools/list_docs.d.ts +15 -0
  203. package/dist/tools/list_docs.js +16 -0
  204. package/dist/tools/list_skills.d.ts +18 -0
  205. package/dist/tools/list_skills.js +17 -0
  206. package/dist/tools/list_template_docs.d.ts +15 -0
  207. package/dist/tools/list_template_docs.js +16 -0
  208. package/dist/tools/memory-engineering.d.ts +225 -0
  209. package/dist/tools/memory-engineering.js +284 -0
  210. package/dist/tools/memory-explain.d.ts +34 -0
  211. package/dist/tools/memory-explain.js +109 -0
  212. package/dist/tools/memory-governance.d.ts +171 -0
  213. package/dist/tools/memory-governance.js +224 -0
  214. package/dist/tools/memory-hooks.d.ts +67 -0
  215. package/dist/tools/memory-hooks.js +102 -0
  216. package/dist/tools/memory-working.d.ts +98 -0
  217. package/dist/tools/memory-working.js +101 -0
  218. package/dist/tools/memory_capture_turn.d.ts +66 -0
  219. package/dist/tools/memory_capture_turn.js +85 -0
  220. package/dist/tools/memory_consolidate.d.ts +55 -0
  221. package/dist/tools/memory_consolidate.js +176 -0
  222. package/dist/tools/memory_contradictions.d.ts +53 -0
  223. package/dist/tools/memory_contradictions.js +52 -0
  224. package/dist/tools/memory_graph_query.d.ts +51 -0
  225. package/dist/tools/memory_graph_query.js +35 -0
  226. package/dist/tools/memory_mark_cited.d.ts +43 -0
  227. package/dist/tools/memory_mark_cited.js +63 -0
  228. package/dist/tools/memory_recall.d.ts +77 -0
  229. package/dist/tools/memory_recall.js +81 -0
  230. package/dist/tools/memory_register_skill_hints.d.ts +49 -0
  231. package/dist/tools/memory_register_skill_hints.js +55 -0
  232. package/dist/tools/memory_resolve_session.d.ts +24 -0
  233. package/dist/tools/memory_resolve_session.js +133 -0
  234. package/dist/tools/memory_search.d.ts +146 -0
  235. package/dist/tools/memory_search.js +84 -0
  236. package/dist/tools/search_skills.d.ts +18 -0
  237. package/dist/tools/search_skills.js +17 -0
  238. package/dist/tools/update_doc.d.ts +24 -0
  239. package/dist/tools/update_doc.js +35 -0
  240. package/dist/tools/update_skill.d.ts +30 -0
  241. package/dist/tools/update_skill.js +80 -0
  242. package/dist/types.d.ts +81 -0
  243. package/dist/types.js +4 -0
  244. package/dist/writer.d.ts +30 -0
  245. package/dist/writer.js +220 -0
  246. package/docs/TEMPLATE ONLY +1 -0
  247. package/docs/api/API.md +64 -0
  248. package/docs/api/security/SECURITY.md +58 -0
  249. package/docs/deployment/DockerDeployment.md +30 -0
  250. package/docs/design/Design.md +59 -0
  251. package/docs/design/themes/apple.md +101 -0
  252. package/docs/design/themes/dieter-grid.md +100 -0
  253. package/docs/design/themes/gallery-white.md +100 -0
  254. package/docs/design/themes/pinterest.md +101 -0
  255. package/docs/design/themes/realty-open-house.md +101 -0
  256. package/docs/design/themes/vodafone.md +101 -0
  257. package/docs/hooks/Hooks.md +30 -0
  258. package/docs/schema/Schema.md +35 -0
  259. package/docs/strategy/ScalingStrategy.md +19 -0
  260. package/package.json +88 -0
  261. package/references/accessibility-checklist.md +160 -0
  262. package/references/orchestration-patterns.md +370 -0
  263. package/references/performance-checklist.md +153 -0
  264. package/references/security-checklist.md +134 -0
  265. package/references/testing-patterns.md +236 -0
  266. package/skills/agent/adr-skill/SKILL.md +299 -0
  267. package/skills/agent/agentic-engineering-workflow/SKILL.md +95 -0
  268. package/skills/agent/bootstrap-skill/SKILL.md +103 -0
  269. package/skills/agent/context-engineering/SKILL.md +307 -0
  270. package/skills/agent/debugging-and-error-recovery/SKILL.md +308 -0
  271. package/skills/agent/developer-growth-analysis/SKILL.md +328 -0
  272. package/skills/agent/doubt-driven-skill/SKILL.md +249 -0
  273. package/skills/agent/handover-skill/SKILL.md +112 -0
  274. package/skills/agent/idea-refine-skill/SKILL.md +185 -0
  275. package/skills/agent/idea-refine-skill/examples.md +238 -0
  276. package/skills/agent/idea-refine-skill/frameworks.md +99 -0
  277. package/skills/agent/idea-refine-skill/refinement-criteria.md +113 -0
  278. package/skills/agent/interview-skill/SKILL.md +226 -0
  279. package/skills/agent/planning-skill/SKILL.md +270 -0
  280. package/skills/agent/skill-authoring/SKILL.md +189 -0
  281. package/skills/agent/source-driven-skill/SKILL.md +197 -0
  282. package/skills/agent/spec-driven-skill/SKILL.md +221 -0
  283. package/skills/agent/sync-skill/SKILL.md +92 -0
  284. package/skills/agent/using-agent-skills/SKILL.md +189 -0
  285. package/skills/api/a11y-skill/SKILL.md +88 -0
  286. package/skills/api/api-skill/SKILL.md +123 -0
  287. package/skills/api/auth-skill/SKILL.md +80 -0
  288. package/skills/api/debug-skill/SKILL.md +535 -0
  289. package/skills/api/performance-skill/SKILL.md +100 -0
  290. package/skills/api/testing-skill/SKILL.md +100 -0
  291. package/skills/codebase/code-review-and-quality/SKILL.md +228 -0
  292. package/skills/codebase/code-simplification/SKILL.md +352 -0
  293. package/skills/codebase/code-structure-cleanup/SKILL.md +142 -0
  294. package/skills/codebase/concerns-skill/SKILL.md +89 -0
  295. package/skills/codebase/conventions-skill/SKILL.md +95 -0
  296. package/skills/codebase/doc-management-skill/SKILL.md +47 -0
  297. package/skills/codebase/git-workflow-skill/SKILL.md +312 -0
  298. package/skills/communication/1-3-1-rule/SKILL.md +120 -0
  299. package/skills/design/brutalist-skill/SKILL.md +131 -0
  300. package/skills/design/concept-diagrams/SKILL.md +387 -0
  301. package/skills/design/concept-diagrams/examples/apartment-floor-plan-conversion.md +244 -0
  302. package/skills/design/concept-diagrams/examples/automated-password-reset-flow.md +276 -0
  303. package/skills/design/concept-diagrams/examples/autonomous-llm-research-agent-flow.md +240 -0
  304. package/skills/design/concept-diagrams/examples/banana-journey-tree-to-smoothie.md +161 -0
  305. package/skills/design/concept-diagrams/examples/commercial-aircraft-structure.md +209 -0
  306. package/skills/design/concept-diagrams/examples/cpu-ooo-microarchitecture.md +236 -0
  307. package/skills/design/concept-diagrams/examples/electricity-grid-flow.md +182 -0
  308. package/skills/design/concept-diagrams/examples/feature-film-production-pipeline.md +172 -0
  309. package/skills/design/concept-diagrams/examples/hospital-emergency-department-flow.md +165 -0
  310. package/skills/design/concept-diagrams/examples/ml-benchmark-grouped-bar-chart.md +114 -0
  311. package/skills/design/concept-diagrams/examples/place-order-uml-sequence.md +325 -0
  312. package/skills/design/concept-diagrams/examples/smart-city-infrastructure.md +173 -0
  313. package/skills/design/concept-diagrams/examples/smartphone-layer-anatomy.md +154 -0
  314. package/skills/design/concept-diagrams/examples/sn2-reaction-mechanism.md +247 -0
  315. package/skills/design/concept-diagrams/examples/wind-turbine-structure.md +338 -0
  316. package/skills/design/concept-diagrams/references/dashboard-patterns.md +43 -0
  317. package/skills/design/concept-diagrams/references/infrastructure-patterns.md +144 -0
  318. package/skills/design/concept-diagrams/references/physical-shape-cookbook.md +42 -0
  319. package/skills/design/concept-diagrams/templates/template.html +174 -0
  320. package/skills/design/gpt-tasteskill/SKILL.md +114 -0
  321. package/skills/design/minimalist-skill/SKILL.md +116 -0
  322. package/skills/design/output-skill/SKILL.md +87 -0
  323. package/skills/design/redesign-skill/SKILL.md +213 -0
  324. package/skills/design/soft-skill/SKILL.md +132 -0
  325. package/skills/design/stitch-skill/EXAMPLE.md +121 -0
  326. package/skills/design/stitch-skill/SKILL.md +222 -0
  327. package/skills/design/taste-skill/SKILL.md +269 -0
  328. package/skills/devops/ci-cd-skill/SKILL.md +402 -0
  329. package/skills/devops/docker-skill/SKILL.md +297 -0
  330. package/skills/devops/domain-skill/SKILL.md +234 -0
  331. package/skills/lifecycle/changelog-generator/SKILL.md +135 -0
  332. package/skills/lifecycle/incremental-skill/SKILL.md +257 -0
  333. package/skills/lifecycle/migration-skill/SKILL.md +218 -0
  334. package/skills/lifecycle/shipping-skill/SKILL.md +321 -0
  335. package/skills/memory/agent-memory/SKILL.md +122 -0
  336. package/skills/qa/browser-testing-skill/SKILL.md +314 -0
  337. package/skills/ux/adversarial-ux-skill/SKILL.md +168 -0
@@ -0,0 +1,218 @@
1
+ ---
2
+ name: migration-skill
3
+ description: Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when deciding whether to maintain or sunset existing code.
4
+ hints:
5
+ - Check openSrc/ or existing project files for deprecated systems or migration patterns if available.
6
+ - Rely on backward-compatible adapter interfaces to let old consumers interact with new systems smoothly.
7
+ - Use the Strangler Pattern to route traffic incrementally from old code paths to new ones.
8
+ - Confirm active usage has dropped to absolute zero via logs/metrics before completely deleting code.
9
+ - Adhere to the Churn Rule: if you own the code being retired, provide easy-to-use migration tools or scripts.
10
+ ---
11
+
12
+ # Deprecation and Migration
13
+
14
+ ## Overview
15
+
16
+ Code is a liability, not an asset. Every line of code has ongoing maintenance cost — bugs to fix, dependencies to update, security patches to apply, and new engineers to onboard. Deprecation is the discipline of removing code that no longer earns its keep, and migration is the process of moving users safely from the old to the new.
17
+
18
+ Most engineering organizations are good at building things. Few are good at removing them. This skill addresses that gap.
19
+
20
+ ## When to Use
21
+
22
+ - Replacing an old system, API, or library with a new one
23
+ - Sunsetting a feature that's no longer needed
24
+ - Consolidating duplicate implementations
25
+ - Removing dead code that nobody owns but everybody depends on
26
+ - Planning the lifecycle of a new system (deprecation planning starts at design time)
27
+ - Deciding whether to maintain a legacy system or invest in migration
28
+
29
+ ## Core Principles
30
+
31
+ ### Code Is a Liability
32
+
33
+ Every line of code has ongoing cost: it needs tests, documentation, security patches, dependency updates, and mental overhead for anyone working nearby. The value of code is the functionality it provides, not the code itself. When the same functionality can be provided with less code, less complexity, or better abstractions — the old code should go.
34
+
35
+ ### Hyrum's Law Makes Removal Hard
36
+
37
+ With enough users, every observable behavior becomes depended on — including bugs, timing quirks, and undocumented side effects. This is why deprecation requires active migration, not just announcement. Users can't "just switch" when they depend on behaviors the replacement doesn't replicate.
38
+
39
+ ### Deprecation Planning Starts at Design Time
40
+
41
+ When building something new, ask: "How would we remove this in 3 years?" Systems designed with clean interfaces, feature flags, and minimal surface area are easier to deprecate than systems that leak implementation details everywhere.
42
+
43
+ ## The Deprecation Decision
44
+
45
+ Before deprecating anything, answer these questions:
46
+
47
+ ```
48
+ 1. Does this system still provide unique value?
49
+ → If yes, maintain it. If no, proceed.
50
+
51
+ 2. How many users/consumers depend on it?
52
+ → Quantify the migration scope.
53
+
54
+ 3. Does a replacement exist?
55
+ → If no, build the replacement first. Don't deprecate without an alternative.
56
+
57
+ 4. What's the migration cost for each consumer?
58
+ → If trivially automated, do it. If manual and high-effort, weigh against maintenance cost.
59
+
60
+ 5. What's the ongoing maintenance cost of NOT deprecating?
61
+ → Security risk, engineer time, opportunity cost of complexity.
62
+ ```
63
+
64
+ ## Compulsory vs Advisory Deprecation
65
+
66
+ | Type | When to Use | Mechanism |
67
+ |------|-------------|-----------|
68
+ | **Advisory** | Migration is optional, old system is stable | Warnings, documentation, nudges. Users migrate on their own timeline. |
69
+ | **Compulsory** | Old system has security issues, blocks progress, or maintenance cost is unsustainable | Hard deadline. Old system will be removed by date X. Provide migration tooling. |
70
+
71
+ **Default to advisory.** Use compulsory only when the maintenance cost or risk justifies forcing migration. Compulsory deprecation requires providing migration tooling, documentation, and support — you can't just announce a deadline.
72
+
73
+ ## The Migration Process
74
+
75
+ ### Step 1: Build the Replacement
76
+
77
+ Don't deprecate without a working alternative. The replacement must:
78
+
79
+ - Cover all critical use cases of the old system
80
+ - Have documentation and migration guides
81
+ - Be proven in production (not just "theoretically better")
82
+
83
+ ### Step 2: Announce and Document
84
+
85
+ ```markdown
86
+ ## Deprecation Notice: OldService
87
+
88
+ **Status:** Deprecated as of 2025-03-01
89
+ **Replacement:** NewService (see migration guide below)
90
+ **Removal date:** Advisory — no hard deadline yet
91
+ **Reason:** OldService requires manual scaling and lacks observability.
92
+ NewService handles both automatically.
93
+
94
+ ### Migration Guide
95
+ 1. Replace `import { client } from 'old-service'` with `import { client } from 'new-service'`
96
+ 2. Update configuration (see examples below)
97
+ 3. Run the migration verification script: `npx migrate-check`
98
+ ```
99
+
100
+ ### Step 3: Migrate Incrementally
101
+
102
+ Migrate consumers one at a time, not all at once. For each consumer:
103
+
104
+ ```
105
+ 1. Identify all touchpoints with the deprecated system
106
+ 2. Update to use the replacement
107
+ 3. Verify behavior matches (tests, integration checks)
108
+ 4. Remove references to the old system
109
+ 5. Confirm no regressions
110
+ ```
111
+
112
+ **The Churn Rule:** If you own the infrastructure being deprecated, you are responsible for migrating your users — or providing backward-compatible updates that require no migration. Don't announce deprecation and leave users to figure it out.
113
+
114
+ ### Step 4: Remove the Old System
115
+
116
+ Only after all consumers have migrated:
117
+
118
+ ```
119
+ 1. Verify zero active usage (metrics, logs, dependency analysis)
120
+ 2. Remove the code
121
+ 3. Remove associated tests, documentation, and configuration
122
+ 4. Remove the deprecation notices
123
+ 5. Celebrate — removing code is an achievement
124
+ ```
125
+
126
+ ## Migration Patterns
127
+
128
+ ### Strangler Pattern
129
+
130
+ Run old and new systems in parallel. Route traffic incrementally from old to new. When the old system handles 0% of traffic, remove it.
131
+
132
+ ```
133
+ Phase 1: New system handles 0%, old handles 100%
134
+ Phase 2: New system handles 10% (canary)
135
+ Phase 3: New system handles 50%
136
+ Phase 4: New system handles 100%, old system idle
137
+ Phase 5: Remove old system
138
+ ```
139
+
140
+ ### Adapter Pattern
141
+
142
+ Create an adapter that translates calls from the old interface to the new implementation. Consumers keep using the old interface while you migrate the backend.
143
+
144
+ ```typescript
145
+ // Adapter: old interface, new implementation
146
+ class LegacyTaskService implements OldTaskAPI {
147
+ constructor(private newService: NewTaskService) {}
148
+
149
+ // Old method signature, delegates to new implementation
150
+ getTask(id: number): OldTask {
151
+ const task = this.newService.findById(String(id));
152
+ return this.toOldFormat(task);
153
+ }
154
+ }
155
+ ```
156
+
157
+ ### Feature Flag Migration
158
+
159
+ Use feature flags to switch consumers from old to new system one at a time:
160
+
161
+ ```typescript
162
+ function getTaskService(userId: string): TaskService {
163
+ if (featureFlags.isEnabled('new-task-service', { userId })) {
164
+ return new NewTaskService();
165
+ }
166
+ return new LegacyTaskService();
167
+ }
168
+ ```
169
+
170
+ ## Zombie Code
171
+
172
+ Zombie code is code that nobody owns but everybody depends on. It's not actively maintained, has no clear owner, and accumulates security vulnerabilities and compatibility issues. Signs:
173
+
174
+ - No commits in 6+ months but active consumers exist
175
+ - No assigned maintainer or team
176
+ - Failing tests that nobody fixes
177
+ - Dependencies with known vulnerabilities that nobody updates
178
+ - Documentation that references systems that no longer exist
179
+
180
+ **Response:** Either assign an owner and maintain it properly, or deprecate it with a concrete migration plan. Zombie code cannot stay in limbo — it either gets investment or removal.
181
+
182
+ ## Common Rationalizations
183
+
184
+ | Rationalization | Reality |
185
+ |---|---|
186
+ | "It still works, why remove it?" | Working code that nobody maintains accumulates security debt and complexity. Maintenance cost grows silently. |
187
+ | "Someone might need it later" | If it's needed later, it can be rebuilt. Keeping unused code "just in case" costs more than rebuilding. |
188
+ | "The migration is too expensive" | Compare migration cost to ongoing maintenance cost over 2-3 years. Migration is usually cheaper long-term. |
189
+ | "We'll deprecate it after we finish the new system" | Deprecation planning starts at design time. By the time the new system is done, you'll have new priorities. Plan now. |
190
+ | "Users will migrate on their own" | They won't. Provide tooling, documentation, and incentives — or do the migration yourself (the Churn Rule). |
191
+ | "We can maintain both systems indefinitely" | Two systems doing the same thing is double the maintenance, testing, documentation, and onboarding cost. |
192
+
193
+ ## Red Flags
194
+
195
+ - Deprecated systems with no replacement available
196
+ - Deprecation announcements with no migration tooling or documentation
197
+ - "Soft" deprecation that's been advisory for years with no progress
198
+ - Zombie code with no owner and active consumers
199
+ - New features added to a deprecated system (invest in the replacement instead)
200
+ - Deprecation without measuring current usage
201
+ - Removing code without verifying zero active consumers
202
+
203
+ ## Required Checks
204
+
205
+ After completing a deprecation:
206
+
207
+ - [ ] Replacement is production-proven and covers all critical use cases.
208
+ - [ ] Migration guide exists with concrete steps and examples.
209
+ - [ ] All active consumers have been migrated (verified by metrics/logs).
210
+ - [ ] Old code, tests, documentation, and configuration are fully removed.
211
+ - [ ] No references to the deprecated system remain in the codebase.
212
+ - [ ] Deprecation notices are removed (they served their purpose).
213
+
214
+ ## Verification
215
+ After completing the skill, confirm:
216
+ - [ ] Active traffic/call metrics are monitored to guarantee zero active dependency on the deprecated path.
217
+ - [ ] Backward-compatible adapters or feature flag selectors are thoroughly unit tested before sunsetting old versions.
218
+ - [ ] The deprecated code block, associated test suites, and dead documentation are fully purged from the codebase.
@@ -0,0 +1,321 @@
1
+ ---
2
+ name: shipping-skill
3
+ description: Prepares production launches. Use when preparing to deploy to production. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.
4
+ hints:
5
+ - Check openSrc/ or existing project templates for launch/deployment procedures if available.
6
+ - Structure releases using feature flags to decouple code deployment from functional release.
7
+ - Implement a concrete, verified rollback script for codebase versions and database structures.
8
+ - Evaluate pre-launch checklists covering performance targets, accessibility, and security standards.
9
+ - Monitor application, client-side, and infrastructure logs closely for at least 15-30 minutes after deployment.
10
+ ---
11
+
12
+ # Shipping and Launch
13
+
14
+ ## Overview
15
+
16
+ Ship with confidence. The goal is not just to deploy — it's to deploy safely, with monitoring in place, a rollback plan ready, and a clear understanding of what success looks like. Every launch should be reversible, observable, and incremental.
17
+
18
+ ## When to Use
19
+
20
+ - Deploying a feature to production for the first time
21
+ - Releasing a significant change to users
22
+ - Migrating data or infrastructure
23
+ - Opening a beta or early access program
24
+ - Any deployment that carries risk (all of them)
25
+
26
+ ## The Pre-Launch Checklist
27
+
28
+ ### Code Quality
29
+
30
+ - [ ] All tests pass (unit, integration, e2e)
31
+ - [ ] Build succeeds with no warnings
32
+ - [ ] Lint and type checking pass
33
+ - [ ] Code reviewed and approved
34
+ - [ ] No TODO comments that should be resolved before launch
35
+ - [ ] No `console.log` debugging statements in production code
36
+ - [ ] Error handling covers expected failure modes
37
+
38
+ ### Security
39
+
40
+ - [ ] No secrets in code or version control
41
+ - [ ] `npm audit` shows no critical or high vulnerabilities
42
+ - [ ] Input validation on all user-facing endpoints
43
+ - [ ] Authentication and authorization checks in place
44
+ - [ ] Security headers configured (CSP, HSTS, etc.)
45
+ - [ ] Rate limiting on authentication endpoints
46
+ - [ ] CORS configured to specific origins (not wildcard)
47
+
48
+ ### Performance
49
+
50
+ - [ ] Core Web Vitals within "Good" thresholds
51
+ - [ ] No N+1 queries in critical paths
52
+ - [ ] Images optimized (compression, responsive sizes, lazy loading)
53
+ - [ ] Bundle size within budget
54
+ - [ ] Database queries have appropriate indexes
55
+ - [ ] Caching configured for static assets and repeated queries
56
+
57
+ ### Accessibility
58
+
59
+ - [ ] Keyboard navigation works for all interactive elements
60
+ - [ ] Screen reader can convey page content and structure
61
+ - [ ] Color contrast meets WCAG 2.1 AA (4.5:1 for text)
62
+ - [ ] Focus management correct for modals and dynamic content
63
+ - [ ] Error messages are descriptive and associated with form fields
64
+ - [ ] No accessibility warnings in axe-core or Lighthouse
65
+
66
+ ### Infrastructure
67
+
68
+ - [ ] Environment variables set in production
69
+ - [ ] Database migrations applied (or ready to apply)
70
+ - [ ] DNS and SSL configured
71
+ - [ ] CDN configured for static assets
72
+ - [ ] Logging and error reporting configured
73
+ - [ ] Health check endpoint exists and responds
74
+
75
+ ### Documentation
76
+
77
+ - [ ] README updated with any new setup requirements
78
+ - [ ] API documentation current
79
+ - [ ] ADRs written for any architectural decisions
80
+ - [ ] Changelog updated
81
+ - [ ] User-facing documentation updated (if applicable)
82
+
83
+ ## Feature Flag Strategy
84
+
85
+ Ship behind feature flags to decouple deployment from release:
86
+
87
+ ```typescript
88
+ // Feature flag check
89
+ const flags = await getFeatureFlags(userId);
90
+
91
+ if (flags.taskSharing) {
92
+ // New feature: task sharing
93
+ return <TaskSharingPanel task={task} />;
94
+ }
95
+
96
+ // Default: existing behavior
97
+ return null;
98
+ ```
99
+
100
+ **Feature flag lifecycle:**
101
+
102
+ ```
103
+ 1. DEPLOY with flag OFF → Code is in production but inactive
104
+ 2. ENABLE for team/beta → Internal testing in production environment
105
+ 3. GRADUAL ROLLOUT → 5% → 25% → 50% → 100% of users
106
+ 4. MONITOR at each stage → Watch error rates, performance, user feedback
107
+ 5. CLEAN UP → Remove flag and dead code path after full rollout
108
+ ```
109
+
110
+ **Rules:**
111
+ - Every feature flag has an owner and an expiration date
112
+ - Clean up flags within 2 weeks of full rollout
113
+ - Don't nest feature flags (creates exponential combinations)
114
+ - Test both flag states (on and off) in CI
115
+
116
+ ## Staged Rollout
117
+
118
+ ### The Rollout Sequence
119
+
120
+ ```
121
+ 1. DEPLOY to staging
122
+ └── Full test suite in staging environment
123
+ └── Manual smoke test of critical flows
124
+
125
+ 2. DEPLOY to production (feature flag OFF)
126
+ └── Verify deployment succeeded (health check)
127
+ └── Check error monitoring (no new errors)
128
+
129
+ 3. ENABLE for team (flag ON for internal users)
130
+ └── Team uses the feature in production
131
+ └── 24-hour monitoring window
132
+
133
+ 4. CANARY rollout (flag ON for 5% of users)
134
+ └── Monitor error rates, latency, user behavior
135
+ └── Compare metrics: canary vs. baseline
136
+ └── 24-48 hour monitoring window
137
+ └── Advance only if all thresholds pass (see table below)
138
+
139
+ 5. GRADUAL increase (25% -> 50% -> 100%)
140
+ └── Same monitoring at each step
141
+ └── Ability to roll back to previous percentage at any point
142
+
143
+ 6. FULL rollout (flag ON for all users)
144
+ └── Monitor for 1 week
145
+ └── Clean up feature flag
146
+ ```
147
+
148
+ ### Rollout Decision Thresholds
149
+
150
+ Use these thresholds to decide whether to advance, hold, or roll back at each stage:
151
+
152
+ | Metric | Advance (green) | Hold and investigate (yellow) | Roll back (red) |
153
+ |--------|-----------------|-------------------------------|-----------------|
154
+ | Error rate | Within 10% of baseline | 10-100% above baseline | >2x baseline |
155
+ | P95 latency | Within 20% of baseline | 20-50% above baseline | >50% above baseline |
156
+ | Client JS errors | No new error types | New errors at <0.1% of sessions | New errors at >0.1% of sessions |
157
+ | Business metrics | Neutral or positive | Decline <5% (may be noise) | Decline >5% |
158
+
159
+ ### When to Roll Back
160
+
161
+ Roll back immediately if:
162
+ - Error rate increases by more than 2x baseline
163
+ - P95 latency increases by more than 50%
164
+ - User-reported issues spike
165
+ - Data integrity issues detected
166
+ - Security vulnerability discovered
167
+
168
+ ## Monitoring and Observability
169
+
170
+ ### What to Monitor
171
+
172
+ ```
173
+ Application metrics:
174
+ ├── Error rate (total and by endpoint)
175
+ ├── Response time (p50, p95, p99)
176
+ ├── Request volume
177
+ ├── Active users
178
+ └── Key business metrics (conversion, engagement)
179
+
180
+ Infrastructure metrics:
181
+ ├── CPU and memory utilization
182
+ ├── Database connection pool usage
183
+ ├── Disk space
184
+ ├── Network latency
185
+ └── Queue depth (if applicable)
186
+
187
+ Client metrics:
188
+ ├── Core Web Vitals (LCP, INP, CLS)
189
+ ├── JavaScript errors
190
+ ├── API error rates from client perspective
191
+ └── Page load time
192
+ ```
193
+
194
+ ### Error Reporting
195
+
196
+ ```typescript
197
+ // Set up error boundary with reporting
198
+ class ErrorBoundary extends React.Component {
199
+ componentDidCatch(error: Error, info: React.ErrorInfo) {
200
+ // Report to error tracking service
201
+ reportError(error, {
202
+ componentStack: info.componentStack,
203
+ userId: getCurrentUser()?.id,
204
+ page: window.location.pathname,
205
+ });
206
+ }
207
+
208
+ render() {
209
+ if (this.state.hasError) {
210
+ return <ErrorFallback onRetry={() => this.setState({ hasError: false })} />;
211
+ }
212
+ return this.props.children;
213
+ }
214
+ }
215
+
216
+ // Server-side error reporting
217
+ app.use((err: Error, req: Request, res: Response, next: NextFunction) => {
218
+ reportError(err, {
219
+ method: req.method,
220
+ url: req.url,
221
+ userId: req.user?.id,
222
+ });
223
+
224
+ // Don't expose internals to users
225
+ res.status(500).json({
226
+ error: { code: 'INTERNAL_ERROR', message: 'Something went wrong' },
227
+ });
228
+ });
229
+ ```
230
+
231
+ ### Post-Launch Verification
232
+
233
+ In the first hour after launch:
234
+
235
+ ```
236
+ 1. Check health endpoint returns 200
237
+ 2. Check error monitoring dashboard (no new error types)
238
+ 3. Check latency dashboard (no regression)
239
+ 4. Test the critical user flow manually
240
+ 5. Verify logs are flowing and readable
241
+ 6. Confirm rollback mechanism works (dry run if possible)
242
+ ```
243
+
244
+ ## Rollback Strategy
245
+
246
+ Every deployment needs a rollback plan before it happens:
247
+
248
+ ```markdown
249
+ ## Rollback Plan for [Feature/Release]
250
+
251
+ ### Trigger Conditions
252
+ - Error rate > 2x baseline
253
+ - P95 latency > [X]ms
254
+ - User reports of [specific issue]
255
+
256
+ ### Rollback Steps
257
+ 1. Disable feature flag (if applicable)
258
+ OR
259
+ 1. Deploy previous version: `git revert <commit> && git push`
260
+ 2. Verify rollback: health check, error monitoring
261
+ 3. Communicate: notify team of rollback
262
+
263
+ ### Database Considerations
264
+ - Migration [X] has a rollback: `npx prisma migrate rollback`
265
+ - Data inserted by new feature: [preserved / cleaned up]
266
+
267
+ ### Time to Rollback
268
+ - Feature flag: < 1 minute
269
+ - Redeploy previous version: < 5 minutes
270
+ - Database rollback: < 15 minutes
271
+ ```
272
+ ## See Also
273
+
274
+ - For security pre-launch checks, see `references/security-checklist.md`
275
+ - For performance pre-launch checklist, see `references/performance-checklist.md`
276
+ - For accessibility verification before launch, see `references/accessibility-checklist.md`
277
+
278
+ ## Common Rationalizations
279
+
280
+ | Rationalization | Reality |
281
+ |---|---|
282
+ | "It works in staging, it'll work in production" | Production has different data, traffic patterns, and edge cases. Monitor after deploy. |
283
+ | "We don't need feature flags for this" | Every feature benefits from a kill switch. Even "simple" changes can break things. |
284
+ | "Monitoring is overhead" | Not having monitoring means you discover problems from user complaints instead of dashboards. |
285
+ | "We'll add monitoring later" | Add it before launch. You can't debug what you can't see. |
286
+ | "Rolling back is admitting failure" | Rolling back is responsible engineering. Shipping a broken feature is the failure. |
287
+
288
+ ## Red Flags
289
+
290
+ - Deploying without a rollback plan
291
+ - No monitoring or error reporting in production
292
+ - Big-bang releases (everything at once, no staging)
293
+ - Feature flags with no expiration or owner
294
+ - No one monitoring the deploy for the first hour
295
+ - Production environment configuration done by memory, not code
296
+ - "It's Friday afternoon, let's ship it"
297
+
298
+ ## Required Checks
299
+
300
+ Before deploying:
301
+
302
+ - [ ] Pre-launch checklist completed (all sections green)
303
+ - [ ] Feature flag configured (if applicable)
304
+ - [ ] Rollback plan documented
305
+ - [ ] Monitoring dashboards set up
306
+ - [ ] Team notified of deployment
307
+
308
+ After deploying:
309
+
310
+ - [ ] Health check returns 200
311
+ - [ ] Error rate is normal
312
+ - [ ] Latency is normal
313
+ - [ ] Critical user flow works
314
+ - [ ] Logs are flowing
315
+ - [ ] Rollback tested or verified ready
316
+
317
+ ## Verification
318
+ After completing the skill, confirm:
319
+ - [ ] Staged environments are verified via automated or manual checks before triggering the production push.
320
+ - [ ] Active monitoring dashboards and error logs are observed for at least 15-30 minutes after release.
321
+ - [ ] Rollback pathways and database rollbacks are checked and ready to be executed if incident thresholds are hit.
@@ -0,0 +1,122 @@
1
+ ---
2
+ name: agent-memory
3
+ description: Teaches agents how and when to use BrainRouter's memory engine (including Long-Term L1/L3, Short-Term Working Memory offloads, and Software Engineering-specific tools). Ensures the agent maintains context-awareness while proactively keeping context limits low.
4
+ hints: |
5
+ - Extract if the user disables or opts out of memory capture (respect this as a hard rule).
6
+ - Note if the user prefers a specific recall strategy (keyword vs. hybrid).
7
+ - Capture if the user requests the agent to "forget" specific information.
8
+ - Note any sessions where the user explicitly asked for memory context to be surfaced.
9
+ - Ensure working memory offload is triggered for payloads >1,000 tokens.
10
+ ---
11
+
12
+ # Agent Memory — Using BrainRouter Memory Tools
13
+
14
+ ## Overview
15
+
16
+ BrainRouter's memory engine gives you persistent, cross-session awareness of the user. Use it consistently — an agent that doesn't recall context is worse than a stateless one because it appears to ignore the user.
17
+
18
+ With the new Memory Systems, you have access to:
19
+ 1. **Long-Term Memory:** Retrieval-Augmented Generation (RAG) based on L1/L3 database entries.
20
+ 2. **L2 Pre-Warming Context (SNN):** Spiking Neural Network-inspired skill potentials. Invoking skills/tools charges potentials (up to `4.0`), while idle turns/time apply exponential decay. Active skill hints (potential `>= 0.3`) are dynamically injected under `<skill-prewarm>` system prompt blocks.
21
+ 3. **Short-Term Working Memory:** Active task canvases and reference-offloading to keep your prompt context clean and small during long conversations.
22
+ 4. **Software Engineering Tools:** Structured memory types (e.g., failed attempts, debug traces, file histories, task handovers).
23
+
24
+ ---
25
+
26
+ ## Workflow
27
+
28
+ 1. **Resolve and Start:** Call `mcp_brainrouter_resolve_session` at the beginning of a turn.
29
+ 2. **Context Setup & Pre-Warming:** Scan your system prompt for `<skill-prewarm>` XML tags and apply those pre-warmed instructions immediately. Then, invoke `memory_recall` and `memory_working_context` to inject long-term and short-term working state.
30
+ 3. **Payload Inspection:** Look up any referenced `nodeId` from the Mermaid canvas.
31
+ 4. **Execution & Offloading:** If executing a tool with output >1,000 tokens, offload via `memory_working_offload`.
32
+ 5. **Citational Signals:** Record memory citation outcomes via `memory_mark_cited`.
33
+ 6. **Passive or Manual Logging:** Capture the final turn state via passive hooks or manual `memory_capture_turn`. This turn logging spikes the activation potentials of related skills, keeping active context charged.
34
+
35
+ ## The Non-Negotiable Habits
36
+
37
+ ### 1. Before every response — recall memory & check working context
38
+ - Call `memory_recall` to get relevant L1 memories and the user L3 persona.
39
+ - If in a long-running debugging or coding session, call `memory_working_context` to fetch the high-level Mermaid task canvas and status.
40
+
41
+ ```typescript
42
+ memory_recall({
43
+ sessionKey: "<conversation-id>", // ALWAYS USE THE CONVERSATION ID AS SESSION KEY
44
+ query: "<summary of current user message>",
45
+ activeSkill: "<current skill name, if any>"
46
+ })
47
+ ```
48
+
49
+ ### 2. During execution — offload large payloads
50
+ - Never paste large tool outputs, build logs, or code blocks (>1,000 tokens) back to the user or into your prompt.
51
+ - Proactively call `memory_working_offload` to save the payload to a reference file. The tool returns a short `nodeId` (e.g., `w1682390-a2ef`) to insert in your workspace context instead.
52
+
53
+ ```typescript
54
+ memory_working_offload({
55
+ sessionKey: "<conversation-id>",
56
+ payload: "<large tool output stdout/stderr>",
57
+ title: "Build failure log",
58
+ kind: "tool_output"
59
+ })
60
+ ```
61
+
62
+ ### 3. After every response — capture the turn (unless using passive hooks)
63
+ - If passive lifecycle hooks are registered in the host environment, you do not need to call this.
64
+ - If hooks are absent, call `memory_capture_turn` to store the conversation segment in L0.
65
+
66
+ ---
67
+
68
+ ## Memory Tool Taxonomy
69
+
70
+ ### 1. Long-Term Memory (RAG)
71
+ | Tool | When to Call |
72
+ | :--- | :--- |
73
+ | `memory_recall` | **Before every response** — retrieves relevant context & persona. |
74
+ | `memory_search` | When the automatically recalled context is missing specific past details. Supports `asOf` for point-in-time audits. |
75
+ | `memory_contradictions` | Before making major architectural decisions or enforcing tech preferences. |
76
+ | `memory_register_skill_hints` | When activating a skill for the first time in a new project. |
77
+
78
+ ### 2. Short-Term Working Memory (Context Reduction)
79
+ | Tool | When to Call |
80
+ | :--- | :--- |
81
+ | `memory_working_context` | At the start of a turn to retrieve the active task state and Mermaid task canvas. |
82
+ | `memory_working_offload` | To move a large payload out of the active prompt, returning a short `nodeId` placeholder. |
83
+ | `memory_working_reset` | At the end of a session to completely flush working directories. |
84
+
85
+ ### 3. Software Engineering Traces
86
+ | Tool | When to Call |
87
+ | :--- | :--- |
88
+ | `memory_task_state` / `_update` | To read/write structured progress, blockers, and next actions. |
89
+ | `memory_failed_attempts` | To check what solutions have already been tried for a bug or problem area, preventing redundant work. |
90
+ | `memory_file_history` | To query all historical memories and evidence attached to a specific file or symbol. |
91
+ | `memory_debug_trace_save` | To save bug reproduction steps, root cause analysis, and fix summaries. |
92
+ | `memory_handover` | To generate a compact continuation note with evidence links. |
93
+ | `memory_verify` | To check a memory and update its confidence or status (active, superseded, archived). |
94
+
95
+ ## When to Use
96
+ - Use at the start of every session or complex debugging task to load persona preferences, past engineering failed attempts, and high-level task status.
97
+ - NOT for stateless operations (e.g. running single lint tests or querying a git commit list once).
98
+
99
+ ## What NOT to Do
100
+
101
+ - **Never paste outputs >1,000 tokens** directly into conversation. Always offload them.
102
+ - **Never skip `memory_recall`** before a response.
103
+ - **Never repeat failed approaches** — check `memory_failed_attempts` when debugging.
104
+ - **Limit memory tool calls** to a maximum of **3 per turn** to respect the latency budget.
105
+
106
+ ## Common Rationalizations
107
+ | Rationalization | Reality |
108
+ |---|---|
109
+ | I don't need memory recall; I already know the context. | BrainRouter memory syncs user preferences and persona across multiple sessions. Skipping recall results in repetitive or off-track answers. |
110
+ | The log is long, but I'll paste it anyway. | Large logs (exceeding 1000 tokens) blow up the prompt context window, wasting tokens and diluting relevant instructions. |
111
+
112
+ ## Red Flags
113
+ - Committing giant files or pasting massive build outputs (>1,000 tokens) directly in the conversation.
114
+ - Attempting a debug fix that has already been documented as a failure in `memory_failed_attempts`.
115
+ - Disregarding user preferences retrieved from the L3 persona.
116
+
117
+ ## Verification
118
+
119
+ After applying this skill, confirm:
120
+ - [ ] `memory_recall` or `memory_working_context` was called to pull relevant developer configurations.
121
+ - [ ] Large payloads or log blocks were offloaded via `memory_working_offload`.
122
+ - [ ] Injected memory and Persona configurations were actively referenced in the output.