contextos-agents 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (310) hide show
  1. package/.agents/AGENTS.md +421 -0
  2. package/.agents/adapters/aider/export.js +137 -0
  3. package/.agents/adapters/claude/export.js +55 -0
  4. package/.agents/adapters/copilot/export.js +107 -0
  5. package/.agents/adapters/cursor/export.js +210 -0
  6. package/.agents/adapters/gemini/export.js +115 -0
  7. package/.agents/adapters/shared.js +119 -0
  8. package/.agents/adapters/zed/export.js +111 -0
  9. package/.agents/core/profiles/backend.yaml +47 -0
  10. package/.agents/core/profiles/enterprise.yaml +46 -0
  11. package/.agents/core/profiles/frontend.yaml +46 -0
  12. package/.agents/core/profiles/hackathon.yaml +45 -0
  13. package/.agents/core/profiles/mvp.yaml +43 -0
  14. package/.agents/core/profiles/startup.yaml +48 -0
  15. package/.agents/core/skills/adapters/EXAMPLES.md +19 -0
  16. package/.agents/core/skills/adapters/SKILL.md +105 -0
  17. package/.agents/core/skills/adapters/TROUBLESHOOTING.md +7 -0
  18. package/.agents/core/skills/adapters/VALIDATION.json +12 -0
  19. package/.agents/core/skills/adapters/skill.yaml +10 -0
  20. package/.agents/core/skills/architecture-diagrams/SKILL.md +108 -0
  21. package/.agents/core/skills/architecture-diagrams/VALIDATION.json +12 -0
  22. package/.agents/core/skills/architecture-diagrams/skill.yaml +8 -0
  23. package/.agents/core/skills/brutalist-design/SKILL.md +150 -0
  24. package/.agents/core/skills/brutalist-design/VALIDATION.json +12 -0
  25. package/.agents/core/skills/brutalist-design/skill.yaml +8 -0
  26. package/.agents/core/skills/context-manager/EXAMPLES.md +19 -0
  27. package/.agents/core/skills/context-manager/SKILL.md +126 -0
  28. package/.agents/core/skills/context-manager/TROUBLESHOOTING.md +7 -0
  29. package/.agents/core/skills/context-manager/VALIDATION.json +12 -0
  30. package/.agents/core/skills/context-manager/skill.yaml +10 -0
  31. package/.agents/core/skills/context-os/EXAMPLES.md +21 -0
  32. package/.agents/core/skills/context-os/SKILL.md +169 -0
  33. package/.agents/core/skills/context-os/TROUBLESHOOTING.md +7 -0
  34. package/.agents/core/skills/context-os/VALIDATION.json +12 -0
  35. package/.agents/core/skills/context-os/packs.yaml +59 -0
  36. package/.agents/core/skills/context-os/references/context-rules.md +68 -0
  37. package/.agents/core/skills/context-os/references/pipeline.md +119 -0
  38. package/.agents/core/skills/context-os/references/project-graph.md +103 -0
  39. package/.agents/core/skills/context-os/rules.yaml +135 -0
  40. package/.agents/core/skills/context-os/skill.yaml +10 -0
  41. package/.agents/core/skills/database/EXAMPLES.md +74 -0
  42. package/.agents/core/skills/database/SKILL.md +101 -0
  43. package/.agents/core/skills/database/TROUBLESHOOTING.md +18 -0
  44. package/.agents/core/skills/database/VALIDATION.json +11 -0
  45. package/.agents/core/skills/database/skill.yaml +25 -0
  46. package/.agents/core/skills/ddd/EXAMPLES.md +42 -0
  47. package/.agents/core/skills/ddd/SKILL.md +247 -0
  48. package/.agents/core/skills/ddd/TROUBLESHOOTING.md +19 -0
  49. package/.agents/core/skills/ddd/VALIDATION.json +12 -0
  50. package/.agents/core/skills/ddd/ddd.md +178 -0
  51. package/.agents/core/skills/ddd/skill.yaml +10 -0
  52. package/.agents/core/skills/decisions/EXAMPLES.md +35 -0
  53. package/.agents/core/skills/decisions/SKILL.md +90 -0
  54. package/.agents/core/skills/decisions/TROUBLESHOOTING.md +13 -0
  55. package/.agents/core/skills/decisions/VALIDATION.json +12 -0
  56. package/.agents/core/skills/decisions/skill.yaml +10 -0
  57. package/.agents/core/skills/docker/EXAMPLES.md +56 -0
  58. package/.agents/core/skills/docker/SKILL.md +63 -0
  59. package/.agents/core/skills/docker/TROUBLESHOOTING.md +18 -0
  60. package/.agents/core/skills/docker/VALIDATION.json +11 -0
  61. package/.agents/core/skills/docker/skill.yaml +23 -0
  62. package/.agents/core/skills/engineering-workflow/EXAMPLES.md +57 -0
  63. package/.agents/core/skills/engineering-workflow/SKILL.md +343 -0
  64. package/.agents/core/skills/engineering-workflow/TROUBLESHOOTING.md +19 -0
  65. package/.agents/core/skills/engineering-workflow/VALIDATION.json +12 -0
  66. package/.agents/core/skills/engineering-workflow/skill.yaml +13 -0
  67. package/.agents/core/skills/fastapi/EXAMPLES.md +36 -0
  68. package/.agents/core/skills/fastapi/SKILL.md +148 -0
  69. package/.agents/core/skills/fastapi/TROUBLESHOOTING.md +19 -0
  70. package/.agents/core/skills/fastapi/VALIDATION.json +12 -0
  71. package/.agents/core/skills/fastapi/fastapi.md +112 -0
  72. package/.agents/core/skills/fastapi/skill.yaml +10 -0
  73. package/.agents/core/skills/gemini-precision/SKILL.md +169 -0
  74. package/.agents/core/skills/gemini-precision/VALIDATION.json +12 -0
  75. package/.agents/core/skills/gemini-precision/skill.yaml +9 -0
  76. package/.agents/core/skills/generators/EXAMPLES.md +19 -0
  77. package/.agents/core/skills/generators/SKILL.md +112 -0
  78. package/.agents/core/skills/generators/TROUBLESHOOTING.md +7 -0
  79. package/.agents/core/skills/generators/VALIDATION.json +12 -0
  80. package/.agents/core/skills/generators/skill.yaml +10 -0
  81. package/.agents/core/skills/generators/templates/API.md +77 -0
  82. package/.agents/core/skills/generators/templates/ARCHITECTURE.md +70 -0
  83. package/.agents/core/skills/generators/templates/DATABASE.md +42 -0
  84. package/.agents/core/skills/generators/templates/DECISION.md +46 -0
  85. package/.agents/core/skills/generators/templates/PRD.md +67 -0
  86. package/.agents/core/skills/generators/templates/PROJECT_GRAPH.md +56 -0
  87. package/.agents/core/skills/generators/templates/ROADMAP.md +51 -0
  88. package/.agents/core/skills/generators/templates/TASKS.md +43 -0
  89. package/.agents/core/skills/generators/templates/UI.md +73 -0
  90. package/.agents/core/skills/graphify/EXAMPLES.md +73 -0
  91. package/.agents/core/skills/graphify/SKILL.md +130 -0
  92. package/.agents/core/skills/graphify/VALIDATION.json +12 -0
  93. package/.agents/core/skills/graphify/skill.yaml +13 -0
  94. package/.agents/core/skills/gstack-roles/EXAMPLES.md +23 -0
  95. package/.agents/core/skills/gstack-roles/SKILL.md +152 -0
  96. package/.agents/core/skills/gstack-roles/TROUBLESHOOTING.md +13 -0
  97. package/.agents/core/skills/gstack-roles/VALIDATION.json +12 -0
  98. package/.agents/core/skills/gstack-roles/skill.yaml +12 -0
  99. package/.agents/core/skills/impeccable-design/EXAMPLES.md +26 -0
  100. package/.agents/core/skills/impeccable-design/SKILL.md +201 -0
  101. package/.agents/core/skills/impeccable-design/TROUBLESHOOTING.md +19 -0
  102. package/.agents/core/skills/impeccable-design/VALIDATION.json +12 -0
  103. package/.agents/core/skills/impeccable-design/skill.yaml +14 -0
  104. package/.agents/core/skills/interview-me/SKILL.md +97 -0
  105. package/.agents/core/skills/interview-me/VALIDATION.json +12 -0
  106. package/.agents/core/skills/interview-me/skill.yaml +8 -0
  107. package/.agents/core/skills/microservices/EXAMPLES.md +38 -0
  108. package/.agents/core/skills/microservices/SKILL.md +164 -0
  109. package/.agents/core/skills/microservices/TROUBLESHOOTING.md +19 -0
  110. package/.agents/core/skills/microservices/VALIDATION.json +12 -0
  111. package/.agents/core/skills/microservices/microservices.md +119 -0
  112. package/.agents/core/skills/microservices/skill.yaml +10 -0
  113. package/.agents/core/skills/minimalist-design/SKILL.md +113 -0
  114. package/.agents/core/skills/minimalist-design/VALIDATION.json +12 -0
  115. package/.agents/core/skills/minimalist-design/skill.yaml +8 -0
  116. package/.agents/core/skills/nestjs/EXAMPLES.md +40 -0
  117. package/.agents/core/skills/nestjs/SKILL.md +139 -0
  118. package/.agents/core/skills/nestjs/TROUBLESHOOTING.md +19 -0
  119. package/.agents/core/skills/nestjs/VALIDATION.json +12 -0
  120. package/.agents/core/skills/nestjs/nestjs.md +103 -0
  121. package/.agents/core/skills/nestjs/skill.yaml +10 -0
  122. package/.agents/core/skills/nextjs/EXAMPLES.md +40 -0
  123. package/.agents/core/skills/nextjs/SKILL.md +163 -0
  124. package/.agents/core/skills/nextjs/TROUBLESHOOTING.md +19 -0
  125. package/.agents/core/skills/nextjs/VALIDATION.json +12 -0
  126. package/.agents/core/skills/nextjs/nextjs.md +67 -0
  127. package/.agents/core/skills/nextjs/skill.yaml +10 -0
  128. package/.agents/core/skills/node/EXAMPLES.md +80 -0
  129. package/.agents/core/skills/node/SKILL.md +128 -0
  130. package/.agents/core/skills/node/TROUBLESHOOTING.md +19 -0
  131. package/.agents/core/skills/node/VALIDATION.json +12 -0
  132. package/.agents/core/skills/node/node.md +87 -0
  133. package/.agents/core/skills/node/skill.yaml +10 -0
  134. package/.agents/core/skills/performance/EXAMPLES.md +30 -0
  135. package/.agents/core/skills/performance/SKILL.md +75 -0
  136. package/.agents/core/skills/performance/TROUBLESHOOTING.md +19 -0
  137. package/.agents/core/skills/performance/VALIDATION.json +12 -0
  138. package/.agents/core/skills/performance/performance.md +52 -0
  139. package/.agents/core/skills/performance/skill.yaml +10 -0
  140. package/.agents/core/skills/ponytail-mindset/EXAMPLES.md +45 -0
  141. package/.agents/core/skills/ponytail-mindset/SKILL.md +193 -0
  142. package/.agents/core/skills/ponytail-mindset/TROUBLESHOOTING.md +19 -0
  143. package/.agents/core/skills/ponytail-mindset/VALIDATION.json +12 -0
  144. package/.agents/core/skills/ponytail-mindset/skill.yaml +14 -0
  145. package/.agents/core/skills/react/EXAMPLES.md +79 -0
  146. package/.agents/core/skills/react/SKILL.md +132 -0
  147. package/.agents/core/skills/react/TROUBLESHOOTING.md +19 -0
  148. package/.agents/core/skills/react/VALIDATION.json +12 -0
  149. package/.agents/core/skills/react/react.md +93 -0
  150. package/.agents/core/skills/react/skill.yaml +10 -0
  151. package/.agents/core/skills/react-best-practices/SKILL.md +155 -0
  152. package/.agents/core/skills/react-best-practices/VALIDATION.json +12 -0
  153. package/.agents/core/skills/react-best-practices/skill.yaml +10 -0
  154. package/.agents/core/skills/redesign-audit/SKILL.md +117 -0
  155. package/.agents/core/skills/redesign-audit/VALIDATION.json +12 -0
  156. package/.agents/core/skills/redesign-audit/skill.yaml +8 -0
  157. package/.agents/core/skills/security/EXAMPLES.md +64 -0
  158. package/.agents/core/skills/security/SKILL.md +158 -0
  159. package/.agents/core/skills/security/TROUBLESHOOTING.md +19 -0
  160. package/.agents/core/skills/security/VALIDATION.json +12 -0
  161. package/.agents/core/skills/security/security.md +106 -0
  162. package/.agents/core/skills/security/skill.yaml +10 -0
  163. package/.agents/core/skills/soft-design/SKILL.md +108 -0
  164. package/.agents/core/skills/soft-design/VALIDATION.json +12 -0
  165. package/.agents/core/skills/soft-design/skill.yaml +8 -0
  166. package/.agents/core/skills/state-management/EXAMPLES.md +56 -0
  167. package/.agents/core/skills/state-management/SKILL.md +48 -0
  168. package/.agents/core/skills/state-management/TROUBLESHOOTING.md +18 -0
  169. package/.agents/core/skills/state-management/VALIDATION.json +11 -0
  170. package/.agents/core/skills/state-management/skill.yaml +22 -0
  171. package/.agents/core/skills/subagent-orchestrator/SKILL.md +100 -0
  172. package/.agents/core/skills/subagent-orchestrator/VALIDATION.json +12 -0
  173. package/.agents/core/skills/subagent-orchestrator/skill.yaml +8 -0
  174. package/.agents/core/skills/system-design/EXAMPLES.md +75 -0
  175. package/.agents/core/skills/system-design/SKILL.md +419 -0
  176. package/.agents/core/skills/system-design/TROUBLESHOOTING.md +19 -0
  177. package/.agents/core/skills/system-design/VALIDATION.json +12 -0
  178. package/.agents/core/skills/system-design/skill.yaml +13 -0
  179. package/.agents/core/skills/system-design/system-design.md +112 -0
  180. package/.agents/core/skills/testing/EXAMPLES.md +71 -0
  181. package/.agents/core/skills/testing/SKILL.md +70 -0
  182. package/.agents/core/skills/testing/TROUBLESHOOTING.md +18 -0
  183. package/.agents/core/skills/testing/VALIDATION.json +11 -0
  184. package/.agents/core/skills/testing/skill.yaml +26 -0
  185. package/.agents/core/skills/typescript/EXAMPLES.md +64 -0
  186. package/.agents/core/skills/typescript/SKILL.md +112 -0
  187. package/.agents/core/skills/typescript/TROUBLESHOOTING.md +19 -0
  188. package/.agents/core/skills/typescript/VALIDATION.json +12 -0
  189. package/.agents/core/skills/typescript/skill.yaml +10 -0
  190. package/.agents/core/skills/typescript/typescript.md +71 -0
  191. package/.agents/core/skills/ui-design/EXAMPLES.md +21 -0
  192. package/.agents/core/skills/ui-design/SKILL.md +124 -0
  193. package/.agents/core/skills/ui-design/TROUBLESHOOTING.md +19 -0
  194. package/.agents/core/skills/ui-design/VALIDATION.json +12 -0
  195. package/.agents/core/skills/ui-design/skill.yaml +10 -0
  196. package/.agents/core/skills/ui-design/ui.md +88 -0
  197. package/.agents/core/skills/ui-ux-pro/EXAMPLES.md +62 -0
  198. package/.agents/core/skills/ui-ux-pro/SKILL.md +375 -0
  199. package/.agents/core/skills/ui-ux-pro/TROUBLESHOOTING.md +19 -0
  200. package/.agents/core/skills/ui-ux-pro/VALIDATION.json +12 -0
  201. package/.agents/core/skills/ui-ux-pro/skill.yaml +13 -0
  202. package/.agents/core/skills/ux-design/EXAMPLES.md +36 -0
  203. package/.agents/core/skills/ux-design/SKILL.md +116 -0
  204. package/.agents/core/skills/ux-design/TROUBLESHOOTING.md +19 -0
  205. package/.agents/core/skills/ux-design/VALIDATION.json +12 -0
  206. package/.agents/core/skills/ux-design/skill.yaml +10 -0
  207. package/.agents/core/skills/ux-design/ux.md +80 -0
  208. package/.agents/core/skills/vercel-optimize/SKILL.md +83 -0
  209. package/.agents/core/skills/vercel-optimize/VALIDATION.json +12 -0
  210. package/.agents/core/skills/vercel-optimize/skill.yaml +10 -0
  211. package/.agents/core/skills/web-accessibility/EXAMPLES.md +39 -0
  212. package/.agents/core/skills/web-accessibility/SKILL.md +170 -0
  213. package/.agents/core/skills/web-accessibility/TROUBLESHOOTING.md +19 -0
  214. package/.agents/core/skills/web-accessibility/VALIDATION.json +12 -0
  215. package/.agents/core/skills/web-accessibility/accessibility.md +63 -0
  216. package/.agents/core/skills/web-accessibility/skill.yaml +10 -0
  217. package/.agents/ctx.js +370 -0
  218. package/.agents/generated/claude/skills/adapters/SKILL.md +126 -0
  219. package/.agents/generated/claude/skills/architecture-diagrams/SKILL.md +101 -0
  220. package/.agents/generated/claude/skills/brutalist-design/SKILL.md +145 -0
  221. package/.agents/generated/claude/skills/context-manager/SKILL.md +147 -0
  222. package/.agents/generated/claude/skills/context-os/SKILL.md +191 -0
  223. package/.agents/generated/claude/skills/database/SKILL.md +191 -0
  224. package/.agents/generated/claude/skills/ddd/SKILL.md +305 -0
  225. package/.agents/generated/claude/skills/decisions/SKILL.md +134 -0
  226. package/.agents/generated/claude/skills/docker/SKILL.md +135 -0
  227. package/.agents/generated/claude/skills/engineering-workflow/SKILL.md +414 -0
  228. package/.agents/generated/claude/skills/fastapi/SKILL.md +200 -0
  229. package/.agents/generated/claude/skills/gemini-precision/SKILL.md +161 -0
  230. package/.agents/generated/claude/skills/generators/SKILL.md +133 -0
  231. package/.agents/generated/claude/skills/graphify/SKILL.md +198 -0
  232. package/.agents/generated/claude/skills/gstack-roles/SKILL.md +184 -0
  233. package/.agents/generated/claude/skills/impeccable-design/SKILL.md +241 -0
  234. package/.agents/generated/claude/skills/interview-me/SKILL.md +90 -0
  235. package/.agents/generated/claude/skills/microservices/SKILL.md +218 -0
  236. package/.agents/generated/claude/skills/minimalist-design/SKILL.md +108 -0
  237. package/.agents/generated/claude/skills/nestjs/SKILL.md +195 -0
  238. package/.agents/generated/claude/skills/nextjs/SKILL.md +219 -0
  239. package/.agents/generated/claude/skills/node/SKILL.md +224 -0
  240. package/.agents/generated/claude/skills/performance/SKILL.md +121 -0
  241. package/.agents/generated/claude/skills/ponytail-mindset/SKILL.md +252 -0
  242. package/.agents/generated/claude/skills/react/SKILL.md +227 -0
  243. package/.agents/generated/claude/skills/react-best-practices/SKILL.md +146 -0
  244. package/.agents/generated/claude/skills/redesign-audit/SKILL.md +112 -0
  245. package/.agents/generated/claude/skills/security/SKILL.md +237 -0
  246. package/.agents/generated/claude/skills/soft-design/SKILL.md +103 -0
  247. package/.agents/generated/claude/skills/state-management/SKILL.md +120 -0
  248. package/.agents/generated/claude/skills/subagent-orchestrator/SKILL.md +93 -0
  249. package/.agents/generated/claude/skills/system-design/SKILL.md +507 -0
  250. package/.agents/generated/claude/skills/testing/SKILL.md +157 -0
  251. package/.agents/generated/claude/skills/typescript/SKILL.md +192 -0
  252. package/.agents/generated/claude/skills/ui-design/SKILL.md +161 -0
  253. package/.agents/generated/claude/skills/ui-ux-pro/SKILL.md +451 -0
  254. package/.agents/generated/claude/skills/ux-design/SKILL.md +168 -0
  255. package/.agents/generated/claude/skills/vercel-optimize/SKILL.md +76 -0
  256. package/.agents/generated/claude/skills/web-accessibility/SKILL.md +225 -0
  257. package/.agents/generated/gemini/skills/adapters/SKILL.md +135 -0
  258. package/.agents/generated/gemini/skills/architecture-diagrams/SKILL.md +107 -0
  259. package/.agents/generated/gemini/skills/brutalist-design/SKILL.md +151 -0
  260. package/.agents/generated/gemini/skills/context-manager/SKILL.md +156 -0
  261. package/.agents/generated/gemini/skills/context-os/SKILL.md +200 -0
  262. package/.agents/generated/gemini/skills/database/SKILL.md +200 -0
  263. package/.agents/generated/gemini/skills/ddd/SKILL.md +314 -0
  264. package/.agents/generated/gemini/skills/decisions/SKILL.md +143 -0
  265. package/.agents/generated/gemini/skills/docker/SKILL.md +144 -0
  266. package/.agents/generated/gemini/skills/engineering-workflow/SKILL.md +423 -0
  267. package/.agents/generated/gemini/skills/fastapi/SKILL.md +209 -0
  268. package/.agents/generated/gemini/skills/gemini-precision/SKILL.md +167 -0
  269. package/.agents/generated/gemini/skills/generators/SKILL.md +142 -0
  270. package/.agents/generated/gemini/skills/graphify/SKILL.md +205 -0
  271. package/.agents/generated/gemini/skills/gstack-roles/SKILL.md +193 -0
  272. package/.agents/generated/gemini/skills/impeccable-design/SKILL.md +250 -0
  273. package/.agents/generated/gemini/skills/interview-me/SKILL.md +96 -0
  274. package/.agents/generated/gemini/skills/microservices/SKILL.md +227 -0
  275. package/.agents/generated/gemini/skills/minimalist-design/SKILL.md +114 -0
  276. package/.agents/generated/gemini/skills/nestjs/SKILL.md +204 -0
  277. package/.agents/generated/gemini/skills/nextjs/SKILL.md +298 -0
  278. package/.agents/generated/gemini/skills/node/SKILL.md +323 -0
  279. package/.agents/generated/gemini/skills/performance/SKILL.md +185 -0
  280. package/.agents/generated/gemini/skills/ponytail-mindset/SKILL.md +261 -0
  281. package/.agents/generated/gemini/skills/react/SKILL.md +332 -0
  282. package/.agents/generated/gemini/skills/react-best-practices/SKILL.md +152 -0
  283. package/.agents/generated/gemini/skills/redesign-audit/SKILL.md +118 -0
  284. package/.agents/generated/gemini/skills/security/SKILL.md +355 -0
  285. package/.agents/generated/gemini/skills/soft-design/SKILL.md +109 -0
  286. package/.agents/generated/gemini/skills/state-management/SKILL.md +129 -0
  287. package/.agents/generated/gemini/skills/subagent-orchestrator/SKILL.md +99 -0
  288. package/.agents/generated/gemini/skills/system-design/SKILL.md +631 -0
  289. package/.agents/generated/gemini/skills/testing/SKILL.md +166 -0
  290. package/.agents/generated/gemini/skills/typescript/SKILL.md +275 -0
  291. package/.agents/generated/gemini/skills/ui-design/SKILL.md +170 -0
  292. package/.agents/generated/gemini/skills/ui-ux-pro/SKILL.md +460 -0
  293. package/.agents/generated/gemini/skills/ux-design/SKILL.md +177 -0
  294. package/.agents/generated/gemini/skills/vercel-optimize/SKILL.md +82 -0
  295. package/.agents/generated/gemini/skills/web-accessibility/SKILL.md +300 -0
  296. package/.agents/mcp/runtime.py +454 -0
  297. package/.agents/mcp/server.mjs +189373 -0
  298. package/.agents/plugins.js +574 -0
  299. package/.agents/profiles.js +267 -0
  300. package/.agents/resolver.js +336 -0
  301. package/.agents/skills-index.json +200 -0
  302. package/.agents/skills.json +6 -0
  303. package/.agents/validate.js +500 -0
  304. package/LICENSE +21 -0
  305. package/README.md +415 -0
  306. package/benchmarks/gemini-issues.js +533 -0
  307. package/bin/index.js +458 -0
  308. package/package.json +70 -0
  309. package/registry.json +53 -0
  310. package/registry.schema.json +32 -0
@@ -0,0 +1,68 @@
1
+ # Context Loading Rules
2
+
3
+ ## Task Type → Document Mapping
4
+
5
+ | Task Type | Level 1 (Always) | Level 2 (If exists) | Level 3 (Per task) |
6
+ | --- | --- | --- | --- |
7
+ | **New project** | PRD, ROADMAP | ARCHITECTURE, DATABASE, API | UI, TASKS, all relevant skills |
8
+ | **New feature** | PRD | ARCHITECTURE, API | PROJECT_GRAPH, relevant skills |
9
+ | **Frontend** | — | ARCHITECTURE, API | UI, frontend skills |
10
+ | **Backend** | — | ARCHITECTURE, DATABASE, API | backend skills |
11
+ | **Database** | — | ARCHITECTURE, DATABASE | — |
12
+ | **Bugfix** | — | — | PROJECT_GRAPH (affected module only) |
13
+ | **Refactor** | — | ARCHITECTURE | PROJECT_GRAPH, affected skills |
14
+ | **Review** | PRD | ARCHITECTURE | TASKS, all loaded skills |
15
+ | **Deploy** | — | ARCHITECTURE | DEPLOYMENT, infrastructure skills |
16
+
17
+ ## Skill Category → Document Mapping
18
+
19
+ | Skill Category | Required Documents | Optional Documents |
20
+ | --- | --- | --- |
21
+ | `frontend` | UI.md, API.md | ARCHITECTURE.md |
22
+ | `backend` | API.md, DATABASE.md | ARCHITECTURE.md |
23
+ | `design` | UI.md | PRD.md |
24
+ | `architecture` | ARCHITECTURE.md, DATABASE.md | PRD.md, API.md |
25
+ | `infrastructure` | ARCHITECTURE.md | — |
26
+ | `security` | ARCHITECTURE.md, API.md | DATABASE.md |
27
+ | `testing` | API.md | ARCHITECTURE.md |
28
+
29
+ ## Context Budget
30
+
31
+ To prevent context window overflow, apply these limits:
32
+
33
+ | Priority | Max tokens | Content |
34
+ | --- | --- | --- |
35
+ | 1 (Critical) | 2000 | Current task description + relevant skill instructions |
36
+ | 2 (Important) | 3000 | Architecture + API contracts for affected modules |
37
+ | 3 (Context) | 2000 | Decision records + project graph (affected branch) |
38
+ | 4 (Background) | 1000 | PRD summary + coding rules |
39
+
40
+ **Total budget: ~8000 tokens of context per task.**
41
+
42
+ If context exceeds budget:
43
+
44
+ 1. Trim Level 1 docs to summaries only
45
+ 2. Load only affected sections of Level 2 docs
46
+ 3. Keep Level 3 (skills) at full detail — they contain the actual instructions
47
+
48
+ ## Module-Based Filtering
49
+
50
+ When the Project Graph is available, use it to filter context:
51
+
52
+ ```
53
+ Task: "Fix appointment reminder bug"
54
+
55
+ Project Graph lookup: "reminder" → module: appointments
56
+
57
+ Appointments depends_on: [patients, auth]
58
+
59
+ Load only:
60
+ - appointments module docs
61
+ - auth module docs (dependency)
62
+ - API.md (appointments section only)
63
+
64
+ Skip:
65
+ - patients module docs (not a dependency for this task)
66
+ - DATABASE.md (no schema change expected)
67
+ - UI.md (backend task)
68
+ ```
@@ -0,0 +1,119 @@
1
+ # Development Pipeline
2
+
3
+ ## The ContextOS Lifecycle
4
+
5
+ ```
6
+ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
7
+ │ DEFINE │ ──▶ │ PLAN │ ──▶ │ BUILD │ ──▶ │ VERIFY │ ──▶ │ REVIEW │ ──▶ │ SHIP │
8
+ │ │ │ │ │ │ │ │ │ │ │ │
9
+ │ What to │ │ How to │ │ Write │ │ Test & │ │ Quality │ │ Deploy & │
10
+ │ build │ │ build it │ │ code │ │ validate │ │ gates │ │ document │
11
+ └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘
12
+ │ │ │ │ │ │
13
+ PRD.md ARCHITECTURE.md source code tests code review DECISION.md
14
+ UI.md DATABASE.md components coverage self-review changelog
15
+ ROADMAP.md API.md API routes edge cases security scan deploy
16
+ PROJECT_GRAPH TASKS.md migrations performance a11y audit release notes
17
+ ```
18
+
19
+ ## Stage Details
20
+
21
+ ### 1. DEFINE — "What are we building?"
22
+
23
+ **Input:** User idea or feature request
24
+ **Output:** PRD.md, UI.md, ROADMAP.md, PROJECT_GRAPH.md
25
+
26
+ Process:
27
+
28
+ 1. Intent Analysis — parse the user's request
29
+ 2. Clarifying questions — fill gaps
30
+ 3. Generate PRD with clear requirements
31
+ 4. Generate UI spec if frontend is involved
32
+ 5. Create initial Project Graph
33
+
34
+ **Context loaded:** None (this is the starting point)
35
+
36
+ ### 2. PLAN — "How will we build it?"
37
+
38
+ **Input:** PRD.md
39
+ **Output:** ARCHITECTURE.md, DATABASE.md, API.md, TASKS.md
40
+
41
+ Process:
42
+
43
+ 1. Choose architecture based on profile + requirements
44
+ 2. Design database schema
45
+ 3. Define API contracts
46
+ 4. Break work into atomic tasks
47
+ 5. Update Project Graph with modules and features
48
+
49
+ **Context loaded:** PRD.md, profiles/
50
+
51
+ ### 3. BUILD — "Write the code"
52
+
53
+ **Input:** TASKS.md + relevant architecture docs
54
+ **Output:** Source code, migrations, configurations
55
+
56
+ Process:
57
+
58
+ 1. Pick next task from TASKS.md
59
+ 2. Context Compiler loads only relevant skills and docs
60
+ 3. Write code following loaded skill instructions
61
+ 4. Commit after each completed task
62
+ 5. Update Project Graph if structure changes
63
+
64
+ **Context loaded:** Task-specific (via Context Manager)
65
+
66
+ ### 4. VERIFY — "Prove it works"
67
+
68
+ **Input:** Source code
69
+ **Output:** Tests, coverage reports
70
+
71
+ Process:
72
+
73
+ 1. Write tests for new code
74
+ 2. Run existing tests — ensure nothing broke
75
+ 3. Check edge cases
76
+ 4. Verify performance (if applicable)
77
+
78
+ **Context loaded:** Testing skills + API.md
79
+
80
+ ### 5. REVIEW — "Quality check"
81
+
82
+ **Input:** Code changes (diff)
83
+ **Output:** Review comments, approved changes
84
+
85
+ Process:
86
+
87
+ 1. Self-review against coding standards
88
+ 2. Security scan (if security skill loaded)
89
+ 3. Accessibility audit (if frontend)
90
+ 4. Check against ARCHITECTURE.md — does this align?
91
+ 5. Check against Decision Records — does this contradict anything?
92
+
93
+ **Context loaded:** ARCHITECTURE.md + relevant skills + decisions/
94
+
95
+ ### 6. SHIP — "Deploy and document"
96
+
97
+ **Input:** Reviewed, tested code
98
+ **Output:** Deployment, decision records, release notes
99
+
100
+ Process:
101
+
102
+ 1. Record any architectural decisions made (ADR)
103
+ 2. Update ROADMAP.md — mark completed items
104
+ 3. Update TASKS.md — close completed tasks
105
+ 4. Deploy (if deployment skill loaded)
106
+ 5. Update Project Graph
107
+
108
+ **Context loaded:** ROADMAP.md, TASKS.md, deployment skills
109
+
110
+ ## Profiles and Pipeline
111
+
112
+ Different profiles customize the pipeline:
113
+
114
+ | Profile | Skips | Adds |
115
+ | --- | --- | --- |
116
+ | **Hackathon** | REVIEW, detailed PLAN | Speed shortcuts |
117
+ | **MVP** | Detailed REVIEW, DEPLOY | Quick iterations |
118
+ | **Startup** | Heavy docs | Balance of speed and quality |
119
+ | **Enterprise** | Nothing | ADR enforcement, security gates, full testing |
@@ -0,0 +1,103 @@
1
+ # Project Graph
2
+
3
+ The Project Graph is the **central nervous system** of ContextOS. It maps the entire project as a hierarchy:
4
+
5
+ ```
6
+ Project
7
+ └── Module
8
+ └── Feature
9
+ └── Task
10
+ └── File
11
+ └── Skill
12
+ ```
13
+
14
+ ## Why Project Graph?
15
+
16
+ Without a Project Graph, an AI agent sees a flat list of files. With it, the agent understands:
17
+
18
+ 1. **Impact analysis** — changing `calendar.ts` affects the Appointments module, which affects Patients
19
+ 2. **Scope detection** — a task touching `api/patients/` only needs Patient-related context
20
+ 3. **Skill selection** — files in `components/` need React skills, files in `api/` need backend skills
21
+ 4. **Dependency tracking** — the Calendar feature depends on the Auth module
22
+
23
+ ## Structure
24
+
25
+ The Project Graph lives in `docs/PROJECT_GRAPH.md` and follows this format:
26
+
27
+ ```yaml
28
+ project:
29
+ name: "DentalCRM"
30
+ type: crm
31
+
32
+ modules:
33
+ patients:
34
+ description: "Patient management"
35
+ features:
36
+ - patient-list
37
+ - patient-profile
38
+ - medical-history
39
+ files:
40
+ - src/modules/patients/**
41
+ skills: [react, typescript, postgres]
42
+ depends_on: [auth]
43
+
44
+ appointments:
45
+ description: "Appointment scheduling"
46
+ features:
47
+ - appointment-calendar
48
+ - appointment-booking
49
+ - notifications
50
+ files:
51
+ - src/modules/appointments/**
52
+ skills: [react, typescript, postgres]
53
+ depends_on: [patients, auth]
54
+
55
+ auth:
56
+ description: "Authentication and authorization"
57
+ features:
58
+ - login
59
+ - registration
60
+ - role-management
61
+ files:
62
+ - src/modules/auth/**
63
+ skills: [security, typescript, jwt]
64
+ depends_on: []
65
+ ```
66
+
67
+ ## How the Context Compiler Uses It
68
+
69
+ ### Task: "Add a reminder notification for appointments"
70
+
71
+ 1. **Locate module**: `appointments`
72
+ 2. **Check dependencies**: `appointments` → `patients`, `auth`
73
+ 3. **Load relevant files**: `src/modules/appointments/**`, `src/modules/notifications/**`
74
+ 4. **Load relevant skills**: `react`, `typescript`, notification patterns
75
+ 5. **Load relevant docs**: `ARCHITECTURE.md` (notifications section), `API.md` (endpoints)
76
+ 6. **Skip irrelevant**: `DATABASE.md` (no schema change), `UI.md` (if backend-only)
77
+
78
+ ### Task: "Refactor the database schema"
79
+
80
+ 1. **Affected modules**: ALL (schema change is cross-cutting)
81
+ 2. **Load**: `DATABASE.md`, `ARCHITECTURE.md`, `PROJECT_GRAPH.md`
82
+ 3. **Show impact**: which modules/features are affected by each table change
83
+ 4. **Load skills**: `postgres` (or relevant DB skill)
84
+
85
+ ## Automatic Updates
86
+
87
+ The Project Graph should be updated when:
88
+
89
+ - New modules are added
90
+ - Features are completed
91
+ - File structure changes significantly
92
+ - Dependencies between modules change
93
+
94
+ Use `ctx graph` to regenerate the Project Graph from the current codebase.
95
+
96
+ ## Graph Queries
97
+
98
+ The Context Compiler can answer questions like:
99
+
100
+ - "What modules does this file belong to?"
101
+ - "What skills are needed for this module?"
102
+ - "What other modules will be affected if I change this?"
103
+ - "Show me the dependency chain from here"
@@ -0,0 +1,135 @@
1
+ # Rule Engine
2
+ # Conditional logic for context compilation based on project profile and task type
3
+
4
+ rules:
5
+ # ═══════════════════════════════════════
6
+ # Profile-based rules
7
+ # ═══════════════════════════════════════
8
+
9
+ - name: mvp-minimal
10
+ description: MVP projects skip heavy infrastructure
11
+ if:
12
+ profile: mvp
13
+ then:
14
+ exclude_skills: [microservices, ddd, kubernetes, monitoring, cicd]
15
+ exclude_docs: [DEPLOYMENT.md]
16
+ prefer_skills: [sqlite, simple-auth, minimal-architecture]
17
+ max_doc_depth: 2 # Only Level 1 + Level 2
18
+
19
+ - name: enterprise-strict
20
+ description: Enterprise projects require full documentation and rigor
21
+ if:
22
+ profile: enterprise
23
+ then:
24
+ require_skills: [ddd, security, testing, cicd]
25
+ require_docs: [ARCHITECTURE.md, DATABASE.md, API.md, DECISIONS]
26
+ enforce_adr: true # Every architectural decision must be recorded
27
+ enforce_testing: true
28
+ min_doc_depth: 3 # All levels required
29
+
30
+ - name: hackathon-speed
31
+ description: Hackathon mode — maximum speed, minimum ceremony
32
+ if:
33
+ profile: hackathon
34
+ then:
35
+ exclude_skills: [kubernetes, monitoring, cicd, ddd, microservices]
36
+ exclude_docs: [DEPLOYMENT.md, ROADMAP.md]
37
+ prefer_skills: [sqlite, simple-auth]
38
+ skip_review: true
39
+ max_doc_depth: 1 # Vision only
40
+
41
+ - name: startup-balanced
42
+ description: Startup balance between speed and quality
43
+ if:
44
+ profile: startup
45
+ then:
46
+ exclude_skills: [kubernetes, ddd]
47
+ prefer_skills: [postgres, jwt-auth, docker]
48
+ enforce_adr: false
49
+ max_doc_depth: 2
50
+
51
+ # ═══════════════════════════════════════
52
+ # Task-based rules
53
+ # ═══════════════════════════════════════
54
+
55
+ - name: frontend-task
56
+ description: Frontend tasks don't need database or deployment docs
57
+ if:
58
+ task_type: frontend
59
+ then:
60
+ load_docs: [UI.md, ARCHITECTURE.md, API.md]
61
+ skip_docs: [DATABASE.md, DEPLOYMENT.md]
62
+ load_skill_categories: [frontend, design]
63
+ skip_skill_categories: [backend, infrastructure]
64
+
65
+ - name: backend-task
66
+ description: Backend tasks don't need UI docs
67
+ if:
68
+ task_type: backend
69
+ then:
70
+ load_docs: [ARCHITECTURE.md, DATABASE.md, API.md]
71
+ skip_docs: [UI.md]
72
+ load_skill_categories: [backend, architecture]
73
+ skip_skill_categories: [design]
74
+
75
+ - name: architecture-task
76
+ description: Architecture tasks load everything at high level
77
+ if:
78
+ task_type: architecture
79
+ then:
80
+ load_docs: [PRD.md, ARCHITECTURE.md, DATABASE.md, API.md, PROJECT_GRAPH.md]
81
+ load_skill_categories: [architecture]
82
+ skip_skill_categories: [design]
83
+
84
+ - name: bugfix-task
85
+ description: Bugfixes need minimal context — focus on affected module
86
+ if:
87
+ task_type: bugfix
88
+ then:
89
+ load_docs: [PROJECT_GRAPH.md] # Find affected module
90
+ max_doc_depth: 1
91
+ skip_docs: [PRD.md, ROADMAP.md]
92
+
93
+ - name: refactor-task
94
+ description: Refactoring needs architecture context
95
+ if:
96
+ task_type: refactor
97
+ then:
98
+ load_docs: [ARCHITECTURE.md, PROJECT_GRAPH.md]
99
+ load_skill_categories: [architecture]
100
+
101
+ # ═══════════════════════════════════════
102
+ # Stack-based rules
103
+ # ═══════════════════════════════════════
104
+
105
+ - name: react-ecosystem
106
+ description: React projects auto-load TypeScript
107
+ if:
108
+ skill_loaded: react
109
+ then:
110
+ auto_load: [typescript]
111
+ suggest: [tailwind, react-query]
112
+
113
+ - name: nextjs-ecosystem
114
+ description: Next.js implies React + TypeScript + SSR patterns
115
+ if:
116
+ skill_loaded: nextjs
117
+ then:
118
+ auto_load: [react, typescript]
119
+ suggest: [prisma, next-auth, tailwind]
120
+
121
+ - name: fastapi-ecosystem
122
+ description: FastAPI implies Python + Pydantic
123
+ if:
124
+ skill_loaded: fastapi
125
+ then:
126
+ auto_load: [python, pydantic]
127
+ suggest: [postgres, docker, testing]
128
+
129
+ - name: no-conflicts
130
+ description: Prevent incompatible frameworks
131
+ if:
132
+ any_loaded: [react, vue, angular, svelte]
133
+ then:
134
+ conflict_check: true
135
+ max_frontend_frameworks: 1
@@ -0,0 +1,10 @@
1
+ name: context-os
2
+ description: >
3
+ AI Project Operating System context compiler that transforms user intent into
4
+ minimal, relevant context for any AI agent across the full development lifecycle.
5
+ tags:
6
+ - workflow
7
+ - orchestration
8
+ - architecture
9
+ - context
10
+ version: 1.0.0
@@ -0,0 +1,74 @@
1
+ # Database Examples — Anti-patterns vs ContextOS Standard
2
+
3
+ ## Example 1: Solving the N+1 Query Problem
4
+
5
+ ### Anti-pattern: Anti-pattern (N+1 database queries in a loop)
6
+
7
+ ```typescript
8
+ // BAD: 1 query for users + N queries for posts!
9
+ const users = await prisma.user.findMany();
10
+ const usersWithPosts = [];
11
+ for (const user of users) {
12
+ const posts = await prisma.post.findMany({ where: { userId: user.id } }); // N queries!
13
+ usersWithPosts.push({ ...user, posts });
14
+ }
15
+ ```
16
+
17
+ ### Best practice: ContextOS Standard (Batch query or relational include)
18
+
19
+ ```typescript
20
+ // GOOD: 1 single optimized batch query
21
+ const usersWithPosts = await prisma.user.findMany({
22
+ where: { isActive: true },
23
+ select: {
24
+ id: true,
25
+ name: true,
26
+ email: true,
27
+ posts: {
28
+ where: { published: true },
29
+ select: { id: true, title: true, createdAt: true },
30
+ take: 5
31
+ }
32
+ }
33
+ });
34
+ ```
35
+
36
+ ---
37
+
38
+ ## Example 2: Safe Atomic Transactions with Locking
39
+
40
+ ### Anti-pattern: Anti-pattern (Unprotected read-modify-write race condition)
41
+
42
+ ```typescript
43
+ // BAD: race condition between reading balance and updating
44
+ const account = await prisma.account.findUnique({ where: { id } });
45
+ if (account.balance >= amount) {
46
+ await prisma.account.update({
47
+ where: { id },
48
+ data: { balance: account.balance - amount }
49
+ });
50
+ }
51
+ ```
52
+
53
+ ### Best practice: ContextOS Standard (Atomic conditional update in transaction)
54
+
55
+ ```typescript
56
+ // GOOD: atomic database transaction with invariant check
57
+ export async function deductBalance(accountId: string, amount: number) {
58
+ return await prisma.$transaction(async (tx) => {
59
+ const updated = await tx.account.updateMany({
60
+ where: {
61
+ id: accountId,
62
+ balance: { gte: amount }
63
+ },
64
+ data: {
65
+ balance: { decrement: amount }
66
+ }
67
+ });
68
+
69
+ if (updated.count === 0) {
70
+ throw new InsufficientFundsError(accountId);
71
+ }
72
+ });
73
+ }
74
+ ```
@@ -0,0 +1,101 @@
1
+ ---
2
+ name: database
3
+ description: Database architecture, schema design, Prisma, Drizzle ORM, indexing strategies, migrations, and N+1 query resolution.
4
+ ---
5
+
6
+ # database
7
+
8
+ ## Overview
9
+
10
+ Relational database design, query optimization, migration safety, connection pooling in serverless environments, and ORM usage across PostgreSQL, Prisma, and Drizzle.
11
+
12
+ ## When to Use
13
+
14
+ Activate for tasks involving database schema design, migrations, indexing, relational models, ORM queries, transactions, or query performance tuning.
15
+
16
+ ## Rules & Patterns
17
+
18
+ ### Negative Constraints (What NOT to Do)
19
+
20
+ 1. **NEVER do `SELECT *` in production**: Always select explicit columns required by the caller to minimize memory bandwidth and lock footprint.
21
+ 2. **NEVER run destructive migrations without backward compatibility**: Always follow expand-and-contract (Phase 1: add new column as nullable; Phase 2: backfill; Phase 3: make non-nullable & remove old column).
22
+ 3. **NEVER execute queries in loops (The N+1 Anti-Pattern)**: Always use batch loading (`inArray`, `DataLoader`, or relational `include` / `JOIN`).
23
+ 4. **NEVER leave foreign keys without indexes**: In PostgreSQL/MySQL, child foreign key columns must always have an index to prevent table-level locking on cascade deletes.
24
+ 5. **NEVER perform multi-entity writes without a database transaction**: Any operation touching multiple records must use `prisma.$transaction` or `db.transaction`.
25
+ 6. **NEVER open unpooled database connections in Serverless / Edge functions**: Serverless scale-outs will instantly exhaust PostgreSQL's `max_connections`.
26
+
27
+ ---
28
+
29
+ ### Zero-Downtime Migrations (Expand-and-Contract)
30
+
31
+ When modifying schemas with zero downtime:
32
+
33
+ 1. **Phase 1 (Expand)**: Add the new column as `NULLABLE` (or with a default value). Deploy the application code that reads from old column and writes to both old and new.
34
+ 2. **Phase 2 (Backfill)**: Run an asynchronous batch migration job in chunks (e.g. 1000 rows at a time) to populate data from old column to new column.
35
+ 3. **Phase 3 (Contract)**: Update application code to read and write exclusively from the new column.
36
+ 4. **Phase 4 (Cleanup)**: Once traffic is fully shifted, remove the old column and mark the new column as `NOT NULL` in a separate migration.
37
+
38
+ ---
39
+
40
+ ### Serverless & Edge Connection Pooling
41
+
42
+ In serverless environments (AWS Lambda, Vercel Functions):
43
+
44
+ - Always connect via a connection pooler:
45
+ - **Prisma**: Use Prisma Accelerate or configure transaction mode connection URLs.
46
+ - **Drizzle / Node-Postgres**: Use `@neondatabase/serverless` or connect to PgBouncer pooler port (`6543`) with `max: 1` per serverless container.
47
+ - Set strict statement timeouts (e.g. `statement_timeout = '5000'`) to prevent hanging queries from exhausting pool capacity.
48
+
49
+ ---
50
+
51
+ ### Indexing & Performance Rules
52
+
53
+ - **B-Tree Indexes**: For high-cardinality filters (`status`, `user_id`, `created_at`).
54
+ - **Composite Indexes**: When querying multiple columns together (`WHERE organization_id = ? AND status = ?`), order columns in index by equality first, range second.
55
+ - **Partial Indexes**: For sparse boolean flags (`WHERE is_processed = false`).
56
+ - **Covering Indexes**: Include frequently selected columns (`INCLUDE (title, created_at)`) to enable index-only scans without table heap access.
57
+
58
+ ---
59
+
60
+ ## Code Examples
61
+
62
+ ### Zero-Downtime Column Rename (Drizzle ORM)
63
+
64
+ ```typescript
65
+ // Step 1 (Expand): Keep old column, add new column
66
+ export const users = pgTable('users', {
67
+ id: uuid('id').primaryKey().defaultRandom(),
68
+ fullName: varchar('full_name', { length: 255 }), // new column
69
+ name: varchar('name', { length: 255 }), // old column kept during transition
70
+ });
71
+
72
+ // App write logic during transition:
73
+ await db.insert(users).values({
74
+ name: input.name,
75
+ fullName: input.name
76
+ });
77
+ ```
78
+
79
+ ---
80
+
81
+ ## Validation Checklist
82
+
83
+ - [ ] All database queries select explicit required columns (no `SELECT *`).
84
+ - [ ] Foreign keys have matching indexes on child tables.
85
+ - [ ] Multi-table writes wrapped in ACID transactions.
86
+ - [ ] No N+1 queries in loops.
87
+ - [ ] Schema migrations tested against expand-and-contract pattern.
88
+ - [ ] Serverless database connection string uses pooling proxy.
89
+
90
+ ---
91
+
92
+ ## Common Mistakes
93
+
94
+ - **Missing pagination limits**: Unbounded `findMany()` calls leading to Out-Of-Memory crashes under production volume.
95
+ - **Locking entire tables**: Adding `NOT NULL` columns with heavy compute defaults in PostgreSQL without concurrent index creation.
96
+
97
+ ---
98
+
99
+ ## Integration Notes
100
+
101
+ - Interacts with `system-design`, `ddd`, and `security` (multi-tenant tenantId scoping).
@@ -0,0 +1,18 @@
1
+ # Database Troubleshooting Guide
2
+
3
+ ## Common Issues & Fixes
4
+
5
+ ### 1. Connection Pool Exhaustion in Serverless / Edge
6
+
7
+ - **Cause**: Creating a new PrismaClient / DB connection instance on every serverless function invocation.
8
+ - **Fix**: Declare PrismaClient as a global singleton across warm lambdas, and enable PgBouncer or Prisma Accelerate.
9
+
10
+ ### 2. Slow Queries on Large Tables
11
+
12
+ - **Cause**: Missing composite index on filtered and ordered columns.
13
+ - **Fix**: Run `EXPLAIN ANALYZE <query>` and add targeted indexes matching the WHERE and ORDER BY columns.
14
+
15
+ ### 3. Database Deadlocks during Concurrent Transactions
16
+
17
+ - **Cause**: Different transactions updating resources in different orders.
18
+ - **Fix**: Always acquire locks and update entities in a deterministic alphabetical or ID-ordered sequence.
@@ -0,0 +1,11 @@
1
+ {
2
+ "skill": "database",
3
+ "version": "1.0.0",
4
+ "checks": [
5
+ "No SELECT * in application queries",
6
+ "All foreign keys indexed",
7
+ "Multi-table writes enclosed in database transactions",
8
+ "No N+1 queries in loops",
9
+ "Safe expand-and-contract migration strategy"
10
+ ]
11
+ }
@@ -0,0 +1,25 @@
1
+ name: database
2
+ description: Database architecture, schema design, Prisma, Drizzle ORM, indexing strategies, migrations, and N+1 query resolution.
3
+ version: 1.0.0
4
+ category: backend
5
+ requires:
6
+ - system-design
7
+ - typescript
8
+ triggers:
9
+ files:
10
+ - "*.prisma"
11
+ - "schema.prisma"
12
+ - "drizzle.config.*"
13
+ - "migrations/*"
14
+ - "*.sql"
15
+ keywords:
16
+ - "database"
17
+ - "prisma"
18
+ - "drizzle"
19
+ - "postgres"
20
+ - "postgresql"
21
+ - "sql"
22
+ - "migration"
23
+ - "index"
24
+ - "transaction"
25
+ - "orm"