@caddis/cli 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/bundles/antigravity-plugin/agents/knowledge-transfer.md +17 -32
  2. package/bundles/antigravity-plugin/caddis_statusline.py +25 -3
  3. package/bundles/antigravity-plugin/guard_agy.py +41 -9
  4. package/bundles/antigravity-plugin/plugin.json +1 -1
  5. package/bundles/antigravity-plugin/scripts/caddis_inventory.py +73 -3
  6. package/bundles/antigravity-plugin/scripts/caddis_statusline.py +25 -3
  7. package/bundles/antigravity-plugin/scripts/check_doc_coverage.py +1 -1
  8. package/bundles/antigravity-plugin/scripts/claudster_config.py +0 -5
  9. package/bundles/antigravity-plugin/scripts/hook_log.py +1 -1
  10. package/bundles/antigravity-plugin/scripts/new-machine.ps1 +170 -0
  11. package/bundles/antigravity-plugin/scripts/oss_ask.py +1 -1
  12. package/bundles/antigravity-plugin/scripts/oss_model.py +10 -2
  13. package/bundles/antigravity-plugin/scripts/oss_review.py +1 -1
  14. package/bundles/antigravity-plugin/scripts/setup_project_ai.py +42 -10
  15. package/bundles/antigravity-plugin/session_end_agy.py +31 -6
  16. package/bundles/antigravity-plugin/skills/_registry.md +1 -0
  17. package/bundles/antigravity-plugin/skills/advisory-hub/SKILL.md +44 -0
  18. package/bundles/antigravity-plugin/skills/code-review/SKILL.md +11 -0
  19. package/bundles/antigravity-plugin/skills/feature-plan/SKILL.md +21 -0
  20. package/bundles/antigravity-plugin/skills/gate-review/SKILL.md +11 -0
  21. package/bundles/antigravity-plugin/skills/implement/SKILL.md +36 -0
  22. package/bundles/antigravity-plugin/skills/safe-cleanup/SKILL.md +186 -0
  23. package/bundles/antigravity-plugin/skills/security-review/SKILL.md +9 -0
  24. package/bundles/antigravity-plugin/skills/validate-phase/SKILL.md +31 -0
  25. package/bundles/antigravity-plugin/warm_start_agy.py +96 -9
  26. package/bundles/antigravity-plugin-extras/plugin.json +1 -1
  27. package/bundles/antigravity-plugin-extras/skills/_registry.md +1 -0
  28. package/bundles/antigravity-plugin-extras/skills/safe-cleanup/SKILL.md +186 -0
  29. package/bundles/codex/.codex/config.toml.example +36 -0
  30. package/bundles/codex/.codex/skills/coding/api-design/SKILL.md +249 -0
  31. package/bundles/codex/.codex/skills/coding/backend-development/SKILL.md +305 -0
  32. package/bundles/codex/.codex/skills/coding/code-review/SKILL.md +140 -0
  33. package/bundles/codex/.codex/skills/coding/codebase-audit/SKILL.md +204 -0
  34. package/bundles/codex/.codex/skills/coding/dashboard-perf-sweep/SKILL.md +132 -0
  35. package/bundles/codex/.codex/skills/coding/dashboard-perf-sweep/scripts/perf_sweep.py +249 -0
  36. package/bundles/codex/.codex/skills/coding/error-handling/SKILL.md +260 -0
  37. package/bundles/codex/.codex/skills/coding/fastapi-dev/SKILL.md +300 -0
  38. package/bundles/codex/.codex/skills/coding/javascript-typescript/SKILL.md +142 -0
  39. package/bundles/codex/.codex/skills/coding/python/SKILL.md +388 -0
  40. package/bundles/codex/.codex/skills/coding/refactoring/SKILL.md +486 -0
  41. package/bundles/codex/.codex/skills/coding/security-review/SKILL.md +205 -0
  42. package/bundles/codex/.codex/skills/coding/sql/SKILL.md +321 -0
  43. package/bundles/codex/.codex/skills/data/database-design/SKILL.md +177 -0
  44. package/bundles/codex/.codex/skills/data/db-diagram/SKILL.md +148 -0
  45. package/bundles/codex/.codex/skills/data/db-diagram/scripts/sql_to_graph.py +1212 -0
  46. package/bundles/codex/.codex/skills/devops/ci-cd-pipeline/SKILL.md +315 -0
  47. package/bundles/codex/.codex/skills/devops/gh-cli/SKILL.md +195 -0
  48. package/bundles/codex/.codex/skills/devops/git-commit/SKILL.md +285 -0
  49. package/bundles/codex/.codex/skills/devops/safe-cleanup/SKILL.md +186 -0
  50. package/bundles/codex/.codex/skills/devops/using-git-worktrees/SKILL.md +217 -0
  51. package/bundles/codex/.codex/skills/devops/windows-deployment/SKILL.md +880 -0
  52. package/bundles/codex/.codex/skills/docs/code-documentation/SKILL.md +271 -0
  53. package/bundles/codex/.codex/skills/docs/explainer-doc/SKILL.md +97 -0
  54. package/bundles/codex/.codex/skills/docs/technical-writing/SKILL.md +286 -0
  55. package/bundles/codex/.codex/skills/docs/writing-plans/SKILL.md +387 -0
  56. package/bundles/codex/.codex/skills/frontend/css-architecture/SKILL.md +305 -0
  57. package/bundles/codex/.codex/skills/frontend/css-architecture/references/RESPONSIVE-DESIGN.md +604 -0
  58. package/bundles/codex/.codex/skills/frontend/frontend-design/SKILL.md +193 -0
  59. package/bundles/codex/.codex/skills/frontend/frontend-design/references/my-tech-stack.md +127 -0
  60. package/bundles/codex/.codex/skills/frontend/mockup/SKILL.md +242 -0
  61. package/bundles/codex/.codex/skills/frontend/react-best-practices/SKILL.md +269 -0
  62. package/bundles/codex/.codex/skills/frontend/react-dev/README.md +404 -0
  63. package/bundles/codex/.codex/skills/frontend/react-dev/SKILL.md +459 -0
  64. package/bundles/codex/.codex/skills/frontend/react-dev/examples/generic-components.md +579 -0
  65. package/bundles/codex/.codex/skills/frontend/react-dev/examples/server-components.md +579 -0
  66. package/bundles/codex/.codex/skills/frontend/react-dev/references/event-handlers.md +574 -0
  67. package/bundles/codex/.codex/skills/frontend/react-dev/references/hooks.md +456 -0
  68. package/bundles/codex/.codex/skills/frontend/react-dev/references/react-19-patterns.md +638 -0
  69. package/bundles/codex/.codex/skills/frontend/react-dev/references/react-router.md +1002 -0
  70. package/bundles/codex/.codex/skills/frontend/react-dev/references/tanstack-router.md +587 -0
  71. package/bundles/codex/.codex/skills/frontend/ui-review/SKILL.md +176 -0
  72. package/bundles/codex/.codex/skills/frontend/ui-review/references/framework-fixes.md +471 -0
  73. package/bundles/codex/.codex/skills/frontend/ui-review/references/visual-checklist.md +236 -0
  74. package/bundles/codex/.codex/skills/frontend/warm-editorial-ui/DESIGN_TOKENS.md +487 -0
  75. package/bundles/codex/.codex/skills/frontend/warm-editorial-ui/IMPLEMENTATION_GUIDE.md +177 -0
  76. package/bundles/codex/.codex/skills/frontend/warm-editorial-ui/SKILL.md +732 -0
  77. package/bundles/codex/.codex/skills/media/draw-io/SKILL.md +162 -0
  78. package/bundles/codex/.codex/skills/media/draw-io/references/aws-icons.md +677 -0
  79. package/bundles/codex/.codex/skills/media/draw-io/references/layout-guidelines.md +142 -0
  80. package/bundles/codex/.codex/skills/media/draw-io/references/troubleshooting.md +118 -0
  81. package/bundles/codex/.codex/skills/media/draw-io/references/workflows.md +103 -0
  82. package/bundles/codex/.codex/skills/media/draw-io/scripts/convert-drawio-to-png.sh +25 -0
  83. package/bundles/codex/.codex/skills/media/draw-io/scripts/find_aws_icon.py +79 -0
  84. package/bundles/codex/.codex/skills/media/mermaid-diagrams/SKILL.md +292 -0
  85. package/bundles/codex/.codex/skills/media/mermaid-diagrams/references/ENHANCEMENTS.md +264 -0
  86. package/bundles/codex/.codex/skills/media/mermaid-diagrams/references/MERMAID-SUMMARY.md +137 -0
  87. package/bundles/codex/.codex/skills/media/mermaid-diagrams/references/advanced-features.md +556 -0
  88. package/bundles/codex/.codex/skills/media/mermaid-diagrams/references/architecture-diagrams.md +192 -0
  89. package/bundles/codex/.codex/skills/media/mermaid-diagrams/references/c4-diagrams.md +410 -0
  90. package/bundles/codex/.codex/skills/media/mermaid-diagrams/references/class-diagrams.md +361 -0
  91. package/bundles/codex/.codex/skills/media/mermaid-diagrams/references/erd-diagrams.md +510 -0
  92. package/bundles/codex/.codex/skills/media/mermaid-diagrams/references/flowcharts.md +450 -0
  93. package/bundles/codex/.codex/skills/media/mermaid-diagrams/references/sequence-diagrams.md +394 -0
  94. package/bundles/codex/.codex/skills/media/mermaid-diagrams/references/troubleshooting.md +335 -0
  95. package/bundles/codex/.codex/skills/media/mermaid-diagrams/references/workflows.md +418 -0
  96. package/bundles/codex/.codex/skills/media/particle-art/SKILL.md +243 -0
  97. package/bundles/codex/.codex/skills/media/particle-art/references/canvas-utils.ts +171 -0
  98. package/bundles/codex/.codex/skills/media/particle-art/references/dot-field.template.tsx +203 -0
  99. package/bundles/codex/.codex/skills/media/particle-art/references/flow-field.template.tsx +263 -0
  100. package/bundles/codex/.codex/skills/media/particle-art/references/node-shape.template.tsx +261 -0
  101. package/bundles/codex/.codex/skills/media/particle-art/references/shape-sampler.ts +281 -0
  102. package/bundles/codex/.codex/skills/media/particle-art/references/stipple-morph.template.tsx +167 -0
  103. package/bundles/codex/.codex/skills/media/particle-art/references/stipple.template.tsx +175 -0
  104. package/bundles/codex/.codex/skills/media/particle-art/references/trail-ghost.template.tsx +266 -0
  105. package/bundles/codex/.codex/skills/media/particle-art/references/usage-examples.md +320 -0
  106. package/bundles/codex/.codex/skills/testing/playwright/API_REFERENCE.md +653 -0
  107. package/bundles/codex/.codex/skills/testing/playwright/SKILL.md +454 -0
  108. package/bundles/codex/.codex/skills/testing/playwright/lib/helpers.js +441 -0
  109. package/bundles/codex/.codex/skills/testing/playwright/package.json +26 -0
  110. package/bundles/codex/.codex/skills/testing/playwright/run.js +228 -0
  111. package/bundles/codex/.codex/skills/testing/tdd-workflow/SKILL.md +188 -0
  112. package/bundles/codex/.codex/skills/testing/test-strategy/SKILL.md +155 -0
  113. package/bundles/codex/.codex/skills/testing/webapp-testing/LICENSE.txt +202 -0
  114. package/bundles/codex/.codex/skills/testing/webapp-testing/SKILL.md +97 -0
  115. package/bundles/codex/.codex/skills/testing/webapp-testing/examples/console_logging.py +35 -0
  116. package/bundles/codex/.codex/skills/testing/webapp-testing/examples/element_discovery.py +40 -0
  117. package/bundles/codex/.codex/skills/testing/webapp-testing/examples/static_html_automation.py +33 -0
  118. package/bundles/codex/.codex/skills/testing/webapp-testing/scripts/with_server.py +106 -0
  119. package/bundles/codex/.codex/skills/workflow/advisory-hub/SKILL.md +227 -0
  120. package/bundles/codex/.codex/skills/workflow/advisory-hub/reference/context-template.md +214 -0
  121. package/bundles/codex/.codex/skills/workflow/advisory-hub/reference/hub-handbook.md +233 -0
  122. package/bundles/codex/.codex/skills/workflow/advisory-hub/reference/report-contract.md +94 -0
  123. package/bundles/codex/.codex/skills/workflow/advisory-hub/reference/succession.md +118 -0
  124. package/bundles/codex/.codex/skills/workflow/best-practices/SKILL.md +500 -0
  125. package/bundles/codex/.codex/skills/workflow/best-practices/agents/best-practices-referencer.md +263 -0
  126. package/bundles/codex/.codex/skills/workflow/best-practices/agents/codebase-context-builder.md +326 -0
  127. package/bundles/codex/.codex/skills/workflow/best-practices/agents/task-intent-analyzer.md +245 -0
  128. package/bundles/codex/.codex/skills/workflow/best-practices/references/anti-patterns.md +571 -0
  129. package/bundles/codex/.codex/skills/workflow/best-practices/references/before-after-examples.md +1114 -0
  130. package/bundles/codex/.codex/skills/workflow/best-practices/references/best-practices-guide.md +513 -0
  131. package/bundles/codex/.codex/skills/workflow/best-practices/references/common-workflows.md +692 -0
  132. package/bundles/codex/.codex/skills/workflow/best-practices/references/prompt-patterns.md +547 -0
  133. package/bundles/codex/.codex/skills/workflow/brainstorming/SKILL.md +57 -0
  134. package/bundles/codex/.codex/skills/workflow/context-curator/SKILL.md +157 -0
  135. package/bundles/codex/.codex/skills/workflow/golden-plan/SKILL.md +586 -0
  136. package/bundles/codex/.codex/skills/workflow/preflight/SKILL.md +440 -0
  137. package/bundles/codex/.codex/skills/workflow/skill-creator/LICENSE.txt +202 -0
  138. package/bundles/codex/.codex/skills/workflow/skill-creator/SKILL.md +491 -0
  139. package/bundles/codex/.codex/skills/workflow/skill-creator/agents/analyzer.md +274 -0
  140. package/bundles/codex/.codex/skills/workflow/skill-creator/agents/comparator.md +202 -0
  141. package/bundles/codex/.codex/skills/workflow/skill-creator/agents/grader.md +223 -0
  142. package/bundles/codex/.codex/skills/workflow/skill-creator/assets/eval_review.html +146 -0
  143. package/bundles/codex/.codex/skills/workflow/skill-creator/eval-viewer/generate_review.py +471 -0
  144. package/bundles/codex/.codex/skills/workflow/skill-creator/eval-viewer/viewer.html +1325 -0
  145. package/bundles/codex/.codex/skills/workflow/skill-creator/references/schemas.md +430 -0
  146. package/bundles/codex/.codex/skills/workflow/skill-creator/scripts/__init__.py +0 -0
  147. package/bundles/codex/.codex/skills/workflow/skill-creator/scripts/aggregate_benchmark.py +401 -0
  148. package/bundles/codex/.codex/skills/workflow/skill-creator/scripts/generate_report.py +326 -0
  149. package/bundles/codex/.codex/skills/workflow/skill-creator/scripts/improve_description.py +247 -0
  150. package/bundles/codex/.codex/skills/workflow/skill-creator/scripts/package_skill.py +136 -0
  151. package/bundles/codex/.codex/skills/workflow/skill-creator/scripts/quick_validate.py +103 -0
  152. package/bundles/codex/.codex/skills/workflow/skill-creator/scripts/run_eval.py +310 -0
  153. package/bundles/codex/.codex/skills/workflow/skill-creator/scripts/run_loop.py +328 -0
  154. package/bundles/codex/.codex/skills/workflow/skill-creator/scripts/utils.py +47 -0
  155. package/bundles/codex/AGENTS.md +146 -0
  156. package/bundles/manifest.json +4 -3
  157. package/dist/claude-deepseek.js +2 -2
  158. package/dist/claude-glm.js +2 -2
  159. package/dist/claude-oss.js +2 -2
  160. package/dist/cli.js +187 -56
  161. package/package.json +1 -1
  162. package/bundles/antigravity-plugin/scripts/dream_capture.py +0 -249
  163. package/bundles/antigravity-plugin/scripts/dream_memory.py +0 -438
  164. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/ArsenalSC-OFL.txt +0 -93
  165. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/ArsenalSC-Regular.ttf +0 -0
  166. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/BigShoulders-Bold.ttf +0 -0
  167. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/BigShoulders-OFL.txt +0 -93
  168. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/BigShoulders-Regular.ttf +0 -0
  169. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/Boldonse-OFL.txt +0 -93
  170. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/Boldonse-Regular.ttf +0 -0
  171. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/BricolageGrotesque-Bold.ttf +0 -0
  172. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/BricolageGrotesque-OFL.txt +0 -93
  173. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/BricolageGrotesque-Regular.ttf +0 -0
  174. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/CrimsonPro-Bold.ttf +0 -0
  175. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/CrimsonPro-Italic.ttf +0 -0
  176. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/CrimsonPro-OFL.txt +0 -93
  177. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/CrimsonPro-Regular.ttf +0 -0
  178. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/DMMono-OFL.txt +0 -93
  179. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/DMMono-Regular.ttf +0 -0
  180. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/EricaOne-OFL.txt +0 -94
  181. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/EricaOne-Regular.ttf +0 -0
  182. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/GeistMono-Bold.ttf +0 -0
  183. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/GeistMono-OFL.txt +0 -93
  184. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/GeistMono-Regular.ttf +0 -0
  185. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/Gloock-OFL.txt +0 -93
  186. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/Gloock-Regular.ttf +0 -0
  187. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/IBMPlexMono-Bold.ttf +0 -0
  188. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/IBMPlexMono-OFL.txt +0 -93
  189. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/IBMPlexMono-Regular.ttf +0 -0
  190. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/IBMPlexSerif-Bold.ttf +0 -0
  191. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/IBMPlexSerif-BoldItalic.ttf +0 -0
  192. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/IBMPlexSerif-Italic.ttf +0 -0
  193. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/IBMPlexSerif-Regular.ttf +0 -0
  194. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/InstrumentSans-Bold.ttf +0 -0
  195. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/InstrumentSans-BoldItalic.ttf +0 -0
  196. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/InstrumentSans-Italic.ttf +0 -0
  197. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/InstrumentSans-OFL.txt +0 -93
  198. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/InstrumentSans-Regular.ttf +0 -0
  199. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/InstrumentSerif-Italic.ttf +0 -0
  200. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/InstrumentSerif-Regular.ttf +0 -0
  201. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/Italiana-OFL.txt +0 -93
  202. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/Italiana-Regular.ttf +0 -0
  203. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/JetBrainsMono-Bold.ttf +0 -0
  204. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/JetBrainsMono-OFL.txt +0 -93
  205. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/JetBrainsMono-Regular.ttf +0 -0
  206. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/Jura-Light.ttf +0 -0
  207. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/Jura-Medium.ttf +0 -0
  208. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/Jura-OFL.txt +0 -93
  209. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/LibreBaskerville-OFL.txt +0 -93
  210. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/LibreBaskerville-Regular.ttf +0 -0
  211. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/Lora-Bold.ttf +0 -0
  212. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/Lora-BoldItalic.ttf +0 -0
  213. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/Lora-Italic.ttf +0 -0
  214. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/Lora-OFL.txt +0 -93
  215. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/Lora-Regular.ttf +0 -0
  216. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/NationalPark-Bold.ttf +0 -0
  217. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/NationalPark-OFL.txt +0 -93
  218. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/NationalPark-Regular.ttf +0 -0
  219. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/NothingYouCouldDo-OFL.txt +0 -93
  220. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/NothingYouCouldDo-Regular.ttf +0 -0
  221. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/Outfit-Bold.ttf +0 -0
  222. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/Outfit-OFL.txt +0 -93
  223. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/Outfit-Regular.ttf +0 -0
  224. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/PixelifySans-Medium.ttf +0 -0
  225. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/PixelifySans-OFL.txt +0 -93
  226. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/PoiretOne-OFL.txt +0 -93
  227. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/PoiretOne-Regular.ttf +0 -0
  228. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/RedHatMono-Bold.ttf +0 -0
  229. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/RedHatMono-OFL.txt +0 -93
  230. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/RedHatMono-Regular.ttf +0 -0
  231. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/Silkscreen-OFL.txt +0 -93
  232. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/Silkscreen-Regular.ttf +0 -0
  233. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/SmoochSans-Medium.ttf +0 -0
  234. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/SmoochSans-OFL.txt +0 -93
  235. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/Tektur-Medium.ttf +0 -0
  236. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/Tektur-OFL.txt +0 -93
  237. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/Tektur-Regular.ttf +0 -0
  238. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/WorkSans-Bold.ttf +0 -0
  239. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/WorkSans-BoldItalic.ttf +0 -0
  240. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/WorkSans-Italic.ttf +0 -0
  241. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/WorkSans-OFL.txt +0 -93
  242. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/WorkSans-Regular.ttf +0 -0
  243. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/YoungSerif-OFL.txt +0 -93
  244. package/bundles/antigravity-plugin-extras/skills/canvas-design/canvas-fonts/YoungSerif-Regular.ttf +0 -0
@@ -0,0 +1,321 @@
1
+ ---
2
+ name: sql
3
+ description: Write high-quality, optimized SQL with best practices for performance, NULL handling, security, and readability. Database-agnostic patterns with dialect-specific notes.
4
+ ---
5
+
6
+ # SQL Expert Skill
7
+
8
+ Write high-quality, optimized SQL for enterprise environments. Covers performance, edge cases, and real-world gotchas.
9
+
10
+ ## When to Use
11
+
12
+ - Writing new SQL queries
13
+ - Optimizing existing queries
14
+ - Handling large datasets (100K+ rows)
15
+ - Creating stored procedures or views
16
+ - Debugging slow queries
17
+
18
+ ---
19
+
20
+ ## SQL Quality Standards
21
+
22
+ ### 1. Always Include Comments
23
+
24
+ ```sql
25
+ -- Get open orders with SLA breach risk
26
+ -- Filters: Last 7 days, excludes test data
27
+ -- Expected rows: ~500-2000
28
+ SELECT
29
+ OrderID,
30
+ CustomerName,
31
+ DATEDIFF(HOUR, CreatedAt, GETDATE()) AS hours_open
32
+ FROM Orders
33
+ WHERE CreatedAt >= DATEADD(DAY, -7, GETDATE())
34
+ AND Status = 'Open'
35
+ ORDER BY hours_open DESC;
36
+ ```
37
+
38
+ ### 2. Readable Formatting
39
+
40
+ ```sql
41
+ SELECT
42
+ o.OrderID,
43
+ o.CustomerName,
44
+ o.Status,
45
+ COUNT(i.ItemID) AS item_count
46
+ FROM Orders o
47
+ LEFT JOIN OrderItems i ON o.OrderID = i.OrderID
48
+ WHERE o.Status = 'Open'
49
+ GROUP BY o.OrderID, o.CustomerName, o.Status
50
+ HAVING COUNT(i.ItemID) > 0
51
+ ORDER BY item_count DESC;
52
+ ```
53
+
54
+ ---
55
+
56
+ ## Large Dataset Patterns
57
+
58
+ ### Pagination
59
+
60
+ ```sql
61
+ -- OFFSET-FETCH (SQL Server 2012+ / PostgreSQL)
62
+ SELECT OrderID, CustomerName, Status
63
+ FROM Orders
64
+ WHERE Status = 'Open'
65
+ ORDER BY CreatedAt DESC
66
+ OFFSET 50 ROWS FETCH NEXT 25 ROWS ONLY;
67
+
68
+ -- Keyset pagination (faster for deep pages)
69
+ SELECT TOP 25 OrderID, CustomerName, CreatedAt
70
+ FROM Orders
71
+ WHERE CreatedAt < @lastSeenDate AND Status = 'Open'
72
+ ORDER BY CreatedAt DESC;
73
+ ```
74
+
75
+ ### Batching Large Operations
76
+
77
+ ```sql
78
+ DECLARE @BatchSize INT = 5000;
79
+ DECLARE @RowsAffected INT = 1;
80
+
81
+ WHILE @RowsAffected > 0
82
+ BEGIN
83
+ UPDATE TOP (@BatchSize) Orders
84
+ SET ProcessedFlag = 1
85
+ WHERE Status = 'Closed' AND ProcessedFlag = 0;
86
+ SET @RowsAffected = @@ROWCOUNT;
87
+ WAITFOR DELAY '00:00:00.100';
88
+ END
89
+ ```
90
+
91
+ ---
92
+
93
+ ## NULL Handling
94
+
95
+ ```sql
96
+ -- Use IS NULL (not = NULL)
97
+ SELECT * FROM Orders WHERE Category IS NULL;
98
+
99
+ -- ISNULL (SQL Server) vs COALESCE (ANSI standard)
100
+ SELECT ISNULL(Category, 'Unknown') FROM Orders;
101
+ SELECT COALESCE(Category, SubCategory, 'Unknown') FROM Orders;
102
+
103
+ -- NULL in aggregations: COUNT(*) counts all, COUNT(col) excludes NULLs
104
+ SELECT COUNT(*) AS total, COUNT(Category) AS non_null FROM Orders;
105
+ SELECT ISNULL(SUM(Amount), 0) AS total FROM Orders;
106
+ ```
107
+
108
+ ---
109
+
110
+ ## Performance Killers to Avoid
111
+
112
+ 1. **Implicit type conversions** -- match parameter types to column types
113
+ 2. **Functions on indexed columns** -- rewrite `WHERE YEAR(date) = 2026` as range
114
+ 3. **OR conditions** -- consider UNION ALL for index use
115
+ 4. **SELECT DISTINCT on large sets** -- use GROUP BY or EXISTS
116
+ 5. **UNION vs UNION ALL** -- use UNION ALL when duplicates are OK
117
+
118
+ ---
119
+
120
+ ## Window Functions
121
+
122
+ ```sql
123
+ -- Running totals
124
+ SELECT OrderID, CreatedAt,
125
+ COUNT(*) OVER (ORDER BY CreatedAt) AS running_count,
126
+ SUM(Amount) OVER (ORDER BY CreatedAt) AS running_total
127
+ FROM Orders;
128
+
129
+ -- Latest record per group
130
+ WITH ranked AS (
131
+ SELECT *, ROW_NUMBER() OVER (PARTITION BY CustomerID ORDER BY CreatedAt DESC) AS rn
132
+ FROM Orders
133
+ )
134
+ SELECT * FROM ranked WHERE rn = 1;
135
+ ```
136
+
137
+ ---
138
+
139
+ ## Error Handling
140
+
141
+ ```sql
142
+ BEGIN TRY
143
+ BEGIN TRANSACTION;
144
+ UPDATE Orders SET Status = 'Processed' WHERE OrderID = @OrderID;
145
+ IF @@ROWCOUNT = 0 THROW 50001, 'Order not found', 1;
146
+ COMMIT;
147
+ END TRY
148
+ BEGIN CATCH
149
+ IF @@TRANCOUNT > 0 ROLLBACK;
150
+ DECLARE @ErrorMsg NVARCHAR(4000) = ERROR_MESSAGE();
151
+ RAISERROR(@ErrorMsg, ERROR_SEVERITY(), ERROR_STATE());
152
+ END CATCH;
153
+ ```
154
+
155
+ ---
156
+
157
+ ## Security (CRITICAL)
158
+
159
+ ```sql
160
+ -- NEVER concatenate user input
161
+ -- Always use parameterized queries
162
+ EXEC sp_executesql N'SELECT * FROM Orders WHERE OrderID = @id',
163
+ N'@id UNIQUEIDENTIFIER', @id = @orderId;
164
+ ```
165
+
166
+ ```python
167
+ # Python: always parameterized
168
+ query = "SELECT * FROM Orders WHERE Status = ?"
169
+ result = adapter.fetch_dataframe(query, (user_input,))
170
+ ```
171
+
172
+ ---
173
+
174
+ ## EXISTS vs IN vs JOIN
175
+
176
+ ```sql
177
+ -- EXISTS: Best for "does any match exist?" - stops at first match
178
+ SELECT * FROM Customers c
179
+ WHERE EXISTS (SELECT 1 FROM Orders WHERE CustomerID = c.CustomerID);
180
+
181
+ -- IN: Good for small lists, can be slow with NULLs in subquery
182
+ SELECT * FROM Orders WHERE CustomerID IN ('CUST001', 'CUST002', 'CUST003');
183
+
184
+ -- ⚠️ IN with subquery containing NULLs can return unexpected results
185
+ SELECT * FROM Orders
186
+ WHERE CustomerID IN (SELECT CustomerID FROM FlaggedCustomers); -- If NULL in subquery, watch out!
187
+
188
+ -- JOIN: Best when you need columns from both tables
189
+ SELECT c.*, o.OrderID
190
+ FROM Customers c
191
+ INNER JOIN Orders o ON c.CustomerID = o.CustomerID;
192
+ ```
193
+
194
+ ---
195
+
196
+ ## Concurrency & Locking
197
+
198
+ ### Read Patterns
199
+
200
+ ```sql
201
+ -- For reports/dashboards (OK with slightly stale data)
202
+ SELECT * FROM Orders WITH (NOLOCK) -- Dirty reads, but no blocking
203
+ WHERE Status = 'Open';
204
+
205
+ -- ⚠️ NOLOCK risks:
206
+ -- - Can read uncommitted data (that might roll back)
207
+ -- - Can read rows twice or skip rows during scans
208
+ -- Only use for approximate counts, dashboards, reports
209
+
210
+ -- For accurate reads that shouldn't block
211
+ SET TRANSACTION ISOLATION LEVEL READ COMMITTED SNAPSHOT;
212
+ -- Requires database setting: ALTER DATABASE [DB] SET READ_COMMITTED_SNAPSHOT ON;
213
+ ```
214
+
215
+ ### Deadlock Prevention
216
+
217
+ ```sql
218
+ -- ✅ Always access tables in same order across all processes
219
+ -- ✅ Keep transactions short
220
+
221
+ BEGIN TRANSACTION;
222
+ UPDATE Orders SET Status = 'Processed' WHERE OrderID = @id;
223
+ COMMIT;
224
+ ```
225
+
226
+ ---
227
+
228
+ ## Temp Tables vs Table Variables
229
+
230
+ ```sql
231
+ -- TEMP TABLES: Better for large datasets (has statistics)
232
+ CREATE TABLE #TempOrders (
233
+ OrderID VARCHAR(50),
234
+ CustomerID VARCHAR(50),
235
+ INDEX IX_Temp_CustomerID (CustomerID)
236
+ );
237
+ INSERT INTO #TempOrders SELECT OrderID, CustomerID FROM Orders WHERE Status = 'Open';
238
+ SELECT * FROM #TempOrders t JOIN Customers c ON t.CustomerID = c.CustomerID;
239
+ DROP TABLE #TempOrders;
240
+
241
+ -- TABLE VARIABLES: Better for small datasets (<1000 rows)
242
+ DECLARE @Orders TABLE (OrderID VARCHAR(50), CustomerID VARCHAR(50));
243
+ INSERT INTO @Orders SELECT OrderID, CustomerID FROM Orders WHERE Status = 'Closed';
244
+ -- ⚠️ Table variables assume 1 row for optimization - bad for large sets
245
+ ```
246
+
247
+ ---
248
+
249
+ ## Date/Time Gotchas
250
+
251
+ ```sql
252
+ -- ❌ BAD: String comparison for dates (locale issues)
253
+ SELECT * FROM Orders WHERE CreatedAt > '01/02/2026'; -- Jan 2 or Feb 1?
254
+
255
+ -- ✅ GOOD: Use unambiguous ISO format
256
+ SELECT * FROM Orders WHERE CreatedAt > '2026-01-02';
257
+
258
+ -- Date range queries (include full day)
259
+ -- ❌ WRONG: BETWEEN misses end-of-day records
260
+ SELECT * FROM Orders WHERE CreatedAt BETWEEN '2026-01-01' AND '2026-01-31';
261
+
262
+ -- ✅ CORRECT: Use < next day
263
+ SELECT * FROM Orders
264
+ WHERE CreatedAt >= '2026-01-01' AND CreatedAt < '2026-02-01';
265
+
266
+ -- Get date part only (for grouping)
267
+ SELECT CAST(CreatedAt AS DATE) AS created_date, COUNT(*) AS daily_count
268
+ FROM Orders GROUP BY CAST(CreatedAt AS DATE);
269
+ ```
270
+
271
+ ---
272
+
273
+ ## Query Complexity Guidelines
274
+
275
+ | Guideline | Threshold | If Exceeded |
276
+ |-----------|-----------|-------------|
277
+ | Max JOINs | 3-4 | Create VIEW or break into CTEs |
278
+ | Max subqueries | 2 levels | Use CTEs instead |
279
+ | Max CASE statements | 3-4 | Move logic to application layer |
280
+ | Max columns | 15-20 | Consider if all are needed |
281
+
282
+ ### CTEs for Complex Logic
283
+
284
+ ```sql
285
+ WITH open_orders AS (
286
+ SELECT OrderID, CustomerID, CreatedAt FROM Orders WHERE Status = 'Open'
287
+ ),
288
+ order_metrics AS (
289
+ SELECT o.OrderID, COUNT(i.ItemID) AS item_count, MAX(i.UpdatedAt) AS last_update
290
+ FROM open_orders o
291
+ LEFT JOIN OrderItems i ON o.OrderID = i.OrderID
292
+ GROUP BY o.OrderID
293
+ )
294
+ SELECT * FROM order_metrics WHERE item_count > 5;
295
+ ```
296
+
297
+ ---
298
+
299
+ ## Execution Plan Red Flags
300
+
301
+ | Warning | Meaning | Fix |
302
+ |---------|---------|-----|
303
+ | Table Scan | No index used | Add index or fix WHERE clause |
304
+ | Key Lookup | Extra I/O for non-covered columns | Add columns to index or use covering index |
305
+ | CONVERT_IMPLICIT | Type mismatch causing conversion | Match parameter types to column types |
306
+ | Sort (high cost) | Sorting large dataset | Add index that matches ORDER BY |
307
+ | Hash Match | Large join, possibly missing index | Add indexes on join columns |
308
+ | Parallelism | Query is complex/large | May be OK, but check if needed |
309
+
310
+ ---
311
+
312
+ ## Performance Checklist
313
+
314
+ - [ ] Only selecting needed columns (no SELECT *)
315
+ - [ ] Filtering in WHERE, not application code
316
+ - [ ] JOINs on indexed columns
317
+ - [ ] No functions on indexed columns in WHERE
318
+ - [ ] Types match (no implicit conversions)
319
+ - [ ] Parameterized (no string concatenation)
320
+ - [ ] Pagination for large result sets
321
+ - [ ] Comments explain purpose and expected volume
@@ -0,0 +1,177 @@
1
+ ---
2
+ name: database-design
3
+ description: Database schema design, optimization, and migration patterns for PostgreSQL, MySQL, and NoSQL databases. Use for designing schemas, writing migrations, or optimizing queries.
4
+ source: wshobson/agents
5
+ license: MIT
6
+ ---
7
+
8
+ # Database Design
9
+
10
+ ## Schema Design Principles
11
+
12
+ ### Normalization Guidelines
13
+ ```sql
14
+ -- 1NF: Atomic values, no repeating groups
15
+ -- 2NF: No partial dependencies on composite keys
16
+ -- 3NF: No transitive dependencies
17
+
18
+ -- Users table (normalized)
19
+ CREATE TABLE users (
20
+ id SERIAL PRIMARY KEY,
21
+ email VARCHAR(255) UNIQUE NOT NULL,
22
+ created_at TIMESTAMPTZ DEFAULT NOW()
23
+ );
24
+
25
+ -- Addresses table (separate entity)
26
+ CREATE TABLE addresses (
27
+ id SERIAL PRIMARY KEY,
28
+ user_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
29
+ street VARCHAR(255),
30
+ city VARCHAR(100),
31
+ country VARCHAR(100),
32
+ is_primary BOOLEAN DEFAULT false
33
+ );
34
+ ```
35
+
36
+ ### Denormalization for Performance
37
+ ```sql
38
+ -- When read performance matters more than write consistency
39
+ CREATE TABLE order_summaries (
40
+ id SERIAL PRIMARY KEY,
41
+ order_id INTEGER REFERENCES orders(id),
42
+ customer_name VARCHAR(255), -- Denormalized from customers
43
+ total_amount DECIMAL(10,2),
44
+ item_count INTEGER,
45
+ last_updated TIMESTAMPTZ DEFAULT NOW()
46
+ );
47
+ ```
48
+
49
+ ## Index Design
50
+
51
+ ### Common Index Patterns
52
+ ```sql
53
+ -- B-tree (default) for equality and range queries
54
+ CREATE INDEX idx_users_email ON users(email);
55
+
56
+ -- Composite index (order matters!)
57
+ CREATE INDEX idx_orders_user_date ON orders(user_id, created_at DESC);
58
+
59
+ -- Partial index for specific conditions
60
+ CREATE INDEX idx_active_users ON users(email) WHERE deleted_at IS NULL;
61
+
62
+ -- GIN index for array/JSONB columns
63
+ CREATE INDEX idx_posts_tags ON posts USING GIN(tags);
64
+
65
+ -- Covering index (includes additional columns)
66
+ CREATE INDEX idx_orders_covering ON orders(user_id) INCLUDE (total, status);
67
+ ```
68
+
69
+ ### Index Analysis
70
+ ```sql
71
+ -- Check index usage
72
+ SELECT
73
+ schemaname, tablename, indexname,
74
+ idx_scan, idx_tup_read, idx_tup_fetch
75
+ FROM pg_stat_user_indexes
76
+ ORDER BY idx_scan DESC;
77
+
78
+ -- Find missing indexes
79
+ SELECT
80
+ relname, seq_scan, seq_tup_read,
81
+ idx_scan, idx_tup_fetch
82
+ FROM pg_stat_user_tables
83
+ WHERE seq_scan > idx_scan
84
+ ORDER BY seq_tup_read DESC;
85
+ ```
86
+
87
+ ## Migration Patterns
88
+
89
+ ### Safe Migration Template
90
+ ```sql
91
+ -- Always use transactions
92
+ BEGIN;
93
+
94
+ -- Add column with default (non-blocking in PG 11+)
95
+ ALTER TABLE users ADD COLUMN status VARCHAR(20) DEFAULT 'active';
96
+
97
+ -- Create index concurrently (doesn't lock table)
98
+ CREATE INDEX CONCURRENTLY idx_users_status ON users(status);
99
+
100
+ -- Backfill data in batches
101
+ UPDATE users SET status = 'active' WHERE status IS NULL AND id BETWEEN 1 AND 10000;
102
+
103
+ COMMIT;
104
+ ```
105
+
106
+ ### Zero-Downtime Migrations
107
+ ```
108
+ 1. Add new column (nullable)
109
+ 2. Deploy code that writes to both columns
110
+ 3. Backfill old data
111
+ 4. Deploy code that reads from new column
112
+ 5. Remove old column
113
+ ```
114
+
115
+ ## Query Optimization
116
+
117
+ ### EXPLAIN Analysis
118
+ ```sql
119
+ -- Always use EXPLAIN ANALYZE
120
+ EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT)
121
+ SELECT * FROM orders WHERE user_id = 123 AND status = 'pending';
122
+
123
+ -- Key metrics to watch:
124
+ -- - Seq Scan vs Index Scan
125
+ -- - Actual rows vs Estimated rows
126
+ -- - Buffers: shared hit vs read
127
+ ```
128
+
129
+ ### Common Optimizations
130
+ ```sql
131
+ -- Use EXISTS instead of IN for large sets
132
+ SELECT * FROM users u
133
+ WHERE EXISTS (SELECT 1 FROM orders o WHERE o.user_id = u.id);
134
+
135
+ -- Pagination with keyset (cursor) instead of OFFSET
136
+ SELECT * FROM posts
137
+ WHERE created_at < '2024-01-01'
138
+ ORDER BY created_at DESC
139
+ LIMIT 20;
140
+
141
+ -- Use CTEs for complex queries
142
+ WITH active_users AS (
143
+ SELECT id FROM users WHERE last_login > NOW() - INTERVAL '30 days'
144
+ )
145
+ SELECT * FROM orders WHERE user_id IN (SELECT id FROM active_users);
146
+ ```
147
+
148
+ ## Constraints & Data Integrity
149
+
150
+ ```sql
151
+ -- Primary key
152
+ ALTER TABLE users ADD PRIMARY KEY (id);
153
+
154
+ -- Foreign key with cascade
155
+ ALTER TABLE orders ADD CONSTRAINT fk_orders_user
156
+ FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
157
+
158
+ -- Check constraint
159
+ ALTER TABLE products ADD CONSTRAINT chk_price_positive
160
+ CHECK (price >= 0);
161
+
162
+ -- Unique constraint
163
+ ALTER TABLE users ADD CONSTRAINT uniq_users_email UNIQUE (email);
164
+
165
+ -- Exclusion constraint (no overlapping ranges)
166
+ ALTER TABLE reservations ADD CONSTRAINT excl_no_overlap
167
+ EXCLUDE USING gist (room_id WITH =, tsrange(start_time, end_time) WITH &&);
168
+ ```
169
+
170
+ ## Best Practices
171
+
172
+ - Use UUIDs for public-facing IDs, SERIAL/BIGSERIAL for internal
173
+ - Always add `created_at` and `updated_at` timestamps
174
+ - Use soft deletes (`deleted_at`) for important data
175
+ - Design for eventual consistency in distributed systems
176
+ - Document schema decisions in migration files
177
+ - Test migrations on production-size data before deploying
@@ -0,0 +1,148 @@
1
+ ---
2
+ name: db-diagram
3
+ context: fork
4
+ description: Turn a SQL artifact — a stored procedure, view, query, .sql file, or table name — into a diagram that explains it to a human. Use when the user says "diagram this query/proc/view/schema", "explain this SQL visually", "draw the ER diagram", "show me the data flow of this stored proc", "/mermaid-db", or "/excalidraw-db". Produces Mermaid (default, git-diffable) or Excalidraw (for design reviews). Read-only — never touches the database.
5
+ ---
6
+
7
+ # db-diagram — explain SQL as a diagram
8
+
9
+ Take a SQL artifact and produce a diagram that explains it to a human. Two output formats, one shared
10
+ extraction: **Mermaid** (default — plain text, diffs cleanly, renders in VS Code/Gitea, regenerable) and
11
+ **Excalidraw** (for a design review / ARB pack / slide — someone drags boxes around).
12
+
13
+ The structure is extracted **deterministically** by `scripts/sql_to_graph.py` (a real sqlglot-based
14
+ parser); you (the model) add the **business narration** on top. Never hand-derive the node graph when the
15
+ script can run — its whole value is reproducibility.
16
+
17
+ ## Two non-negotiable safety rules
18
+
19
+ 1. **Never write to the database.** Read-only by definition — no DDL, no DML, not even in a rolled-back
20
+ transaction. The extractor only ever parses SQL *text*.
21
+ 2. **Never guess schema.** Inspect the actual tables/columns before diagramming. If you can't reach the
22
+ database, diagram only what's provable from the SQL text and **mark inferred elements clearly**.
23
+
24
+ ## Step 1 — get the SQL
25
+
26
+ Resolve the argument:
27
+ - **A file path** → read that file.
28
+ - **A database object name** (proc/view/table) → look it up. Prefer a registered DB **MCP tool** if one
29
+ is available in the session; else `sqlcmd`/`psql` **read-only**; else ask the user to paste it. Never
30
+ guess an object's body.
31
+ - **No argument** → operate on the SQL in the current file/context, or ask.
32
+ - **Multiple objects** → diagram the **relationships between them**, in ONE diagram — not one diagram each.
33
+
34
+ ## Step 2 — run the deterministic extractor
35
+
36
+ ```bash
37
+ python <skill-dir>/scripts/sql_to_graph.py --file <path> # Mermaid block (default)
38
+ python <skill-dir>/scripts/sql_to_graph.py --file <path> --format excalidraw # native .excalidraw JSON
39
+ python <skill-dir>/scripts/sql_to_graph.py --file <path> --format html --title "..." # self-contained page
40
+ python <skill-dir>/scripts/sql_to_graph.py --file <path> --format svg # self-contained .svg
41
+ python <skill-dir>/scripts/sql_to_graph.py --sql "<SELECT ...>" --json # full graph JSON
42
+ ```
43
+ All five formats (`mermaid` | `excalidraw` | `svg` | `html` | `json`) come from **one deterministic layout**
44
+ — same SQL always produces byte-identical output, boxes are grid-aligned, and every label is wrapped to fit
45
+ *inside* its box.
46
+
47
+ **Notation (relational algebra — keep it when narrating):** operations carry the professional symbols
48
+ DB engineers already read — `σ` selection (WHERE), `Σ` aggregation (GROUP BY/HAVING, its own pipeline
49
+ stage), `π` projection (TOP/ORDER BY), `⋈` join (in the joined table's box), `ρ` rename (a CTE),
50
+ `∪`/`∩`/`∖` set operations (annotated on the result). Tables stay symbol-free — the name is the star.
51
+ Palette is the skill's own "jewel on ivory" identity (harbor teal / plum / saffron / madder / ink-blue /
52
+ viridian) — don't restyle it per diagram.
53
+
54
+ `--dialect` defaults to `tsql`; pass `postgres`/`mysql`/etc. for other engines. Requires `sqlglot`
55
+ (`pip install sqlglot` — pure-Python, no DB driver). **If sqlglot is absent** the script exits with an
56
+ actionable message; then hand-parse the SQL yourself and mark every inferred element (per safety rule 2).
57
+
58
+ The extractor classifies the input and picks the diagram type:
59
+
60
+ | Input | Diagram type | Extractor emits |
61
+ |---|---|---|
62
+ | `CREATE TABLE` / schema DDL | `erDiagram` | entities, columns, PK/FK, FK relationships |
63
+ | A query, proc, or CTE chain | `flowchart LR` | a strict pipeline: tables `[(T)]` / CTEs `{{CTE: name}}` → ONE `WHERE` box (all ANDed predicates, one per line) → `result` → projection `[/…/]`; join type+key labels ride on the source edges |
64
+ | An API/service path ending in a DB call | `sequenceDiagram` | *not structural — you build this from the code path; the extractor won't* |
65
+ | A status/lifecycle column | `stateDiagram-v2` | *not structural — you build this from the state values* |
66
+
67
+ The `sequenceDiagram`/`stateDiagram-v2` cases are judgement, not parsing — build those yourself and say so.
68
+ For the two structural cases, **trust the extractor's graph**; your job is narration, not re-deriving nodes.
69
+
70
+ The extractor returns `confidence` (`high` | `partial`) and an `inferred` list. If `partial`, the SQL
71
+ couldn't be fully parsed — surface the `inferred` notes in the output and mark those parts.
72
+
73
+ ## Step 3 — wrap it with narration (your job)
74
+
75
+ Around the extractor's Mermaid block, add:
76
+ - **Above the diagram**: one paragraph explaining what the query/proc is *for* in **business terms** (not
77
+ a restatement of the SQL — the *why*).
78
+ - **Below the diagram**: a bulleted list of every source table with a **one-line description** of what it
79
+ holds and why this query touches it. Inspect the real table (MCP/`sqlcmd`) for this — don't invent.
80
+ - **Traceability**: the source file path or object name, and a **generation date**.
81
+ - **This caveat, verbatim:**
82
+
83
+ > This diagram shows the SQL as written, not the execution plan. For performance analysis use the
84
+ > actual execution plan (SSMS Ctrl+M), which reflects what the optimiser actually chose — the two
85
+ > diverge frequently.
86
+
87
+ ## Step 4 — validate before saving
88
+
89
+ Malformed Mermaid renders as an error block — worse than no diagram. Before writing:
90
+ - Confirm the diagram **parses** (the extractor already sanitizes labels — no unescaped `"`/`[`/`]` — but
91
+ if you hand-edited or hand-built the diagram, re-check).
92
+ - Common breakages: unescaped parentheses, quotes, and square brackets inside node labels.
93
+
94
+ ## Output rules — `/mermaid-db` (the default)
95
+
96
+ - Save as a **`.md`** file. Default path `docs/diagrams/<object-name>.md`, overridable by an argument.
97
+ - **If the file already exists**, diff against it and tell the user *what changed* — don't silently
98
+ overwrite. (Regenerating on a schema change and showing the delta is the point of Mermaid-as-text.)
99
+
100
+ ## Output rules — `/excalidraw-db` (for human conversation)
101
+
102
+ Use for a design review / ARB / slide deck. **The extractor emits the `.excalidraw` JSON directly** — run
103
+ `--format excalidraw` and save the output as a `.excalidraw` file. No separate drawing skill, no MCP server.
104
+ The generator already guarantees what a hand-drawn diagram gets wrong.
105
+
106
+ **Flowchart (query / proc):**
107
+ - **Layout**: a strict left-to-right pipeline — sources → `WHERE` → `result` → projection — on a
108
+ deterministic grid (same-column boxes share an x; columns balanced on one mid-line). **Edges connect
109
+ adjacent stages only**, so an arrow can never cross a box; fan-in arrows land on distinct anchor
110
+ points (never one pile-up).
111
+ - **Arrows carry no text**: each join condition is a `⋈ …` sub-line INSIDE the joined table's box —
112
+ in a converging fan a floating label always ends up covering some arrow, so text never floats.
113
+ - **One WHERE box**: all ANDed predicates in a single box, one per line — stacked filter boxes read as
114
+ alternative paths, which is wrong.
115
+ - **Containment**: every label is a container-**bound** text element that auto-wraps and stays vertically
116
+ centred *inside* its box; box heights are computed from the wrapped line count, so text never overflows.
117
+
118
+ **ER diagram (schema DDL):**
119
+ - **Header + bullet columns**: each entity renders its name as a distinct **header** (bold, larger, in the
120
+ role colour, with a divider rule) and every column as a **bullet-list** item (`• col type · PK/FK`) —
121
+ the title never reads as just another column.
122
+ - **Arrows never cross a box**: entities are stacked in one column and every FK is routed as an
123
+ **orthogonal elbow through a left-side channel** (out the child's edge → down/up its own lane → into
124
+ the parent's edge). Every segment lives left of the boxes, so on a hub / chain / self-reference the FK
125
+ arrows can never run through — or hide behind — an intervening box (the old grid+straight-arrow bug).
126
+ Arrows are painted **on top** so every FK is unmistakably visible.
127
+
128
+ - **Canvas**: pure white (`#ffffff`) by default, both outputs.
129
+ - **Theme**: Excalidraw `appState.theme` is `"light"` (it re-tints for dark itself if toggled).
130
+ - **Determinism**: fixed ids/seeds — regenerating on a schema change produces a clean diff, not a reshuffle.
131
+
132
+ Then add the narration around it (business context + per-table descriptions + the execution-plan caveat).
133
+ If someone wants a **shareable, no-app preview**, `--format html` produces a self-contained page (the SVG
134
+ inline + a light/dark toggle) and `--format svg` a standalone SVG. The HTML theme is **fully
135
+ attribute-driven**: an inline head script seeds light/dark from the OS once, both themes are defined under
136
+ `:root[data-theme=…]` with the full variable set, and there is **no `@media` rule** to fight the toggle —
137
+ so the toggle always applies cleanly (no half-applied / black-page state). Zero external requests.
138
+
139
+ - **Do not maintain both formats for the same artifact.** If a Mermaid diagram already exists for an
140
+ object and the user runs `/excalidraw-db` on it, say so and ask: a one-off review copy, or a replacement?
141
+
142
+ ## The read-only, never-guess discipline (restated because it matters)
143
+
144
+ - Never run anything that mutates the DB.
145
+ - Never assert a table's columns or relationships you haven't verified against the real schema; mark
146
+ anything inferred-from-SQL-text-only.
147
+ - If the extractor's `confidence` is `partial` or sqlglot is unavailable, the diagram is best-effort —
148
+ say so in the output, don't present it as authoritative.