@prestyj/cli 5.11.0 → 5.13.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 (466) hide show
  1. package/README.md +46 -36
  2. package/assets/skills/bulletproof/SKILL.md +158 -0
  3. package/assets/skills/bulletproof/references/agent-surface.md +82 -0
  4. package/assets/skills/bulletproof/references/audit-protocol.md +147 -0
  5. package/assets/skills/bulletproof/references/platform-playbooks.md +176 -0
  6. package/assets/skills/bulletproof/references/provenance.md +45 -0
  7. package/assets/skills/bulletproof/references/secure-defaults.md +108 -0
  8. package/assets/skills/bulletproof/references/supply-chain.md +76 -0
  9. package/assets/skills/bulletproof/references/threat-landscape.md +74 -0
  10. package/assets/skills/bulletproof/references/verification.md +65 -0
  11. package/assets/skills/compliance-guard/SKILL.md +251 -0
  12. package/assets/skills/compliance-guard/references/artifacts.md +186 -0
  13. package/assets/skills/compliance-guard/references/eu-uk.md +151 -0
  14. package/assets/skills/compliance-guard/references/exposure-triage.md +161 -0
  15. package/assets/skills/compliance-guard/references/lawsuit-vectors.md +141 -0
  16. package/assets/skills/compliance-guard/references/provenance.md +42 -0
  17. package/assets/skills/compliance-guard/references/sector-gates.md +173 -0
  18. package/assets/skills/compliance-guard/references/security-baseline.md +130 -0
  19. package/assets/skills/compliance-guard/references/trigger-map.md +163 -0
  20. package/assets/skills/compliance-guard/references/us.md +164 -0
  21. package/assets/skills/durable/SKILL.md +111 -0
  22. package/assets/skills/durable/references/backups-and-runtime.md +86 -0
  23. package/assets/skills/durable/references/migrations-and-schema.md +79 -0
  24. package/assets/skills/lean/SKILL.md +110 -0
  25. package/assets/skills/lean/references/memory-and-processes.md +98 -0
  26. package/assets/skills/lean/references/playbooks.md +107 -0
  27. package/dist/app-sidecar-auth-broadcast.test.js +111 -10
  28. package/dist/app-sidecar-auth-broadcast.test.js.map +1 -1
  29. package/dist/app-sidecar-sessions.test.js +1 -1
  30. package/dist/app-sidecar.js +210 -72
  31. package/dist/app-sidecar.js.map +1 -1
  32. package/dist/chat-agents/jiwa.test.js +1 -1
  33. package/dist/cli/auth.d.ts.map +1 -1
  34. package/dist/cli/auth.js +33 -36
  35. package/dist/cli/auth.js.map +1 -1
  36. package/dist/cli/mcp.js +30 -10
  37. package/dist/cli/mcp.js.map +1 -1
  38. package/dist/cli.d.ts.map +1 -1
  39. package/dist/cli.js +18 -5
  40. package/dist/cli.js.map +1 -1
  41. package/dist/config.d.ts +28 -5
  42. package/dist/config.d.ts.map +1 -1
  43. package/dist/config.js +50 -76
  44. package/dist/config.js.map +1 -1
  45. package/dist/config.test.js +56 -13
  46. package/dist/config.test.js.map +1 -1
  47. package/dist/core/agent-session-checkpoint-flush.test.js +2 -2
  48. package/dist/core/agent-session-compaction.test.js +60 -0
  49. package/dist/core/agent-session-compaction.test.js.map +1 -1
  50. package/dist/core/agent-session-crash-durability.test.js +3 -3
  51. package/dist/core/agent-session-model-switch.test.js +1 -1
  52. package/dist/core/agent-session-process-gate.test.js +7 -1
  53. package/dist/core/agent-session-process-gate.test.js.map +1 -1
  54. package/dist/core/agent-session-review-coverage.test.js +52 -1
  55. package/dist/core/agent-session-review-coverage.test.js.map +1 -1
  56. package/dist/core/agent-session-tool-tiers.test.d.ts +2 -0
  57. package/dist/core/agent-session-tool-tiers.test.d.ts.map +1 -0
  58. package/dist/core/agent-session-tool-tiers.test.js +138 -0
  59. package/dist/core/agent-session-tool-tiers.test.js.map +1 -0
  60. package/dist/core/agent-session-verification-gate.test.d.ts +2 -0
  61. package/dist/core/agent-session-verification-gate.test.d.ts.map +1 -0
  62. package/dist/core/agent-session-verification-gate.test.js +135 -0
  63. package/dist/core/agent-session-verification-gate.test.js.map +1 -0
  64. package/dist/core/agent-session.d.ts +77 -3
  65. package/dist/core/agent-session.d.ts.map +1 -1
  66. package/dist/core/agent-session.js +268 -33
  67. package/dist/core/agent-session.js.map +1 -1
  68. package/dist/core/agents.d.ts +29 -1
  69. package/dist/core/agents.d.ts.map +1 -1
  70. package/dist/core/agents.js +47 -97
  71. package/dist/core/agents.js.map +1 -1
  72. package/dist/core/agents.test.js +87 -7
  73. package/dist/core/agents.test.js.map +1 -1
  74. package/dist/core/api-benchmark.d.ts +3 -3
  75. package/dist/core/api-benchmark.js +7 -7
  76. package/dist/core/auth-providers.d.ts +37 -1
  77. package/dist/core/auth-providers.d.ts.map +1 -1
  78. package/dist/core/auth-providers.js +84 -4
  79. package/dist/core/auth-providers.js.map +1 -1
  80. package/dist/core/auto-update.test.js +1 -1
  81. package/dist/core/autopilot-gate.d.ts +2 -2
  82. package/dist/core/autopilot-gate.js +1 -1
  83. package/dist/core/autopilot-gate.test.js +7 -4
  84. package/dist/core/autopilot-gate.test.js.map +1 -1
  85. package/dist/core/bash-spawn-benchmark.js +6 -6
  86. package/dist/core/bundled-agents.d.ts +3 -0
  87. package/dist/core/bundled-agents.d.ts.map +1 -0
  88. package/dist/core/bundled-agents.js +255 -0
  89. package/dist/core/bundled-agents.js.map +1 -0
  90. package/dist/core/cache-warm-benchmark.d.ts +2 -2
  91. package/dist/core/cache-warm-benchmark.js +5 -5
  92. package/dist/core/code-retrieval-chunkers.d.ts +27 -0
  93. package/dist/core/code-retrieval-chunkers.d.ts.map +1 -0
  94. package/dist/core/code-retrieval-chunkers.js +264 -0
  95. package/dist/core/code-retrieval-chunkers.js.map +1 -0
  96. package/dist/core/code-retrieval-chunkers.test.d.ts +2 -0
  97. package/dist/core/code-retrieval-chunkers.test.d.ts.map +1 -0
  98. package/dist/core/code-retrieval-chunkers.test.js +203 -0
  99. package/dist/core/code-retrieval-chunkers.test.js.map +1 -0
  100. package/dist/core/code-retrieval.d.ts +6 -0
  101. package/dist/core/code-retrieval.d.ts.map +1 -1
  102. package/dist/core/code-retrieval.js +38 -1
  103. package/dist/core/code-retrieval.js.map +1 -1
  104. package/dist/core/compaction/token-estimator.test.js +1 -1
  105. package/dist/core/encode-cwd.test.js +1 -1
  106. package/dist/core/event-bus.d.ts +11 -1
  107. package/dist/core/event-bus.d.ts.map +1 -1
  108. package/dist/core/event-bus.js +1 -0
  109. package/dist/core/event-bus.js.map +1 -1
  110. package/dist/core/event-bus.test.d.ts +2 -0
  111. package/dist/core/event-bus.test.d.ts.map +1 -0
  112. package/dist/core/event-bus.test.js +33 -0
  113. package/dist/core/event-bus.test.js.map +1 -0
  114. package/dist/core/extensions/plugin-bundles.js +2 -2
  115. package/dist/core/extensions/plugin-bundles.js.map +1 -1
  116. package/dist/core/extensions/plugin-bundles.test.js +2 -2
  117. package/dist/core/extensions/plugin-bundles.test.js.map +1 -1
  118. package/dist/core/fast-apply-benchmark.d.ts +2 -2
  119. package/dist/core/fast-apply-benchmark.js +6 -6
  120. package/dist/core/foreign-session-import.test.js +1 -1
  121. package/dist/core/goal-lifecycle-smoke.test.js +2 -2
  122. package/dist/core/goal-store.js +1 -1
  123. package/dist/core/goal-store.test.js +2 -2
  124. package/dist/core/goal-verifier.test.js +2 -2
  125. package/dist/core/goal-worker-dev-server-lifecycle.test.js +1 -1
  126. package/dist/core/goal-worker.test.js +2 -2
  127. package/dist/core/hashline-edit-benchmark.d.ts +2 -2
  128. package/dist/core/hashline-edit-benchmark.js +7 -7
  129. package/dist/core/local-endpoint-store.test.js +1 -1
  130. package/dist/core/logger.d.ts +1 -1
  131. package/dist/core/logger.js +2 -2
  132. package/dist/core/logger.js.map +1 -1
  133. package/dist/core/lsp/client-navigation.test.d.ts +2 -0
  134. package/dist/core/lsp/client-navigation.test.d.ts.map +1 -0
  135. package/dist/core/lsp/client-navigation.test.js +135 -0
  136. package/dist/core/lsp/client-navigation.test.js.map +1 -0
  137. package/dist/core/lsp/client.d.ts +69 -0
  138. package/dist/core/lsp/client.d.ts.map +1 -1
  139. package/dist/core/lsp/client.js +151 -2
  140. package/dist/core/lsp/client.js.map +1 -1
  141. package/dist/core/lsp/integration.test.js +2 -2
  142. package/dist/core/lsp/manager-navigation.test.d.ts +2 -0
  143. package/dist/core/lsp/manager-navigation.test.d.ts.map +1 -0
  144. package/dist/core/lsp/manager-navigation.test.js +121 -0
  145. package/dist/core/lsp/manager-navigation.test.js.map +1 -0
  146. package/dist/core/lsp/manager.d.ts +35 -1
  147. package/dist/core/lsp/manager.d.ts.map +1 -1
  148. package/dist/core/lsp/manager.js +92 -0
  149. package/dist/core/lsp/manager.js.map +1 -1
  150. package/dist/core/lsp/servers.test.js +1 -1
  151. package/dist/core/lsp/windows.test.js +4 -4
  152. package/dist/core/mcp/catalog-cache.test.js +1 -1
  153. package/dist/core/mcp/client-session-recovery.test.js +1 -1
  154. package/dist/core/mcp/client.d.ts.map +1 -1
  155. package/dist/core/mcp/client.js +2 -10
  156. package/dist/core/mcp/client.js.map +1 -1
  157. package/dist/core/mcp/content.d.ts +19 -0
  158. package/dist/core/mcp/content.d.ts.map +1 -0
  159. package/dist/core/mcp/content.js +172 -0
  160. package/dist/core/mcp/content.js.map +1 -0
  161. package/dist/core/mcp/content.test.d.ts +2 -0
  162. package/dist/core/mcp/content.test.d.ts.map +1 -0
  163. package/dist/core/mcp/content.test.js +135 -0
  164. package/dist/core/mcp/content.test.js.map +1 -0
  165. package/dist/core/mcp/defaults.d.ts +3 -1
  166. package/dist/core/mcp/defaults.d.ts.map +1 -1
  167. package/dist/core/mcp/defaults.js +9 -2
  168. package/dist/core/mcp/defaults.js.map +1 -1
  169. package/dist/core/mcp/defaults.test.d.ts +2 -0
  170. package/dist/core/mcp/defaults.test.d.ts.map +1 -0
  171. package/dist/core/mcp/defaults.test.js +60 -0
  172. package/dist/core/mcp/defaults.test.js.map +1 -0
  173. package/dist/core/mcp/deferred-catalog.d.ts +1 -1
  174. package/dist/core/mcp/deferred-catalog.js +1 -1
  175. package/dist/core/mcp/elicitation.test.js +1 -1
  176. package/dist/core/mcp/legacy-negotiation.test.js +2 -2
  177. package/dist/core/mcp/oauth-store.test.js +2 -2
  178. package/dist/core/mcp/resolve-stdio.test.js +5 -5
  179. package/dist/core/mcp/shared-pool.test.js +5 -5
  180. package/dist/core/mcp/store.test.js +5 -5
  181. package/dist/core/mcp/when-connected.test.js +2 -2
  182. package/dist/core/nolan-model.test.js +1 -1
  183. package/dist/core/nolan-prompt.js +5 -5
  184. package/dist/core/oauth/xai.d.ts +2 -0
  185. package/dist/core/oauth/xai.d.ts.map +1 -0
  186. package/dist/core/oauth/xai.js +4 -0
  187. package/dist/core/oauth/xai.js.map +1 -0
  188. package/dist/core/persistent-shell.js +1 -1
  189. package/dist/core/persistent-shell.test.js +6 -6
  190. package/dist/core/process-manager-dev-server-repro.test.js +51 -12
  191. package/dist/core/process-manager-dev-server-repro.test.js.map +1 -1
  192. package/dist/core/process-manager-notifications.test.js +24 -14
  193. package/dist/core/process-manager-notifications.test.js.map +1 -1
  194. package/dist/core/process-manager-wake.test.d.ts +2 -0
  195. package/dist/core/process-manager-wake.test.d.ts.map +1 -0
  196. package/dist/core/process-manager-wake.test.js +96 -0
  197. package/dist/core/process-manager-wake.test.js.map +1 -0
  198. package/dist/core/process-manager.d.ts +61 -1
  199. package/dist/core/process-manager.d.ts.map +1 -1
  200. package/dist/core/process-manager.js +204 -4
  201. package/dist/core/process-manager.js.map +1 -1
  202. package/dist/core/progress/git-xp.test.js +2 -2
  203. package/dist/core/progress/ranks.d.ts +14 -3
  204. package/dist/core/progress/ranks.d.ts.map +1 -1
  205. package/dist/core/progress/ranks.js +181 -12
  206. package/dist/core/progress/ranks.js.map +1 -1
  207. package/dist/core/progress/ranks.test.js +48 -7
  208. package/dist/core/progress/ranks.test.js.map +1 -1
  209. package/dist/core/progress/rebuild.test.js +1 -1
  210. package/dist/core/progress/store.test.js +1 -1
  211. package/dist/core/progress/types.d.ts +2 -1
  212. package/dist/core/progress/types.d.ts.map +1 -1
  213. package/dist/core/project-discovery.d.ts.map +1 -1
  214. package/dist/core/project-discovery.js +62 -48
  215. package/dist/core/project-discovery.js.map +1 -1
  216. package/dist/core/project-discovery.test.js +10 -10
  217. package/dist/core/prompt-commands.d.ts.map +1 -1
  218. package/dist/core/prompt-commands.js +3 -3
  219. package/dist/core/prompt-commands.js.map +1 -1
  220. package/dist/core/provider-cache.e2e.test.d.ts +2 -0
  221. package/dist/core/provider-cache.e2e.test.d.ts.map +1 -0
  222. package/dist/core/provider-cache.e2e.test.js +125 -0
  223. package/dist/core/provider-cache.e2e.test.js.map +1 -0
  224. package/dist/core/radio.d.ts +1 -1
  225. package/dist/core/radio.d.ts.map +1 -1
  226. package/dist/core/radio.js +90 -6
  227. package/dist/core/radio.js.map +1 -1
  228. package/dist/core/radio.test.js +15 -2
  229. package/dist/core/radio.test.js.map +1 -1
  230. package/dist/core/run-journal.test.js +2 -2
  231. package/dist/core/sandbox.test.js +6 -6
  232. package/dist/core/semantic-search-benchmark.d.ts +2 -2
  233. package/dist/core/semantic-search-benchmark.js +5 -5
  234. package/dist/core/session-compaction.test.js +1 -1
  235. package/dist/core/session-injections.test.d.ts +2 -0
  236. package/dist/core/session-injections.test.d.ts.map +1 -0
  237. package/dist/core/session-injections.test.js +117 -0
  238. package/dist/core/session-injections.test.js.map +1 -0
  239. package/dist/core/session-manager.d.ts.map +1 -1
  240. package/dist/core/session-manager.js +83 -67
  241. package/dist/core/session-manager.js.map +1 -1
  242. package/dist/core/session-manager.test.js +7 -7
  243. package/dist/core/session-reconstructability.test.d.ts +2 -0
  244. package/dist/core/session-reconstructability.test.d.ts.map +1 -0
  245. package/dist/core/session-reconstructability.test.js +105 -0
  246. package/dist/core/session-reconstructability.test.js.map +1 -0
  247. package/dist/core/session-storage-fd-leak.test.d.ts +2 -0
  248. package/dist/core/session-storage-fd-leak.test.d.ts.map +1 -0
  249. package/dist/core/session-storage-fd-leak.test.js +116 -0
  250. package/dist/core/session-storage-fd-leak.test.js.map +1 -0
  251. package/dist/core/session-storage.d.ts +22 -2
  252. package/dist/core/session-storage.d.ts.map +1 -1
  253. package/dist/core/session-storage.js +33 -6
  254. package/dist/core/session-storage.js.map +1 -1
  255. package/dist/core/session-storage.test.js +2 -2
  256. package/dist/core/settings-manager.d.ts +12 -0
  257. package/dist/core/settings-manager.d.ts.map +1 -1
  258. package/dist/core/settings-manager.js +46 -1
  259. package/dist/core/settings-manager.js.map +1 -1
  260. package/dist/core/shell-path.js +1 -1
  261. package/dist/core/shell.d.ts +1 -1
  262. package/dist/core/shell.js +2 -2
  263. package/dist/core/shell.test.js +2 -2
  264. package/dist/core/shutdown.d.ts +71 -0
  265. package/dist/core/shutdown.d.ts.map +1 -0
  266. package/dist/core/shutdown.js +144 -0
  267. package/dist/core/shutdown.js.map +1 -0
  268. package/dist/core/shutdown.test.d.ts +2 -0
  269. package/dist/core/shutdown.test.d.ts.map +1 -0
  270. package/dist/core/shutdown.test.js +160 -0
  271. package/dist/core/shutdown.test.js.map +1 -0
  272. package/dist/core/sidecar-error-reporter.js +1 -1
  273. package/dist/core/sidecar-error-reporter.test.js +2 -2
  274. package/dist/core/skills-routing.test.js +142 -0
  275. package/dist/core/skills-routing.test.js.map +1 -1
  276. package/dist/core/skills.d.ts.map +1 -1
  277. package/dist/core/skills.js +4 -1
  278. package/dist/core/skills.js.map +1 -1
  279. package/dist/core/subagent-manager.d.ts +9 -0
  280. package/dist/core/subagent-manager.d.ts.map +1 -1
  281. package/dist/core/subagent-manager.js +45 -12
  282. package/dist/core/subagent-manager.js.map +1 -1
  283. package/dist/core/subagent-manager.test.js +14 -8
  284. package/dist/core/subagent-manager.test.js.map +1 -1
  285. package/dist/core/subagent-store.test.js +3 -3
  286. package/dist/core/task-store.js +1 -1
  287. package/dist/core/verification-gate.d.ts +55 -0
  288. package/dist/core/verification-gate.d.ts.map +1 -0
  289. package/dist/core/verification-gate.js +188 -0
  290. package/dist/core/verification-gate.js.map +1 -0
  291. package/dist/core/verification-gate.test.d.ts +2 -0
  292. package/dist/core/verification-gate.test.d.ts.map +1 -0
  293. package/dist/core/verification-gate.test.js +102 -0
  294. package/dist/core/verification-gate.test.js.map +1 -0
  295. package/dist/index.js +1 -1
  296. package/dist/index.js.map +1 -1
  297. package/dist/modes/acp-mode.js +2 -2
  298. package/dist/modes/acp-mode.test.js +10 -8
  299. package/dist/modes/acp-mode.test.js.map +1 -1
  300. package/dist/modes/agent-home-mode.d.ts.map +1 -1
  301. package/dist/modes/agent-home-mode.js +15 -11
  302. package/dist/modes/agent-home-mode.js.map +1 -1
  303. package/dist/modes/json-mode.d.ts +9 -1
  304. package/dist/modes/json-mode.d.ts.map +1 -1
  305. package/dist/modes/json-mode.js +3 -1
  306. package/dist/modes/json-mode.js.map +1 -1
  307. package/dist/modes/serve-mode.d.ts +1 -1
  308. package/dist/modes/serve-mode.d.ts.map +1 -1
  309. package/dist/modes/serve-mode.js +14 -9
  310. package/dist/modes/serve-mode.js.map +1 -1
  311. package/dist/modes/subagent-worker-mode.d.ts +5 -0
  312. package/dist/modes/subagent-worker-mode.d.ts.map +1 -1
  313. package/dist/modes/subagent-worker-mode.js.map +1 -1
  314. package/dist/session.test.js +1 -1
  315. package/dist/system-prompt.d.ts +37 -1
  316. package/dist/system-prompt.d.ts.map +1 -1
  317. package/dist/system-prompt.js +170 -12
  318. package/dist/system-prompt.js.map +1 -1
  319. package/dist/system-prompt.test.js +170 -11
  320. package/dist/system-prompt.test.js.map +1 -1
  321. package/dist/system-prompt.tiering.test.d.ts +2 -0
  322. package/dist/system-prompt.tiering.test.d.ts.map +1 -0
  323. package/dist/system-prompt.tiering.test.js +108 -0
  324. package/dist/system-prompt.tiering.test.js.map +1 -0
  325. package/dist/tools/bash.d.ts +4 -0
  326. package/dist/tools/bash.d.ts.map +1 -1
  327. package/dist/tools/bash.js +57 -3
  328. package/dist/tools/bash.js.map +1 -1
  329. package/dist/tools/bash.test.js +37 -0
  330. package/dist/tools/bash.test.js.map +1 -1
  331. package/dist/tools/code-nav.d.ts +30 -0
  332. package/dist/tools/code-nav.d.ts.map +1 -0
  333. package/dist/tools/code-nav.js +320 -0
  334. package/dist/tools/code-nav.js.map +1 -0
  335. package/dist/tools/code-nav.test.d.ts +2 -0
  336. package/dist/tools/code-nav.test.d.ts.map +1 -0
  337. package/dist/tools/code-nav.test.js +136 -0
  338. package/dist/tools/code-nav.test.js.map +1 -0
  339. package/dist/tools/edit.d.ts.map +1 -1
  340. package/dist/tools/edit.js +37 -4
  341. package/dist/tools/edit.js.map +1 -1
  342. package/dist/tools/edit.test.js +45 -1
  343. package/dist/tools/edit.test.js.map +1 -1
  344. package/dist/tools/generate-image.d.ts +1 -1
  345. package/dist/tools/goals.d.ts +2 -2
  346. package/dist/tools/goals.test.js +2 -2
  347. package/dist/tools/grep-parity.test.d.ts +2 -0
  348. package/dist/tools/grep-parity.test.d.ts.map +1 -0
  349. package/dist/tools/grep-parity.test.js +92 -0
  350. package/dist/tools/grep-parity.test.js.map +1 -0
  351. package/dist/tools/grep-recall.test.d.ts +2 -0
  352. package/dist/tools/grep-recall.test.d.ts.map +1 -0
  353. package/dist/tools/grep-recall.test.js +114 -0
  354. package/dist/tools/grep-recall.test.js.map +1 -0
  355. package/dist/tools/grep-spawn.test.d.ts +2 -0
  356. package/dist/tools/grep-spawn.test.d.ts.map +1 -0
  357. package/dist/tools/grep-spawn.test.js +66 -0
  358. package/dist/tools/grep-spawn.test.js.map +1 -0
  359. package/dist/tools/grep.d.ts +13 -3
  360. package/dist/tools/grep.d.ts.map +1 -1
  361. package/dist/tools/grep.js +340 -40
  362. package/dist/tools/grep.js.map +1 -1
  363. package/dist/tools/grep.test.js +17 -14
  364. package/dist/tools/grep.test.js.map +1 -1
  365. package/dist/tools/index.d.ts +7 -0
  366. package/dist/tools/index.d.ts.map +1 -1
  367. package/dist/tools/index.js +8 -1
  368. package/dist/tools/index.js.map +1 -1
  369. package/dist/tools/plan-mode.test.js +1 -1
  370. package/dist/tools/prompt-hints.d.ts +9 -0
  371. package/dist/tools/prompt-hints.d.ts.map +1 -1
  372. package/dist/tools/prompt-hints.js +62 -8
  373. package/dist/tools/prompt-hints.js.map +1 -1
  374. package/dist/tools/read-only-bash.d.ts +6 -0
  375. package/dist/tools/read-only-bash.d.ts.map +1 -1
  376. package/dist/tools/read-only-bash.js +168 -9
  377. package/dist/tools/read-only-bash.js.map +1 -1
  378. package/dist/tools/read-only-bash.test.js +49 -0
  379. package/dist/tools/read-only-bash.test.js.map +1 -1
  380. package/dist/tools/safe-env.js +1 -1
  381. package/dist/tools/search-code.d.ts.map +1 -1
  382. package/dist/tools/search-code.js +7 -6
  383. package/dist/tools/search-code.js.map +1 -1
  384. package/dist/tools/search-code.test.js +8 -2
  385. package/dist/tools/search-code.test.js.map +1 -1
  386. package/dist/tools/skill.js +3 -1
  387. package/dist/tools/skill.js.map +1 -1
  388. package/dist/tools/subagent-control.d.ts.map +1 -1
  389. package/dist/tools/subagent-control.js +20 -5
  390. package/dist/tools/subagent-control.js.map +1 -1
  391. package/dist/tools/subagent-control.test.js +34 -1
  392. package/dist/tools/subagent-control.test.js.map +1 -1
  393. package/dist/tools/subagent-shared.d.ts +20 -1
  394. package/dist/tools/subagent-shared.d.ts.map +1 -1
  395. package/dist/tools/subagent-shared.js +34 -7
  396. package/dist/tools/subagent-shared.js.map +1 -1
  397. package/dist/tools/subagent-shared.test.js +43 -9
  398. package/dist/tools/subagent-shared.test.js.map +1 -1
  399. package/dist/tools/subagent.d.ts.map +1 -1
  400. package/dist/tools/subagent.js +11 -8
  401. package/dist/tools/subagent.js.map +1 -1
  402. package/dist/tools/subagent.test.js +3 -0
  403. package/dist/tools/subagent.test.js.map +1 -1
  404. package/dist/tools/task-send.test.js +19 -10
  405. package/dist/tools/task-send.test.js.map +1 -1
  406. package/dist/tools/tool-catalog.test.d.ts +2 -0
  407. package/dist/tools/tool-catalog.test.d.ts.map +1 -0
  408. package/dist/tools/tool-catalog.test.js +124 -0
  409. package/dist/tools/tool-catalog.test.js.map +1 -0
  410. package/dist/tools/tool-search.d.ts.map +1 -1
  411. package/dist/tools/tool-search.js +2 -1
  412. package/dist/tools/tool-search.js.map +1 -1
  413. package/dist/tools/tool-tiers.d.ts +42 -0
  414. package/dist/tools/tool-tiers.d.ts.map +1 -0
  415. package/dist/tools/tool-tiers.js +78 -0
  416. package/dist/tools/tool-tiers.js.map +1 -0
  417. package/dist/tools/tool-tiers.test.d.ts +2 -0
  418. package/dist/tools/tool-tiers.test.d.ts.map +1 -0
  419. package/dist/tools/tool-tiers.test.js +48 -0
  420. package/dist/tools/tool-tiers.test.js.map +1 -0
  421. package/dist/tools/write.test.js +1 -1
  422. package/dist/ui/App.d.ts +3 -0
  423. package/dist/ui/App.d.ts.map +1 -1
  424. package/dist/ui/App.js +39 -3
  425. package/dist/ui/App.js.map +1 -1
  426. package/dist/ui/app-items.d.ts +2 -0
  427. package/dist/ui/app-items.d.ts.map +1 -1
  428. package/dist/ui/app-items.js +2 -0
  429. package/dist/ui/app-items.js.map +1 -1
  430. package/dist/ui/components/Banner.d.ts.map +1 -1
  431. package/dist/ui/components/Banner.js +24 -16
  432. package/dist/ui/components/Banner.js.map +1 -1
  433. package/dist/ui/components/ToolExecution.js +42 -34
  434. package/dist/ui/components/ToolExecution.js.map +1 -1
  435. package/dist/ui/components/force-color.d.ts +2 -0
  436. package/dist/ui/components/force-color.d.ts.map +1 -0
  437. package/dist/ui/components/force-color.js +11 -0
  438. package/dist/ui/components/force-color.js.map +1 -0
  439. package/dist/ui/components/themed-output.test.d.ts +2 -0
  440. package/dist/ui/components/themed-output.test.d.ts.map +1 -0
  441. package/dist/ui/components/themed-output.test.js +111 -0
  442. package/dist/ui/components/themed-output.test.js.map +1 -0
  443. package/dist/ui/error-item.d.ts +1 -1
  444. package/dist/ui/error-item.js +3 -3
  445. package/dist/ui/error-item.js.map +1 -1
  446. package/dist/ui/hooks/useAgentLoop.d.ts +4 -1
  447. package/dist/ui/hooks/useAgentLoop.d.ts.map +1 -1
  448. package/dist/ui/hooks/useAgentLoop.js +27 -2
  449. package/dist/ui/hooks/useAgentLoop.js.map +1 -1
  450. package/dist/ui/login.js +2 -2
  451. package/dist/ui/login.js.map +1 -1
  452. package/dist/ui/render.d.ts +1 -1
  453. package/dist/ui/render.js +6 -6
  454. package/dist/ui/theme/dark-ansi.json +6 -0
  455. package/dist/ui/theme/dark-daltonized.json +6 -0
  456. package/dist/ui/theme/dark.json +6 -0
  457. package/dist/ui/theme/light-ansi.json +6 -0
  458. package/dist/ui/theme/light-daltonized.json +6 -0
  459. package/dist/ui/theme/light.json +6 -0
  460. package/dist/ui/theme/theme.d.ts +6 -0
  461. package/dist/ui/theme/theme.d.ts.map +1 -1
  462. package/dist/ui/tui-terminal-recorder.test.js +1 -1
  463. package/dist/utils/git.test.js +3 -3
  464. package/dist/utils/image.d.ts.map +1 -1
  465. package/dist/utils/image.js.map +1 -1
  466. package/package.json +7 -7
@@ -0,0 +1,164 @@
1
+ # United States
2
+
3
+ Snapshot **11 Aug 2026**. Markers: **[V]** verified against a primary/first-tier source · **[S]** snapshot, re-verify · **[U]** contested or fast-moving.
4
+
5
+ **PRA** = private right of action. This is the field that matters most for a small company: regulator-only laws are a compliance project, PRA laws are a lawsuit.
6
+
7
+ ---
8
+
9
+ ## 0. Scoping reality for a tiny startup
10
+
11
+ Most **comprehensive state privacy laws will not apply** to a pre-scale product — they need tens of thousands of residents' data or large revenue. But four categories apply **at any size**:
12
+
13
+ 1. FTC Act §5 and state unfair-and-deceptive-practices analogues (most state UDAPs *do* have a PRA).
14
+ 2. Breach-notification statutes in every state.
15
+ 3. Sector laws: COPPA, HIPAA, GLBA, TCPA, BIPA, consumer-health-data laws.
16
+ 4. No-threshold plaintiff statutes: CIPA, BIPA, MHMDA, TCPA, VPPA.
17
+
18
+ Also note **Texas and Nebraska have no revenue or volume threshold** — they apply to anyone doing business in-state who is not an SBA "small business", and even exempt small businesses may not sell sensitive personal data without consent **[V]**.
19
+
20
+ **Practical answer:** a US indie app under ~25k users in any single state usually falls outside the comprehensive laws — and is still fully exposed to everything in categories 1–4.
21
+
22
+ ---
23
+
24
+ ## 1. State comprehensive privacy laws
25
+
26
+ **In force in 2026: 20 states** (CA, VA, CO, CT, UT, TX, OR, MT, IA, DE, NE, NH, NJ, TN, MN, MD, IN, KY, RI, and Florida's narrower law which applies only above $1B revenue) **[V]**. Enforcement is AG-only; penalties commonly $7,500–$10,000 per violation **[V]**. Cure periods are expiring across states **[S]**.
27
+
28
+ Thresholds range from 25,000 consumers (Montana) to 175,000 (Tennessee); 10,000 consumers where a share of revenue comes from selling data (RI, DE, NH, MD); Maryland pairs a 35,000-consumer threshold with the strictest data-minimisation and sensitive-data rules, and bans the sale of sensitive data outright **[V]**.
29
+
30
+ **Universal opt-out / Global Privacy Control — the cheapest high-value engineering task.** As of 1 Jan 2026, twelve states require honouring it (CA, CO, CT, DE, MD, MN, MT, NE, NH, NJ, OR, TX); Virginia-template states do not **[V]**.
31
+
32
+ ```
33
+ Read the Sec-GPC: 1 request header and navigator.globalPrivacyControl.
34
+ Treat as an opt-out of sale/share + targeted advertising.
35
+ Apply BEFORE firing any ad pixel. Persist server-side against the user/device.
36
+ Disclose signal handling in the privacy notice.
37
+ ```
38
+ Honouring GPC for **every** visitor is the safe default: it satisfies the strictest state and violates none **[V]**.
39
+
40
+ **Why an ordinary ad pixel triggers everything.** "Sale" requires no money — any disclosure for other valuable consideration counts — and "sharing" expressly covers cross-context behavioural advertising **[V]**. Meta Pixel, GA4 with ad features, TikTok, Reddit and LinkedIn tags are a sale/share/targeted ad in nearly every state. Build: a tag inventory, consent-gated loading, and an opt-out that actually severs the pixel rather than filing a form.
41
+
42
+ **Sensitive data requires opt-in** in Virginia-model states (precise geolocation, race, religion, health, sex life/orientation, immigration status, biometrics, genetic data, children's data) **[V]**. California instead grants a right to limit use.
43
+
44
+ **Minors:** opt-in for targeted ads, sale, and profiling for known 13–16 year-olds; Maryland extends to under-18 on a "should have known" standard **[V]**.
45
+
46
+ **Rights and timing:** access, delete, correct, portability, opt-out, non-discrimination. **45 days, extendable by 45** **[V]**. Virginia-model states require an **appeal** mechanism. California requires two intake methods. Never identity-verify an opt-out — verification is for access/deletion.
47
+
48
+ **Notice content:** categories collected/sources/purposes/recipients, sensitive-data uses, **retention periods per category** (California), rights and how to exercise them, opt-out-signal handling, appeal process, contact, and a last-updated date with an annual refresh **[V]**.
49
+
50
+ **Assessments:** written data-protection assessments required in most Virginia-model states for targeted advertising, sale, sensitive data, and risky profiling; retained and producible to the AG **[V]**.
51
+
52
+ ---
53
+
54
+ ## 2. California specifics
55
+
56
+ **Applicability:** for-profit doing business in CA meeting any one of — annual gross revenue over ~$26.6M (CPI-adjusted), buying/selling/sharing PI of 100,000+ CA consumers or households a year, or 50%+ of revenue from selling/sharing PI **[V]**. Penalties per violation with a higher tier for intentional violations or those involving minors. **Consumers may sue only over certain breaches** ($107–$799 per consumer per incident) — there is no general PRA for policy or opt-out-link failures **[V]**.
57
+
58
+ **2026 regulations package (effective 1 Jan 2026)** **[V]**:
59
+ - *Risk assessments* — begin 1 Jan 2026, complete for ongoing activities by 31 Dec 2027, first certified reports 1 Apr 2028. Triggered by sensitive PI, targeted ads to minors, ADMT for significant decisions, or training ADMT.
60
+ - *ADMT* — pre-use notice, access, and opt-out for automated decision-making about significant decisions (including employees, contractors, applicants). **Compliance deadline 1 Jan 2027.**
61
+ - *Cyber audits* — only above revenue plus scale thresholds; first certifications from 2028. A pre-revenue startup is out of scope.
62
+
63
+ **Delete Act / DROP** — if you sell PI of consumers you have no direct relationship with, you are a data broker. **No revenue threshold.** Registration plus, **from 1 Aug 2026**, processing consumer deletion requests through the state mechanism every 45 days with downstream deletion directives; per-day penalties apply whether or not you registered **[V]**. Enforcement has already hit companies of exactly this size. Ask at design review: *do we sell PI of people who never used us?*
64
+
65
+ **Breach notice (SB 446)** — since 1 Jan 2026, notify affected California residents within **30 calendar days** of discovery, and report to the AG within **15 calendar days** of notifying individuals **[V]**.
66
+
67
+ **AI transparency (SB 942 as amended by AB 853)** — covered providers are generative-AI systems with **over 1M monthly users**; duties operative 2 Aug 2026, with hosting-platform duties from 1 Jan 2027 **[V]**. Most small devs are out of scope, but the hosting-platform duty catches anyone distributing GenAI systems.
68
+
69
+ **AB 2013 training-data transparency** — **no size threshold**. Developers of generative AI systems made available to Californians must publish training-data documentation; compliance required from 1 Jan 2026 and on substantial modification **[V]**. Catches small fine-tuners, not mere API consumers.
70
+
71
+ **SB 243 companion chatbots — the highest-risk new law for small AI apps.** Effective 1 Jan 2026. Applies to chatbots sustaining a relationship or human-like emotional engagement (excludes customer-service bots, limited game NPCs, voice assistants). Requires non-human disclosure, mental-health crisis protocols, and minor protections including blocking sexual content and enforcing breaks. **PRA: YES** — minimum $1,000 damages plus fees, and UCL pairing can reach individuals personally **[V]**.
72
+
73
+ **Employment ADS regulations** under state anti-discrimination law add notice and recordkeeping duties for automated decision systems **[S]**.
74
+
75
+ ---
76
+
77
+ ## 3. Children and teens
78
+
79
+ **COPPA amended Rule — full compliance date 22 Apr 2026** **[V]**. Trigger: a child-directed service, or actual knowledge of collecting personal information from under-13s. Mixed-audience services may age-screen. Concrete changes:
80
+
81
+ - **Separate** verifiable parental consent for disclosing children's data to third parties (including for targeted advertising).
82
+ - New **data-retention limits** and a **published written retention policy** — indefinite retention is prohibited.
83
+ - Broader definition of personal information now expressly including **biometric identifiers** (face templates, fingerprints, voiceprints), government identifiers, phone numbers, audio recordings, and certain geolocation.
84
+ - A written children's information security programme with vendor due diligence.
85
+ - Parent review/deletion flows must cover biometric data.
86
+
87
+ **App Store Accountability Acts (TX, UT, LA, AL, CA)** — these impose duties on **app developers**, not just the stores **[V]**. Texas SB 2420 is in effect after appellate and Supreme Court refusals to freeze it (which is not a ruling on constitutionality) **[V]**; Utah developer requirements from 6 May 2026; Louisiana 1 July 2026; California 1 Jan 2027 **[V]**. Build: consume the store's age-signal API, branch features on age category, store only a category flag, re-request consent on significant app changes. Some states allow private suits.
88
+
89
+ **NY SAFE for Kids** — final rules July 2026, effective **25 Jan 2027**, targeting platforms with addictive feeds **[V]**.
90
+
91
+ **Adult content age verification** — 26 states with live laws following the 2025 Supreme Court decision upholding Texas's law **[V]**. Typical trigger is ≥1/3 sexual material harmful to minors, a few with no threshold. Use a third-party verifier returning a boolean; retain nothing reconstructable; geo-route per state. Several states allow private suits.
92
+
93
+ **TAKE IT DOWN Act §3 (NCII) — enforced from 19 May 2026, and it reaches tiny platforms** **[V]**. Any site, app or service that hosts user content must publish a plain-language notice-and-removal process usable by **users and non-users**, and remove reported non-consensual intimate imagery — including AI-generated — plus known identical copies **within 48 hours**. Non-compliance is trivially detectable: a regulator just checks whether the notice exists. Build `/report/ncii`, an acknowledgement + 48h SLA timer, hash-based re-upload suppression, and a footer link.
94
+
95
+ **CSAM reporting** — providers must report apparent child sexual abuse material to the national tipline as soon as reasonably possible after obtaining actual knowledge, with a **one-year preservation** duty; there is no general proactive monitoring mandate **[V]**. Register a point of contact, define an escalation path, and never re-transmit the material except to the tipline or law enforcement.
96
+
97
+ ---
98
+
99
+ ## 4. Health, biometric, genetic, location
100
+
101
+ **HIPAA usually does *not* cover a direct-to-consumer wellness app** — it reaches covered entities and their business associates. You become a business associate the moment you handle PHI *on behalf of* a covered entity, which requires a BAA, Security Rule compliance, and 60-day breach notice **[V]**. If you are not HIPAA, you are in the consumer-health-data regime below.
102
+
103
+ **Washington My Health My Data Act — the top small-company landmine.** **No revenue or volume threshold**, in effect since 2024 **[V]**. "Consumer health data" is defined broadly enough to include precise location that could indicate seeking health services. Requires a **standalone** consumer-health-data privacy policy at its own link, **separate consent for collection**, **separate consent for sharing**, and a **distinct signed authorisation to sell**, plus a geofencing prohibition and processor contracts. **PRA: YES**, via the state consumer-protection act, up to $7,500 per violation **[V]**. The first class action targeted an ordinary ad SDK collecting location. Any period tracker, fitness, mental-health, or symptom app — or anything collecting precise location — is squarely in scope. Nevada has a similar regime without a PRA **[V]**.
104
+
105
+ **Illinois BIPA** — see `lawsuit-vectors.md` §3. Required **before first capture**: written notice of collection and specific purpose, notice of the retention schedule and destruction guidelines, a **written release**, a publicly available retention/destruction policy, no profiting from biometrics, and reasonable-care storage **[V]**. Texas and Washington have AG-enforced analogues.
106
+
107
+ **Genetic data** — roughly 14 states require separate express consent per purpose and per disclosure; some allow private suits **[S]**. Treat raw DNA as opt-in-per-purpose and get counsel.
108
+
109
+ **Precise geolocation** — sensitive/opt-in in every Virginia-model state, and health-linked location is consumer health data **[V]**. Request coarse location by default; never ship precise location to ad SDKs.
110
+
111
+ **FTC Health Breach Notification Rule** — applies to non-HIPAA health apps that can draw data from multiple sources (e.g. platform health data plus user input). Critically, a "breach" includes an **unauthorised disclosure** — firing a health event to an ad pixel is itself reportable **[V]**. 500+ affected means notifying the regulator within 60 days.
112
+
113
+ ---
114
+
115
+ ## 5. AI laws
116
+
117
+ - **Colorado** — the original AI Act was delayed and then repealed/replaced with a narrower automated-decision framework; assume a scaled-back regime effective **1 Jan 2027** and verify the enrolled text before building **[U]**.
118
+ - **Texas TRAIGA** — effective 1 Jan 2026, reaching out-of-state developers whose AI is accessible to Texas users. Intent-based liability for AI that promotes self-harm, facilitates crime, discriminates, or produces prohibited deepfakes. AG-only with a 60-day cure; **safe harbour for documented NIST AI RMF-aligned compliance** **[V]**. Practical step for a small dev: a one-page RMF-aligned policy plus retained prompt/eval logs.
119
+ - **Illinois HB 3773** — from 1 Jan 2026, using AI with a discriminatory *effect* in employment violates the state human-rights act; intent is no defence **[V]**.
120
+ - **NYC Local Law 144** — annual independent bias audit plus published summary and candidate notice for automated employment decision tools used for NYC roles **[V]**.
121
+ - **Mental-health AI** — Illinois bans AI delivering mental-health treatment or clinical decisions outright; Nevada, Utah and Tennessee restrict or require disclosure; treat "AI therapist" as a **hard gate** **[V]**.
122
+ - **Companion chatbots** — California (PRA), New York (AG-only), Oregon (PRA, from 2027), Washington (from 2027) **[V]**. **Baseline build for any consumer LLM chat:** persistent non-human disclosure, self-harm detection with a crisis interstitial, minor-mode content restrictions and break reminders, retained incident logs.
123
+ - **Frontier-model laws** target training compute far beyond any small developer **[V]**.
124
+ - **Federal posture** — a December 2025 executive order seeks to weaken state AI regulation via litigation and funding conditions, with a DOJ task force operating from January 2026 **[V]**. Do **not** advise a user to ignore state AI law on this basis; the laws remain in force unless and until enjoined.
125
+
126
+ ---
127
+
128
+ ## 6. Cross-cutting federal
129
+
130
+ - **FTC Act §5** — any statement in your privacy policy, marketing page, app-store listing or in-app copy that is not literally true of your code is deception. Dark patterns in consent and cancellation flows are deception/unfairness; failure to maintain reasonable security is unfairness **[V]**. No federal PRA, but most state UDAP analogues have one.
131
+ - **Consumer Reviews and Testimonials Rule** — prohibits fake, incentivised-by-sentiment, and undisclosed insider reviews, with civil penalties in the tens of thousands per violation; enforcement is active **[V]**.
132
+ - **Negative option / click-to-cancel** — the federal rule was vacated in 2025 and a new rulemaking is under way **[V]**. Do not tell a user they are safe: ROSCA and ~25 state auto-renewal laws still govern, and California's amended law broadened liability **[V]**.
133
+ - **TCPA** — see `lawsuit-vectors.md` §4. Consent records, revocation handling on any channel, quiet hours in the recipient's timezone, DNC scrubbing, carrier campaign registration **[V]**. Exact effective dates of the universal-revocation mandate are reported inconsistently **[U]**.
134
+ - **CAN-SPAM** — accurate headers and subject, advertising identification, **valid physical postal address**, working opt-out honoured within **10 business days** and functional for 30 days after send; you are liable for your sending platform and affiliates **[V]**.
135
+ - **State breach notification** — all states; deadlines and AG-notice thresholds vary; several sector rules add shorter clocks **[V]**.
136
+ - **ADA accessibility** — Title II has fixed rule deadlines for public entities; Title III private-business exposure is driven by private litigation rather than a technical rule **[V]**. WCAG 2.1 AA is the practical benchmark.
137
+ - **GLBA Safeguards Rule** — "financial institution" is far broader than banks and catches many fintech, lending, tax-prep and advisory products: written InfoSec programme, a named qualified individual, MFA, encryption, vendor oversight, and 30-day regulator notice for larger incidents **[V]**.
138
+ - **FCRA** — if you assemble or use consumer reports for employment, tenant, credit or insurance decisions: permissible purpose, **standalone** disclosure plus authorisation, pre-adverse-action packet with a waiting period, adverse-action notice. **PRA: YES**, with heavy class-action volume over standalone-disclosure defects **[V]**.
139
+ - **ECOA/Reg B and FHA** — adverse-action notices with **specific principal reasons** within 30 days. A black-box model that cannot articulate reasons is itself the violation **[V]**. **PRA: YES.**
140
+
141
+ ---
142
+
143
+ ## 7. PRA ranking — what actually produces suits against small companies
144
+
145
+ 1. California CIPA (trackers, pixels, chat widgets, session replay) — $5,000 per violation, no threshold **[V]**
146
+ 2. ADA Title III accessibility (plus state statutory damages) **[V]**
147
+ 3. TCPA/SMS — $500–$1,500 per message, uncapped **[V]**
148
+ 4. Illinois BIPA — per-person statutory damages, a single in-state user suffices **[V]**
149
+ 5. Washington MHMDA — up to $7,500 per violation, extremely broad health-data definition **[V]**
150
+ 6. Auto-renewal claims via state consumer statutes **[V]**
151
+ 7. CCPA breach claims — $107–$799 per consumer, filed reflexively after AG breach reports **[V]**
152
+ 8. California SB 243 companion chatbots — new, untested, minimum $1,000 plus fees **[V]**
153
+ 9. VPPA — video plus ad pixel, $2,500 per person, circuit split **[U]**
154
+ 10. FCRA — standalone-disclosure defects **[V]**
155
+ 11. State wiretap analogues beyond California **[U]** on the exact state list
156
+ 12. AI employment discrimination — low volume today, rising **[S]**
157
+
158
+ **Regulator-only (no PRA):** every state comprehensive privacy law except California's breach claim, COPPA, TAKE IT DOWN, TRAIGA, frontier-model laws, SB 942, NYC LL144, Nevada health law, the Delete Act, GLBA, CAN-SPAM, and FTC rules.
159
+
160
+ ---
161
+
162
+ ## 8. Verify before relying
163
+
164
+ Colorado's replacement AI law text and date · Vermont and Nebraska children's-code dates · the TCPA universal-revocation effective date · VPPA scope · state mini-TCPA and mini-wiretap lists · genetic-privacy specifics per state · SaaS sales-tax nexus.
@@ -0,0 +1,111 @@
1
+ ---
2
+ name: durable
3
+ description: Use when user data must not be lost or corrupted — creating the first database/table/schema, writing migrations, backfilling or importing data, any destructive operation (delete, drop, truncate, overwrite), setting up backups or recovery, or moving data between systems; and for "is my data safe", "will I lose my data", "back up my app" checks on existing projects. Any store — SQL (Postgres, MySQL, SQLite), document (Mongo, Firestore), serverless (Supabase, Neon, Turso), files, queues. Do NOT use for query speed or connection-pool sizing (that is lean), access control over data (that is bulletproof), or privacy/legal deletion regimes (that is compliance-guard).
4
+ license: Data-durability engineering guidance, not a DBA certification. Sources and snapshot date are recorded at the foot of each reference file.
5
+ compatibility: Snapshot dated 17 August 2026. Version behaviors (fast-path ALTERs, pooler modes, tool flags) decay — re-verify with web access before asserting them as current.
6
+ ---
7
+
8
+ # Durable
9
+
10
+ Make user data survive everything: bad migrations, crashed writes, retried webhooks, full disks, dead servers, and the 3am `DELETE` without a `WHERE`. Built for the reality that users forgive slow and ugly; they do not forgive gone.
11
+
12
+ **This skill is on from the first table.** The default mode is the inline gate below — every schema change, import, and destructive path gets the durable treatment as it is written. The full pass is for existing projects and "is my data safe" checks.
13
+
14
+ ## Governing rules
15
+
16
+ 1. **The database is the last line of defense, not the app.** Constraints, foreign keys, uniqueness, and NOT NULL live in the store where enforcement cannot be bypassed. App-level validation is UX, not integrity — a bug, a script, or a direct SQL session walks right past it.
17
+ 2. **Destructive operations are guilty until proven guarded.** Any `DROP`, `TRUNCATE`, `DELETE`, `UPDATE` without a `WHERE`, or overwrite of a column/file gets: a guard (`WHERE` + `LIMIT`), a dry-run count first, a backup or snapshot when anything of value exists, and an undo path (soft delete, staging table, or copy) for user-facing data.
18
+ 3. **Migrations are code that runs on data you cannot recreate.** Checked in from day one, reviewed as SQL before applying (ORM-generated SQL included — generators will happily emit `DROP COLUMN` for a rename), never edited once applied, forward-only in production. `db push`-style sync is for throwaway dev databases only.
19
+ 4. **One logical change, one transaction.** Multi-step writes either all land or none do. Anything a retry can hit twice (webhooks, queue jobs, imports, payment callbacks) is idempotent — a dedup key or upsert, not hope.
20
+ 5. **Backups you have not restored are fiction.** Automated, off-platform (or at least off-instance), on anything with real user data — and the restore is exercised, timed, and recorded. RPO (how much loss is acceptable) and RTO (how long recovery takes) are stated numbers, not vibes.
21
+ 6. **Fail loudly, not corruptly.** Partial imports, half-applied backfills, and crashed jobs leave the system in a state the next run can detect and resume — keyset-resumable batches, recorded checkpoints, no silent skips.
22
+ 7. **Respect the writer.** SQLite has one writer; Postgres connections are processes; serverless poolers multiplex transactions and break session state. Designing against the store's real concurrency model is durability work, not just performance work.
23
+ 8. **Numbers or silence.** A backup claim without a timed restore run is unverified. Label every claim `RUNTIME` (observed), `CODE` (read in source), `DEDUCED` (inferred), `SNAPSHOT` (dated source). Never claim data is "safe" — say what loss is survivable and what is not.
24
+ 9. **Proportionality.** A prototype with test rows needs migrations and little else. The first real user row raises the floor: backups, then tested restore, then PITR-class recovery as the product matters.
25
+
26
+ ## Two modes
27
+
28
+ **Inline gate** — while writing anything that touches stored data: the first table, a schema change, a backfill or import script, a delete/edit endpoint, a webhook that writes, a backup cron. Apply the binding defaults below, say one line about the guard you built, move on. Do not stop the build to lecture, and do not ship the unguarded version intending to "add safety later".
29
+
30
+ **Full pass** — triggered by "is my data safe", "will I lose my data if X", "back up my app", a migration about to run on production, or after any data scare. Run the workflow below. Migration and schema detail lives in `references/migrations-and-schema.md`; backups, recovery, and runtime data-safety detail lives in `references/backups-and-runtime.md`.
31
+
32
+ ## Binding defaults (build mode)
33
+
34
+ Apply on every data-touching change, every store:
35
+
36
+ - **Migration tooling from the first table** — checked-in versioned migrations, generated with `--create-only`-style review when the ORM supports it, reviewed as SQL, applied via the tool's deploy path. Never hand-edit an applied migration; write a new one that corrects it.
37
+ - **Destructive ops carry their guard** — `WHERE` + `LIMIT` on mass changes, count-first dry run (`SELECT` the affected rows before `DELETE`/`UPDATE`), and for user-visible data prefer soft delete (`deleted_at`) with partial unique indexes over hard delete until retention policy says otherwise.
38
+ - **Constraints in the store** — `NOT NULL` on required fields, `UNIQUE` where identity lives (email, external IDs), foreign keys with explicit `ON DELETE` behavior chosen (not defaulted), and `CHECK` where a value has a domain. Orphaned rows and duplicate emails are app bugs the DB should have refused.
39
+ - **Transactions around multi-write invariants** — wrap create-order-plus-items, transfer-out-plus-transfer-in, and every read-modify-write that must not interleave. Where the store lacks multi-document transactions, the default is a single-document design or an outbox pattern, never "should be fine".
40
+ - **Idempotency keys on retried writes** — webhook event IDs, job dedup keys, `INSERT ... ON CONFLICT` upserts. Rule of thumb: if it can run twice, assume it will.
41
+ - **Batched, resumable bulk work** — keyset pagination (`WHERE id > last`), fixed batch size, sleep between batches, checkpoint recorded so a crash resumes rather than restarts or double-applies. Never one unbounded `UPDATE` over a production table.
42
+ - **Backups the moment real data exists** — automated (managed-provider backups, `pg_dump` cron, Litestream for SQLite, scheduled snapshots for document stores), retention of days not one copy, at least one copy off the same machine/account. State RPO/RTO in a comment where the backup is configured.
43
+ - **Connection and session hygiene** — close/release connections in `finally`; on serverless, assume transaction-mode pooling (no session state, no prepared statements unless the pooler supports them, no `LISTEN/NOTIFY`, no session advisory locks); one pool per function instance, not per request.
44
+ - **SQLite as SQLite** — WAL mode on, `busy_timeout` set, one writer (route writes through a single instance or a queue), database on local disk not network storage, Litestream-or-scheduled-backup for continuous protection. Do not pretend it is a client-server DB.
45
+
46
+ ## Full-pass workflow
47
+
48
+ ### 1. Profile the data from the code
49
+
50
+ Before asking anything: store type(s) and version, where data files live, ORM/migration tooling present or absent, what writes exist (endpoints, jobs, webhooks, imports), what deletes exist, whether backups are configured anywhere (deploy config, cron, provider settings), and — decisive — whether real user data exists. A repo with seed scripts only is a different engagement than one with a production URL.
51
+
52
+ ### 2. Establish what loss would mean
53
+
54
+ From the code, answer: what is recreated (cache, derived data), what is user-entered and unrecoverable (posts, uploads, messages, payments), and what links out (files on disk referenced by rows, rows referencing deleted files). The unrecoverable set defines backup urgency; the links define cleanup discipline.
55
+
56
+ ### 3. Sweep the six areas
57
+
58
+ In order of how often each actually loses data. Detection specifics and commands: the two reference files.
59
+
60
+ | # | Area | What you are hunting |
61
+ |---|---|---|
62
+ | 1 | **Backups & recovery** | No backups at all; backups only on the same machine/account; no retention; never-restored backups (the norm); no stated RPO/RTO; single copy of file uploads; managed backups assumed but not enabled |
63
+ | 2 | **Destructive paths** | `DELETE`/`UPDATE` without `WHERE` or `LIMIT`; cascade deletes that sweep further than intended (user → everything they own, intended or not); truncate/drop in scripts; no undo for user-facing deletes; `db push` or sync-style schema changes anywhere near production config |
64
+ | 3 | **Migrations health** | No migration tooling (schema by hand/script); applied migrations edited; pending destructive migration; generated SQL never reviewed; migrations untested against prod-shaped data; drift between schema files and the live DB |
65
+ | 4 | **Transactions & idempotency** | Multi-step writes without a transaction; webhook/job handlers that double-apply on retry; check-then-act races (read, decide, write without a constraint); imports that restart from zero |
66
+ | 5 | **Schema integrity** | Foreign keys absent or off (MySQL engines, SQLite `PRAGMA foreign_keys`); duplicate-prone columns without unique constraints; orphaned rows; `NOT NULL`-in-spirit columns that are nullable in fact; money/IDs stored in lossy types (float money, int IDs near overflow) |
67
+ | 6 | **Runtime data safety** | Transaction-pooled connections using session features; SQLite without WAL/busy_timeout or with concurrent writers across instances; files written non-atomically (no temp-then-rename); jobs that mutate state with no record of having run; queues with no dead-letter path |
68
+
69
+ ### 4. Rank by survivability
70
+
71
+ | Severity | Meaning |
72
+ |---|---|
73
+ | **Critical** | Loss is certain or one common failure away: real user data with no backups; destructive path unguarded; pending migration that drops data; double-charge/double-apply on retry |
74
+ | **High** | Loss on a plausible bad day: backups exist but never restored; single copy on one machine/account; cascade deletes broader than intended; multi-write flows without transactions |
75
+ | **Medium** | Fragility that bites at scale or during recovery: missing constraints, schema drift, non-idempotent jobs, non-atomic file writes |
76
+ | **Low** | Hygiene: naming, unused staging tables, comments. Do these when adjacent to a real fix. |
77
+
78
+ Fix Critical and High first; three to five fixes, each verified. A backup you set up is finished only when a restore from it has run and been timed.
79
+
80
+ ### 5. Verify
81
+
82
+ - **Restore drill for any backup fix**: snapshot state, note the time, make a recognizable change, restore to the noted time into a separate location, verify the change is absent, record the wall-clock duration — that number is the real RTO. `RUNTIME` label or it did not happen.
83
+ - **Guard drill for any destructive fix**: run the guarded path against a copy with a row that must survive and a row that must not; assert both outcomes.
84
+ - **Migration drill**: apply the pending migrations to a copy of production-shaped data (a fresh dump, a seeded volume) before it goes near the real thing.
85
+ - Label what you could not run — no environment, no data copy, managed console you cannot touch — as unverified, and say the exact command the user should run.
86
+
87
+ ### 6. Leave a guard behind
88
+
89
+ A tested restore cron'd into a weekly job; a CI step that applies migrations to a throwaway DB before merge; a test that a retried webhook applies once; a constraint added to the store; `--create-only` review in the project's migration docs. One mechanical check beats a README paragraph.
90
+
91
+ ### 7. Report
92
+
93
+ - Lead with the survivability statement in plain words: "if this server dies right now, you lose everything after [backup point]" — the RPO the user actually has, not the one they think they have.
94
+ - Then findings ranked, each with file/line and the fix.
95
+ - Then what was **not checked** — stores skipped, consoles inaccessible, uploads unexamined.
96
+ - Then what you fixed (with verification labels) vs. what needs the user (provider settings, paid tiers, their call on retention).
97
+ - Label every claim `RUNTIME` / `CODE` / `DEDUCED` / `SNAPSHOT`.
98
+
99
+ ## Honesty rules
100
+
101
+ - Never state or imply data is "safe" or "backed up" without an observed, timed restore. "Backups are configured" is a `CODE` claim; "recoverable" requires a `RUNTIME` one.
102
+ - Never present a retention number, provider tier, or version behavior as current without verifying — provider backup defaults change; mark the snapshot date.
103
+ - Never run a destructive command, however obviously safe, against a database with real data without an explicit backup or the user's go-ahead.
104
+ - "I could not verify this" is a legitimate output. A fabricated restore test is the worst lie this skill could tell.
105
+
106
+ ## Reference map
107
+
108
+ Resolve every path from the installed skill root. Load only what the profile triggered.
109
+
110
+ - `references/migrations-and-schema.md` — the migration discipline: expand-contract with concrete lock behavior, batched resumable backfills, index and FK lock-safety, ORM-specific traps (Prisma, Drizzle, and friends), forward-only production, CI and deploy-time application, and schema integrity checks. Read for any migration or schema finding.
111
+ - `references/backups-and-runtime.md` — backup tiers and the restore drill, RPO/RTO, 2026 managed-provider baselines (Supabase, Neon, RDS, Crunchy), self-hosted tooling (pgBackRest, WAL-G, Litestream, restic), file-upload protection, idempotency and outbox patterns, pooling and serverless session-state pitfalls, SQLite runtime rules, and atomic file writes. Read for any backup, recovery, or runtime finding.
@@ -0,0 +1,86 @@
1
+ # Durable — backups, recovery & runtime data safety
2
+
3
+ Load for any backup, recovery, or runtime finding. `SNAPSHOT` = sourced 17 August 2026 — provider tiers and defaults change often; verify before asserting.
4
+
5
+ ## Part 1 — Backups & recovery
6
+
7
+ ### RPO/RTO first
8
+
9
+ - **RPO** (Recovery Point Objective): how much data loss is acceptable — "5 minutes" vs "a day".
10
+ - **RTO** (Recovery Time Objective): how long until you are back up.
11
+
12
+ Pick both consciously; they dictate the tier. An app where users type for hours wants an RPO near zero; a read-mostly catalog may accept a day. Stating them where the backup is configured turns "we have backups" into an actual contract.
13
+
14
+ ### The tiers, best to weakest
15
+
16
+ 1. **PITR (point-in-time recovery)** — base backup + continuous write-ahead-log archive; restore to any second in the retention window. RPO of seconds-to-minutes. Gold standard for transactional data.
17
+ 2. **Scheduled logical dumps** (`pg_dump`, `mongodump`, Firestore export) — portable, cheap, easy to verify by inspection; but restore time scales with size and everything after the dump starts is lost. Fine as the archive layer or the only layer for small apps.
18
+ 3. **Storage/block snapshots** — fast, near-zero impact; restoring a running DB from a raw snapshot leaves crash recovery to do the rest. Good for staging clones; for disaster recovery prefer PITR.
19
+ 4. **Nothing / a copy on the same machine** — the default state of most small projects, and the finding most often reported after it stops mattering.
20
+
21
+ **3-2-1 floor**: at least 3 copies, 2 different media/systems, 1 off-site (different provider or account is fine). A dump cron writing to the same VPS is one disk failure from zero.
22
+
23
+ ### Managed-provider baselines (`SNAPSHOT` 17 Aug 2026 — verify tiers/retention before quoting)
24
+
25
+ | Provider | What you get by default/on paid tiers |
26
+ |---|---|
27
+ | Supabase | Pro: 7-day PITR included; daily logical backups; restore lands a new project |
28
+ | Neon | Continuous WAL archive; PITR up to 30 days on higher tiers; branching doubles as time-travel |
29
+ | AWS RDS | Automated backups 1–35 days (PITR); manual snapshots on demand |
30
+ | Crunchy Bridge | 14-day PITR by default; longer via S3 archive |
31
+ | MongoDB Atlas | Continuous backup / cloud snapshots by tier |
32
+
33
+ The recurring failure: the free tier's weekly backup or none at all, assumed to be PITR because the marketing page said "backups". Check the project's actual settings, not the provider's homepage.
34
+
35
+ **Self-hosted Postgres**: pgBackRest, Barman, or WAL-G → S3-compatible storage. **Self-hosted/embedded SQLite**: Litestream (continuous WAL replication to object storage, near-zero RPO) or restic/borg on a schedule as the weaker floor. **Firestore/DynamoDB-style**: scheduled exports to storage — PITR is a paid or absent feature; check the project's state.
36
+
37
+ ### The restore drill (the only proof)
38
+
39
+ 1. Note the current time / snapshot point of a known state.
40
+ 2. Make a recognizable change (insert a canary row).
41
+ 3. Restore to the noted point into a *separate* location — never over the live DB.
42
+ 4. Verify the canary is absent. Time the whole operation — that measured duration is the real RTO; write it down.
43
+ 5. Repeat on a schedule (quarterly is the common bar); the drill doc itself is the runbook you'll follow at 3am.
44
+
45
+ **File uploads need their own answer** — DB backups don't cover a disk of user uploads unless the backup includes the volume or the uploads live in object storage with versioning (S3 versioning or equivalent preserves deleted/overwritten objects — turn it on and state the retention). DB row + orphaned-file mismatch is a finding: cleanup discipline (delete file then row, in that order, with the row's file path recorded for resweep) or accept orphans.
46
+
47
+ ### What a backup must exclude/include
48
+
49
+ Include: the data, schema history (migrations), and anything unrecreatable (uploads, generated-but-expensive artifacts). Exclude/rotate: secrets in plaintext dumps (a dump with PII inherits compliance-guard's storage rules — encrypt at rest, restrict access), logs, caches. Test that the restore includes what you think: a backup that skips a table because of a wrong flag is the most humiliating restore failure.
50
+
51
+ ## Part 2 — Runtime data safety
52
+
53
+ ### Idempotency & exactly-once writes
54
+
55
+ Anything retried — webhooks, queue jobs, mobile clients on flaky networks, imports — **will** run twice. Patterns, in order of preference:
56
+
57
+ - **Store-side dedup**: unique constraint on the natural key (webhook event ID, job ID + attempt) and `INSERT ... ON CONFLICT DO NOTHING` returning whether it inserted. The store is the arbiter; no race can beat it.
58
+ - **Upsert by natural key**: `ON CONFLICT ... DO UPDATE` with a deterministic outcome, so replay converges instead of duplicating.
59
+ - **Compare-and-set / optimistic concurrency**: `UPDATE ... WHERE version = :expected`, check affected count — the guard for read-modify-write races (balance updates, seat claims, counter increments).
60
+ - **Outbox pattern**: state changes and the events they trigger written in one transaction to an outbox table, published by a separate relay — eliminates "DB updated but email/queue lost" (and its evil twin, "email sent but DB rolled back"). The default answer where a store lacks cross-service transactions.
61
+
62
+ Check-then-act without a constraint (`if not exists: insert`) is a bug that just hasn't raced yet.
63
+
64
+ ### Connection & session pitfalls (correctness, not speed)
65
+
66
+ - **Transaction-mode poolers** (PgBouncer/Supavisor, Neon pooler, RDS Proxy defaults): each transaction may run on a different connection — session state breaks. Casualties: session-level `SET`/`prepared statements` (named ones), advisory locks, `LISTEN/NOTIFY`, temp tables, `COPY`. Patterns: keep per-transaction state in SQL (`SET LOCAL`), use `pg_advisory_xact_lock` (transaction-scoped), or route state-needing work to a direct/session connection.
67
+ - **Serverless functions**: one pool per *instance* (module scope), never per request; assume the process freezes between invocations — no in-memory "it'll flush later".
68
+ - **Postgres connections are processes** — exhausting them fails every new client; the fix is a pooler, not a bigger `max_connections`. (Sizing the pool for throughput is lean's lane.)
69
+ - **Always release/close in `finally`** — a leaked connection per request is a slow outage and a durability finding.
70
+
71
+ ### SQLite runtime rules
72
+
73
+ - **WAL mode on** (`PRAGMA journal_mode=WAL`) — readers don't block the writer; the default rollback journal serializes everything.
74
+ - **`busy_timeout` set** (e.g. 5000ms) — without it, concurrent access returns `SQLITE_BUSY` instantly instead of waiting.
75
+ - **`PRAGMA foreign_keys = ON` on every connection** — it is per-connection and off by default; constraints silently unenforced is a schema-integrity finding wearing runtime clothes.
76
+ - **One writer** — route writes through a single instance or a write queue; multiple app instances writing one SQLite file on shared/network storage corrupts. Local disk (NVMe), not NFS.
77
+ - **Backup without Litestream**: `VACUUM INTO 'backup.db'` or the `sqlite3 .backup` command — never copy the file mid-write; the WAL file and the checkpoint state are part of the database.
78
+
79
+ ### Atomic file writes and cleanup
80
+
81
+ - **Temp-then-rename** for any file a reader may open: write to `path.tmp`, `fsync`, then `rename` over the target. Atomic on POSIX; a crash mid-write never leaves a truncated JSON the app will happily parse.
82
+ - **Delete in dependency order and resweep**: child rows then parent; file after the row referencing it is gone (or record orphans for a sweep job). Reversible orderings first: soft-delete the row, mark the file, sweep files later — undoability beats tidiness.
83
+
84
+ ---
85
+
86
+ **Provenance:** snapshot 17 August 2026. Sources: Postgres WAL/PITR documentation and pgBackRest/Barman/WAL-G docs, Litestream documentation (SQLite WAL replication), provider documentation for Supabase/Neon/RDS/Crunchy/MongoDB Atlas backup tiers (tier specifics are `SNAPSHOT` — they change often), PgBouncer documentation (transaction-mode feature matrix), SQLite documentation (WAL, busy_timeout, foreign_keys pragma, VACUUM INTO), current disaster-recovery practice guides (3-2-1, RPO/RTO, restore drills). Provider tiers and defaults decay fastest — re-verify before asserting.
@@ -0,0 +1,79 @@
1
+ # Durable — migrations & schema
2
+
3
+ Load for any migration or schema finding. Postgres examples dominate because it is the default; MySQL and SQLite divergences are called out. `SNAPSHOT` = sourced 17 August 2026 — version behaviors decay, verify before asserting.
4
+
5
+ ## The one rule that prevents most downtime
6
+
7
+ **Never deploy a schema change and the code that depends on it in the same step.** Old code must keep working against the new schema, and new code must keep working against the old schema, for at least one deploy cycle. That is what expand-contract buys.
8
+
9
+ ## Expand-contract (parallel change)
10
+
11
+ Every breaking change is two or three separately-deployed steps, each leaving the system fully functional:
12
+
13
+ 1. **Expand** — add the new column/table/index (nullable, no constraints yet). Old code ignores it; nothing breaks.
14
+ 2. **Backfill + dual-write** — copy old data to new in batches; code writes both; code reads new with fallback to old. Deploy, watch, wait.
15
+ 3. **Contract** — after the old path is provably dead (feature flag flipped, traffic at zero), remove the old column and the dual-write.
16
+
17
+ Rollback at any point is "flip back to the old path", not "restore the database".
18
+
19
+ **Rename a column** — never `RENAME COLUMN` on a live system (breaks all in-flight code): add `email`, backfill from `email_addr`, dual-write, switch reads, drop `email_addr` in a later deploy.
20
+
21
+ **Change a type or split a column** — add the new column, backfill with transformation in batches, cut writes over, drop old. Same shape, always.
22
+
23
+ ## Lock-safety table (Postgres)
24
+
25
+ What common DDL actually does to a live table (`SNAPSHOT` — verify per version):
26
+
27
+ | Operation | Behavior | Safe pattern |
28
+ |---|---|---|
29
+ | `ADD COLUMN` (no default) | Fast, brief lock | Fine as-is |
30
+ | `ADD COLUMN ... NOT NULL DEFAULT x` | Fast since Postgres 11 (default not backfilled); table rewrite before 11 | Fine on ≥11; otherwise add nullable → backfill → `SET NOT NULL` |
31
+ | `SET NOT NULL` on existing column | Full-table scan under lock | Backfill first, then set; or add a `CHECK` constraint `NOT VALID` then `VALIDATE`, then switch |
32
+ | `CREATE INDEX` | Blocks writes for the whole build | `CREATE INDEX CONCURRENTLY` (drop with `DROP INDEX CONCURRENTLY`); slower, non-transactional — if it fails, drop the invalid index and retry |
33
+ | `ADD FOREIGN KEY` | Locks while validating all rows | Two-step: `ADD CONSTRAINT ... NOT VALID` then `VALIDATE CONSTRAINT` (weaker lock) |
34
+ | One giant `UPDATE`/`DELETE` | Locks rows, bloats the table, stalls replication | Batch: keyset-select N rows → update → sleep → repeat, resumable from last key |
35
+ | `DROP COLUMN` | Fast (metadata) — but data is gone | Only in the contract phase, after dual-write is verified dead |
36
+
37
+ MySQL has no `CONCURRENTLY`: use `ALGORITHM=INSTANT/INPLACE` where the version supports it, `gh-ost` or `pt-online-schema-change` for big tables (`SNAPSHOT` — both maintained; verify current). Postgres big-table rebuilds (PK change, deep bloat, partitioning): `pg_repack`, which rebuilds online with minimal locking and needs ~2x disk temporarily.
38
+
39
+ ## Resumable backfill skeleton
40
+
41
+ ```sql
42
+ -- keyset, not OFFSET: stable order, restartable from last processed id
43
+ UPDATE users
44
+ SET status = 'active'
45
+ WHERE id IN (
46
+ SELECT id FROM users WHERE id > :last_id AND status IS NULL
47
+ ORDER BY id LIMIT 5000
48
+ )
49
+ RETURNING id; -- record max(id) as the checkpoint; sleep between batches
50
+ ```
51
+
52
+ From application code the same shape applies: select batch by `id > last`, write, record checkpoint durably (a checkpoint table or job state), sleep. A crashed backfill resumes at the checkpoint instead of restarting or double-writing. On stores without `RETURNING`, select the batch first, update by primary key, checkpoint the max selected id.
53
+
54
+ ## Migration tooling discipline
55
+
56
+ - **Versioned, checked-in migrations from the first table** — Alembic (Python), Flyway/Liquibase (JVM), golang-migrate (Go), sqlx/Diesel (Rust), Drizzle Kit / Prisma Migrate (TS). Hand-run SQL files and "schema.sql we run sometimes" are how drift starts.
57
+ - **Review generated SQL before it touches anything real.** ORM migration generators emit what the schema diff implies: renaming a column in the schema file becomes `DROP COLUMN` + `ADD COLUMN` — the data is dropped. Prisma flow: `migrate dev --create-only`, read the SQL, fix it to a safe expand-contract, then apply. Drizzle: generate, then read the SQL before `migrate`. This review is the single highest-value habit in this file.
58
+ - **`db push`/sync-style commands are for throwaway dev databases only.** They bypass migration history; on a database with data they can apply destructive diffs without review. If a deploy script or CI contains `db push` against anything shared or persistent, that is a finding.
59
+ - **Never edit an applied migration.** The hash changes, history diverges, teammates' databases desync. Corrections are new migrations.
60
+ - **Forward-only in production.** Down migrations cannot faithfully reverse a migration that touched data (you cannot un-drop a column). "Rollback" is a new forward migration that reverses the change, written and tested like any other. Down migrations are a dev convenience at most.
61
+ - **Apply migrations as a distinct step before the new code rolls out** (deploy script step or pre-deploy Job), never lazily on first request, never concurrently from every replica. One applier, ordered, recorded.
62
+
63
+ ## CI and testing
64
+
65
+ - A CI job that applies all migrations to a throwaway database (a fresh dump or seed of production shape) on every PR — catches broken SQL and lock surprises before merge, and keeps prod-shaped test data honest.
66
+ - Migration + dependent code in one PR is fine; shipping them as one *deploy step* is not — expand and contract are separate deploys even when they merge as one review.
67
+
68
+ ## Schema integrity sweep
69
+
70
+ - **Foreign keys enforced?** MySQL: check the engine (InnoDB enforces, MyISAM does not). SQLite: `PRAGMA foreign_keys = ON` per connection — it is OFF by default and every connection must set it. Postgres: on by default; hunt instead for `ON DELETE` behavior nobody chose — cascade on a `users` delete that sweeps orders, messages, and uploads is a mass-delete path wearing a constraint's clothing.
71
+ - **Unique constraints where identity lives** — email, username, external IDs (`stripe_customer_id`), webhook event IDs. Without the constraint, every race produces a duplicate; with it, the race becomes a retryable error. Partial unique indexes for soft delete: `CREATE UNIQUE INDEX ... ON users(email) WHERE deleted_at IS NULL` — the live rows stay unique, the deleted ones don't collide.
72
+ - **Nullable-in-fact columns** — every column the code treats as required should be `NOT NULL`, or the store will accept what the code never imagined.
73
+ - **Lossy types** — money in floating point (use integer cents or `NUMERIC`), IDs in 32-bit ints near overflow (YouTube hit this), timestamps without timezone when the product is multi-timezone, enums-as-free-text where a `CHECK` or lookup table belongs.
74
+ - **Orphan check** — rows referencing deleted parents (FKs added late don't clean history): count them before adding the constraint, and expect `VALIDATE` to fail if history is dirty. Decide: clean, archive, or keep the constraint `NOT VALID` deliberately and document why.
75
+ - **Drift** — schema file vs live DB: most ORMs can diff (`prisma migrate diff`, `drizzle-kit check`). Drift on production means migrations were bypassed at some point — a process finding, not just a schema one.
76
+
77
+ ---
78
+
79
+ **Provenance:** snapshot 17 August 2026. Sources: Postgres documentation (DDL locking behavior, `CONCURRENTLY`, `NOT VALID`/`VALIDATE`, ADD COLUMN default fast-path), current zero-downtime migration practice guides (expand-contract/parallel-change, batched keyset backfill, forward-only production, pre-deploy application), Prisma/Drizzle documentation (create-only review workflow, `db push` scope), MySQL online-schema-change tooling (gh-ost, pt-online-schema-change) public docs. Version-specific lock behavior decays fastest — re-verify against the running version before asserting.
@@ -0,0 +1,110 @@
1
+ ---
2
+ name: lean
3
+ description: Use when speed or resource efficiency matters — slow loading or startup, janky interaction, high CPU, memory leaks or RAM that grows over time, zombie/orphan processes, bundle bloat, dead code and dead styles, Core Web Vitals; while building anything that should stay fast and light, running a performance pass over an existing project, or pre-ship "will this run smoothly" checks. Any stack — web, backend/API/CLI, desktop (Electron, Tauri), mobile, native, game, ML pipeline. Do NOT use for copy/docs-only changes, design-direction or aesthetic work (that is evidence-led-ui; this skill's styling scope is payload and consistency), or when the user explicitly deprioritizes performance.
4
+ license: Performance engineering guidance, not a benchmark certification. Sources and snapshot date are recorded at the foot of each reference file.
5
+ compatibility: Snapshot dated 17 August 2026. Thresholds, tool names, and defaults decay — re-verify with web access before asserting them as current. Claims sourced to that date carry a SNAPSHOT marker.
6
+ ---
7
+
8
+ # Lean
9
+
10
+ Make software fast, light, and smooth — loads quick, responds instantly, holds memory flat, leaves nothing running behind it. Built for the reality that users rarely ask for performance: they ask for a feature, then quietly leave when it eats RAM or takes five seconds to open.
11
+
12
+ **This skill is on from the first line of code.** The default mode is the inline gate below — build the lean version while writing the feature, in the main thread. The full pass is for existing projects and pre-ship checks.
13
+
14
+ ## Governing rules
15
+
16
+ 1. **Measure, then cut.** In a pass, never optimize from vibes: baseline, find the bottleneck, fix it, re-measure. Guessing produces premature optimization — complexity without user-visible gain. In build mode the binding defaults below are pre-paid by platform evidence: apply them without benchmarking.
17
+ 2. **Fix the shared cause once.** The N+1 belongs in the query layer, not a memo at each call site. Check every caller of the slow path before patching where it hurt.
18
+ 3. **Optimize user time, not machine time.** What users wait on: startup, first paint, navigation, hot interactions, the nightly job. Micro-tuning code nobody waits for is last, always.
19
+ 4. **Memory should be flat.** After N cycles of the core loop, committed memory should look like after 1. Sustained growth is a leak until proven otherwise; a sawtooth that returns to baseline is GC, not a leak.
20
+ 5. **Nothing outlives its job.** Timers, listeners, observers, subscriptions, watchers, child processes, temp files, locks — everything with a lifetime needs an owner that ends it, on the success path *and* every failure path.
21
+ 6. **Bounded by default.** If it can grow — cache, queue, buffer, retry, log, list render — it gets a cap and an eviction policy at creation, not after the incident.
22
+ 7. **Small is fast.** Dead code, unused dependencies, and duplicate styles are parsed, shipped, and paid for. Removing is the cheapest optimization there is.
23
+ 8. **Numbers or silence.** Verify with before/after on the same machine and data, cold and warm. "Feels faster" is not a result, and never claim "optimized", "leak-free", or "fast" — say what moved, from X to Y, and what you could not measure.
24
+ 9. **No perf theater.** Complexity must pay for itself in measured user time; otherwise revert. Caching that introduces staleness bugs for an unmeasured gain is a regression wearing a costume.
25
+ 10. **Label evidence** on every claim: `RUNTIME` (you measured it), `CODE` (you read it), `DEDUCED` (inferred), `SNAPSHOT` (dated source claim). Never present what you read as what you ran.
26
+
27
+ ## Two modes
28
+
29
+ **Inline gate** — while writing any feature, apply the binding defaults below. One line in the reply about what you did and why it matters, then move on. Do not stop the build to lecture, and do not ship the heavy version intending to "optimize later" — later never comes.
30
+
31
+ **Full pass** — triggered by "make it faster", "why is it slow / eating RAM / lagging", "will this run smoothly", a suspected regression, or a pre-ship check. Run the workflow below. Per-stack sweeps and measurement commands live in `references/playbooks.md`; the memory-leak catalog and process/zombie lifecycle detail live in `references/memory-and-processes.md`.
32
+
33
+ ## Binding defaults (build mode)
34
+
35
+ Apply on every feature, every stack. These are the habits that prevent the pass from ever being needed:
36
+
37
+ - **Teardown ships with the feature.** Whatever you start — timer, listener, observer, subscription, child process, watcher — is torn down in the same module that started it, on success and error paths. Prefer one cleanup handle per owner (an `AbortController` for all of a component's fetches and listeners; a destructor/dispose method; a `finally` block) over scattered manual removes.
38
+ - **Cap every accumulation.** LRU/TTL cache, bounded queue, paginated query, virtualized list, capped retries with backoff, rotating logs. Unbounded is a bug with a delay.
39
+ - **Never block the interactive thread.** Chunk, defer, or offload work that can exceed a frame (web main thread long task threshold: 50ms) — web workers, background threads, task queues, utility processes. I/O stays async on the hot path; no sync fs/crypto/CPU spikes inside request handlers or UI code.
40
+ - **Lazy by default, eager only for the first screen.** Below-the-fold media, rare routes, heavy editors, optional services: load on demand (dynamic `import()`, deferred `require`, on-demand plugin init). Preload/preconnect only what the critical path demonstrably needs.
41
+ - **Right-size media.** AVIF/WebP with JPEG fallback, explicit `width`/`height` (also kills layout shift), `srcset`/`sizes` for density, decode thumbnails instead of full images.
42
+ - **Stream, don't hoard.** Stream files and large responses, paginate/cursor DB queries, chunk large jobs. Loading a whole dataset into memory to process it item by item is the classic hog.
43
+ - **Timeout everything external.** Network calls, subprocesses, locks, queues — no unbounded waits, and teardown on timeout.
44
+ - **Price a dependency before adopting it** in anything user-facing: its load cost is your load cost (`node --cpu-prof --heap-prof -e "require('mod')"` for Node-side; bundle impact for client-side). The most-downloaded module is not the lightest.
45
+ - **Batch I/O and reads-then-writes.** One query for N rows, not N queries; group DOM reads before writes; coalesce events (debounce/throttle) when handlers are expensive.
46
+
47
+ ## Full-pass workflow
48
+
49
+ ### 1. Profile the target from the code
50
+
51
+ Before asking the user anything: shape (web app, API, CLI, desktop, mobile, library, game, ML pipeline — read manifests, lockfiles, build and CI configs), the surfaces users wait on (startup, first screen, navigation, hot interactions, batch jobs), scale (data sizes, traffic, session length), and platform constraints (low-end devices matter more than the dev machine).
52
+
53
+ ### 2. Baseline, or say you cannot
54
+
55
+ Runtime numbers when the project runs: load time, startup time, p50/p99 latency, bundle sizes, RSS/heap at rest and after repeated cycles. Exact commands per stack are in `references/playbooks.md`. If you cannot run it (no environment, no data, no time), do a `CODE`-labeled static pass and say plainly in the report that nothing was measured — do not fabricate a baseline.
56
+
57
+ ### 3. Sweep the six areas
58
+
59
+ Work this list in order — it reflects where user-perceived damage concentrates, not what is most interesting to engineer. Detection specifics per stack: `references/playbooks.md`; areas 3–4: `references/memory-and-processes.md`.
60
+
61
+ | # | Area | What you are hunting |
62
+ |---|---|---|
63
+ | 1 | **Loading & startup** | Slow first paint/open, render-blocking resources, giant bundles, eager imports of rarely-used code, waterfall requests, unoptimized media and fonts, cold-start work that could be deferred |
64
+ | 2 | **Runtime responsiveness** | Long tasks blocking input, layout thrash, expensive re-renders, N+1 queries, sync work on hot paths, missing pagination, unvirtualized long lists, GC pressure from allocation churn |
65
+ | 3 | **Memory** | Growth over time (leaks): forgotten timers/listeners/observers, detached DOM held alive, unbounded caches and maps, closures capturing large scope, cycles in non-GC runtimes, undecoded-or-full-size media, whole-file loads where streaming would do |
66
+ | 4 | **Processes & lifecycle** | Zombie children (spawned, never reaped), orphans surviving parent exit (killed the node, not the tree), missing signal handling and graceful shutdown, leaked ports/fds/locks/temp files, no startup sweep for crash leftovers |
67
+ | 5 | **Payload & dead weight** | Unused dependencies, dead code and dead exports, dead/duplicate CSS, two libraries doing one job (two icon sets, two date libs, two CSS systems), ship-weight of debug/symbol payloads, tree-shaking blockers |
68
+ | 6 | **Styling consistency** | Same visual thing built three ways — repeated rule blocks, one-off spacing/color literals that duplicate tokens, framework utilities fighting handwritten CSS. Consistency here is payload: one way to do X is the only way that stays small. (Design direction itself is evidence-led-ui's call.) |
69
+
70
+ ### 4. Rank by user impact, fix the top, not all
71
+
72
+ | Severity | Meaning |
73
+ |---|---|
74
+ | **Critical** | Blocks or breaks: startup counted in tens of seconds, OOM crashes, multi-second UI freezes, a leak that kills a session in minutes |
75
+ | **High** | User-perceivable degradation: sluggish interactions, fan-spinning idle CPU, RAM that climbs over a workday, zombie processes accumulating across runs, slowest paths 2–10× slower than they should be |
76
+ | **Medium** | Waste with symptoms at scale: bundle bloat, N+1 under load, unbounded caches, missing pagination, duplicate dependencies |
77
+ | **Low** | Hygiene without a measured symptom: dead code, dead styles, micro-tuning. Do these when adjacent to a real fix, never instead of one. |
78
+
79
+ Fix the few that measurement actually implicates — three to five, rarely more. Each fix records its baseline number first. Prefer removing work over hiding it (delete the eager import beats code-splitting it beats deferring it), and prefer the platform primitive over a hand-rolled one.
80
+
81
+ ### 5. Verify the fix
82
+
83
+ Re-measure exactly how you baselined, same machine, same data, cold and warm. A fix you did not measure is a hypothesis. For memory: cycle the changed path many times, force GC where the runtime allows (`--expose-gc`, DevTools), and compare committed memory — flat wins, sawtooth is fine, climbing is not fixed. If the number did not move, revert and say so; a change that adds complexity without moving the number is a regression.
84
+
85
+ ### 6. Leave a guard behind
86
+
87
+ One check so it cannot silently return: bundle-size budget in CI, Lighthouse CI or `size-limit` for web, a slow-query threshold, a repeated-cycle memory assertion where feasible, a test that fails if the eager import returns. One gate beats good intentions.
88
+
89
+ ### 7. Report
90
+
91
+ - Lead with numbers: what moved, X → Y, on which machine/data/date.
92
+ - Then remaining findings, ranked, each with file/line and the fix.
93
+ - Then what was **not checked** — unmeasured areas, stacks skipped, environments unavailable. A report that silently skips the mobile client or the batch job reads as complete coverage.
94
+ - Then what you changed vs. what you recommend and did not do.
95
+ - Label every claim `RUNTIME` / `CODE` / `DEDUCED` / `SNAPSHOT`. Include your false positives — candidates you investigated and dropped — so the survivor list is not hiding its noise.
96
+
97
+ ## Honesty rules
98
+
99
+ - Never state or imply the software is "fast", "optimized", or "leak-free". State what was measured, fixed, and left unchecked.
100
+ - Never present a lint rule, bundle analyzer, or profiler as proof of the absence of problems; tools find a minority of what matters.
101
+ - Never invent a number, threshold, or version. If the claim is date-sensitive and unverified, mark it `SNAPSHOT` or say "verify this".
102
+ - "I could not measure this" is a legitimate and useful output. A fabricated confirmation is not.
103
+ - If the project is a prototype with no users and no load, say that proportionality applies — five real fixes beat forty ignored ones — and stop early.
104
+
105
+ ## Reference map
106
+
107
+ Resolve every path from the installed skill root. Load only what the profile triggered.
108
+
109
+ - `references/playbooks.md` — per-stack sweeps and measurement commands: web frontend (Core Web Vitals with official thresholds), Node/backend/API, Electron, Tauri, mobile, native/compiled (Rust, C/C++, Go, JVM), Python, data & queries, and the payload/dead-weight/styling-consistency tooling. Read the sections the profile triggered.
110
+ - `references/memory-and-processes.md` — the leak catalog by pattern, detection technique per runtime (three-snapshot, allocation timeline, heap dumps, pprof, valgrind, Instruments, LeakCanary), component-framework leak rules, and the process lifecycle playbook: zombies, orphans, signal handling, process-tree kills, container PID 1, startup sweeps, leaked fds/ports/temp files. Read for any memory or process finding.