deepmodebot 0.0.0-stage → 0.9.1

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 (313) hide show
  1. package/.claude-plugin/marketplace.json +26 -0
  2. package/.omp-plugin/marketplace.json +26 -0
  3. package/LICENSE +24 -0
  4. package/README.md +377 -2
  5. package/bin/deepmodebot.mjs +247 -0
  6. package/lib/autoupdate.mjs +47 -0
  7. package/lib/clients.mjs +139 -0
  8. package/lib/run.mjs +32 -0
  9. package/lib/state.mjs +52 -0
  10. package/lib/tree.mjs +48 -0
  11. package/lib/version.mjs +26 -0
  12. package/package.json +44 -4
  13. package/plugins/deepmodebot/.antigravity-plugin/plugin.json +35 -0
  14. package/plugins/deepmodebot/.antigravity-plugin/skills/deep/SKILL.md +13 -0
  15. package/plugins/deepmodebot/.antigravity-plugin/skills/land-pr/SKILL.md +23 -0
  16. package/plugins/deepmodebot/.antigravity-plugin/skills/pr-thread/SKILL.md +17 -0
  17. package/plugins/deepmodebot/.antigravity-plugin/skills/review-pr/SKILL.md +16 -0
  18. package/plugins/deepmodebot/.antigravity-plugin/skills/tournament/SKILL.md +14 -0
  19. package/plugins/deepmodebot/.claude-plugin/plugin.json +27 -0
  20. package/plugins/deepmodebot/agents/reviewer/agent.md +33 -0
  21. package/plugins/deepmodebot/agents/scout/agent.md +34 -0
  22. package/plugins/deepmodebot/agents/security-reviewer/agent.md +30 -0
  23. package/plugins/deepmodebot/assets/logo.svg +8 -0
  24. package/plugins/deepmodebot/commands/contribute.md +8 -0
  25. package/plugins/deepmodebot/commands/deep.md +11 -0
  26. package/plugins/deepmodebot/commands/land-pr.md +12 -0
  27. package/plugins/deepmodebot/commands/pr-thread.md +14 -0
  28. package/plugins/deepmodebot/commands/project-brief.md +8 -0
  29. package/plugins/deepmodebot/commands/review-pr.md +10 -0
  30. package/plugins/deepmodebot/commands/tournament.md +12 -0
  31. package/plugins/deepmodebot/hooks/hooks.json +26 -0
  32. package/plugins/deepmodebot/hooks.json +24 -0
  33. package/plugins/deepmodebot/mcp_config.json +11 -0
  34. package/plugins/deepmodebot/scripts/antigravity-guard.mjs +413 -0
  35. package/plugins/deepmodebot/scripts/omp-mcp-server.mjs +1091 -0
  36. package/plugins/deepmodebot/skills/agent-harnesses/SKILL.md +57 -0
  37. package/plugins/deepmodebot/skills/agent-harnesses/assets/sdks/bun.lock +391 -0
  38. package/plugins/deepmodebot/skills/agent-harnesses/assets/sdks/check.ts +53 -0
  39. package/plugins/deepmodebot/skills/agent-harnesses/assets/sdks/check_antigravity.py +38 -0
  40. package/plugins/deepmodebot/skills/agent-harnesses/assets/sdks/check_claude.mjs +11 -0
  41. package/plugins/deepmodebot/skills/agent-harnesses/assets/sdks/package.json +11 -0
  42. package/plugins/deepmodebot/skills/agent-harnesses/assets/sdks/requirements.txt +1 -0
  43. package/plugins/deepmodebot/skills/agent-harnesses/references/ai-native-tooling.md +190 -0
  44. package/plugins/deepmodebot/skills/agent-harnesses/references/ai-sdk-selection.md +50 -0
  45. package/plugins/deepmodebot/skills/agent-harnesses/references/antigravity.md +108 -0
  46. package/plugins/deepmodebot/skills/agent-harnesses/references/claude-code.md +166 -0
  47. package/plugins/deepmodebot/skills/agent-harnesses/references/codex.md +151 -0
  48. package/plugins/deepmodebot/skills/agent-harnesses/references/delegation-efficiency.md +230 -0
  49. package/plugins/deepmodebot/skills/agent-harnesses/references/langchain-ecosystem.md +124 -0
  50. package/plugins/deepmodebot/skills/agent-harnesses/references/omp.md +183 -0
  51. package/plugins/deepmodebot/skills/agent-harnesses/references/protocols.md +172 -0
  52. package/plugins/deepmodebot/skills/agent-harnesses/references/sdks.md +228 -0
  53. package/plugins/deepmodebot/skills/agent-harnesses/references/self-authoring.md +171 -0
  54. package/plugins/deepmodebot/skills/cloud-devsecops/SKILL.md +24 -0
  55. package/plugins/deepmodebot/skills/cloud-devsecops/references/aws.md +264 -0
  56. package/plugins/deepmodebot/skills/cloud-devsecops/references/azure.md +261 -0
  57. package/plugins/deepmodebot/skills/cloud-devsecops/references/containers.md +96 -0
  58. package/plugins/deepmodebot/skills/cloud-devsecops/references/devops-tools.md +297 -0
  59. package/plugins/deepmodebot/skills/cloud-devsecops/references/devsecops-pipeline.md +258 -0
  60. package/plugins/deepmodebot/skills/cloud-devsecops/references/gcp.md +258 -0
  61. package/plugins/deepmodebot/skills/cloud-devsecops/references/kubernetes.md +74 -0
  62. package/plugins/deepmodebot/skills/cloud-devsecops/references/local-emulators.md +265 -0
  63. package/plugins/deepmodebot/skills/contribute/SKILL.md +134 -0
  64. package/plugins/deepmodebot/skills/create-verification-skill/LICENSE +21 -0
  65. package/plugins/deepmodebot/skills/create-verification-skill/SKILL.md +101 -0
  66. package/plugins/deepmodebot/skills/create-verification-skill/references/feature-map-example/README.md +47 -0
  67. package/plugins/deepmodebot/skills/create-verification-skill/references/feature-map-example/create-note.md +39 -0
  68. package/plugins/deepmodebot/skills/create-verification-skill/references/feature-map-example/search.md +45 -0
  69. package/plugins/deepmodebot/skills/deep-stack/SKILL.md +53 -0
  70. package/plugins/deepmodebot/skills/deep-stack/references/AGENTS.template.md +52 -0
  71. package/plugins/deepmodebot/skills/deep-stack/references/agentic-workflow.md +114 -0
  72. package/plugins/deepmodebot/skills/deep-stack/references/any-app-stack.md +51 -0
  73. package/plugins/deepmodebot/skills/deep-stack/references/design-workflow.md +101 -0
  74. package/plugins/deepmodebot/skills/deep-stack/references/isolate.md +23 -0
  75. package/plugins/deepmodebot/skills/deep-stack/references/philosophy.md +306 -0
  76. package/plugins/deepmodebot/skills/deep-stack/references/prove.md +31 -0
  77. package/plugins/deepmodebot/skills/deep-stack/references/stack.md +119 -0
  78. package/plugins/deepmodebot/skills/deep-stack/references/structure.md +22 -0
  79. package/plugins/deepmodebot/skills/deep-stack/references/unslop/LICENSE +21 -0
  80. package/plugins/deepmodebot/skills/deep-stack/references/unslop/unslop.md +80 -0
  81. package/plugins/deepmodebot/skills/deepmodebot/LICENSE +23 -0
  82. package/plugins/deepmodebot/skills/deepmodebot/SKILL.md +198 -0
  83. package/plugins/deepmodebot/skills/deepmodebot/assets/agents-md/agents_md.py +207 -0
  84. package/plugins/deepmodebot/skills/deepmodebot/assets/agents-md/test_agents_md.py +146 -0
  85. package/plugins/deepmodebot/skills/deepmodebot/assets/architecture-review/report-template.html +92 -0
  86. package/plugins/deepmodebot/skills/deepmodebot/assets/contain/claude-guard.sh +42 -0
  87. package/plugins/deepmodebot/skills/deepmodebot/assets/contain/claude_guard.py +135 -0
  88. package/plugins/deepmodebot/skills/deepmodebot/assets/contain/omp-contain-link.ts +12 -0
  89. package/plugins/deepmodebot/skills/deepmodebot/assets/contain/omp-contain.ts +115 -0
  90. package/plugins/deepmodebot/skills/deepmodebot/assets/contain/test_antigravity_guard.py +483 -0
  91. package/plugins/deepmodebot/skills/deepmodebot/assets/contain/test_audit_regressions.py +139 -0
  92. package/plugins/deepmodebot/skills/deepmodebot/assets/contain/test_contain.py +301 -0
  93. package/plugins/deepmodebot/skills/deepmodebot/assets/contain/test_omp_mcp.py +602 -0
  94. package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/design.py +242 -0
  95. package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/evidence.py +293 -0
  96. package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/record.py +387 -0
  97. package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/review.py +339 -0
  98. package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/test_design.py +69 -0
  99. package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/test_evidence.py +160 -0
  100. package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/test_record.py +180 -0
  101. package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/test_review.py +265 -0
  102. package/plugins/deepmodebot/skills/deepmodebot/assets/git-guardrails/git-guard-patterns.txt +44 -0
  103. package/plugins/deepmodebot/skills/deepmodebot/assets/git-guardrails/git-guard.sh +132 -0
  104. package/plugins/deepmodebot/skills/deepmodebot/assets/git-guardrails/git-guard.ts +122 -0
  105. package/plugins/deepmodebot/skills/deepmodebot/assets/git-guardrails/test_git_guard.py +192 -0
  106. package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/bot.py +3037 -0
  107. package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/brand.json +11 -0
  108. package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/brand.py +51 -0
  109. package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/ghapp.py +361 -0
  110. package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/install.py +274 -0
  111. package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/local_updates.py +576 -0
  112. package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/review_context.py +204 -0
  113. package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/test_bot.py +2182 -0
  114. package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/test_brand.py +19 -0
  115. package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/test_local_updates.py +691 -0
  116. package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/test_review_context.py +127 -0
  117. package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/test_workspace_cleanup.py +496 -0
  118. package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/workspace_cleanup.py +351 -0
  119. package/plugins/deepmodebot/skills/deepmodebot/assets/loop/loop.py +2394 -0
  120. package/plugins/deepmodebot/skills/deepmodebot/assets/loop/plan.py +583 -0
  121. package/plugins/deepmodebot/skills/deepmodebot/assets/loop/test_loop.py +1426 -0
  122. package/plugins/deepmodebot/skills/deepmodebot/assets/loop/test_plan.py +320 -0
  123. package/plugins/deepmodebot/skills/deepmodebot/assets/loop/test_windows_job.py +326 -0
  124. package/plugins/deepmodebot/skills/deepmodebot/assets/loop/windows_job.py +244 -0
  125. package/plugins/deepmodebot/skills/deepmodebot/assets/perf-audit/bench_harness.py +165 -0
  126. package/plugins/deepmodebot/skills/deepmodebot/assets/perf-audit/perf_audit.py +240 -0
  127. package/plugins/deepmodebot/skills/deepmodebot/assets/perf-audit/test_bench_harness.py +55 -0
  128. package/plugins/deepmodebot/skills/deepmodebot/assets/perf-audit/test_perf_audit.py +53 -0
  129. package/plugins/deepmodebot/skills/deepmodebot/assets/pr-agent/diff_coverage.py +350 -0
  130. package/plugins/deepmodebot/skills/deepmodebot/assets/pr-agent/pr_agent_local.py +370 -0
  131. package/plugins/deepmodebot/skills/deepmodebot/assets/pr-agent/test_diff_coverage.py +94 -0
  132. package/plugins/deepmodebot/skills/deepmodebot/assets/pr-conversation/arena.html +425 -0
  133. package/plugins/deepmodebot/skills/deepmodebot/assets/pr-conversation/arena.py +579 -0
  134. package/plugins/deepmodebot/skills/deepmodebot/assets/pr-conversation/arena_tui.py +839 -0
  135. package/plugins/deepmodebot/skills/deepmodebot/assets/pr-conversation/font8x8_basic.hex +1 -0
  136. package/plugins/deepmodebot/skills/deepmodebot/assets/pr-conversation/show_thread.py +329 -0
  137. package/plugins/deepmodebot/skills/deepmodebot/assets/pr-conversation/test_arena.py +610 -0
  138. package/plugins/deepmodebot/skills/deepmodebot/assets/repo-references.json +637 -0
  139. package/plugins/deepmodebot/skills/deepmodebot/assets/scrape/test_yt_enrich.py +250 -0
  140. package/plugins/deepmodebot/skills/deepmodebot/assets/scrape/yt_enrich.py +1820 -0
  141. package/plugins/deepmodebot/skills/deepmodebot/assets/scrape/yt_meta.py +156 -0
  142. package/plugins/deepmodebot/skills/deepmodebot/assets/scrape/yt_transcript_relay.js +54 -0
  143. package/plugins/deepmodebot/skills/deepmodebot/assets/security-audit/audit-pr.sh +122 -0
  144. package/plugins/deepmodebot/skills/deepmodebot/assets/security-audit/gate.cjs +155 -0
  145. package/plugins/deepmodebot/skills/deepmodebot/assets/security-audit/prompt.md +13 -0
  146. package/plugins/deepmodebot/skills/deepmodebot/assets/tournament/test_tournament.py +654 -0
  147. package/plugins/deepmodebot/skills/deepmodebot/assets/tournament/tournament.py +1285 -0
  148. package/plugins/deepmodebot/skills/deepmodebot/assets/wizard/wizard.sh +234 -0
  149. package/plugins/deepmodebot/skills/deepmodebot/assets/workspace-map/test_workspace_map.py +879 -0
  150. package/plugins/deepmodebot/skills/deepmodebot/assets/workspace-map/workspace_map.py +2436 -0
  151. package/plugins/deepmodebot/skills/deepmodebot/references/README.md +61 -0
  152. package/plugins/deepmodebot/skills/deepmodebot/references/catalog.md +105 -0
  153. package/plugins/deepmodebot/skills/deepmodebot/references/contain.md +39 -0
  154. package/plugins/deepmodebot/skills/deepmodebot/references/factory-landscape.md +147 -0
  155. package/plugins/deepmodebot/skills/deepmodebot/references/flows.md +50 -0
  156. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/authoring-a-skill.md +37 -0
  157. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/babysit.md +77 -0
  158. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/bug-fix.md +34 -0
  159. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/end-to-end.md +50 -0
  160. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/eval.md +39 -0
  161. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/feature.md +60 -0
  162. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/handoff.md +52 -0
  163. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/hillclimb.md +46 -0
  164. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/investigation.md +20 -0
  165. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/opening-a-pr.md +97 -0
  166. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/pause-safely.md +30 -0
  167. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/perf-issue.md +31 -0
  168. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/phased-build.md +146 -0
  169. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/prototype.md +31 -0
  170. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/refactoring.md +60 -0
  171. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/reference-rebuild.md +45 -0
  172. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/run-a-goal.md +143 -0
  173. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/runtime-forensics.md +22 -0
  174. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/self-authoring.md +130 -0
  175. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/session-pickup.md +33 -0
  176. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/setup.md +105 -0
  177. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/shipping.md +52 -0
  178. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/spec.md +67 -0
  179. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/tickets.md +56 -0
  180. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/trace-forensics.md +24 -0
  181. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/triage.md +102 -0
  182. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/visual-parity.md +19 -0
  183. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/wayfinder.md +44 -0
  184. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/work-a-queue.md +189 -0
  185. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/worktree-cleanup.md +35 -0
  186. package/plugins/deepmodebot/skills/deepmodebot/references/principles/attack-the-premise.md +7 -0
  187. package/plugins/deepmodebot/skills/deepmodebot/references/principles/boundary-discipline.md +8 -0
  188. package/plugins/deepmodebot/skills/deepmodebot/references/principles/build-the-lever.md +8 -0
  189. package/plugins/deepmodebot/skills/deepmodebot/references/principles/encode-lessons-in-structure.md +6 -0
  190. package/plugins/deepmodebot/skills/deepmodebot/references/principles/exhaust-the-design-space.md +4 -0
  191. package/plugins/deepmodebot/skills/deepmodebot/references/principles/experience-first.md +7 -0
  192. package/plugins/deepmodebot/skills/deepmodebot/references/principles/explain-the-number.md +9 -0
  193. package/plugins/deepmodebot/skills/deepmodebot/references/principles/fix-root-causes.md +6 -0
  194. package/plugins/deepmodebot/skills/deepmodebot/references/principles/foundational-thinking.md +9 -0
  195. package/plugins/deepmodebot/skills/deepmodebot/references/principles/guard-the-context-window.md +7 -0
  196. package/plugins/deepmodebot/skills/deepmodebot/references/principles/laziness-protocol.md +6 -0
  197. package/plugins/deepmodebot/skills/deepmodebot/references/principles/make-operations-idempotent.md +7 -0
  198. package/plugins/deepmodebot/skills/deepmodebot/references/principles/migrate-callers-then-delete-legacy-apis.md +5 -0
  199. package/plugins/deepmodebot/skills/deepmodebot/references/principles/minimize-reader-load.md +7 -0
  200. package/plugins/deepmodebot/skills/deepmodebot/references/principles/model-the-domain.md +7 -0
  201. package/plugins/deepmodebot/skills/deepmodebot/references/principles/never-block-on-the-human.md +7 -0
  202. package/plugins/deepmodebot/skills/deepmodebot/references/principles/outcome-oriented-execution.md +6 -0
  203. package/plugins/deepmodebot/skills/deepmodebot/references/principles/prove-it-works.md +8 -0
  204. package/plugins/deepmodebot/skills/deepmodebot/references/principles/redesign-from-first-principles.md +7 -0
  205. package/plugins/deepmodebot/skills/deepmodebot/references/principles/separate-before-serializing-shared-state.md +6 -0
  206. package/plugins/deepmodebot/skills/deepmodebot/references/principles/sequence-verifiable-units.md +7 -0
  207. package/plugins/deepmodebot/skills/deepmodebot/references/principles/subtract-before-you-add.md +6 -0
  208. package/plugins/deepmodebot/skills/deepmodebot/references/principles/test-behavior-not-implementation.md +7 -0
  209. package/plugins/deepmodebot/skills/deepmodebot/references/principles/type-system-discipline.md +6 -0
  210. package/plugins/deepmodebot/skills/deepmodebot/references/rust-migration-case-studies.md +26 -0
  211. package/plugins/deepmodebot/skills/deepmodebot/references/startup-ideas.md +21 -0
  212. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/agent-collaboration.md +82 -0
  213. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/architect.md +32 -0
  214. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/architecture-review.md +43 -0
  215. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/arena.md +20 -0
  216. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/benchmark-checklist.md +31 -0
  217. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/blast-radius.md +19 -0
  218. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/correct.md +20 -0
  219. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/course.md +47 -0
  220. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/coworkers.md +70 -0
  221. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/domain-model.md +69 -0
  222. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/figure-it-out.md +25 -0
  223. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/git-guardrails.md +44 -0
  224. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/github-app.md +160 -0
  225. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/goal-review.md +156 -0
  226. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/grill.md +27 -0
  227. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/how.md +23 -0
  228. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/in-your-own-words.md +12 -0
  229. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/inner-loop.md +39 -0
  230. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/interrogate.md +16 -0
  231. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/issue-conversation.md +52 -0
  232. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/no-comments.md +29 -0
  233. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/open-design-evidence.md +65 -0
  234. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/panel.md +34 -0
  235. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/pr-agent.md +39 -0
  236. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/pr-conversation.md +135 -0
  237. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/pr-review.md +138 -0
  238. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/pre-commit.md +31 -0
  239. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/prior-art.md +44 -0
  240. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/questionnaire.md +46 -0
  241. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/re-explain.md +23 -0
  242. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/recall.md +19 -0
  243. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/reflect.md +20 -0
  244. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/research.md +99 -0
  245. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/retro.md +30 -0
  246. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/scrape.md +32 -0
  247. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/security-audit.md +40 -0
  248. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/sharpen.md +15 -0
  249. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/show-me-your-work.md +19 -0
  250. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/sme-review.md +49 -0
  251. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/swarm.md +14 -0
  252. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/tdd.md +55 -0
  253. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/teach.md +20 -0
  254. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/technical-writing.md +22 -0
  255. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/tool-routing.md +85 -0
  256. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/tournament.md +44 -0
  257. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/tracker.md +78 -0
  258. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/unslop.md +15 -0
  259. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/visual-e2e.md +78 -0
  260. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/why.md +31 -0
  261. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/wizard.md +25 -0
  262. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/workspace-map.md +35 -0
  263. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/writing-for-agents.md +66 -0
  264. package/plugins/deepmodebot/skills/deepmodebot/scripts/check_skill.py +93 -0
  265. package/plugins/deepmodebot/skills/deepmodebot/scripts/trending.py +598 -0
  266. package/plugins/deepmodebot/skills/domain-rules/SKILL.md +131 -0
  267. package/plugins/deepmodebot/skills/domain-rules/references/agent-engineering.md +105 -0
  268. package/plugins/deepmodebot/skills/domain-rules/references/ai-concepts.md +103 -0
  269. package/plugins/deepmodebot/skills/domain-rules/references/aws-networking.md +121 -0
  270. package/plugins/deepmodebot/skills/domain-rules/references/backend-system-design.md +162 -0
  271. package/plugins/deepmodebot/skills/domain-rules/references/data-structures-and-cache-optimization.md +48 -0
  272. package/plugins/deepmodebot/skills/domain-rules/references/devops-and-fundamentals.md +137 -0
  273. package/plugins/deepmodebot/skills/domain-rules/references/engineering-practice.md +100 -0
  274. package/plugins/deepmodebot/skills/domain-rules/references/high-scale-server-optimization.md +181 -0
  275. package/plugins/deepmodebot/skills/domain-rules/references/language-ecosystems.md +56 -0
  276. package/plugins/deepmodebot/skills/frontend-ui/SKILL.md +146 -0
  277. package/plugins/deepmodebot/skills/frontend-ui/references/patterns/live-demos.md +38 -0
  278. package/plugins/deepmodebot/skills/frontend-ui/references/patterns/mobbin-shipped-apps.md +28 -0
  279. package/plugins/deepmodebot/skills/frontend-ui/references/patterns/motion-clips.md +269 -0
  280. package/plugins/deepmodebot/skills/frontend-ui/references/patterns/motion-graphics.md +62 -0
  281. package/plugins/deepmodebot/skills/frontend-ui/references/patterns/pinterest-animations.md +217 -0
  282. package/plugins/deepmodebot/skills/frontend-ui/references/patterns/pinterest-patterns.md +101 -0
  283. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/01-workflow.md +25 -0
  284. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/02-review-rubric.md +21 -0
  285. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/03-ai-tells.md +46 -0
  286. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/04-components.md +21 -0
  287. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/04a-agent-ui.md +153 -0
  288. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/05-motion.md +106 -0
  289. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/05a-motion-graphics.md +121 -0
  290. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/06-typography-layout.md +48 -0
  291. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/06a-color.md +26 -0
  292. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/07-copy.md +11 -0
  293. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/08-quality-floor.md +63 -0
  294. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/09-steering-agents.md +13 -0
  295. package/plugins/deepmodebot/skills/maintain-verification-skill/LICENSE +21 -0
  296. package/plugins/deepmodebot/skills/maintain-verification-skill/SKILL.md +47 -0
  297. package/plugins/deepmodebot/skills/project-brief/SKILL.md +100 -0
  298. package/plugins/deepmodebot/skills/project-brief/assets/CONTRIBUTING.template.md +124 -0
  299. package/plugins/deepmodebot/skills/project-brief/assets/ISSUE_TEMPLATE/task.yml +61 -0
  300. package/plugins/deepmodebot/skills/project-brief/assets/PROJECT_BRIEF.template.md +98 -0
  301. package/plugins/deepmodebot/skills/project-brief/assets/PULL_REQUEST_TEMPLATE.md +35 -0
  302. package/plugins/deepmodebot/skills/project-brief/assets/pr-overlap.py +643 -0
  303. package/plugins/deepmodebot/skills/project-brief/assets/sync-roadmap.py +314 -0
  304. package/plugins/deepmodebot/skills/secrets-and-auth/SKILL.md +60 -0
  305. package/plugins/deepmodebot/skills/secrets-and-auth/references/agent-authentication.md +198 -0
  306. package/plugins/deepmodebot/skills/secrets-and-auth/references/leak-prevention.md +206 -0
  307. package/plugins/deepmodebot/skills/secrets-and-auth/references/logins-and-passwords.md +165 -0
  308. package/plugins/deepmodebot/skills/secrets-and-auth/references/secrets-and-env.md +182 -0
  309. package/plugins/deepmodebot/skills/software-architecture/SKILL.md +47 -0
  310. package/plugins/deepmodebot/skills/software-architecture/references/backend-infrastructure.md +273 -0
  311. package/plugins/deepmodebot/skills/software-architecture/references/databases.md +277 -0
  312. package/plugins/deepmodebot/skills/software-architecture/references/monorepos.md +210 -0
  313. package/plugins/deepmodebot/skills/software-architecture/references/ontology.md +287 -0
@@ -0,0 +1,181 @@
1
+ # High-scale server & code optimization lessons
2
+
3
+ Distilled from 96 implementations, infrastructure configs, and benchmarks in the Million Users Challenge (`arjaythedev/million-users-challenge`: 1M-3M concurrent keep-alive connections, ~42k req/s on 2-16 vCPUs + dedicated Postgres 18). Every rule targets measurable CPU, tail-latency, memory-per-connection, packet, or DB-round-trip wins.
4
+
5
+ ## Quick Triage: Symptom -> Suspect -> Fix
6
+
7
+ | Symptom | Primary Suspects | First Fixes (Rule #) |
8
+ |---|---|---|
9
+ | High idle RSS / OOM at 100k+ conns | Per-socket read/write buffers, fiber/task trees, GC heap scanning, `gin-contrib/gzip` | 16-40 B fd-slots, detach idle buffers, `MAP_NORESERVE`, `gzhttp` (#1-2, #66, #74) |
10
+ | Throughput stalls far below 100% CPU | Soft `RLIMIT_NOFILE=1024`, missing `SO_REUSEPORT`, cross-thread hops, `UnfairSemaphoreSpinLimit` | Raise `nofile`, per-core `SO_REUSEPORT`, pin DB pool to loop, `SpinLimit=0` (#4, #6, #9, #86) |
11
+ | Tail latency (p95/p99) collapses under burst | FIFO backlog >40 ms delayed-ACK spiral, `fq_codel` drops, `ENOBUFS` partial re-arm, GC pauses | LIFO newest-first + `--busy-max`, `tc qdisc fq`, full `ENOBUFS` re-arm, `gc.freeze()` (#16, #23, #34, #88) |
12
+ | High Postgres CPU on simple queries | `ExecMemoize` (`memset`), unnamed prepared stmts, `RESET ALL`, unbatched `Sync`s | `enable_memoize = off`, named `Parse`, `NoResetOnClose`, pass-batched reads (#38, #41, #44-48) |
13
+ | Intermittent 500s / wrong order on writes | `Prepare` without `Sync`, `23503` batch rollback, `GZipStream` `leaveOpen=false`, Swoole flush | Always `Sync` after `Prepare`, unwind `23503`, `leaveOpen=true`, decouple queues (#43, #52, #67, #78) |
14
+
15
+ ## 1. Cost Model & First-Principles Thinking
16
+
17
+ 1. **Budget per idle connection first.** At 1M open keep-alive sockets, 38 KB/conn (Scala/fs2) needs ~38 GB RAM and OOMs; 16-40 byte pointer-free fd-indexed slots use ~16-40 MB total.
18
+ 2. **Detach buffers from idle connections.** Never hold per-socket 8-16 KB read/write buffers while idle; borrow shared per-thread scratch or provided buffer rings only during active I/O.
19
+ 3. **Count syscalls, packets, and allocations per request.** Hand-rolled HTTP/1.1 + PG wire loops cut syscalls/req from >2 to ~0.11 via batching.
20
+ 4. **Raise soft `RLIMIT_NOFILE` before binding.** Default `1024` causes silent `EMFILE` accept sleeps (1 s/accept), slashing throughput 2.5x+ before hitting CPU limits.
21
+ 5. **Measure with `Accept-Encoding: gzip` enabled.** Compression often dominates 20-40% of server CPU and exposes buffer/stream-closing bugs missed by un-compressed smoke tests.
22
+ 6. **Avoid cross-core hops on hot paths.** Passing accepted sockets from an acceptor thread to HTTP workers then DB workers via queues stalls throughput well below single-thread-per-core loops.
23
+ 7. **Eliminate framework object graphs on hot routes.** Stripping Pydantic/DI/middleware in FastAPI (raw Starlette `Route` + `orjson`) yielded 4.2x on 4 cores; dropping frameworks for raw `Protocol`/reactor yielded 8.5x+.
24
+ 8. **Use `bench` / profiler evidence before tuning.** Checking `perf`, GC logs, and `EXPLAIN ANALYZE` exposed Postgres `ExecMemoize` (24% DB CPU) and .NET `UnfairSemaphoreSpinLimit` (18% CPU).
25
+
26
+ ## 2. Event Loops, Reactors & Kernel I/O (`epoll` / `io_uring`)
27
+
28
+ 9. **Use share-nothing thread- or process-per-core reactors.** Give each worker its own event loop, `SO_REUSEPORT` listeners, and private DB connections to eliminate mutexes and cache-line bouncing.
29
+ 10. **Prefer `fork` + `unshare(CLONE_FILES)` for GC'd runtimes or fd isolation.** Separate processes isolate stop-the-world GC heaps and split kernel fd-table locks.
30
+ 11. **Oversubscribe loops on 2-3 vCPUs when the NIC has one RX queue.** Running 4 loops on 2-3 CPUs prevents softirq pinning 1 core at 100% while the other idles.
31
+ 12. **Cap workers at high core counts when softirq/RPS saturates.** Capping workers at `min(cpus/2, 8)` can leave headroom for `ksoftirqd` and improve DB batch density.
32
+ 13. **Use full `io_uring` performance flags.** Pair `SINGLE_ISSUER | DEFER_TASKRUN | COOP_TASKRUN | SUBMIT_ALL | NO_SQARRAY` with `IORING_REGISTER_RING_FDS` and `IORING_REGISTER_IOWQ_MAX_WORKERS`.
33
+ 14. **Use registered direct descriptors + multishot accept/recv.** `IORING_REGISTER_FILES2` + `IORING_FILE_INDEX_ALLOC` + multishot `ACCEPT`/`RECV` + provided buffer rings avoid fd-table growth and `fget`/`fput`.
34
+ 15. **Handle Ubuntu 6.8 `IORING_REGISTER_PBUF_RING` `EINVAL`.** Try `resv[0] = 0` first; on `EINVAL`, retry with `resv[0] = 1` (or fall back to `IORING_OP_PROVIDE_BUFFERS` / `epoll`).
35
+ 16. **Re-arm ALL `ENOBUFS`-starved multishot receives when buffers return.** Capping re-arms (e.g., 32/pass) creates multi-second tail-latency spikes under buffer pressure.
36
+ 17. **Never reuse a direct-descriptor slot before CQEs drain.** Gate slot closure/reuse on `SHUTDOWN` and all pending `RECV`/`SEND` completions plus generation/epoch tags.
37
+ 18. **Use hybrid `epoll` + `io_uring` syscall batching when `io_uring` isn't the poll source.** Drain `epoll_wait`, then submit all `RECV`s in one `io_uring_enter` and all `SEND`s in a second.
38
+ 19. **Use one-shot `POLL` SQEs for `libpq` pipeline sockets on `io_uring`.** Edge-triggered multishot poll misses bytes already buffered inside `libpq`'s user-space buffer.
39
+ 20. **Coalesce loop wakeups with a 1-4 ms cadence when not saturated.** If `epoll_wait` did work without filling its event array, sleep the remaining 1-4 ms; skip sleeping when saturated.
40
+ 21. **Account for outbound `SEND` CQEs in `io_uring_wait_cqe`.** Use `IORING_FEAT_MIN_TIMEOUT` / `IORING_ENTER_EXT_ARG` so TX completions do not break RX coalescing early.
41
+ 22. **Set `SCHED_IDLE` (or `SCHED_BATCH`) on busy reactor threads.** Yielding to `ksoftirqd` prevents user polling loops from starving NIC RX softirq processing.
42
+ 23. **Drain overloaded backlogs newest-first (LIFO) + bound in-flight work.** Serving freshest requests first keeps them inside the 40 ms delayed-ACK window; FIFO lets every request go late and triggers extra bare ACKs.
43
+ 24. **Be cautious with `SO_INCOMING_CPU` on single-queue NICs.** Pinning connections to incoming RX CPUs can skew load onto one worker when RPS/softirq concentrates on one core.
44
+ 25. **Use `recvfrom`/`sendto` or `MSG_DONTWAIT` instead of `read`/`write` in raw syscalls.** Bypassing VFS `fdget_pos`/position locks saves ~4% kernel CPU on hot socket loops.
45
+
46
+ ## 3. TCP, Socket & Kernel/NIC Tuning
47
+
48
+ 26. **Set socket options on the listening fd before `listen()` so `accept4` inherits them.** Zero per-connection `setsockopt` syscalls are needed for `TCP_NODELAY`, `TCP_THIN_LINEAR_TIMEOUTS`, etc.
49
+ 27. **Enable `TCP_NODELAY = 1` on API listeners.** Small JSON responses must flush immediately without waiting for Nagle's algorithm.
50
+ 28. **Use `TCP_DEFER_ACCEPT` carefully.** Waking `accept` only when data arrives saves a wakeup on immediate-send clients, but clients that connect and sit idle park in the SYN/accept queue.
51
+ 29. **Piggyback ACKs with `TCP_QUICKACK = 0`.** Set `TCP_QUICKACK = 0` *after* `listen()` (since `listen()` resets it) and re-clear it when a response takes `>= 25 ms` so ACKs ride on responses.
52
+ 30. **Set `TCP_THIN_LINEAR_TIMEOUTS = 1` (and `TCP_THIN_DUPACK = 1`).** Avoids exponential RTO doubling on 1-2 packet thin-stream responses when a packet drops.
53
+ 31. **Disable `TCP_KEEPALIVE` probes for million-connection idle pools.** At 1M sockets, 15-second OS keepalive timers generate constant background packet/CPU churn.
54
+ 32. **Clamp socket buffers at extreme connection counts.** Setting `SO_RCVBUF`/`SO_SNDBUF = 8192` and `TCP_WINDOW_CLAMP = 4096` halves kernel socket memory at 1.5M+ connections.
55
+ 33. **Set `TCP_USER_TIMEOUT` on database connections.** Bounds dead-TCP detection (e.g., 15-60 s) instead of waiting 15+ minutes on silent drops.
56
+ 34. **Use `tc qdisc fq` instead of `fq_codel` on 100k+ concurrent flows.** With massive flow counts behind one TX ring, `fq_codel` drops packets aggressively (causing TCP retransmits); `fq` queues bursts cleanly.
57
+ 35. **Enable Receive Packet Steering (RPS) on single-queue VM NICs.** Spread `rx-0` softirq across all vCPUs via `rps_cpus` + `rps_sock_flow_entries` so one core doesn't bottleneck RX.
58
+ 36. **Bind multiple ports (`PORT` + `EXTRA_PORT`) for >64k client connections per IP.** A single `(client_ip, server_ip, server_port)` tuple caps around ~64k ephemeral source ports.
59
+ 37. **Size `somaxconn`, `tcp_max_syn_backlog`, and `tcp_rmem`/`tcp_wmem` together.** High `65535` listen queues need tight `4096 16384 4194304` buffer floors so 1M idle sockets fit in RAM.
60
+
61
+ ## 4. PostgreSQL Wire Protocol, Pooling & Query Execution
62
+
63
+ 38. **Check `EXPLAIN ANALYZE` for `Memoize` overhead on hot OLTP joins.** In Postgres 18, `ExecMemoize` zero-initialized a `work_mem` hash table every execution (24% DB CPU); `enable_memoize = off` cut query time 3.4x.
64
+ 39. **Disable `jit` and parallel gather for short OLTP queries.** Set `jit = off`, `max_parallel_workers_per_gather = 0`, `client_min_messages = error`, and `plan_cache_mode = force_generic_plan` per session.
65
+ 40. **Keep `LIMIT` constants literal in SQL, not `$1` bind params.** Parameterizing `LIMIT $1` can defeat generic-plan caching and trigger per-execution re-planning.
66
+ 41. **Prefer custom v3 wire (`Parse` once -> `Bind`+`Execute`) without `Describe`.** Skipping per-query `RowDescription` saves ~130 bytes/req and avoids `PGresult` heap allocations.
67
+ 42. **If using `libpq` pipelines, build `libpq` 17/18+ for `PQsendPipelineSync`.** Older `libpq` 16 `PQpipelineSync` flushes immediately per sync, adding ~7% CPU overhead.
68
+ 43. **Never send `Prepare` (`Parse+Describe+Flush`) without `Sync`.** Leaving a pooled connection inside an unclosed implicit transaction pins `now()` to startup time and breaks ordering.
69
+ 44. **Never leave `asyncpg` `statement_cache_size=0` with unnamed `prepare()`.** Unnamed prepared statements re-parse and re-plan every query on Postgres, halving DB capacity.
70
+ 45. **Eliminate `RESET ALL` / `UNLISTEN *` pool-checkout round trips on read-only/stateless pools.** Use `NoResetOnClose=true` (Npgsql) or lightweight session pools instead of 2 extra RTTs/req.
71
+ 46. **Request mixed wire column formats (`text` ints, `binary` timestamps).** Decimal text IDs/counts (1-6 bytes) copy straight into JSON without `itoa`; 8-byte binary `timestamptz` avoids 29-byte text parsing.
72
+ 47. **Format binary `timestamptz` with Hinnant's `civil_from_days` + `DayPrefixCache`.** Caching the `YYYY-MM-DDT` prefix and using a 200-byte two-digit lookup table eliminates `gmtime` and division overhead.
73
+ 48. **Batch a loop pass's reads onto ONE least-loaded DB connection under one `Sync`.** Funneling 16-64/128 reads into one `Sync` beats spraying across connections, cutting server CPU 25-33% and DB CPU 45-75%.
74
+ 49. **Right-size read-pool count for fuller TCP packets.** Often 48-96 read connections beat 448 connections because batching produces fuller frames and halves DB TCP retransmits.
75
+ 50. **Isolate write connections from read connections.** Dedicated write lanes ensure `fsync` stalls on `INSERT`/`COMMIT` never block `SELECT` read latency.
76
+ 51. **Use group commit answered only at `ReadyForQuery` / `COMMIT`.** Batch queued writes into one explicit or implicit transaction, and reply to clients only after commit completes.
77
+ 52. **Handle `23503` (FK violation) batch rollbacks explicitly.** If one write in a batched transaction fails (`23503`), Postgres aborts the batch: never answer earlier writes as success; reply error to the bad item and replay the rest individually.
78
+ 53. **Sort or shard writes by `(user_id, post_id)` inside a batch.** Consistent lock ordering or lane hashing avoids row-lock deadlocks on concurrent duplicate writes.
79
+ 54. **Bound read batch sizes under packet loss.** Tiny read batches (e.g., 2 feeds / 8 point-reads) limit blast radius when `cwnd=2` drops a packet.
80
+ 55. **Nudge silent DB connections to trigger TCP fast retransmit.** Sending a lone `Sync` after 3-50 ms of silence (or failing over writes >10 ms) triggers SACK/fast-retransmit instead of waiting for RTO.
81
+ 56. **Watchdog-close silent DB connections (10 s) and replay idempotent reads.** Close stalled DB sockets, replay in-flight reads up to 3x on healthy lanes, and fail uncertain writes with 500.
82
+ 57. **Bulk-load seed/migration data BEFORE creating indexes and foreign keys.** Building indexes after `\copy` produces compact B-trees and avoids per-row index maintenance.
83
+
84
+ ## 5. HTTP, Auth (JWT), JSON & Compression
85
+
86
+ 58. **Parse HTTP/1.1 in-place on a reusable per-thread scratch buffer.** Reserve 160-256 bytes of headroom before the JSON body so headers and `Content-Length` prepend in place for one `send()`.
87
+ 59. **Scan delimiters (`\r\n\r\n`, `.` in JWT) with SIMD (`SSE2`/`AVX2`) or `memchr`.** Avoid byte-by-byte scalar loops and regexes for request framing.
88
+ 60. **Validate auth BEFORE validating path/body parameters when security-ordered.** Check `Authorization` + HS256 signature + `exp` before parsing IDs or touching the DB.
89
+ 61. **Precompute HMAC-SHA256 `ipad`/`opad` midstates once at startup.** Verify the signature *before* Base64-decoding or JSON-parsing JWT claims; fast-path `{"alg":"HS256","typ":"JWT"}`.
90
+ 62. **Never accept JWTs missing `exp` or non-HS256 algorithms (`alg=none`).** Always enforce algorithm pinning and expiration checks.
91
+ 63. **Use optimistic SIMD/SWAR scanning for JSON string escaping.** Scan 8-64 bytes at a time for control chars/quotes/backslashes; copy straight through and branch cold only on hits.
92
+ 64. **Write compact JSON directly into the response buffer without intermediate DOM/structs.** Stream `DataRow` fields directly into fixed key templates (`DirectBodyWriter` / `Utf8JsonWriter` / `orjson`).
93
+ 65. **Only gzip bodies `>= 1 KB`.** Small responses (<1 KB) already fit in a single TCP segment with headers and often inflate or waste CPU when compressed.
94
+ 66. **Never allocate `flate`/gzip writers before waiting on the DB.** Holding ~1 MB `compress/flate` writers across async DB awaits (e.g., `gin-contrib/gzip`) explodes heap by gigabytes; use `gzhttp` or compress at write time.
95
+ 67. **Always set `leaveOpen = true` on wrapper `GZipStream`s.** Closing a compressing stream without `leaveOpen` disposes the backing `MemoryStream` and causes 500s under `Accept-Encoding: gzip`.
96
+ 68. **Eliminate `memset` in hot LZ77 gzip hash tables.** Use a rolling `base` cursor on a pre-sized `u32` table (`cand >= base` rejects stale entries) instead of zeroing 8-16 KB per response.
97
+ 69. **Use a branch-free 64-bit `BitWriter` for deflate.** Accumulate bits in `u64`, store 8 bytes unaligned unconditionally, and advance `ptr += bits >> 3; bits &= 7`.
98
+ 70. **Retrain ISA-L or dynamic Huffman tables periodically from live bodies.** Updating `isal_hufftables` every ~1 s (or 256 responses) captures repeated JSON key frequencies without per-request tree building.
99
+ 71. **Offload CRC-32 to hardware `PCLMULQDQ` / `VPCLMULQDQ` or ISA-L.** Scalar CRC-32 loops often consume a surprising fraction of gzip CPU.
100
+ 72. **Verify compression-vs-bandwidth trade-offs on your target core count.** At 4 cores with fast networks, plain 4-segment TCP writes can beat gzip CPU cost when `GZIP_MIN` is tuned.
101
+
102
+ ## 6. Memory Layout, Allocators & Admission Control
103
+
104
+ 73. **Replace per-connection runtime timers with a hashed timing wheel.** A 512-slot 1 s wheel cut Go timer CPU from 3.4% to 0.2% across 1M idle sockets.
105
+ 74. **Back large fd/connection arrays with `mmap(MAP_NORESERVE)` + `MADV_HUGEPAGE`.** Untouched slots consume zero RSS while active slots get 2 MiB TLB coverage.
106
+ 75. **Use thread-local bounded freelists + `mimalloc`/`jemalloc`.** Standard glibc `malloc` arena contention can burn ~28% CPU under multi-core allocation churn; set `mallopt(M_ARENA_MAX, 1)` on single-threaded workers.
107
+ 76. **Use `MADV_COLLAPSE` on `.text` segments + `SYS_MSEAL` for ultra-hot binaries.** Collapsing hot code onto 2 MiB hugepages cuts iTLB misses; disable ambient heap THP via `PR_SET_THP_DISABLE`.
108
+ 77. **Acquire response buffers AFTER the DB query returns.** Hold only tiny parsed metadata in admission/DB wait queues so queued requests don't pin KB-sized buffers.
109
+ 78. **Decouple admission queue budgets from DB pool size.** Coupling a 256-waiter queue with tight 250 ms timeouts triggers cascading 500s during short GC/lock stalls; use larger bounded admission + backpressure (`EPOLLIN` pause).
110
+ 79. **Reserve top fds + brief `accept` backoff (1-100 ms) to prevent DB reconnect starvation.** Keep ~256 fds reserved below `RLIMIT_NOFILE` so Postgres reconnects never hit `EMFILE`.
111
+ 80. **Enforce pass time budgets and step-aside stalled work.** Capping loop-pass work (e.g., 12 ms) and parking slow outliers prevents one slow batch from collapsing p95/p99 for everyone.
112
+
113
+ ## 7. Language & Runtime Playbooks
114
+
115
+ 81. **Rust:** For maximum density, use raw `libc` `epoll`/`io_uring` without an async runtime; if using `tokio`, run `current_thread` per core, keep futures small (box DB states), and use `mimalloc`.
116
+ 82. **Rust / C / C++ on Cascade Lake / pre-VAES CPUs:** Pass `-C target-feature=-avx512f` or `-mprefer-vector-width=256` to prevent AVX-512 turbo frequency throttling unless `VAES` is present.
117
+ 83. **Rust / C / C++ / Zig PGO & linker layout:** Two-stage `llvm-profdata` PGO + `-Wl,--call-graph-profile-sort=cdsort` + `-Wl,--icf=safe` + `-enable-ext-tsp-block-placement` + `-split-machine-functions` delivers measurable instruction-cache wins.
118
+ 84. **C++:** Use `EASTL` / flat hash maps, size-classed thread-local coroutine frame freelists, and `MIMALLOC_ALLOW_LARGE_OS_PAGES=1` (`PURGE_DELAY=-1`) via startup re-exec if needed.
119
+ 85. **Go:** Use `GOMAXPROCS=1` per forked worker (or `gnet` epoll loops with 8-byte pointer-free `slot`s), `GOGC=400` + `GOMEMLIMIT=70-75% RAM`, `syscall.RawSyscall` on non-blocking fds, `pgx.Batch`, and `gzhttp`.
120
+ 86. **C# / F# (.NET):** Prefer NativeAOT (`PublishAot=true`, `IlcInstructionSet=x86-64-v3`) + `[SuppressGCTransition]` on non-blocking FFI, `ServerGarbageCollection=false` + `ConcurrentGarbageCollection=false` (per-core) or `DOTNET_GCHeapHardLimitPercent=0x46`, `DOTNET_ThreadPool_UnfairSemaphoreSpinLimit=0` (saved 18% CPU), `UnsafePreferInlineScheduling`, and `Npgsql` `Multiplexing=true;NoResetOnClose=true;MaxAutoPrepare=10`.
121
+ 87. **Java / Kotlin:** Replace Tomcat/JDBC/G1 with Netty native epoll + pinned per-loop Vert.x reactive `pg-client` (`pipeliningLimit=256`) + `FlushConsolidationHandler` + `thread-selection: MANUAL`; disable Netty idle-timeout `ScheduledFutureTask`s; set `-XX:+UseParallelGC` (or ZGC) + `-XX:+AlwaysPreTouch` + `-XX:+UseCompactObjectHeaders`; keep Tomcat `appReadBufSize=4096` if stuck on Tomcat; use JDK FFM (`captureCallState("errno")`) and verify zero primitive boxing via `javap` in CI.
122
+ 88. **Python:** Call `gc.freeze()` after startup *and* inside a `gc.callbacks` post-collection hook (cut gen-1 pause 177 ms -> 0.04 ms); replace FastAPI `APIRoute` with Starlette `Route` + `orjson` + ASGI header/body `coalesce`; use `asyncio.Protocol` + `.send(None)` coroutine stepping instead of `asyncio.Task`; offload hot read routes (`GET`) to a C `epoll` + `libpq` extension; slice UTC `timestamptz` strings instead of `datetime.isoformat()`.
123
+ 89. **JS / TS (Bun / Node):** `Bun.serve` (`reusePort: true`) + `Bun.SQL` + `Bun.gzipSync` beats Node Fastify 3.2x on 4 cores (`<1 KB`/idle conn); in `bun:ffi`, type `ssize_t`/`size_t` returns as `i32` where safe to avoid `BigInt` allocations; in Node, set `--max-old-space-size` per cluster worker (defaults cap at ~4 GB) and raise `node-postgres` `idleTimeoutMillis` to stop SCRAM reconnect storms.
124
+ 90. **PHP:** Framework DI containers (Laravel Octane) fail under concurrent Swoole coroutine container flushes and cap low; raw `epoll` via PHP FFI + OPcache tracing JIT + persistent `ext-pgsql` hits 7x higher 4-core scale.
125
+ 91. **Ruby:** Patch/enable per-worker `SO_REUSEPORT` in `iodine` (preventing 2.7x-4.4x kernel accept skew across workers) on Ruby 4.0 + YJIT.
126
+ 92. **Erlang / Elixir:** Force per-request heap shrink (`erlang:garbage_collect()` / `gc_every_n_keepalive_requests: 1`) so idle connection processes drop back to ~233 words, and pass `+sbwt none` to stop scheduler busy-waiting.
127
+ 93. **Pony:** Never let per-connection actors hold a reference to a shared coordinator actor that references the whole DB pool (ORCA graph tracing leaked 296 KB/conn vs 11 KB/conn when passing only the single assigned `DbSlot`).
128
+ 94. **Scala / Cats Effect / ZIO:** Audit per-connection fiber/scope retention (`fs2` + `Ember` held 38.1 KB/idle conn); use generational ZGC for pause control if heap stays large, and pool sessions without `RESET ALL`.
129
+ 95. **Crystal / Nelua / Common Lisp:** `-Dgc_none -Dwithout_mt` (Crystal) and `pragmas.nogc` (Nelua) eliminate GC pauses; SBCL Common Lisp with forked workers + `VOP` assembly intrinsics competes directly with C/Rust.
130
+
131
+ ## 8. Benchmarking & Correctness Harnesses
132
+
133
+ 96. **Use `SO_REUSEPORT` in multi-worker servers** so the kernel distributes accepts evenly instead of LIFO-starving most workers.
134
+ 97. **Subtract TCP `connect()` dial time from request latency** in custom load generators so SYN-queue wait doesn't distort app latency.
135
+ 98. **Pool `gzip.Reader`s (`sync.Pool`) in load generators.** Unpooled 32 KB `gzip.Reader`s across 250k simulated users waste >8 GB RAM on the load box.
136
+ 99. **Snapshot benchmark counters BEFORE closing `stop` channels.** Stopping workers concurrently with stat reads injects artificial teardown errors and map races.
137
+ 100. **Retry idempotent `GET`s once on `status == 0` stale keep-alive EOFs** while failing non-idempotent writes cleanly.
138
+ 101. **Coordinate distributed load generators with shared `-start` unix-ms and disjoint `-offset` auth slices** + log-bucket histograms (`1.01^b`) that merge by exact array addition.
139
+ 102. **Test golden-byte exactness (key order, UTC ms truncation without rounding), auth-before-validation ordering, AND `Accept-Encoding: gzip` in CI.**
140
+ 103. **Reset DB caches (`sync; echo 3 > /proc/sys/vm/drop_caches`) and clone from `TEMPLATE` DB between runs** so warm-cache runs don't mask cold-start or index-fit bugs.
141
+ 104. **Keep `mload`/client GC behavior in mind when tuning compression.** Generating unusually sized bursts can shift client-side GC mark pauses and distort p99.
142
+ 105. **Tune `TCP_RTO_MIN_US` (e.g. `60_000`) and `PR_SET_TIMERSLACK` on latency-sensitive listeners** to tighten Linux retransmission and timer coalescing floors.
143
+ 106. **Weigh `SO_ATTACH_REUSEPORT_CBPF` accept steering against single-queue NIC skew:** steering accepts to the SYN core helps multi-queue NICs, but can overload one worker when RPS/softirq concentrates RX.
144
+ 107. **Pass `-mllvm -static-func-full-module-prefix=false` during clang PGO (`-fprofile-generate`/`-fprofile-use`)** so static-function profile counters match reliably across unity/LTO builds.
145
+ 108. **Use `ABBABAB` online tuning only under healthy headroom (`p99 < 100 ms`, `busy < 60%`)** with an >=8% CPU/req win threshold.
146
+ 109. **Co-locate `ksoftirqd` awareness with loop sizing:** on small VMs (2-4 vCPUs), kernel RX/TX softirq share is a first-class competitor for CPU cycles.
147
+ 110. **Treat architecture beats micro-tuning as a strict hierarchy:** Share-nothing per-core + zero-idle-buffer + DB pipelining/batching gives 5x-10x; SIMD/gzip/PGO gives the final 10-30%.
148
+
149
+ ## 9. Embedded SQLite & Single-Core Optimization ($12 Server)
150
+
151
+ 111. **Use canonical SQLite OLTP PRAGMAs with `mmap_size=0`.** Set `journal_mode=WAL`, `synchronous=NORMAL`, `temp_store=MEMORY`, `wal_autocheckpoint=0`, `mmap_size=0`, and `cache_size` sized to the hot working set (e.g. `-49152` for 48 MB). `mmap_size=0` beats `mmap` by 3.4-12% CPU.
152
+ 112. **Open in-process SQLite connections with `unix-excl` VFS.** Acquires one process-lifetime lock and keeps the WAL index in heap memory, eliminating file-lock and `-shm` I/O.
153
+ 113. **Coalesce WAL `pwrite`s in a custom `SQLITE_VFS` shim.** Buffering contiguous 24 B frame headers + pages into one `pwrite` per commit (chunked at `0x1ffff`) cuts `pwrite`s from ~0.24 to ~0.095/req.
154
+ 114. **Offload `PASSIVE` checkpoints + `fdatasync` to a `nice 5-10` background thread.** Never run at `nice 19` (starves under 100% load and grows WALs to GBs); pause new writes briefly (reads continue) so the **loop connection's** next write restarts the WAL without dropping its page cache.
155
+ 115. **Preallocate DB growth via `SQLITE_FCNTL_CHUNK_SIZE` instead of `journal_size_limit` truncation.** Truncating the WAL forces ext4 extent/metadata journal sync stalls on re-extension; drop copied WAL pages with `POSIX_FADV_DONTNEED`.
156
+ 116. **Serialize SQLite writes in-process; never rely on `busy_timeout` contention.** Use one writer connection/queue + read pool (`_mutex=no`), skip `INSERT ... RETURNING` (ephemeral temp table), and avoid redundant `ORDER BY` inside `group_concat`/`json_group_array`.
157
+ 117. **Bypass SQLVM via B-tree cursors for hot read paths when justified.** Decode local payloads zero-copy off pinned pages, keep positioned cursors across read passes, and keep writes on prepared SQL with startup schema/cookie validation.
158
+ 118. **On 1 vCPU, run ONE event-loop thread driving all rings (`SINGLE_ISSUER | DEFER_TASKRUN`).** Poll secondary rings non-blockingly and sleep only on ring 0; multiple worker threads on 1 core cause context-switch thrash.
159
+ 119. **Defeat `RLIMIT_NOFILE=65535` with direct-descriptor ring rollover.** Use `IORING_FILE_INDEX_ALLOC` across 8-16 rings, stop accepting at `margin > accept_depth`, and bind 8 `SO_REUSEPORT` listeners so SYN queues don't drop during ramps.
160
+ 120. **Cap answers per pass (`answerCap`) + use LIFO-with-aging (`>= 8s`/`16s`).** Prevents backlog passes from crossing 40 ms and triggering thousands of bare TCP delayed-ACK packets/s.
161
+ 121. **Skip Nginx on tight single-box deployments when direct serving works.** Nginx's `keepalive 64` upstream pool and CPU share capped diverse stacks at 24k users with POST EOFs.
162
+
163
+ ## 10. Co-Located DB & Contention Tuning (Multicore)
164
+
165
+ 122. **Set `SCHED_BATCH` + `nice 5` on app reactor loops when sharing cores with Postgres.** Prevents epoll/`io_uring` wakeups from preempting active Postgres backends mid-query (halved feed p95 and cut DB CPU wait 18%).
166
+ 123. **Tier CPU priority for heavy crypto (`bcrypt`) + add a 3 s watchdog.** Run 1 primary hasher at `nice 0` and spares at `nice 10` (or `SCHED_IDLE` + watchdog) so hashing never starves Postgres or logins.
167
+ 124. **Under-provision HTTP reactors (`cores/2` or `cores/4`) on co-located boxes.** Leaving 4-5 cores for Postgres and 1-2 for heavy compute beats running 1 HTTP loop per core.
168
+ 125. **Use ONE box-wide read queue/planner across all reactors, capping active DB concurrency below core count.** Funneling reads through a shared planner (e.g., 6-7 active batches on 8 cores, splitting fast vs slow lanes) cut Postgres CPU 20-33%.
169
+ 126. **Use `unshare(CLONE_FILES)` per reactor thread.** Eliminates kernel `files_struct` lock contention across threads and gives each reactor its own `RLIMIT_NOFILE` budget.
170
+ 127. **Leave `TCP_QUICKACK` alone under saturation.** Toggling `TCP_QUICKACK=0` per reply helps at medium load but hurts p95 by 33-72 ms at saturation when replies miss the delayed-ACK window.
171
+ 128. **Drop already-disconnected client requests before hitting Postgres.** Checking a connection epoch atomic at DB-dispatch time avoids wasting DB CPU on timed-out callers.
172
+ 129. **Pipeline Phase A1 (cheap lookups + `Flush`) before Phase A2 (heavy feeds) in one socket write.** Dispatches auth/fast paths concurrently while Postgres executes heavy queries.
173
+ 130. **Scope `EXISTS`/flag checks to rendered `(viewer, target)` pairs & pace huge batch replies.** Probing only displayed pairs cut 30% PG time on aged DBs; pacing large batch flushes (`ANSWER_PACE`) avoids NIC TX drops.
174
+
175
+ ## 11. Non-CRUD Edge, TLS, Streaming & Lock-Free Observability
176
+
177
+ 131. **Enable TLS 1.3 session resumption (tickets/PSK) and kernel `kTLS` (`SSL_OP_ENABLE_KTLS`).** Offloads symmetric crypto to the kernel so `sendfile`/`splice` zero-copy still works over HTTPS.
178
+ 132. **Bound HTTP/2 & HTTP/3 (QUIC) per-connection stream concurrency and HPACK/QPACK dynamic tables.** Unbounded `MAX_CONCURRENT_STREAMS` and huge header tables recreate per-connection memory bloat at 100k+ users.
179
+ 133. **Share one ring buffer across SSE/WebSocket subscribers with per-consumer cursors.** Never clone or allocate a payload per subscriber; drop or disconnect slow consumers that fall behind the ring tail.
180
+ 134. **Use `sendfile`, `splice`, or `MSG_ZEROCOPY` for static or multi-KB streaming payloads.** Avoids copying file/pipe buffers through user space on the event loop.
181
+ 135. **Log and emit metrics through thread-local lock-free ring buffers.** Never call `malloc`, format strings synchronously, or lock a shared logger mutex on the request thread; sample tails asynchronously.
@@ -0,0 +1,56 @@
1
+ # Language ecosystems
2
+
3
+ Read when choosing a language or runtime, setting up a project's build, test, or debug tooling, or working in an unfamiliar language and needing its runtime model, concurrency model, and traps. The one-line pick-by-domain table is in `backend-system-design.md`; this file has the depth. Source keys are in this skill's `SKILL.md`.
4
+
5
+ ## Runtime model at a glance
6
+
7
+ | Language | Execution | Memory management | Concurrency |
8
+ |---|---|---|---|
9
+ | C | AOT native: preprocess → compile (GCC, Clang, MSVC) → assemble → link | Manual `malloc`/`free`; stack + heap; no GC | OS threads (pthreads), C11 `<threads.h>` and `stdatomic.h` |
10
+ | C++ | AOT native (GCC/libstdc++, Clang/libc++, MSVC/STL) | RAII, `unique_ptr` (single owner), `shared_ptr` (ref-counted); no GC | Threads, mutexes, atomics, async tasks; no compiler race safety |
11
+ | Rust | AOT native via `rustc` on LLVM; one self-contained binary | Ownership, borrowing, lifetimes checked at compile time: many shared refs or one mutable ref; no GC | Type system blocks data races; Tokio for async I/O |
12
+ | Go | AOT single static binary, no host runtime needed | Concurrent low-latency tracing GC; escape analysis moves values to the heap | Goroutines multiplexed onto few OS threads, typed channels |
13
+ | Java | `javac` → bytecode → JVM interprets and JITs (OpenJDK, Oracle, Corretto) | Tracing GC (G1, ZGC); bounds-checked arrays | Platform threads plus Java 21 virtual threads for cheap I/O concurrency |
14
+ | C# / .NET | Roslyn → CIL → CLR JIT (.NET 10 LTS) | Tracing GC; structs on the stack; `unsafe` pointers for interop | `async`/`await` on the thread pool, Task Parallel Library |
15
+ | Python | CPython compiles to `.pyc` bytecode, runs on its VM; no build step | Reference counting plus a cycle collector; everything is a heap object; assignment copies the reference | `asyncio` event loop for I/O; standard CPython's GIL limits CPU threads (use processes, or free-threaded PEP 703 3.13t/3.14t builds for multi-core threads) |
16
+ | JavaScript / TypeScript | V8, SpiderMonkey, JavaScriptCore: bytecode plus JIT on hot paths; TS type-checks then transpiles to JS | Tracing GC; objects, arrays, closures on the heap | One thread plus event loop (microtasks, macrotasks); Web Workers or Worker Threads for CPU work |
17
+ | PHP | Zend Engine compiles to opcodes per request; OpCache speeds it up | Ref counting plus cycle GC; memory is per request and freed when the response ends | Many worker processes (PHP-FPM), not threads |
18
+ | Ruby | YARV bytecode VM | Mark-and-sweep GC; everything is an object | Global VM lock in MRI; multi-process servers (Puma) |
19
+ | Kotlin | Compiles to JVM bytecode; also JS and native via Kotlin Multiplatform | JVM GC (ART on Android); null safety in the type system (`Type?`) | Coroutines |
20
+ | Swift | AOT native on LLVM | ARC, no GC; value types with copy-on-write; `weak` and `unowned` break cycles | `async`/`await`, actors isolate mutable state, task groups |
21
+
22
+ (C-ECO, CPP-ECO, RUST-ECO, GO-4MIN, JAVA-ECO, CSHARP, PY-ECO, JS-ECO, FRAMEWORKS-2026, LANGS-2026)
23
+
24
+ ## Tooling
25
+
26
+ | Language | Packages and build | Main frameworks and libraries | Test, lint, debug |
27
+ |---|---|---|---|
28
+ | C | No standard package manager; CMake, Make, Ninja; Conan, vcpkg, or OS packages | glibc, musl, newlib; OpenSSL, FreeRTOS, Zephyr | GDB, LLDB; clang-tidy, cppcheck; ASan, UBSan; libFuzzer, AFL |
29
+ | C++ | CMake generating Make or Ninja; vcpkg, Conan | STL, Boost, Qt, C++20 modules | GoogleTest, Catch2; GDB, LLDB, VS debugger; clang-format; TSan, ASan, UBSan |
30
+ | Rust | Cargo, crates.io, `Cargo.lock` | Axum (HTTP), SQLx (compile-time checked SQL), Serde, Tokio | `cargo test`, Clippy, rustfmt, cargo-audit |
31
+ | Go | Go modules (`go.mod`); `go build`, `go fmt`, `go test` | Large stdlib (`net/http`) | `go test`, `-race` detector, Delve |
32
+ | Java | Maven (`pom.xml`) or Gradle; Maven Central | Spring Boot, Spring Data JPA, Hibernate, Jackson; Micronaut, Quarkus | JUnit, Mockito; IntelliJ, Eclipse; Actuator, Micrometer |
33
+ | C# | .NET CLI, NuGet, `.csproj` | ASP.NET Core, EF Core, Blazor, .NET MAUI, .NET Aspire | xUnit, NUnit; Visual Studio, Rider, VS Code C# Dev Kit; profilers |
34
+ | Python | `uv` + `pyproject.toml` (2026 default); pip/PyPI, `requirements.txt`, Poetry, `venv` | FastAPI, Django, Flask; PyTorch, TensorFlow, Transformers, Pandas, NumPy | pytest, unittest; Ruff, Flake8, Black; PyCharm, VS Code |
35
+ | JS / TS | npm, pnpm, Yarn; Vite (Rolldown), Webpack, Bun | React, Next.js, Vue; Express, NestJS, Fastify, Koa; Zod | Vitest, Jest, Playwright; ESLint, Prettier; browser DevTools |
36
+ | PHP | Composer, Packagist | Laravel (auth, routing, Eloquent), Symfony | PHPUnit, Pest; Xdebug |
37
+ | Ruby | RubyGems, Bundler (`Gemfile.lock`) | Rails, Sinatra | RSpec, Minitest; Pry |
38
+ | Kotlin | Gradle or Maven | Ktor, Spring Boot; Jetpack Compose | JUnit, MockK; IntelliJ, Android Studio |
39
+ | Swift | Swift Package Manager | SwiftUI, UIKit; Vapor (server) | XCTest, Swift Testing; LLDB in Xcode |
40
+
41
+ ## Where each shines, and the traps
42
+
43
+ | Language | Built with it | Choose for | Avoid for | Traps |
44
+ |---|---|---|---|---|
45
+ | C | Linux kernel, SQLite, Git, cURL, PostgreSQL, Redis, CPython | Kernels, drivers, microcontrollers, hard real-time | Web APIs, business apps, anything where memory-safety risk is not justified | Buffer overflows, leaks, use-after-free, undefined behavior |
46
+ | C++ | Unreal Engine, Chrome, Firefox, PyTorch backend, HFT | Game and browser engines, ML runtimes, hot paths | Small CLIs, CRUD backends, quick prototypes | Complex syntax, slow template-heavy builds, no ABI stability across compilers, UB |
47
+ | Rust | Cloudflare Pingora (trillions of requests a day), parts of Linux, Android components, Hugging Face tokenizers | Proxies, network infrastructure, security-critical services, fast AI utilities, CLIs | Throwaway scripts, early exploration, simple business apps | Steep learning curve with the borrow checker, lifetimes, slow builds on big codebases |
48
+ | Go | Docker, Kubernetes, Terraform, the TypeScript 7 compiler | Cloud-native infrastructure, DevOps tools, microservices, distributed systems | GPU ML research, AAA games, mobile front ends | No inheritance; repetitive `if err != nil`; slices share their backing array unless copied |
49
+ | Java | Banking, airline booking, Kafka, Minecraft | Big enterprise backends, financial platforms, streaming | Sub-ms cold-start serverless, tiny embedded, bare metal | High baseline memory, slow cold start, leaks from collections that never drop references |
50
+ | C# | Azure services, Unity scripts, WPF and WinForms apps | Enterprise APIs, Azure backends, MAUI apps, Unity games | Drivers, microcontrollers | .NET Framework vs Core vs .NET naming confusion, heavier runtime than Go or Rust |
51
+ | Python | AI research, LangChain, LangGraph, Instagram | AI and ML, data work, automation, FastAPI services | 3D engines, mobile apps, kernels | Slow CPU-bound code, runtime type errors, mutable default arguments, the GIL |
52
+ | JS / TS | Web front ends, Electron (VS Code, Slack, Discord), Cloudflare Workers | Web apps, full stack, real-time event backends, desktop tools | Scientific computing, model training, low-latency systems | Type coercion quirks, npm supply-chain risk, CPU work blocks the single thread, promise confusion |
53
+ | PHP | WordPress, Wikipedia, e-commerce | Portals, stores, CMS, business web apps | Real-time games, systems infrastructure, ML pipelines | Inconsistent legacy functions, framework boot cost per request without persistent workers, poor fit for long-lived sockets |
54
+ | Ruby | GitHub, Shopify, Basecamp, Airbnb (early) | Startup MVPs, fast iteration, CRUD apps | High-throughput streaming, big data, low-latency finance | Slow CPU, metaprogramming that makes large codebases hard to trace, high memory |
55
+ | Kotlin | Android (Google's preferred language), JVM backends | Native Android, a modern Java replacement | Systems programming, places that cannot run a JVM | Slower compiles than Java, small ecosystem outside JVM and Android, coroutine debugging |
56
+ | Swift | iOS, iPadOS, macOS, watchOS, visionOS apps | Apple client apps | Cross-platform web services, non-Apple servers | Weak server adoption, breaking changes in early versions, leaks from strong reference cycles |
@@ -0,0 +1,146 @@
1
+ ---
2
+ name: frontend-ui
3
+ description: "UI and UX rules for building, restyling, or reviewing interfaces: components, layout, typography, color, motion and animation, motion graphics, accessibility, copy, and chat or agent UI, with patterns learned from shipped apps. Use before writing or reviewing UI code."
4
+ metadata:
5
+ as-of: "2026-11-12"
6
+ ---
7
+
8
+ # Frontend UI/UX rules (bundled)
9
+
10
+ Distilled from the optional private reference repo `TimothyVang/frontend` (`7c57c43`). The bundled playbook and pattern files under `references/` stand on their own for general UI/UX work; optional deep-dive paths prefixed `TimothyVang/frontend:` below exist only when you have access to that private repo.
11
+
12
+ Paths written `TimothyVang/frontend:<path>` and bracketed citations like `[youtube/...]` point at that repo's evidence (transcripts, clips, screenshots, vendored skills). If `gh` can read it, shallow-clone it into the project's self-ignored scratch folder (`gh repo clone TimothyVang/frontend .scratch/refs/frontend -- --depth 1`, about 300 MB) and never commit from it: deepmodebot keeps every write inside the project root, and `.scratch/` holds a `.gitignore` of `*`. Otherwise skip the evidence; the rules below stand alone.
13
+
14
+ ## Playbook sections (read the one the task routes to)
15
+
16
+ - `references/playbook/01-workflow.md`
17
+ - `references/playbook/02-review-rubric.md`
18
+ - `references/playbook/03-ai-tells.md`
19
+ - `references/playbook/04-components.md`
20
+ - `references/playbook/04a-agent-ui.md`
21
+ - `references/playbook/05-motion.md`
22
+ - `references/playbook/05a-motion-graphics.md`
23
+ - `references/playbook/06-typography-layout.md`
24
+ - `references/playbook/06a-color.md`
25
+ - `references/playbook/07-copy.md`
26
+ - `references/playbook/08-quality-floor.md`
27
+ - `references/playbook/09-steering-agents.md`
28
+
29
+ ## What the images and motion clips taught (text)
30
+
31
+ - `references/patterns/mobbin-shipped-apps.md`: layout patterns from shipped apps
32
+ - `references/patterns/pinterest-patterns.md`: patterns and AI tells from 341 popular UI pins
33
+ - `references/patterns/pinterest-animations.md`: 193 animated pins as motion techniques, by type
34
+ - `references/patterns/motion-clips.md`: what every reference-talk clip shows, as motion vocabulary
35
+ - `references/patterns/live-demos.md`: Sonner, Vaul, cmdk, NumberFlow behaviour
36
+ - `references/patterns/motion-graphics.md`: engines, stack, lessons for rendered video
37
+
38
+ ## Playbook intro
39
+
40
+ General UI/UX rules distilled from shipped-app patterns and design references. Use the bundled `references/` files directly; optional `TimothyVang/frontend:*` citations link deeper evidence when that private repo is available.
41
+
42
+ Leading idea: **defaults are tells.** Every unexamined default (library styling, stock layout, generic motion) reads as AI-generated. Every visible choice must be one made *for this brief*.
43
+
44
+ **Bans are defaults, not laws.** The brief's explicit words always win, even when they ask for something listed in §3. [github/INDEX tensions; anthropic frontend-design]
45
+
46
+ **Decide the surface mode first; ambition follows from it.** [github/pbakaus-impeccable; github/Leonxlnx-taste-skill]
47
+
48
+ | Mode | Surfaces | How it expresses the brand |
49
+ | --- | --- | --- |
50
+ | Operate | App UI, dashboards, settings, the agent console | Precision and restraint |
51
+ | Persuade | Landing, pricing, onboarding hero | Bold work, including the one standout moment |
52
+
53
+ Most application and agent-console surfaces are *Operate*.
54
+
55
+ ---
56
+
57
+ ## Rules (always apply)
58
+
59
+ Every visible UI choice must be made for this brief. Defaults are tells: unmodified library styling, stock layouts and generic motion read as AI-generated.
60
+
61
+ Prefer retrieval-led reasoning over pretraining for UI work. Explore the project first (`package.json`, existing components, tokens), then load the routed source below.
62
+
63
+ ## Always
64
+ - **Pick the surface mode.** Operate surfaces (the app, the agent console, settings) express the brand through precision and restraint. Persuade surfaces (landing, pricing) get the bold work. The brief's explicit words override any rule here.
65
+ - **Plan before code.** Write a token plan: OKLCH seed colors with role names, typefaces and their roles, and a layout concept with an ASCII wireframe. Revise any part that would fit any similar page. Where `frontend-design` says hex, `references/playbook/06a-color.md` overrides it.
66
+ - **Compose, don't hand-roll.** Use the library already in `package.json` first. For React apps, use shadcn/ui restyled on Base UI or Radix (for SvelteKit — `skill://deep-stack`'s default — use `shadcn-svelte` or equivalent accessible primitives with the same token and quality rules), plus:
67
+
68
+ | Need | Library |
69
+ | --- | --- |
70
+ | Toasts | Sonner |
71
+ | Drawers | Vaul |
72
+ | ⌘K | cmdk |
73
+ | Animated numbers | NumberFlow |
74
+ | OTP inputs | input-otp |
75
+ | Long lists | Virtuoso |
76
+ | Drag and drop | dnd kit |
77
+ | Animation | motion |
78
+ | Charts | recharts |
79
+ | State | zustand |
80
+ | Variants | cva + clsx |
81
+ | Theme | next-themes |
82
+
83
+ - **Agent UI uses shadcn's chat components:**
84
+ - Threads: `MessageScroller`, which follows the reply but yields when the user scrolls up.
85
+ - Turns: `Message` + `Bubble`.
86
+ - Agent activity: one `TraceLine` per action inside a `Trace`.
87
+ - Status words match the state (Running → Ran / Failed to run).
88
+ - Tool approvals: a prompt *outside* the trace, tiered by risk (read-only tools run unprompted), phrased as a proposal stating target, effect and reversibility. One decision per prompt.
89
+ - Stop stays visible for the whole run, beside a working Send (messages sent mid-run steer the agent). A dropped connection reconnects; it never acts as a stop.
90
+ - Delegated work gets a task list with per-task status and a jump to whatever is awaiting the user.
91
+ - Streaming Markdown goes through a renderer that heals unterminated syntax (Streamdown).
92
+ - Never hand-roll "Thinking..." collapsibles or a stick-to-bottom div.
93
+
94
+ - **Retheme shadcn.** Change radius, palette and type before shipping anything.
95
+ - **Color through tokens:**
96
+ - Author in OKLCH. Components use only role tokens (`--bg-subtle`, `--fg-muted`, `--border-strong`); no raw `bg-zinc-*` or hex.
97
+ - Neutrals are tinted with the brand hue.
98
+ - Status colors share lightness and chroma.
99
+ - Text on a colored fill uses that fill's hue.
100
+ - Dark mode is a token remap.
101
+ - **Hierarchy:**
102
+ - Three text tones; weight and color before size.
103
+ - One solid primary per view.
104
+ - Separate things with spacing before borders.
105
+ - Lay components out with `@container`, not viewport breakpoints.
106
+ - **One standout moment per page.** Keep everything around it quiet.
107
+ - **Motion:**
108
+ - Easing: ease-out to enter or exit; ease-in-out to move on screen; never ease-in. Anything draggable or reversible uses a spring (duration + bounce; bounce 0 by default, never above 0.4).
109
+ - View Transitions only for discrete changes (routes, filters, add/remove), because they can't be interrupted. Animate layout with Motion `layout`, never `width`/`height`.
110
+ - Duration: 100–300 ms by size. Exits run about 20% faster.
111
+ - Press: `scale(0.97)`. Enter from `scale(0.95)`. Origin-aware popovers.
112
+ - Animate `transform` and `opacity` only, with no `transition: all`. Reduced motion means a fade, not nothing.
113
+ - Gate motion by frequency. Anything keyboard-initiated (⌘K, shortcuts, Escape-to-close) or used 100+ times a day gets no animation.
114
+ - **Motion graphics (anything rendered to video)** follow `references/playbook/05a-motion-graphics.md`, not §5's UI timings:
115
+ - Every frame is a pure function of `t`, with one timeline file.
116
+ - Write a director's brief with a Banned list, and gate on a beat map plus stills before the full render.
117
+ - Text holds 0.3 s/word + 0.5 s; landed titles stay still.
118
+ - Cuts land on the beat; sound is mastered to −14 LUFS.
119
+ - Show real product UI only.
120
+ - Critique with timestamped notes, not scores.
121
+ - **Copy:**
122
+ - Sentence case, the user's vocabulary.
123
+ - A CTA names its result. Destructive actions use Verb + Noun.
124
+ - Errors say what happened and how to fix it. In-progress labels end in `…`.
125
+ - **Quality floor:**
126
+ - Responsive to mobile; visible focus; WCAG AA contrast.
127
+ - Accessible names; 44 px hit areas.
128
+ - Every reachable state: loading, empty, error, permission, disabled, optimistic, destructive.
129
+ - **Verify in a real browser.** Screenshots at compact and wide widths, a keyboard pass, every changed state. Never claim visual quality from code alone. Then run a skeptical critique against the `references/playbook/02-review-rubric.md` rubric (design quality, originality, craft, functionality).
130
+
131
+ ## Route by task
132
+ Read the bundled `references/` file first. Paths prefixed `TimothyVang/frontend:` are optional private-repo deep dives available only if you have access to that repo.
133
+
134
+ | Task | Read (bundled first; optional private-repo deep dive) |
135
+ | --- | --- |
136
+ | Full workflow, AI-tell list, review rubric | `references/playbook/01-workflow.md`, `references/playbook/02-review-rubric.md`, `references/playbook/03-ai-tells.md` |
137
+ | New page, visual direction, color, typography | `references/playbook/06-typography-layout.md`, `references/playbook/06a-color.md`, `references/playbook/03-ai-tells.md` |
138
+ | Picking a component library or shadcn theming | `references/playbook/04-components.md`, `references/patterns/live-demos.md` (optional: `TimothyVang/frontend:.claude/skills/shadcn/SKILL.md`) |
139
+ | Chat, agent activity, tool calls, approvals, AI UX | `references/playbook/04a-agent-ui.md` (optional: `TimothyVang/frontend:reference/articles/ai-ux/_batch-ai-ux-guidelines.md`) |
140
+ | Seeing shipped layouts or motion vocabulary | `references/patterns/mobbin-shipped-apps.md`, `references/patterns/pinterest-patterns.md`, `references/patterns/pinterest-animations.md`, `references/patterns/motion-clips.md` |
141
+ | Building UI animation, choreography, gestures, perf | `references/playbook/05-motion.md`, `references/patterns/motion-clips.md` |
142
+ | Motion graphics, launch/promo videos, Remotion/HyperFrames | `references/playbook/05a-motion-graphics.md`, `references/patterns/motion-graphics.md` |
143
+ | Copy, microcopy, CTAs, error messages | `references/playbook/07-copy.md` |
144
+ | Reviewing UI, accessibility, keyboard, ARIA, mobile, edge cases | `references/playbook/02-review-rubric.md`, `references/playbook/08-quality-floor.md`, `references/playbook/03-ai-tells.md` |
145
+ | Steering UI agents and revision passes | `references/playbook/09-steering-agents.md`, `references/playbook/01-workflow.md` |
146
+ | Optional private evidence archive (if accessible) | `TimothyVang/frontend:reference/INDEX.md` (vendored skills, WAI-ARIA APG notes, Mobbin screenshots, channel transcripts) |
@@ -0,0 +1,38 @@
1
+ # Live library demos (what specialists do that hand-rolled versions don't)
2
+
3
+ Recordings: `TimothyVang/frontend:reference/demos/`.
4
+
5
+ These were recorded on 2026-11-11 from each library's official demo page in a headless browser (1280×800, 30 fps). They're the reference for "what the specialist does that a hand-rolled version doesn't" (PLAYBOOK §4). Click a preview for the MP4.
6
+
7
+ ## Sonner: toasts
8
+ Sonner: four toasts collapse into a stack, expand on hover, then success, error, and a promise toast going from loading to success
9
+
10
+ - **Stacking:** new toasts push older ones back into a collapsed, scaled stack instead of piling up.
11
+ - **Hover to expand:** the stack fans out with even gaps; the auto-dismiss timers pause while it's open.
12
+ - **Typed toasts and promise:** a promise toast swaps from "Loading…" to its result in place, without a second toast.
13
+
14
+ Source: https://sonner.emilkowal.ski
15
+
16
+ ## Vaul: drawer
17
+ Vaul: drawer opens with a dimmed backdrop, a partial drag springs back, a quick flick dismisses it
18
+
19
+ - **Tracks the pointer 1:1** while dragging. The backdrop and the scaled page behind follow the drag.
20
+ - **Partial drag, release:** it springs back open (below the distance and velocity threshold).
21
+ - **Fast flick:** it dismisses on velocity even though the distance was short. See PLAYBOOK §5, Gestures (momentum projection).
22
+
23
+ Source: https://vaul.emilkowal.ski
24
+
25
+ ## cmdk: command menu
26
+ cmdk via shadcn Command: typing filters the list live, deleting restores it, arrow keys move the highlight
27
+
28
+ - **Live filtering:** groups collapse to the matches ("cal" → Calculator, Calendar) and the first match is highlighted.
29
+ - **Keyboard first:** arrow keys move the highlight across groups. There's no animation on these 100+-times-a-day interactions (PLAYBOOK §5, frequency gate).
30
+ - `cmdk.paco.me` now redirects to GitHub, so this was recorded from shadcn's `Command` (built on cmdk): https://ui.shadcn.com/docs/components/command
31
+
32
+ ## NumberFlow: animated numbers
33
+ NumberFlow: Shuffle rolls each digit into the next value, across currency, percent, negative and CJK compact formats
34
+
35
+ - **Digit rolls:** each digit translates and fades into its new value. Changed digits move; unchanged ones stay put.
36
+ - **Format changes animate too:** `$12,348.43` → `42` → `+39,843%` → `-3,243.5` → `143.52万米` (sign, separators, suffix).
37
+
38
+ Source: https://number-flow.barvian.me
@@ -0,0 +1,28 @@
1
+ # Patterns from shipped apps (Mobbin)
2
+
3
+ Real, shipped products, so prefer these over concept shots as layout references. Free-tier previews only (2 per pattern). Screens: `TimothyVang/frontend:reference/screens/mobbin/`.
4
+
5
+ ## What each pattern search showed
6
+
7
+ | Pattern (facet) | Total on Mobbin | Captured | What it shows |
8
+ | --- | --- | --- | --- |
9
+ | Chat Bot (`screenPatterns.Chat+Bot`) | 524 screens | `chat-bot/strut`, `chat-bot/linear` | **Strut:** a three-pane writing app with the AI chat docked right. The "You" / assistant turns sit in a narrow column, with an orange inline "Create a doc" action on the reply and the composer pinned at the bottom. **Linear:** an empty-state agent home ("Welcome to Linear / Ask anything") with a centered composer and three suggestion cards below it, which are capability chips (PLAYBOOK §4a) |
10
+ | Settings & Preferences (`screenPatterns.Settings+%26+Preferences`) | 3,202 screens | `attio`, `patreon` | Both use a left settings nav with grouped sections and a single narrow form column. Patreon has a large page title and a solid primary button at the form's end; Attio is denser, with its profile section in a card |
11
+ | Notifications (`screenPatterns.Notifications`) | 612 screens | `bonsai`, `deel` | **Bonsai:** an activity feed as a right-hand column on the dashboard. **Deel:** a popover notification panel with tabs and per-item actions, anchored to the bell |
12
+ | My Account & Profile (`screenPatterns.My+Account+%26+Profile`) | 369 screens | `peerlist`, `duolingo` | Profile header card, then stat tiles and lists. Duolingo puts gamified stats in a 2×2 grid |
13
+ | Charts (`screenPatterns.Charts`) | 1,404 screens | `beehiiv`, `cake-equity` | **beehiiv:** KPI row → line chart → right rail. **Cake Equity:** a donut ownership chart in a card grid with an activity rail |
14
+ | Side Navigation (`screenElements.Side+Navigation`) | 1,566 UI | `pandadoc`, `opensea` | **PandaDoc:** a light, grouped sidebar with a workspace switcher on top and a "Get started" checklist panel on the right. **OpenSea:** a collapsed icon rail beside a dense data table |
15
+ | Progress Indicator (`screenElements.Progress+Indicator`) | 1,783 UI | `pandadoc`, `cake-equity` | Setup-progress checklists in a dashboard rail or banner ("n of m complete") |
16
+ | Stepper (`screenElements.Stepper`) | 347 UI | `uniswap`, `zoom` | **Zoom:** a numbered vertical checkout stepper ("1. How many licenses… 2. Choose your plan…"). **Uniswap:** a stepped liquidity form |
17
+ | File Upload (`screenElements.File+Upload`) | 1,157 UI | `shopify`, `veed` | **Shopify:** an inline dropzone inside a long product form. **VEED:** a modal "New Project" with a dropzone and source options (record, stock) |
18
+ | Onboarding (`flowActions.Onboarding`) | 683 flows | `remote-onboarding` | A split screen: a solid brand-color left panel with the sign-up form, and a product preview on the right |
19
+ | Setting Up (`flowActions.Setting+Up`) | 767 flows | `shopify-setting-up-an-account` | "Let's get started. Which of these best describes you?" A single question in a centered card over a blurred app shell |
20
+ | Filtering & Sorting (`flowActions.Filtering+%26+Sorting`) | 2,016 flows | `deel-filtering-people` | A filter popover with checkbox options anchored to a "Filter" button above a people table |
21
+
22
+ ## Patterns worth taking for an agent product
23
+
24
+ - **Empty-state agent home** (Linear): a centered composer with 3 capability cards, matching PLAYBOOK §4a "idle composer".
25
+ - **Docked assistant pane** (Strut): chat as a right pane beside the work, with actions inline on the reply. Fits an agent that edits a document or workspace.
26
+ - **Setup checklist in a rail** (PandaDoc, Cake Equity): progress for first-run configuration, such as connecting tools or setting permissions.
27
+ - **Notification popover with per-item actions** (Deel): a model for an approvals inbox when the agent waits on the user while they're elsewhere.
28
+ - **One question per onboarding step** (Shopify): matches "one decision per approval" (PLAYBOOK §4a).