@kinqs/brainrouter-mcp-server 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (337) hide show
  1. package/.env.example +144 -0
  2. package/README.md +56 -0
  3. package/agents/README.md +120 -0
  4. package/agents/code-reviewer.md +97 -0
  5. package/agents/security-auditor.md +101 -0
  6. package/agents/test-engineer.md +95 -0
  7. package/dist/__tests__/agent_mode.test.d.ts +1 -0
  8. package/dist/__tests__/api-routes.test.d.ts +1 -0
  9. package/dist/__tests__/api-routes.test.js +170 -0
  10. package/dist/__tests__/crypto.test.d.ts +1 -0
  11. package/dist/__tests__/crypto.test.js +28 -0
  12. package/dist/__tests__/host-integrations.test.d.ts +1 -0
  13. package/dist/__tests__/host-integrations.test.js +82 -0
  14. package/dist/__tests__/integration.test.d.ts +1 -0
  15. package/dist/__tests__/integration.test.js +50 -0
  16. package/dist/__tests__/loader.test.d.ts +1 -0
  17. package/dist/__tests__/loader.test.js +89 -0
  18. package/dist/__tests__/neural-spark.test.d.ts +1 -0
  19. package/dist/__tests__/neural-spark.test.js +112 -0
  20. package/dist/__tests__/pagination.test.d.ts +1 -0
  21. package/dist/__tests__/pagination.test.js +23 -0
  22. package/dist/__tests__/redaction.test.d.ts +1 -0
  23. package/dist/__tests__/redaction.test.js +17 -0
  24. package/dist/__tests__/registry.test.d.ts +1 -0
  25. package/dist/__tests__/registry.test.js +56 -0
  26. package/dist/__tests__/retry.test.d.ts +1 -0
  27. package/dist/__tests__/retry.test.js +30 -0
  28. package/dist/__tests__/skill-activation.test.d.ts +1 -0
  29. package/dist/__tests__/skill-activation.test.js +112 -0
  30. package/dist/__tests__/working-memory.test.d.ts +1 -0
  31. package/dist/__tests__/working-memory.test.js +200 -0
  32. package/dist/__tests__/workspace-paths.test.d.ts +1 -0
  33. package/dist/__tests__/workspace-paths.test.js +56 -0
  34. package/dist/__tests__/writer.test.d.ts +1 -0
  35. package/dist/__tests__/writer.test.js +94 -0
  36. package/dist/api/auth/crypto.d.ts +4 -0
  37. package/dist/api/auth/crypto.js +54 -0
  38. package/dist/api/middleware/auth.d.ts +12 -0
  39. package/dist/api/middleware/auth.js +90 -0
  40. package/dist/api/pagination.d.ts +18 -0
  41. package/dist/api/pagination.js +32 -0
  42. package/dist/api/routes/auth.d.ts +1 -0
  43. package/dist/api/routes/auth.js +130 -0
  44. package/dist/api/routes/chat-completions.d.ts +7 -0
  45. package/dist/api/routes/chat-completions.js +474 -0
  46. package/dist/api/routes/contradictions.d.ts +1 -0
  47. package/dist/api/routes/contradictions.js +28 -0
  48. package/dist/api/routes/evidence.d.ts +1 -0
  49. package/dist/api/routes/evidence.js +59 -0
  50. package/dist/api/routes/governance.d.ts +1 -0
  51. package/dist/api/routes/governance.js +95 -0
  52. package/dist/api/routes/graph.d.ts +1 -0
  53. package/dist/api/routes/graph.js +25 -0
  54. package/dist/api/routes/hooks.d.ts +1 -0
  55. package/dist/api/routes/hooks.js +88 -0
  56. package/dist/api/routes/memories.d.ts +1 -0
  57. package/dist/api/routes/memories.js +92 -0
  58. package/dist/api/routes/persona.d.ts +1 -0
  59. package/dist/api/routes/persona.js +9 -0
  60. package/dist/api/routes/scenes.d.ts +1 -0
  61. package/dist/api/routes/scenes.js +35 -0
  62. package/dist/api/routes/skills.d.ts +1 -0
  63. package/dist/api/routes/skills.js +14 -0
  64. package/dist/api/routes/stats.d.ts +1 -0
  65. package/dist/api/routes/stats.js +8 -0
  66. package/dist/api/routes/users.d.ts +1 -0
  67. package/dist/api/routes/users.js +82 -0
  68. package/dist/api/routes/working.d.ts +1 -0
  69. package/dist/api/routes/working.js +88 -0
  70. package/dist/index.d.ts +2 -0
  71. package/dist/index.js +492 -0
  72. package/dist/integrations/claude-code.d.ts +12 -0
  73. package/dist/integrations/claude-code.js +35 -0
  74. package/dist/integrations/codex.d.ts +12 -0
  75. package/dist/integrations/codex.js +34 -0
  76. package/dist/integrations/generic-mcp.d.ts +52 -0
  77. package/dist/integrations/generic-mcp.js +118 -0
  78. package/dist/loader.d.ts +29 -0
  79. package/dist/loader.js +200 -0
  80. package/dist/memory/capture.d.ts +35 -0
  81. package/dist/memory/capture.js +230 -0
  82. package/dist/memory/config.d.ts +2 -0
  83. package/dist/memory/config.js +3 -0
  84. package/dist/memory/engine.d.ts +203 -0
  85. package/dist/memory/engine.js +626 -0
  86. package/dist/memory/llm-semaphore.d.ts +41 -0
  87. package/dist/memory/llm-semaphore.js +81 -0
  88. package/dist/memory/memory-type-config.d.ts +11 -0
  89. package/dist/memory/memory-type-config.js +65 -0
  90. package/dist/memory/pipeline/cognitive-contradiction.d.ts +7 -0
  91. package/dist/memory/pipeline/cognitive-contradiction.js +59 -0
  92. package/dist/memory/pipeline/cognitive-dedup.d.ts +23 -0
  93. package/dist/memory/pipeline/cognitive-dedup.js +38 -0
  94. package/dist/memory/pipeline/cognitive-extractor.d.ts +21 -0
  95. package/dist/memory/pipeline/cognitive-extractor.js +183 -0
  96. package/dist/memory/pipeline/contextual-focus-builder.d.ts +13 -0
  97. package/dist/memory/pipeline/contextual-focus-builder.js +135 -0
  98. package/dist/memory/pipeline/focus-direction-shift.d.ts +10 -0
  99. package/dist/memory/pipeline/focus-direction-shift.js +27 -0
  100. package/dist/memory/pipeline/graph-builder.d.ts +11 -0
  101. package/dist/memory/pipeline/graph-builder.js +88 -0
  102. package/dist/memory/pipeline/graph-recall.d.ts +13 -0
  103. package/dist/memory/pipeline/graph-recall.js +55 -0
  104. package/dist/memory/pipeline/identity-distiller.d.ts +15 -0
  105. package/dist/memory/pipeline/identity-distiller.js +40 -0
  106. package/dist/memory/pipeline/l1-contradiction.d.ts +7 -0
  107. package/dist/memory/pipeline/l1-contradiction.js +66 -0
  108. package/dist/memory/pipeline/l1-dedup.d.ts +23 -0
  109. package/dist/memory/pipeline/l1-dedup.js +39 -0
  110. package/dist/memory/pipeline/l1-extractor.d.ts +21 -0
  111. package/dist/memory/pipeline/l1-extractor.js +180 -0
  112. package/dist/memory/pipeline/l2-direction-shift.d.ts +10 -0
  113. package/dist/memory/pipeline/l2-direction-shift.js +27 -0
  114. package/dist/memory/pipeline/l2-scene.d.ts +15 -0
  115. package/dist/memory/pipeline/l2-scene.js +140 -0
  116. package/dist/memory/pipeline/l3-distiller.d.ts +15 -0
  117. package/dist/memory/pipeline/l3-distiller.js +40 -0
  118. package/dist/memory/pipeline/neural-spark.d.ts +27 -0
  119. package/dist/memory/pipeline/neural-spark.js +78 -0
  120. package/dist/memory/pipeline/skill-prewarm.d.ts +63 -0
  121. package/dist/memory/pipeline/skill-prewarm.js +127 -0
  122. package/dist/memory/pipeline/task-queue.d.ts +54 -0
  123. package/dist/memory/pipeline/task-queue.js +117 -0
  124. package/dist/memory/prompts/cognitive-contradiction.d.ts +1 -0
  125. package/dist/memory/prompts/cognitive-contradiction.js +25 -0
  126. package/dist/memory/prompts/cognitive-extraction.d.ts +10 -0
  127. package/dist/memory/prompts/cognitive-extraction.js +114 -0
  128. package/dist/memory/prompts/core-identity.d.ts +6 -0
  129. package/dist/memory/prompts/core-identity.js +60 -0
  130. package/dist/memory/prompts/focus-direction-shift.d.ts +5 -0
  131. package/dist/memory/prompts/focus-direction-shift.js +32 -0
  132. package/dist/memory/prompts/focus-scene-cluster.d.ts +2 -0
  133. package/dist/memory/prompts/focus-scene-cluster.js +33 -0
  134. package/dist/memory/prompts/focus-scene.d.ts +7 -0
  135. package/dist/memory/prompts/focus-scene.js +40 -0
  136. package/dist/memory/prompts/graph-extraction-batch.d.ts +14 -0
  137. package/dist/memory/prompts/graph-extraction-batch.js +54 -0
  138. package/dist/memory/prompts/graph-extraction.d.ts +2 -0
  139. package/dist/memory/prompts/graph-extraction.js +53 -0
  140. package/dist/memory/prompts/l1-contradiction-batch.d.ts +16 -0
  141. package/dist/memory/prompts/l1-contradiction-batch.js +47 -0
  142. package/dist/memory/prompts/l1-contradiction.d.ts +1 -0
  143. package/dist/memory/prompts/l1-contradiction.js +25 -0
  144. package/dist/memory/prompts/l1-extraction.d.ts +10 -0
  145. package/dist/memory/prompts/l1-extraction.js +114 -0
  146. package/dist/memory/prompts/l2-direction-shift.d.ts +5 -0
  147. package/dist/memory/prompts/l2-direction-shift.js +32 -0
  148. package/dist/memory/prompts/l2-scene-cluster.d.ts +2 -0
  149. package/dist/memory/prompts/l2-scene-cluster.js +33 -0
  150. package/dist/memory/prompts/l2-scene.d.ts +7 -0
  151. package/dist/memory/prompts/l2-scene.js +40 -0
  152. package/dist/memory/prompts/l3-persona.d.ts +6 -0
  153. package/dist/memory/prompts/l3-persona.js +60 -0
  154. package/dist/memory/recall.d.ts +47 -0
  155. package/dist/memory/recall.js +427 -0
  156. package/dist/memory/redaction.d.ts +1 -0
  157. package/dist/memory/redaction.js +24 -0
  158. package/dist/memory/retry.d.ts +13 -0
  159. package/dist/memory/retry.js +53 -0
  160. package/dist/memory/scheduler.d.ts +9 -0
  161. package/dist/memory/scheduler.js +16 -0
  162. package/dist/memory/skill-hints-loader.d.ts +30 -0
  163. package/dist/memory/skill-hints-loader.js +100 -0
  164. package/dist/memory/store/embedding.d.ts +16 -0
  165. package/dist/memory/store/embedding.js +68 -0
  166. package/dist/memory/store/reranker.d.ts +24 -0
  167. package/dist/memory/store/reranker.js +83 -0
  168. package/dist/memory/store/sqlite.d.ts +167 -0
  169. package/dist/memory/store/sqlite.js +1816 -0
  170. package/dist/memory/store/types.d.ts +101 -0
  171. package/dist/memory/store/types.js +1 -0
  172. package/dist/memory/types.d.ts +207 -0
  173. package/dist/memory/types.js +7 -0
  174. package/dist/memory/validation.d.ts +441 -0
  175. package/dist/memory/validation.js +129 -0
  176. package/dist/memory/working/canvas.d.ts +5 -0
  177. package/dist/memory/working/canvas.js +43 -0
  178. package/dist/memory/working/offload.d.ts +71 -0
  179. package/dist/memory/working/offload.js +211 -0
  180. package/dist/memory/working/step-log.d.ts +16 -0
  181. package/dist/memory/working/step-log.js +35 -0
  182. package/dist/registry.d.ts +34 -0
  183. package/dist/registry.js +305 -0
  184. package/dist/resolver.d.ts +17 -0
  185. package/dist/resolver.js +126 -0
  186. package/dist/scripts/validate-foreign-workspace-path.d.ts +1 -0
  187. package/dist/scripts/validate-foreign-workspace-path.js +39 -0
  188. package/dist/tools/agent_memory_tools.d.ts +485 -0
  189. package/dist/tools/agent_memory_tools.js +793 -0
  190. package/dist/tools/create_skill.d.ts +46 -0
  191. package/dist/tools/create_skill.js +46 -0
  192. package/dist/tools/get_doc.d.ts +21 -0
  193. package/dist/tools/get_doc.js +24 -0
  194. package/dist/tools/get_persona.d.ts +15 -0
  195. package/dist/tools/get_persona.js +20 -0
  196. package/dist/tools/get_reference.d.ts +15 -0
  197. package/dist/tools/get_reference.js +20 -0
  198. package/dist/tools/get_skill.d.ts +34 -0
  199. package/dist/tools/get_skill.js +65 -0
  200. package/dist/tools/get_template_doc.d.ts +21 -0
  201. package/dist/tools/get_template_doc.js +24 -0
  202. package/dist/tools/list_docs.d.ts +15 -0
  203. package/dist/tools/list_docs.js +16 -0
  204. package/dist/tools/list_skills.d.ts +18 -0
  205. package/dist/tools/list_skills.js +17 -0
  206. package/dist/tools/list_template_docs.d.ts +15 -0
  207. package/dist/tools/list_template_docs.js +16 -0
  208. package/dist/tools/memory-engineering.d.ts +225 -0
  209. package/dist/tools/memory-engineering.js +284 -0
  210. package/dist/tools/memory-explain.d.ts +34 -0
  211. package/dist/tools/memory-explain.js +109 -0
  212. package/dist/tools/memory-governance.d.ts +171 -0
  213. package/dist/tools/memory-governance.js +224 -0
  214. package/dist/tools/memory-hooks.d.ts +67 -0
  215. package/dist/tools/memory-hooks.js +102 -0
  216. package/dist/tools/memory-working.d.ts +98 -0
  217. package/dist/tools/memory-working.js +101 -0
  218. package/dist/tools/memory_capture_turn.d.ts +66 -0
  219. package/dist/tools/memory_capture_turn.js +85 -0
  220. package/dist/tools/memory_consolidate.d.ts +55 -0
  221. package/dist/tools/memory_consolidate.js +176 -0
  222. package/dist/tools/memory_contradictions.d.ts +53 -0
  223. package/dist/tools/memory_contradictions.js +52 -0
  224. package/dist/tools/memory_graph_query.d.ts +51 -0
  225. package/dist/tools/memory_graph_query.js +35 -0
  226. package/dist/tools/memory_mark_cited.d.ts +43 -0
  227. package/dist/tools/memory_mark_cited.js +63 -0
  228. package/dist/tools/memory_recall.d.ts +77 -0
  229. package/dist/tools/memory_recall.js +81 -0
  230. package/dist/tools/memory_register_skill_hints.d.ts +49 -0
  231. package/dist/tools/memory_register_skill_hints.js +55 -0
  232. package/dist/tools/memory_resolve_session.d.ts +24 -0
  233. package/dist/tools/memory_resolve_session.js +133 -0
  234. package/dist/tools/memory_search.d.ts +146 -0
  235. package/dist/tools/memory_search.js +84 -0
  236. package/dist/tools/search_skills.d.ts +18 -0
  237. package/dist/tools/search_skills.js +17 -0
  238. package/dist/tools/update_doc.d.ts +24 -0
  239. package/dist/tools/update_doc.js +35 -0
  240. package/dist/tools/update_skill.d.ts +30 -0
  241. package/dist/tools/update_skill.js +80 -0
  242. package/dist/types.d.ts +81 -0
  243. package/dist/types.js +4 -0
  244. package/dist/writer.d.ts +30 -0
  245. package/dist/writer.js +220 -0
  246. package/docs/TEMPLATE ONLY +1 -0
  247. package/docs/api/API.md +64 -0
  248. package/docs/api/security/SECURITY.md +58 -0
  249. package/docs/deployment/DockerDeployment.md +30 -0
  250. package/docs/design/Design.md +59 -0
  251. package/docs/design/themes/apple.md +101 -0
  252. package/docs/design/themes/dieter-grid.md +100 -0
  253. package/docs/design/themes/gallery-white.md +100 -0
  254. package/docs/design/themes/pinterest.md +101 -0
  255. package/docs/design/themes/realty-open-house.md +101 -0
  256. package/docs/design/themes/vodafone.md +101 -0
  257. package/docs/hooks/Hooks.md +30 -0
  258. package/docs/schema/Schema.md +35 -0
  259. package/docs/strategy/ScalingStrategy.md +19 -0
  260. package/package.json +88 -0
  261. package/references/accessibility-checklist.md +160 -0
  262. package/references/orchestration-patterns.md +370 -0
  263. package/references/performance-checklist.md +153 -0
  264. package/references/security-checklist.md +134 -0
  265. package/references/testing-patterns.md +236 -0
  266. package/skills/agent/adr-skill/SKILL.md +299 -0
  267. package/skills/agent/agentic-engineering-workflow/SKILL.md +95 -0
  268. package/skills/agent/bootstrap-skill/SKILL.md +103 -0
  269. package/skills/agent/context-engineering/SKILL.md +307 -0
  270. package/skills/agent/debugging-and-error-recovery/SKILL.md +308 -0
  271. package/skills/agent/developer-growth-analysis/SKILL.md +328 -0
  272. package/skills/agent/doubt-driven-skill/SKILL.md +249 -0
  273. package/skills/agent/handover-skill/SKILL.md +112 -0
  274. package/skills/agent/idea-refine-skill/SKILL.md +185 -0
  275. package/skills/agent/idea-refine-skill/examples.md +238 -0
  276. package/skills/agent/idea-refine-skill/frameworks.md +99 -0
  277. package/skills/agent/idea-refine-skill/refinement-criteria.md +113 -0
  278. package/skills/agent/interview-skill/SKILL.md +226 -0
  279. package/skills/agent/planning-skill/SKILL.md +270 -0
  280. package/skills/agent/skill-authoring/SKILL.md +189 -0
  281. package/skills/agent/source-driven-skill/SKILL.md +197 -0
  282. package/skills/agent/spec-driven-skill/SKILL.md +221 -0
  283. package/skills/agent/sync-skill/SKILL.md +92 -0
  284. package/skills/agent/using-agent-skills/SKILL.md +189 -0
  285. package/skills/api/a11y-skill/SKILL.md +88 -0
  286. package/skills/api/api-skill/SKILL.md +123 -0
  287. package/skills/api/auth-skill/SKILL.md +80 -0
  288. package/skills/api/debug-skill/SKILL.md +535 -0
  289. package/skills/api/performance-skill/SKILL.md +100 -0
  290. package/skills/api/testing-skill/SKILL.md +100 -0
  291. package/skills/codebase/code-review-and-quality/SKILL.md +228 -0
  292. package/skills/codebase/code-simplification/SKILL.md +352 -0
  293. package/skills/codebase/code-structure-cleanup/SKILL.md +142 -0
  294. package/skills/codebase/concerns-skill/SKILL.md +89 -0
  295. package/skills/codebase/conventions-skill/SKILL.md +95 -0
  296. package/skills/codebase/doc-management-skill/SKILL.md +47 -0
  297. package/skills/codebase/git-workflow-skill/SKILL.md +312 -0
  298. package/skills/communication/1-3-1-rule/SKILL.md +120 -0
  299. package/skills/design/brutalist-skill/SKILL.md +131 -0
  300. package/skills/design/concept-diagrams/SKILL.md +387 -0
  301. package/skills/design/concept-diagrams/examples/apartment-floor-plan-conversion.md +244 -0
  302. package/skills/design/concept-diagrams/examples/automated-password-reset-flow.md +276 -0
  303. package/skills/design/concept-diagrams/examples/autonomous-llm-research-agent-flow.md +240 -0
  304. package/skills/design/concept-diagrams/examples/banana-journey-tree-to-smoothie.md +161 -0
  305. package/skills/design/concept-diagrams/examples/commercial-aircraft-structure.md +209 -0
  306. package/skills/design/concept-diagrams/examples/cpu-ooo-microarchitecture.md +236 -0
  307. package/skills/design/concept-diagrams/examples/electricity-grid-flow.md +182 -0
  308. package/skills/design/concept-diagrams/examples/feature-film-production-pipeline.md +172 -0
  309. package/skills/design/concept-diagrams/examples/hospital-emergency-department-flow.md +165 -0
  310. package/skills/design/concept-diagrams/examples/ml-benchmark-grouped-bar-chart.md +114 -0
  311. package/skills/design/concept-diagrams/examples/place-order-uml-sequence.md +325 -0
  312. package/skills/design/concept-diagrams/examples/smart-city-infrastructure.md +173 -0
  313. package/skills/design/concept-diagrams/examples/smartphone-layer-anatomy.md +154 -0
  314. package/skills/design/concept-diagrams/examples/sn2-reaction-mechanism.md +247 -0
  315. package/skills/design/concept-diagrams/examples/wind-turbine-structure.md +338 -0
  316. package/skills/design/concept-diagrams/references/dashboard-patterns.md +43 -0
  317. package/skills/design/concept-diagrams/references/infrastructure-patterns.md +144 -0
  318. package/skills/design/concept-diagrams/references/physical-shape-cookbook.md +42 -0
  319. package/skills/design/concept-diagrams/templates/template.html +174 -0
  320. package/skills/design/gpt-tasteskill/SKILL.md +114 -0
  321. package/skills/design/minimalist-skill/SKILL.md +116 -0
  322. package/skills/design/output-skill/SKILL.md +87 -0
  323. package/skills/design/redesign-skill/SKILL.md +213 -0
  324. package/skills/design/soft-skill/SKILL.md +132 -0
  325. package/skills/design/stitch-skill/EXAMPLE.md +121 -0
  326. package/skills/design/stitch-skill/SKILL.md +222 -0
  327. package/skills/design/taste-skill/SKILL.md +269 -0
  328. package/skills/devops/ci-cd-skill/SKILL.md +402 -0
  329. package/skills/devops/docker-skill/SKILL.md +297 -0
  330. package/skills/devops/domain-skill/SKILL.md +234 -0
  331. package/skills/lifecycle/changelog-generator/SKILL.md +135 -0
  332. package/skills/lifecycle/incremental-skill/SKILL.md +257 -0
  333. package/skills/lifecycle/migration-skill/SKILL.md +218 -0
  334. package/skills/lifecycle/shipping-skill/SKILL.md +321 -0
  335. package/skills/memory/agent-memory/SKILL.md +122 -0
  336. package/skills/qa/browser-testing-skill/SKILL.md +314 -0
  337. package/skills/ux/adversarial-ux-skill/SKILL.md +168 -0
@@ -0,0 +1,142 @@
1
+ ---
2
+ name: code-structure-cleanup
3
+ description: Guides a service-layer extraction pass after an AI-built feature ships. Use when feature code works but contains duplicated mechanics, repeated API calls, or copy-pasted logic across multiple callers. Use when deciding what belongs in shared services vs. domain-specific actions.
4
+ hints: |
5
+ - Run cleanup AFTER the feature works, never during feature development.
6
+ - Extract only logic repeated across 2+ callers — never abstract singletons.
7
+ - Keep domain rules (auth, error classification, status transitions) in actions.
8
+ - Replace one caller first, verify, then migrate the rest.
9
+ - Keep the diff small and focused on the feature area only.
10
+ ---
11
+
12
+ # Code Structure Cleanup & Service Layer Architecture
13
+
14
+ ## Overview
15
+
16
+ AI agents often take the easiest path: they create new functions instead of reusing existing ones. A feature can work while still leaving behind duplicated logic, inconsistent validation, and repeated API calls that future agents will struggle to debug.
17
+
18
+ The fix is a two-layer architecture: **actions orchestrate domain rules** (the "why/when"), while a **service layer centralizes reusable mechanics** (the "how"). Run the cleanup pass after the feature works — not before, and not during.
19
+
20
+ ## When to Use
21
+
22
+ - A feature works but the code has duplicated mechanics across multiple files.
23
+ - Multiple callers perform the same low-level operation (email sending, sandbox creation, API calls, data parsing).
24
+ - The agent created similar helper functions in different files.
25
+ - A bug fix in one flow was not propagated to other flows doing the same thing.
26
+
27
+ **When NOT to use:** Logic used by only one caller — extracting it is over-abstraction. Do not use this as permission to redesign the whole app.
28
+
29
+ ## The Service Layer Pattern
30
+
31
+ ```
32
+ Orchestration Layer (Actions) Service Layer (Shared Mechanics)
33
+ ├── owns business rules ├── owns reusable operations
34
+ ├── owns state transitions ├── owns provider/SDK interactions
35
+ ├── owns auth/ownership checks ├── owns command execution details
36
+ ├── owns failure classification ├── owns health checks / readiness
37
+ ├── owns retries / user-facing errors └── returns structured results
38
+ └── calls service functions
39
+ ```
40
+
41
+ **Decision rule:**
42
+ - "What this product flow means" → keep in actions
43
+ - "How to do this operation reliably" → move to service layer
44
+
45
+ ### Designing Service Functions
46
+
47
+ Design as **capability blocks**, not monoliths. Each function should:
48
+ - Accept all required data as **explicit parameters** (no hidden global state)
49
+ - Return **structured outputs** — e.g., `{ ready, previewUrl, proxyPort }`
50
+ - Never reach into the database or domain state directly
51
+ - Make failure explicit (structured results, not swallowed errors)
52
+
53
+ ```ts
54
+ // Good: composable blocks — each caller picks what it needs
55
+ createManagedSandbox(...)
56
+ prepareRepo(...)
57
+ detectPackageManager(...)
58
+ installDependencies(...)
59
+ runBuildCommand(...)
60
+
61
+ // Bad: one god function that hides all control flow
62
+ doEverythingForSandbox(...)
63
+ ```
64
+
65
+ ## Cleanup Process
66
+
67
+ ### Step 1: Run the Cleanup Prompt
68
+
69
+ ```md
70
+ The feature is working. Now do a code-structure cleanup pass.
71
+
72
+ Goal:
73
+ - Find duplicated runtime mechanics, repeated API calls, repeated parsing, repeated validation.
74
+ - Move repeated mechanics into reusable service-layer functions/modules.
75
+ - Keep domain policy (auth, status transitions, error classification) in the calling route/action.
76
+ - Do not change user-facing behavior.
77
+ - Keep the diff small.
78
+
79
+ Process:
80
+ 1. Inspect the files touched by the feature.
81
+ 2. Identify repeated logic and name the duplication clearly.
82
+ 3. Propose the smallest service-layer extraction.
83
+ 4. Implement it.
84
+ 5. Run the relevant tests/typechecks.
85
+ 6. Summarize exactly what got simpler.
86
+ ```
87
+
88
+ ### Step 2: Migrate Incrementally
89
+
90
+ 1. Write the flow in action code first — establish clear behavior.
91
+ 2. Mark repeated operational chunks across callers.
92
+ 3. Extract **only** repeated, non-domain chunks to a service function.
93
+ 4. Replace **one caller first** → verify tests pass → replace remaining callers.
94
+ 5. Run typecheck, lint, and confirm all flows still work.
95
+
96
+ ### Example: Email Service
97
+
98
+ ```ts
99
+ // emailService.ts — shared mechanics (the "how")
100
+ export async function sendWelcomeEmail(params: { to: string; name: string }) {
101
+ const html = `<h1>Welcome ${params.name}</h1>`;
102
+ await emailProvider.send(params.to, "Welcome", html);
103
+ }
104
+
105
+ // userSignup.ts — orchestration (the "when" — different business rule)
106
+ if (user.marketingOptIn) {
107
+ await sendWelcomeEmail({ to: user.email, name: user.name });
108
+ }
109
+
110
+ // adminInvite.ts — orchestration (same mechanic, different domain rule)
111
+ await sendWelcomeEmail({ to: invitee.email, name: invitee.name });
112
+ ```
113
+
114
+ ## Common Rationalizations
115
+
116
+ | Rationalization | Reality |
117
+ |---|---|
118
+ | "I'll clean it up later" | Later never comes. AI agents copy existing patterns — duplicated code compounds with every new feature. |
119
+ | "It's only in two places" | Two callers is exactly when to extract. Three callers means the window for clean extraction is closing. |
120
+ | "Cleanup will change behavior" | It should not. Behavior-changing cleanup is a bug fix or refactor — do it separately. |
121
+ | "I'll just refactor the whole module while I'm here" | Unscoped cleanup creates risky diffs and noisy PRs. Stay focused on the feature area. |
122
+ | "The service should handle business logic too" | Services own mechanics, not decisions. Auth, error classification, and policy stay in actions. |
123
+
124
+ ## Red Flags
125
+
126
+ - A bug fix applied in one flow was not applied to other flows doing the same thing.
127
+ - Helper functions with the same logic scattered across action files.
128
+ - Service functions that directly mutate database tables or domain state.
129
+ - A single "do-everything" service function hiding all control flow.
130
+ - Cleanup and feature development mixed in the same PR.
131
+ - Extracting logic used by only one caller (premature abstraction).
132
+
133
+ ## Verification
134
+
135
+ After completing the cleanup pass, confirm:
136
+
137
+ - [ ] User-facing behavior is unchanged (existing tests still pass).
138
+ - [ ] Duplicated mechanics were reduced — callers now share the extracted function.
139
+ - [ ] Calling files became simpler, not more complex.
140
+ - [ ] Domain policy (auth, transitions, error classification) remained in actions.
141
+ - [ ] Typecheck and lint passed.
142
+ - [ ] Diff is focused on the feature area — no unrelated changes mixed in.
@@ -0,0 +1,89 @@
1
+ ---
2
+ name: concerns-skill
3
+ description: Framework for surfacing and tracking tech debt, known bugs, and security gaps in software codebases.
4
+ hints:
5
+ - Check openSrc/ or docs for existing tech debt registers and known bugs if available.
6
+ - Formulate codebase concern reports with specific file paths, line numbers, and factual impact.
7
+ - Avoid emotional adjectives; use precise engineering terms (e.g. N+1 queries, race conditions).
8
+ - Provide a clear, actionable fix or mitigation approach for every logged concern.
9
+ - Update or remove concern entries immediately upon resolution.
10
+ ---
11
+
12
+ # Codebase Concerns Skill
13
+
14
+ ## Overview
15
+
16
+ This skill governs how known risks, tech debt, and codebase health issues are surfaced and maintained. Load this before making changes to high-risk areas, during phase planning, or when onboarding a new agent context.
17
+
18
+ ## Workflow
19
+
20
+ - **[CONCERN-001] Always Check Before Changing**
21
+ - Before modifying a flagged area, read its concern entry to understand risk, workarounds, and safe modification paths.
22
+ - If no concern entry exists for an area you're about to change, check for fragility signals (complex chains, missing tests, shared mutable state).
23
+
24
+ - **[CONCERN-002] Concern Entry Format**
25
+ - Every concern must include: area/component, issue description, why it exists, impact, and fix approach.
26
+ - Always include **file paths** — concerns without locations are not actionable.
27
+ - Use specific measurements for performance issues (`500ms p95`, not "slow").
28
+ - Include reproduction steps for bugs.
29
+
30
+ - **[CONCERN-003] Categories**
31
+ - **Tech Debt**: Shortcuts with known impact and a fix path.
32
+ - **Known Bugs**: Reproducible defects with symptoms, trigger, and workaround.
33
+ - **Security Considerations**: Risks with current mitigation and recommendations.
34
+ - **Performance Bottlenecks**: Measured slow paths with root cause and improvement plan.
35
+ - **Fragile Areas**: Components that break easily — document safe modification steps.
36
+ - **Scaling Limits**: Capacity numbers and what happens at the limit.
37
+ - **Dependencies at Risk**: Deprecated, unmaintained, or breaking-change packages.
38
+ - **Test Coverage Gaps**: Untested paths and the risk they carry.
39
+
40
+ - **[CONCERN-004] Tone & Accuracy**
41
+ - Professional, not emotional (`"N+1 query pattern"` not `"terrible queries"`)
42
+ - Solution-oriented — always suggest a fix approach, not just a problem
43
+ - Factual — use real numbers, not vague qualifiers
44
+ - No opinions without evidence; no complaints without solutions
45
+
46
+ - **[CONCERN-005] Maintenance**
47
+ - Mark concerns as resolved when the underlying issue is fixed.
48
+ - Add new concerns as they are discovered — during audits, debugging, or code review.
49
+ - Include the analysis date on each update.
50
+ - This is a living document, not a complaint list.
51
+
52
+ ## When to Load This Skill
53
+
54
+ | Scenario | Action |
55
+ |---|---|
56
+ | About to change auth, middleware, or DB layer | Read **Fragile Areas** and **Security Considerations** |
57
+ | Planning a new feature phase | Read **Tech Debt** and **Scaling Limits** |
58
+ | Debugging an unexpected failure | Read **Known Bugs** |
59
+ | Writing or reviewing tests | Read **Test Coverage Gaps** |
60
+ | Evaluating dependencies | Read **Dependencies at Risk** |
61
+
62
+ ## Required Checks
63
+
64
+ - [ ] Concern entry has a file path — no location-less concerns.
65
+ - [ ] Performance numbers are actual measurements, not estimates.
66
+ - [ ] Bugs include a reproduction trigger.
67
+ - [ ] Resolved concerns are removed or marked fixed with a date.
68
+ - [ ] New concerns added after any audit or incident.
69
+
70
+ ## When to Use
71
+ - Use when preparing to work on existing codebases, planning refactoring phases, or onboarding onto unfamiliar directories.
72
+ - NOT for styling changes or single-file variable renames unless they are part of a larger architectural risk.
73
+
74
+ ## Common Rationalizations
75
+ | Rationalization | Reality |
76
+ |---|---|
77
+ | I don't have time to catalog debt. | Logging debt takes 2 minutes and prevents the next developer from breaking the system. |
78
+ | It's just a temporary hack, no need to log it. | Temporary hacks frequently become permanent; documenting them prevents future blindspots. |
79
+
80
+ ## Red Flags
81
+ - Technical debt or security gaps left unrecorded in codebase documentation.
82
+ - Vague reports like "the DB is slow" without specific query profiles, execution times, or metric traces.
83
+ - Modifying fragile codebase components without checking existing concern registers or tech debt lists first.
84
+
85
+ ## Verification
86
+ After completing the skill, confirm:
87
+ - [ ] All newly identified concerns are logged with precise file paths, triggers, and suggested fix paths.
88
+ - [ ] Any resolved concerns are updated in the tracking documents.
89
+ - [ ] Tone of logged issues is kept entirely factual, metric-driven, and constructive.
@@ -0,0 +1,95 @@
1
+ ---
2
+ name: conventions-skill
3
+ description: Naming patterns, formatting rules, import order, and module design standards for modern software codebases.
4
+ hints:
5
+ - Inspect project root configuration files (e.g. .prettierrc, eslint.config.js) to align with existing styling tools.
6
+ - Check openSrc/ or existing project files for naming patterns and module architecture styles.
7
+ - Follow kebab-case for system files and PascalCase for UI components (e.g. React components).
8
+ - Keep functions focused and under 50 lines; extract complex logic into small, reusable helpers.
9
+ - Eliminate console.log statements before committing, substituting appropriate logging utilities.
10
+ ---
11
+
12
+ # Coding Conventions Skill
13
+
14
+ ## Overview
15
+
16
+ This skill ensures all new code written in the codebase matches existing style and patterns. Load this before writing new files, adding features, or conducting code reviews.
17
+
18
+ ## Workflow
19
+
20
+ - **[CONV-001] Naming**
21
+ - Files: `kebab-case` for all files (`user-service.ts`, `location-controller.ts`)
22
+ - React components: `PascalCase.tsx` (`SpotCard.tsx`, `AuthGuard.tsx`)
23
+ - Functions & variables: `camelCase`
24
+ - Constants: `UPPER_SNAKE_CASE`
25
+ - Types & Interfaces: `PascalCase`, no `I` prefix (`User`, not `IUser`)
26
+ - Event handlers: `handleEventName` pattern (`handleSubmit`, `handleDelete`)
27
+
28
+ - **[CONV-002] Code Style**
29
+ - Formatter: Prettier (check `.prettierrc`)
30
+ - Linter: ESLint (check `eslint.config.js`)
31
+ - Quotes: single quotes for strings
32
+ - Semicolons: required
33
+ - Line length: 100 characters max
34
+ - Indentation: 2 spaces
35
+ - No `console.log` in committed code — use the project logger
36
+
37
+ - **[CONV-003] Import Order**
38
+ 1. External packages (`react`, `express`, `zod`)
39
+ 2. Internal modules (`@/lib`, `@/services`, `@/components`)
40
+ 3. Relative imports (`./utils`, `../types`)
41
+ 4. Type imports (`import type {}`) — always last
42
+ - Blank line between each group; alphabetical within groups
43
+
44
+ - **[CONV-004] Error Handling**
45
+ - Throw errors, catch at route/boundary level — not deep in utilities
46
+ - Custom errors extend `Error` class, named `*Error` (`ValidationError`, `NotFoundError`)
47
+ - Async functions use `try/catch` — no `.catch()` chains
48
+ - Always log error context before re-throwing
49
+
50
+ - **[CONV-005] Function Design**
51
+ - Keep functions under 50 lines; extract helpers for complex logic
52
+ - Max 3 parameters — use an options object for 4+
53
+ - Destructure object parameters in the signature: `function fn({ id, name }: Params)`
54
+ - Use explicit `return` statements; return early for guard clauses
55
+
56
+ - **[CONV-006] Module Design**
57
+ - Named exports preferred; default exports only for React components
58
+ - Barrel files (`index.ts`) re-export the public API only
59
+ - Do not export internal helpers from barrel files
60
+ - Avoid circular dependencies — import from specific files if needed
61
+
62
+ - **[CONV-007] Comments**
63
+ - Explain *why*, not *what*
64
+ - Document business rules and non-obvious algorithms
65
+ - JSDoc required for public API functions (`@param`, `@returns`, `@throws`)
66
+ - TODOs: `// TODO: description` — link to issue number if available
67
+
68
+ ## Required Checks
69
+
70
+ - [ ] File and function names match `CONV-001` patterns.
71
+ - [ ] No `console.log` left in committed code.
72
+ - [ ] Imports are ordered and grouped per `CONV-003`.
73
+ - [ ] All async code uses `try/catch`.
74
+ - [ ] Functions stay under 50 lines.
75
+
76
+ ## When to Use
77
+ - Use when creating new modules, adding endpoints, writing frontend components, or conducting local codebase cleanups and refactoring.
78
+ - NOT for simple documentation-only changes or config modifications.
79
+
80
+ ## Common Rationalizations
81
+ | Rationalization | Reality |
82
+ |---|---|
83
+ | I'll format the code manually later. | Automated formatting ensures clean git diffs and prevents formatting noise. |
84
+ | It's just a single console.log for quick debugging. | Forgotten debug logs clutter runtime output in production and create noise. |
85
+
86
+ ## Red Flags
87
+ - Committing code with generic `console.log` statements instead of proper logging mechanisms.
88
+ - Functions exceeding 50-60 lines without being split into cohesive helpers.
89
+ - Inconsistent file naming conventions (e.g. mixing `camelCase` and `kebab-case` filenames in the same folder).
90
+
91
+ ## Verification
92
+ After completing the skill, confirm:
93
+ - [ ] Prettier/ESLint rules have been run and all styling warnings are cleared.
94
+ - [ ] All imported modules are ordered according to standard grouping.
95
+ - [ ] Functions are short, clean, well-scoped, and documented where necessary.
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: doc-management-skill
3
+ description: Guidelines for reading living project documentation using MCP tools.
4
+ hints:
5
+ - Query project-level documentation using list_template_docs and get_template_doc to discover existing specifications.
6
+ - Utilize specific section parameters in get_template_doc to read target content efficiently.
7
+ - Load reference guidelines (e.g. security-checklist, testing-patterns) using get_reference to respect engineering checklists.
8
+ - Restrict actions to read-only when interacting with documentation via MCP to avoid modifying architectural blueprints.
9
+ - Fall back to checking openSrc/ or standard project directories (e.g., docs/, doc/) if MCP tools are not available.
10
+ ---
11
+
12
+ # Doc Management Skill
13
+
14
+ ## Overview
15
+ This skill defines the workflow for interacting with project documentation. The Global BrainRouter `docs/` folder contains universal templates. However, the actual living documentation for a user's project resides strictly in their **local project's** `docs/` directory. The MCP tools (`list_template_docs` and `get_template_doc`) only load the local project documents. Documentation via MCP is entirely read-only to prevent unexpected modifications to the user's local architectural blueprints or the server's templates.
16
+
17
+ ## When to Use
18
+ Use this skill whenever you need to understand existing architectural decisions, read API endpoint specifications, check database schemas, load persistent project context from the living documentation, or consult project reference checklists/patterns.
19
+
20
+ ## Workflow
21
+
22
+ 1. **Discover Docs**: Run `list_template_docs` to see the current living documents available for the local project.
23
+ 2. **Read Docs**: Run `get_template_doc` to read existing documentation sections to gain important context before working on tasks.
24
+ 3. **Read References**: Run `get_reference` to load specific checklists and patterns (e.g., `security-checklist`, `accessibility-checklist`, `orchestration-patterns`) from the `references/` directory.
25
+
26
+ ## Usage
27
+
28
+ When you are asked to read documentation or reference constraints for the current project:
29
+ 1. Always prioritize using the MCP tools (`list_template_docs`, `get_template_doc`, `get_reference`) to locate and load information.
30
+ - `get_template_doc` expects the doc name (e.g. `api`, `design`, `schema`, `hooks`, `strategy`, `deployment`).
31
+ - Use the `section` parameter with `get_template_doc` to target specific headings for larger documents.
32
+ - `get_reference` expects the name of the reference file without extension (e.g., `security-checklist`, `testing-patterns`).
33
+ 2. Do not attempt to update or create documents via standard file writes or non-existent MCP tools.
34
+
35
+ ## Common Rationalizations
36
+
37
+ | Rationalization | Reality |
38
+ |---|---|
39
+ | "I'll just try to use a generic write tool to create docs/API.md" | Modifying or creating docs is intentionally restricted in the MCP context. Read only. |
40
+
41
+ ## Red Flags
42
+ - Attempting to edit docs instead of reading them.
43
+ - Assuming you can update the docs based on outdated context.
44
+
45
+ ## Verification
46
+ - [ ] Did you properly locate the needed documentation using `list_template_docs`?
47
+ - [ ] Did you read the existing documentation section using `get_template_doc` to gain context?
@@ -0,0 +1,312 @@
1
+ ---
2
+ name: git-workflow-skill
3
+ description: Structures git workflow practices. Use when making any code change. Use when committing, branching, resolving conflicts, or when you need to organize work across multiple parallel streams.
4
+ hints:
5
+ - Formulate small, atomic commits addressing single logical changes (typically under 100 lines).
6
+ - Use conventional commit formats (feat:, fix:, refactor:, test:) explaining the "why" instead of the "what".
7
+ - Inspect stages using git diff --staged to review and purge accidentally staged secrets or temporary comments.
8
+ - Separate formatting or styling adjustments from behavioral logic updates in distinct commits.
9
+ - Utilize short-lived feature branches, avoiding long-lived branches that diverge from the main branch.
10
+ ---
11
+
12
+ # Git Workflow and Versioning
13
+
14
+ ## Overview
15
+
16
+ Git is your safety net. Treat commits as save points, branches as sandboxes, and history as documentation. With AI agents generating code at high speed, disciplined version control is the mechanism that keeps changes manageable, reviewable, and reversible.
17
+
18
+ ## When to Use
19
+
20
+ Always. Every code change flows through git.
21
+
22
+ ## Workflow
23
+
24
+ ### Trunk-Based Development (Recommended)
25
+
26
+ Keep `main` always deployable. Work in short-lived feature branches that merge back within 1-3 days. Long-lived development branches are hidden costs — they diverge, create merge conflicts, and delay integration. DORA research consistently shows trunk-based development correlates with high-performing engineering teams.
27
+
28
+ ```
29
+ main ──●──●──●──●──●──●──●──●──●── (always deployable)
30
+ ╲ ╱ ╲ ╱
31
+ ●──●─╱ ●──╱ ← short-lived feature branches (1-3 days)
32
+ ```
33
+
34
+ This is the recommended default. Teams using gitflow or long-lived branches can adapt the principles (atomic commits, small changes, descriptive messages) to their branching model — the commit discipline matters more than the specific branching strategy.
35
+
36
+ - **Dev branches are costs.** Every day a branch lives, it accumulates merge risk.
37
+ - **Release branches are acceptable.** When you need to stabilize a release while main moves forward.
38
+ - **Feature flags > long branches.** Prefer deploying incomplete work behind flags rather than keeping it on a branch for weeks.
39
+
40
+ ### 1. Commit Early, Commit Often
41
+
42
+ Each successful increment gets its own commit. Don't accumulate large uncommitted changes.
43
+
44
+ ```
45
+ Work pattern:
46
+ Implement slice → Test → Verify → Commit → Next slice
47
+
48
+ Not this:
49
+ Implement everything → Hope it works → Giant commit
50
+ ```
51
+
52
+ Commits are save points. If the next change breaks something, you can revert to the last known-good state instantly.
53
+
54
+ ### 2. Atomic Commits
55
+
56
+ Each commit does one logical thing:
57
+
58
+ ```
59
+ # Good: Each commit is self-contained
60
+ git log --oneline
61
+ a1b2c3d Add task creation endpoint with validation
62
+ d4e5f6g Add task creation form component
63
+ h7i8j9k Connect form to API and add loading state
64
+ m1n2o3p Add task creation tests (unit + integration)
65
+
66
+ # Bad: Everything mixed together
67
+ git log --oneline
68
+ x1y2z3a Add task feature, fix sidebar, update deps, refactor utils
69
+ ```
70
+
71
+ ### 3. Descriptive Messages
72
+
73
+ Commit messages explain the *why*, not just the *what*:
74
+
75
+ ```
76
+ # Good: Explains intent
77
+ feat: add email validation to registration endpoint
78
+
79
+ Prevents invalid email formats from reaching the database.
80
+ Uses Zod schema validation at the route handler level,
81
+ consistent with existing validation patterns in auth.ts.
82
+
83
+ # Bad: Describes what's obvious from the diff
84
+ update auth.ts
85
+ ```
86
+
87
+ **Format:**
88
+ ```
89
+ <type>: <short description>
90
+
91
+ <optional body explaining why, not what>
92
+ ```
93
+
94
+ **Types:**
95
+ - `feat` — New feature
96
+ - `fix` — Bug fix
97
+ - `refactor` — Code change that neither fixes a bug nor adds a feature
98
+ - `test` — Adding or updating tests
99
+ - `docs` — Documentation only
100
+ - `chore` — Tooling, dependencies, config
101
+
102
+ ### 4. Keep Concerns Separate
103
+
104
+ Don't combine formatting changes with behavior changes. Don't combine refactors with features. Each type of change should be a separate commit — and ideally a separate PR:
105
+
106
+ ```
107
+ # Good: Separate concerns
108
+ git commit -m "refactor: extract validation logic to shared utility"
109
+ git commit -m "feat: add phone number validation to registration"
110
+
111
+ # Bad: Mixed concerns
112
+ git commit -m "refactor validation and add phone number field"
113
+ ```
114
+
115
+ **Separate refactoring from feature work.** A refactoring change and a feature change are two different changes — submit them separately. This makes each change easier to review, revert, and understand in history. Small cleanups (renaming a variable) can be included in a feature commit at reviewer discretion.
116
+
117
+ ### 5. Size Your Changes
118
+
119
+ Target ~100 lines per commit/PR. Changes over ~1000 lines should be split. See the splitting strategies in `code-review-and-quality` for how to break down large changes.
120
+
121
+ ```
122
+ ~100 lines → Easy to review, easy to revert
123
+ ~300 lines → Acceptable for a single logical change
124
+ ~1000 lines → Split into smaller changes
125
+ ```
126
+
127
+ ## Branching Strategy
128
+
129
+ ### Feature Branches
130
+
131
+ ```
132
+ main (always deployable)
133
+
134
+ ├── feature/task-creation ← One feature per branch
135
+ ├── feature/user-settings ← Parallel work
136
+ └── fix/duplicate-tasks ← Bug fixes
137
+ ```
138
+
139
+ - Branch from `main` (or the team's default branch)
140
+ - Keep branches short-lived (merge within 1-3 days) — long-lived branches are hidden costs
141
+ - Delete branches after merge
142
+ - Prefer feature flags over long-lived branches for incomplete features
143
+
144
+ ### Branch Naming
145
+
146
+ ```
147
+ feature/<short-description> → feature/task-creation
148
+ fix/<short-description> → fix/duplicate-tasks
149
+ chore/<short-description> → chore/update-deps
150
+ refactor/<short-description> → refactor/auth-module
151
+ ```
152
+
153
+ ## Working with Worktrees
154
+
155
+ For parallel AI agent work, use git worktrees to run multiple branches simultaneously:
156
+
157
+ ```bash
158
+ # Create a worktree for a feature branch
159
+ git worktree add ../project-feature-a feature/task-creation
160
+ git worktree add ../project-feature-b feature/user-settings
161
+
162
+ # Each worktree is a separate directory with its own branch
163
+ # Agents can work in parallel without interfering
164
+ ls ../
165
+ project/ ← main branch
166
+ project-feature-a/ ← task-creation branch
167
+ project-feature-b/ ← user-settings branch
168
+
169
+ # When done, merge and clean up
170
+ git worktree remove ../project-feature-a
171
+ ```
172
+
173
+ Benefits:
174
+ - Multiple agents can work on different features simultaneously
175
+ - No branch switching needed (each directory has its own branch)
176
+ - If one experiment fails, delete the worktree — nothing is lost
177
+ - Changes are isolated until explicitly merged
178
+
179
+ ## The Save Point Pattern
180
+
181
+ ```
182
+ Agent starts work
183
+
184
+ ├── Makes a change
185
+ │ ├── Test passes? → Commit → Continue
186
+ │ └── Test fails? → Revert to last commit → Investigate
187
+
188
+ ├── Makes another change
189
+ │ ├── Test passes? → Commit → Continue
190
+ │ └── Test fails? → Revert to last commit → Investigate
191
+
192
+ └── Feature complete → All commits form a clean history
193
+ ```
194
+
195
+ This pattern means you never lose more than one increment of work. If an agent goes off the rails, `git reset --hard HEAD` takes you back to the last successful state.
196
+
197
+ ## Change Summaries
198
+
199
+ After any modification, provide a structured summary. This makes review easier, documents scope discipline, and surfaces unintended changes:
200
+
201
+ ```
202
+ CHANGES MADE:
203
+ - src/routes/tasks.ts: Added validation middleware to POST endpoint
204
+ - src/lib/validation.ts: Added TaskCreateSchema using Zod
205
+
206
+ THINGS I DIDN'T TOUCH (intentionally):
207
+ - src/routes/auth.ts: Has similar validation gap but out of scope
208
+ - src/middleware/error.ts: Error format could be improved (separate task)
209
+
210
+ POTENTIAL CONCERNS:
211
+ - The Zod schema is strict — rejects extra fields. Confirm this is desired.
212
+ - Added zod as a dependency (72KB gzipped) — already in package.json
213
+ ```
214
+
215
+ This pattern catches wrong assumptions early and gives reviewers a clear map of the change. The "DIDN'T TOUCH" section is especially important — it shows you exercised scope discipline and didn't go on an unsolicited renovation.
216
+
217
+ ## Pre-Commit Hygiene
218
+
219
+ Before every commit:
220
+
221
+ ```bash
222
+ # 1. Check what you're about to commit
223
+ git diff --staged
224
+
225
+ # 2. Ensure no secrets
226
+ git diff --staged | grep -i "password\|secret\|api_key\|token"
227
+
228
+ # 3. Run tests
229
+ npm test
230
+
231
+ # 4. Run linting
232
+ npm run lint
233
+
234
+ # 5. Run type checking
235
+ npx tsc --noEmit
236
+ ```
237
+
238
+ Automate this with git hooks:
239
+
240
+ ```json
241
+ // package.json (using lint-staged + husky)
242
+ {
243
+ "lint-staged": {
244
+ "*.{ts,tsx}": ["eslint --fix", "prettier --write"],
245
+ "*.{json,md}": ["prettier --write"]
246
+ }
247
+ }
248
+ ```
249
+
250
+ ## Handling Generated Files
251
+
252
+ - **Commit generated files** only if the project expects them (e.g., `package-lock.json`, Prisma migrations)
253
+ - **Don't commit** build output (`dist/`, `.next/`), environment files (`.env`), or IDE config (`.vscode/settings.json` unless shared)
254
+ - **Have a `.gitignore`** that covers: `node_modules/`, `dist/`, `.env`, `.env.local`, `*.pem`
255
+
256
+ ## Using Git for Debugging
257
+
258
+ ```bash
259
+ # Find which commit introduced a bug
260
+ git bisect start
261
+ git bisect bad HEAD
262
+ git bisect good <known-good-commit>
263
+ # Git checkouts midpoints; run your test at each to narrow down
264
+
265
+ # View what changed recently
266
+ git log --oneline -20
267
+ git diff HEAD~5..HEAD -- src/
268
+
269
+ # Find who last changed a specific line
270
+ git blame src/services/task.ts
271
+
272
+ # Search commit messages for a keyword
273
+ git log --grep="validation" --oneline
274
+ ```
275
+
276
+ ## Common Rationalizations
277
+
278
+ | Rationalization | Reality |
279
+ |---|---|
280
+ | "I'll commit when the feature is done" | One giant commit is impossible to review, debug, or revert. Commit each slice. |
281
+ | "The message doesn't matter" | Messages are documentation. Future you (and future agents) will need to understand what changed and why. |
282
+ | "I'll squash it all later" | Squashing destroys the development narrative. Prefer clean incremental commits from the start. |
283
+ | "Branches add overhead" | Short-lived branches are free and prevent conflicting work from colliding. Long-lived branches are the problem — merge within 1-3 days. |
284
+ | "I'll split this change later" | Large changes are harder to review, riskier to deploy, and harder to revert. Split before submitting, not after. |
285
+ | "I don't need a .gitignore" | Until `.env` with production secrets gets committed. Set it up immediately. |
286
+
287
+ ## Red Flags
288
+
289
+ - Large uncommitted changes accumulating
290
+ - Commit messages like "fix", "update", "misc"
291
+ - Formatting changes mixed with behavior changes
292
+ - No `.gitignore` in the project
293
+ - Committing `node_modules/`, `.env`, or build artifacts
294
+ - Long-lived branches that diverge significantly from main
295
+ - Force-pushing to shared branches
296
+
297
+ ## Required Checks
298
+
299
+ For every commit:
300
+
301
+ - [ ] Commit does one logical thing
302
+ - [ ] Message explains the why, follows type conventions
303
+ - [ ] Tests pass before committing
304
+ - [ ] No secrets in the diff
305
+ - [ ] No formatting-only changes mixed with behavior changes
306
+ - [ ] `.gitignore` covers standard exclusions
307
+
308
+ ## Verification
309
+ After completing the skill, confirm:
310
+ - [ ] All staged files are reviewed with `git diff --staged` to confirm formatting is separated from behavior changes.
311
+ - [ ] Commit message is conventional, descriptive, and accurately conveys the "why".
312
+ - [ ] Clean working directory achieved and test passes before pushing.