@kolbo/kolbo-code-linux-arm64-musl 1.1.74 → 2.0.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 (239) hide show
  1. package/bin/kolbo +0 -0
  2. package/package.json +1 -1
  3. package/skills/brainstorming/SKILL.md +164 -0
  4. package/skills/brainstorming/scripts/frame-template.html +214 -0
  5. package/skills/brainstorming/scripts/helper.js +88 -0
  6. package/skills/brainstorming/scripts/server.cjs +354 -0
  7. package/skills/brainstorming/scripts/start-server.sh +148 -0
  8. package/skills/brainstorming/scripts/stop-server.sh +56 -0
  9. package/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  10. package/skills/brainstorming/visual-companion.md +287 -0
  11. package/skills/dispatching-parallel-agents/SKILL.md +182 -0
  12. package/skills/docx/.skillfish.json +10 -0
  13. package/skills/docx/SKILL.md +196 -0
  14. package/skills/docx/docx-js.md +350 -0
  15. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
  16. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
  17. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
  18. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
  19. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
  20. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
  21. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
  22. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
  23. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
  24. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
  25. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
  26. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
  27. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
  28. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
  29. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
  30. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
  31. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
  32. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
  33. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
  34. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
  35. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
  36. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
  37. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
  38. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
  39. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
  40. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
  41. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
  42. package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
  43. package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
  44. package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
  45. package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
  46. package/skills/docx/ooxml/schemas/mce/mc.xsd +75 -0
  47. package/skills/docx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
  48. package/skills/docx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
  49. package/skills/docx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
  50. package/skills/docx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
  51. package/skills/docx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
  52. package/skills/docx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
  53. package/skills/docx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
  54. package/skills/docx/ooxml/scripts/pack.py +159 -0
  55. package/skills/docx/ooxml/scripts/unpack.py +29 -0
  56. package/skills/docx/ooxml/scripts/validate.py +69 -0
  57. package/skills/docx/ooxml/scripts/validation/__init__.py +15 -0
  58. package/skills/docx/ooxml/scripts/validation/base.py +951 -0
  59. package/skills/docx/ooxml/scripts/validation/docx.py +274 -0
  60. package/skills/docx/ooxml/scripts/validation/pptx.py +315 -0
  61. package/skills/docx/ooxml/scripts/validation/redlining.py +279 -0
  62. package/skills/docx/ooxml.md +599 -0
  63. package/skills/docx/scripts/__init__.py +1 -0
  64. package/skills/docx/scripts/document.py +1272 -0
  65. package/skills/docx/scripts/templates/comments.xml +3 -0
  66. package/skills/docx/scripts/templates/commentsExtended.xml +3 -0
  67. package/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
  68. package/skills/docx/scripts/templates/commentsIds.xml +3 -0
  69. package/skills/docx/scripts/templates/people.xml +3 -0
  70. package/skills/docx/scripts/utilities.py +374 -0
  71. package/skills/executing-plans/SKILL.md +70 -0
  72. package/skills/finishing-a-development-branch/SKILL.md +200 -0
  73. package/skills/fullstack-app/SKILL.md +621 -0
  74. package/skills/kolbo/SKILL.md +19 -263
  75. package/skills/ollama-vision/SKILL.md +105 -0
  76. package/skills/pdf/.skillfish.json +10 -0
  77. package/skills/pdf/FORMS.md +205 -0
  78. package/skills/pdf/REFERENCE.md +612 -0
  79. package/skills/pdf/SKILL.md +293 -0
  80. package/skills/pdf/scripts/check_bounding_boxes.py +70 -0
  81. package/skills/pdf/scripts/check_bounding_boxes_test.py +226 -0
  82. package/skills/pdf/scripts/check_fillable_fields.py +12 -0
  83. package/skills/pdf/scripts/convert_pdf_to_images.py +35 -0
  84. package/skills/pdf/scripts/create_validation_image.py +41 -0
  85. package/skills/pdf/scripts/extract_form_field_info.py +152 -0
  86. package/skills/pdf/scripts/fill_fillable_fields.py +114 -0
  87. package/skills/pdf/scripts/fill_pdf_form_with_annotations.py +108 -0
  88. package/skills/photo-studio/SKILL.md +122 -0
  89. package/skills/pptx/.skillfish.json +10 -0
  90. package/skills/pptx/SKILL.md +483 -0
  91. package/skills/pptx/html2pptx.md +626 -0
  92. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
  93. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
  94. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
  95. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
  96. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
  97. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
  98. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
  99. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
  100. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
  101. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
  102. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
  103. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
  104. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
  105. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
  106. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
  107. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
  108. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
  109. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
  110. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
  111. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
  112. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
  113. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
  114. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
  115. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
  116. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
  117. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
  118. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
  119. package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
  120. package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
  121. package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
  122. package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
  123. package/skills/pptx/ooxml/schemas/mce/mc.xsd +75 -0
  124. package/skills/pptx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
  125. package/skills/pptx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
  126. package/skills/pptx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
  127. package/skills/pptx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
  128. package/skills/pptx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
  129. package/skills/pptx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
  130. package/skills/pptx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
  131. package/skills/pptx/ooxml/scripts/pack.py +159 -0
  132. package/skills/pptx/ooxml/scripts/unpack.py +29 -0
  133. package/skills/pptx/ooxml/scripts/validate.py +69 -0
  134. package/skills/pptx/ooxml/scripts/validation/__init__.py +15 -0
  135. package/skills/pptx/ooxml/scripts/validation/base.py +951 -0
  136. package/skills/pptx/ooxml/scripts/validation/docx.py +274 -0
  137. package/skills/pptx/ooxml/scripts/validation/pptx.py +315 -0
  138. package/skills/pptx/ooxml/scripts/validation/redlining.py +279 -0
  139. package/skills/pptx/ooxml.md +427 -0
  140. package/skills/pptx/scripts/html2pptx.js +995 -0
  141. package/skills/pptx/scripts/inventory.py +1020 -0
  142. package/skills/pptx/scripts/rearrange.py +231 -0
  143. package/skills/pptx/scripts/replace.py +385 -0
  144. package/skills/pptx/scripts/thumbnail.py +450 -0
  145. package/skills/receiving-code-review/SKILL.md +213 -0
  146. package/skills/requesting-code-review/SKILL.md +105 -0
  147. package/skills/requesting-code-review/code-reviewer.md +146 -0
  148. package/skills/subagent-driven-development/SKILL.md +277 -0
  149. package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
  150. package/skills/subagent-driven-development/implementer-prompt.md +113 -0
  151. package/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
  152. package/skills/supabase/.skillfish.json +10 -0
  153. package/skills/supabase/SKILL.md +106 -0
  154. package/skills/supabase/assets/feedback-issue-template.md +17 -0
  155. package/skills/supabase/references/skill-feedback.md +17 -0
  156. package/skills/supabase-postgres-best-practices/.skillfish.json +10 -0
  157. package/skills/supabase-postgres-best-practices/SKILL.md +64 -0
  158. package/skills/supabase-postgres-best-practices/references/_contributing.md +170 -0
  159. package/skills/supabase-postgres-best-practices/references/_sections.md +39 -0
  160. package/skills/supabase-postgres-best-practices/references/_template.md +34 -0
  161. package/skills/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -0
  162. package/skills/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -0
  163. package/skills/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -0
  164. package/skills/supabase-postgres-best-practices/references/conn-limits.md +44 -0
  165. package/skills/supabase-postgres-best-practices/references/conn-pooling.md +41 -0
  166. package/skills/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -0
  167. package/skills/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -0
  168. package/skills/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -0
  169. package/skills/supabase-postgres-best-practices/references/data-pagination.md +50 -0
  170. package/skills/supabase-postgres-best-practices/references/data-upsert.md +50 -0
  171. package/skills/supabase-postgres-best-practices/references/lock-advisory.md +56 -0
  172. package/skills/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -0
  173. package/skills/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -0
  174. package/skills/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -0
  175. package/skills/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -0
  176. package/skills/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -0
  177. package/skills/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -0
  178. package/skills/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -0
  179. package/skills/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -0
  180. package/skills/supabase-postgres-best-practices/references/query-index-types.md +48 -0
  181. package/skills/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -0
  182. package/skills/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -0
  183. package/skills/supabase-postgres-best-practices/references/schema-constraints.md +80 -0
  184. package/skills/supabase-postgres-best-practices/references/schema-data-types.md +46 -0
  185. package/skills/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -0
  186. package/skills/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -0
  187. package/skills/supabase-postgres-best-practices/references/schema-partitioning.md +55 -0
  188. package/skills/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -0
  189. package/skills/supabase-postgres-best-practices/references/security-privileges.md +54 -0
  190. package/skills/supabase-postgres-best-practices/references/security-rls-basics.md +50 -0
  191. package/skills/supabase-postgres-best-practices/references/security-rls-performance.md +57 -0
  192. package/skills/supabase-quickstart/SKILL.md +400 -0
  193. package/skills/systematic-debugging/CREATION-LOG.md +119 -0
  194. package/skills/systematic-debugging/SKILL.md +296 -0
  195. package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  196. package/skills/systematic-debugging/condition-based-waiting.md +115 -0
  197. package/skills/systematic-debugging/defense-in-depth.md +122 -0
  198. package/skills/systematic-debugging/find-polluter.sh +63 -0
  199. package/skills/systematic-debugging/root-cause-tracing.md +169 -0
  200. package/skills/systematic-debugging/test-academic.md +14 -0
  201. package/skills/systematic-debugging/test-pressure-1.md +58 -0
  202. package/skills/systematic-debugging/test-pressure-2.md +68 -0
  203. package/skills/systematic-debugging/test-pressure-3.md +69 -0
  204. package/skills/test-driven-development/SKILL.md +371 -0
  205. package/skills/test-driven-development/testing-anti-patterns.md +299 -0
  206. package/skills/using-git-worktrees/SKILL.md +218 -0
  207. package/skills/using-superpowers/SKILL.md +115 -0
  208. package/skills/using-superpowers/references/codex-tools.md +100 -0
  209. package/skills/using-superpowers/references/gemini-tools.md +33 -0
  210. package/skills/verification-before-completion/SKILL.md +139 -0
  211. package/skills/video-production/SKILL.md +8 -7
  212. package/skills/writing-plans/SKILL.md +152 -0
  213. package/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
  214. package/skills/writing-skills/SKILL.md +655 -0
  215. package/skills/writing-skills/anthropic-best-practices.md +1150 -0
  216. package/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
  217. package/skills/writing-skills/graphviz-conventions.dot +172 -0
  218. package/skills/writing-skills/persuasion-principles.md +187 -0
  219. package/skills/writing-skills/render-graphs.js +168 -0
  220. package/skills/writing-skills/testing-skills-with-subagents.md +384 -0
  221. package/skills/xlsx/.skillfish.json +10 -0
  222. package/skills/xlsx/SKILL.md +288 -0
  223. package/skills/xlsx/recalc.py +178 -0
  224. package/skills/color-grading/SKILL.md +0 -152
  225. package/skills/ffmpeg-patterns/SKILL.md +0 -240
  226. package/skills/image-prompting-guide/SKILL.md +0 -143
  227. package/skills/music-prompting/SKILL.md +0 -146
  228. package/skills/production-review/SKILL.md +0 -152
  229. package/skills/short-form-video/SKILL.md +0 -168
  230. package/skills/sound-design/SKILL.md +0 -154
  231. package/skills/storytelling/SKILL.md +0 -139
  232. package/skills/subtitle-production/SKILL.md +0 -244
  233. package/skills/subtitle-production/reference/burn_to_video.py +0 -222
  234. package/skills/subtitle-production/reference/export_srts.py +0 -127
  235. package/skills/subtitle-production/reference/gen_srt.py +0 -42
  236. package/skills/typography-video/SKILL.md +0 -182
  237. package/skills/typography-video/reference/KineticTitleScene.tsx +0 -345
  238. package/skills/video-editing/SKILL.md +0 -128
  239. package/skills/video-prompting-guide/SKILL.md +0 -268
@@ -0,0 +1,61 @@
1
+ # Spec Compliance Reviewer Prompt Template
2
+
3
+ Use this template when dispatching a spec compliance reviewer subagent.
4
+
5
+ **Purpose:** Verify implementer built what was requested (nothing more, nothing less)
6
+
7
+ ```
8
+ Task tool (general-purpose):
9
+ description: "Review spec compliance for Task N"
10
+ prompt: |
11
+ You are reviewing whether an implementation matches its specification.
12
+
13
+ ## What Was Requested
14
+
15
+ [FULL TEXT of task requirements]
16
+
17
+ ## What Implementer Claims They Built
18
+
19
+ [From implementer's report]
20
+
21
+ ## CRITICAL: Do Not Trust the Report
22
+
23
+ The implementer finished suspiciously quickly. Their report may be incomplete,
24
+ inaccurate, or optimistic. You MUST verify everything independently.
25
+
26
+ **DO NOT:**
27
+ - Take their word for what they implemented
28
+ - Trust their claims about completeness
29
+ - Accept their interpretation of requirements
30
+
31
+ **DO:**
32
+ - Read the actual code they wrote
33
+ - Compare actual implementation to requirements line by line
34
+ - Check for missing pieces they claimed to implement
35
+ - Look for extra features they didn't mention
36
+
37
+ ## Your Job
38
+
39
+ Read the implementation code and verify:
40
+
41
+ **Missing requirements:**
42
+ - Did they implement everything that was requested?
43
+ - Are there requirements they skipped or missed?
44
+ - Did they claim something works but didn't actually implement it?
45
+
46
+ **Extra/unneeded work:**
47
+ - Did they build things that weren't requested?
48
+ - Did they over-engineer or add unnecessary features?
49
+ - Did they add "nice to haves" that weren't in spec?
50
+
51
+ **Misunderstandings:**
52
+ - Did they interpret requirements differently than intended?
53
+ - Did they solve the wrong problem?
54
+ - Did they implement the right feature but wrong way?
55
+
56
+ **Verify by reading code, not by trusting report.**
57
+
58
+ Report:
59
+ - ✅ Spec compliant (if everything matches after code inspection)
60
+ - ❌ Issues found: [list specifically what's missing or extra, with file:line references]
61
+ ```
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 2,
3
+ "name": "supabase",
4
+ "owner": "supabase",
5
+ "repo": "agent-skills",
6
+ "path": "skills/supabase",
7
+ "branch": "main",
8
+ "sha": "512c575a9b68d271682f9a39a01e4e9ea1156fa1",
9
+ "source": "manual"
10
+ }
@@ -0,0 +1,106 @@
1
+ ---
2
+ name: supabase
3
+ description: "Use when doing ANY task involving Supabase. Triggers: Supabase products (Database, Auth, Edge Functions, Realtime, Storage, Vectors, Cron, Queues); client libraries and SSR integrations (supabase-js, @supabase/ssr) in Next.js, React, SvelteKit, Astro, Remix; auth issues (login, logout, sessions, JWT, cookies, getSession, getUser, getClaims, RLS); Supabase CLI or MCP server; schema changes, migrations, security audits, Postgres extensions (pg_graphql, pg_cron, pg_vector)."
4
+ metadata:
5
+ author: supabase
6
+ version: "0.1.0"
7
+ ---
8
+
9
+ # Supabase
10
+
11
+ > **ROUTING:** If the user does NOT already have Supabase set up in this project (no `opencode.json` MCP config, no `.env.local` with Supabase vars, no AGENTS.md mentioning Supabase), STOP and load the `supabase-quickstart` skill instead. This skill assumes an existing Supabase project. The quickstart skill handles initial setup, MCP configuration, auth scaffolding, and generates project rules.
12
+
13
+ ## Core Principles
14
+
15
+ **1. Supabase changes frequently — verify against current docs before implementing.**
16
+ Do not rely on training data for Supabase features. Function signatures, config.toml settings, and API conventions change between versions. Before implementing, look up the relevant topic using the documentation access methods below.
17
+
18
+ **2. Verify your work.**
19
+ After implementing any fix, run a test query to confirm the change works. A fix without verification is incomplete.
20
+
21
+ **3. Recover from errors, don't loop.**
22
+ If an approach fails after 2-3 attempts, stop and reconsider. Try a different method, check documentation, inspect the error more carefully, and review relevant logs when available. Supabase issues are not always solved by retrying the same command, and the answer is not always in the logs, but logs are often worth checking before proceeding.
23
+
24
+ **4. RLS by default in exposed schemas.**
25
+ Enable RLS on every table in any exposed schema, especially `public`. This is critical in Supabase because tables in exposed schemas can be reachable through the Data API. For private schemas, prefer RLS as defense in depth. After enabling RLS, create policies that match the actual access model rather than defaulting every table to the same `auth.uid()` pattern.
26
+
27
+ **5. Security checklist.**
28
+ When working on any Supabase task that touches auth, RLS, views, storage, or user data, run through this checklist. These are Supabase-specific security traps that silently create vulnerabilities:
29
+
30
+ - **Auth and session security**
31
+ - **Never use `user_metadata` claims in JWT-based authorization decisions.** In Supabase, `raw_user_meta_data` is user-editable and can appear in `auth.jwt()`, so it is unsafe for RLS policies or any other authorization logic. Store authorization data in `raw_app_meta_data` / `app_metadata` instead.
32
+ - **Deleting a user does not invalidate existing access tokens.** Sign out or revoke sessions first, keep JWT expiry short for sensitive apps, and for strict guarantees validate `session_id` against `auth.sessions` on sensitive operations.
33
+ - **If you use `app_metadata` or `auth.jwt()` for authorization, remember JWT claims are not always fresh until the user's token is refreshed.**
34
+
35
+ - **API key and client exposure**
36
+ - **Never expose the `service_role` or secret key in public clients.** Prefer publishable keys for frontend code. Legacy `anon` keys are only for compatibility. In Next.js, any `NEXT_PUBLIC_` env var is sent to the browser.
37
+
38
+ - **RLS, views, and privileged database code**
39
+ - **Views bypass RLS by default.** In Postgres 15 and above, use `CREATE VIEW ... WITH (security_invoker = true)`. In older versions of Postgres, protect your views by revoking access from the `anon` and `authenticated` roles, or by putting them in an unexposed schema.
40
+ - **UPDATE requires a SELECT policy.** In Postgres RLS, an UPDATE needs to first SELECT the row. Without a SELECT policy, updates silently return 0 rows — no error, just no change.
41
+ - **Do not put `security definer` functions in an exposed schema.** Keep them in a private or otherwise unexposed schema.
42
+
43
+
44
+ - **Storage access control**
45
+ - **Storage upsert requires INSERT + SELECT + UPDATE.** Granting only INSERT allows new uploads but file replacement (upsert) silently fails. You need all three.
46
+
47
+ For any security concern not covered above, fetch the Supabase product security index: `https://supabase.com/docs/guides/security/product-security.md`
48
+
49
+ ## Supabase CLI
50
+
51
+ Always discover commands via `--help` — never guess. The CLI structure changes between versions.
52
+
53
+ ```bash
54
+ supabase --help # All top-level commands
55
+ supabase <group> --help # Subcommands (e.g., supabase db --help)
56
+ supabase <group> <command> --help # Flags for a specific command
57
+ ```
58
+
59
+ **Supabase CLI Known gotchas:**
60
+ - `supabase db query` requires **CLI v2.79.0+** → use MCP `execute_sql` or `psql` as fallback
61
+ - `supabase db advisors` requires **CLI v2.81.3+** → use MCP `get_advisors` as fallback
62
+ - When you need a new migration SQL file, **always** create it with `supabase migration new <name>` first. Never invent a migration filename or rely on memory for the expected format.
63
+
64
+ **Version check and upgrade:** Run `supabase --version` to check. For CLI changelogs and version-specific features, consult the [CLI documentation](https://supabase.com/docs/reference/cli/introduction) or [GitHub releases](https://github.com/supabase/cli/releases).
65
+
66
+ ## Supabase MCP Server
67
+
68
+ For setup instructions, server URL, and configuration, see the [MCP setup guide](https://supabase.com/docs/guides/getting-started/mcp).
69
+
70
+ **Troubleshooting connection issues** — follow these steps in order:
71
+
72
+ 1. **Check if the server is reachable:**
73
+ `curl -so /dev/null -w "%{http_code}" https://mcp.supabase.com/mcp`
74
+ A `401` is expected (no token) and means the server is up. Timeout or "connection refused" means it may be down.
75
+
76
+ 2. **Check `.mcp.json` configuration:**
77
+ Verify the project root has a valid `.mcp.json` with the correct server URL. If missing, create one pointing to `https://mcp.supabase.com/mcp`.
78
+
79
+ 3. **Authenticate the MCP server:**
80
+ If the server is reachable and `.mcp.json` is correct but tools aren't visible, the user needs to authenticate. The Supabase MCP server uses OAuth 2.1 — tell the user to trigger the auth flow in their agent, complete it in the browser, and reload the session.
81
+
82
+ ## Supabase Documentation
83
+
84
+ Before implementing any Supabase feature, find the relevant documentation. Use these methods in priority order:
85
+
86
+ 1. **MCP `search_docs` tool** (preferred — returns relevant snippets directly)
87
+ 2. **Fetch docs pages as markdown** — any docs page can be fetched by appending `.md` to the URL path.
88
+ 3. **Web search** for Supabase-specific topics when you don't know which page to look at.
89
+
90
+ ## Making and Committing Schema Changes
91
+
92
+ **To make schema changes, use `execute_sql` (MCP) or `supabase db query` (CLI).** These run SQL directly on the database without creating migration history entries, so you can iterate freely and generate a clean migration when ready.
93
+
94
+ Do NOT use `apply_migration` to change a local database schema — it writes a migration history entry on every call, which means you can't iterate, and `supabase db diff` / `supabase db pull` will produce empty or conflicting diffs. If you use it, you'll be stuck with whatever SQL you passed on the first try.
95
+
96
+ **When ready to commit** your changes to a migration file:
97
+
98
+ 1. **Run advisors** → `supabase db advisors` (CLI v2.81.3+) or MCP `get_advisors`. Fix any issues.
99
+ 2. **Review the Security Checklist above** if your changes involve views, functions, triggers, or storage.
100
+ 3. **Generate the migration** → `supabase db pull <descriptive-name> --local --yes`
101
+ 4. **Verify** → `supabase migration list --local`
102
+
103
+ ## Reference Guides
104
+
105
+ - **Skill Feedback** → [references/skill-feedback.md](references/skill-feedback.md)
106
+ **MUST read when** the user reports that this skill gave incorrect guidance or is missing information.
@@ -0,0 +1,17 @@
1
+ ## What happened
2
+
3
+ **Task:** <!-- e.g., "Set up MFA on patient records" -->
4
+
5
+ **Skill said:** <!-- e.g., "Use auth.jwt()->'app_metadata' in the RLS policy" -->
6
+
7
+ **Expected:** <!-- e.g., "The function also needs SECURITY DEFINER + grant to supabase_auth_admin" -->
8
+
9
+ ## Source
10
+
11
+ **File:** <!-- e.g., references/security-model.md -->
12
+
13
+ **Section:** <!-- e.g., "Trust Boundaries > user_metadata vs app_metadata" -->
14
+
15
+ ## Fix suggestion
16
+
17
+ <!-- Leave blank if unsure -->
@@ -0,0 +1,17 @@
1
+ # Skill Feedback
2
+
3
+ Use this when the user reports that the skill gave incorrect guidance, is missing information, or could be improved. This is about the skill (agent instructions), not about Supabase the product.
4
+
5
+ ## Steps
6
+
7
+ 1. **Ask permission** — Ask the user if they'd like to submit feedback to the skill maintainers. If they decline, move on.
8
+
9
+ 2. **Draft the issue** — Use the template at [assets/feedback-issue-template.md](../assets/feedback-issue-template.md) to structure the feedback. Fill in the fields based on the conversation. Always identify which specific reference file and section caused the problem.
10
+
11
+ 3. **Submit** — Create a GitHub Issue on the `supabase/agent-skills` repository using the draft as the issue body. The title must follow this format: `user-feedback: <summary of the problem>`.
12
+
13
+ 4. **Share the result** — Share the issue URL with the user after submission. If submission fails, give the user this link to create the issue manually:
14
+
15
+ ```
16
+ https://github.com/supabase/agent-skills/issues/new
17
+ ```
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 2,
3
+ "name": "supabase-postgres-best-practices",
4
+ "owner": "supabase",
5
+ "repo": "agent-skills",
6
+ "path": "skills/supabase-postgres-best-practices",
7
+ "branch": "main",
8
+ "sha": "9e4dd36978eedd04efc649b4d431ab5ce4bb3896",
9
+ "source": "manual"
10
+ }
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: supabase-postgres-best-practices
3
+ description: Postgres performance optimization and best practices from Supabase. Use this skill when writing, reviewing, or optimizing Postgres queries, schema designs, or database configurations.
4
+ license: MIT
5
+ metadata:
6
+ author: supabase
7
+ version: "1.1.1"
8
+ organization: Supabase
9
+ date: January 2026
10
+ abstract: Comprehensive Postgres performance optimization guide for developers using Supabase and Postgres. Contains performance rules across 8 categories, prioritized by impact from critical (query performance, connection management) to incremental (advanced features). Each rule includes detailed explanations, incorrect vs. correct SQL examples, query plan analysis, and specific performance metrics to guide automated optimization and code generation.
11
+ ---
12
+
13
+ # Supabase Postgres Best Practices
14
+
15
+ Comprehensive performance optimization guide for Postgres, maintained by Supabase. Contains rules across 8 categories, prioritized by impact to guide automated query optimization and schema design.
16
+
17
+ ## When to Apply
18
+
19
+ Reference these guidelines when:
20
+ - Writing SQL queries or designing schemas
21
+ - Implementing indexes or query optimization
22
+ - Reviewing database performance issues
23
+ - Configuring connection pooling or scaling
24
+ - Optimizing for Postgres-specific features
25
+ - Working with Row-Level Security (RLS)
26
+
27
+ ## Rule Categories by Priority
28
+
29
+ | Priority | Category | Impact | Prefix |
30
+ |----------|----------|--------|--------|
31
+ | 1 | Query Performance | CRITICAL | `query-` |
32
+ | 2 | Connection Management | CRITICAL | `conn-` |
33
+ | 3 | Security & RLS | CRITICAL | `security-` |
34
+ | 4 | Schema Design | HIGH | `schema-` |
35
+ | 5 | Concurrency & Locking | MEDIUM-HIGH | `lock-` |
36
+ | 6 | Data Access Patterns | MEDIUM | `data-` |
37
+ | 7 | Monitoring & Diagnostics | LOW-MEDIUM | `monitor-` |
38
+ | 8 | Advanced Features | LOW | `advanced-` |
39
+
40
+ ## How to Use
41
+
42
+ Read individual rule files for detailed explanations and SQL examples:
43
+
44
+ ```
45
+ references/query-missing-indexes.md
46
+ references/query-partial-indexes.md
47
+ references/_sections.md
48
+ ```
49
+
50
+ Each rule file contains:
51
+ - Brief explanation of why it matters
52
+ - Incorrect SQL example with explanation
53
+ - Correct SQL example with explanation
54
+ - Optional EXPLAIN output or metrics
55
+ - Additional context and references
56
+ - Supabase-specific notes (when applicable)
57
+
58
+ ## References
59
+
60
+ - https://www.postgresql.org/docs/current/
61
+ - https://supabase.com/docs
62
+ - https://wiki.postgresql.org/wiki/Performance_Optimization
63
+ - https://supabase.com/docs/guides/database/overview
64
+ - https://supabase.com/docs/guides/auth/row-level-security
@@ -0,0 +1,170 @@
1
+ # Writing Guidelines for Postgres References
2
+
3
+ This document provides guidelines for creating effective Postgres best
4
+ practice references that work well with AI agents and LLMs.
5
+
6
+ ## Key Principles
7
+
8
+ ### 1. Concrete Transformation Patterns
9
+
10
+ Show exact SQL rewrites. Avoid philosophical advice.
11
+
12
+ **Good:** "Use `WHERE id = ANY(ARRAY[...])` instead of
13
+ `WHERE id IN (SELECT ...)`" **Bad:** "Design good schemas"
14
+
15
+ ### 2. Error-First Structure
16
+
17
+ Always show the problematic pattern first, then the solution. This trains agents
18
+ to recognize anti-patterns.
19
+
20
+ ```markdown
21
+ **Incorrect (sequential queries):** [bad example]
22
+
23
+ **Correct (batched query):** [good example]
24
+ ```
25
+
26
+ ### 3. Quantified Impact
27
+
28
+ Include specific metrics. Helps agents prioritize fixes.
29
+
30
+ **Good:** "10x faster queries", "50% smaller index", "Eliminates N+1"
31
+ **Bad:** "Faster", "Better", "More efficient"
32
+
33
+ ### 4. Self-Contained Examples
34
+
35
+ Examples should be complete and runnable (or close to it). Include `CREATE TABLE`
36
+ if context is needed.
37
+
38
+ ```sql
39
+ -- Include table definition when needed for clarity
40
+ CREATE TABLE users (
41
+ id bigint PRIMARY KEY,
42
+ email text NOT NULL,
43
+ deleted_at timestamptz
44
+ );
45
+
46
+ -- Now show the index
47
+ CREATE INDEX users_active_email_idx ON users(email) WHERE deleted_at IS NULL;
48
+ ```
49
+
50
+ ### 5. Semantic Naming
51
+
52
+ Use meaningful table/column names. Names carry intent for LLMs.
53
+
54
+ **Good:** `users`, `email`, `created_at`, `is_active`
55
+ **Bad:** `table1`, `col1`, `field`, `flag`
56
+
57
+ ---
58
+
59
+ ## Code Example Standards
60
+
61
+ ### SQL Formatting
62
+
63
+ ```sql
64
+ -- Use lowercase keywords, clear formatting
65
+ CREATE INDEX CONCURRENTLY users_email_idx
66
+ ON users(email)
67
+ WHERE deleted_at IS NULL;
68
+
69
+ -- Not cramped or ALL CAPS
70
+ CREATE INDEX CONCURRENTLY USERS_EMAIL_IDX ON USERS(EMAIL) WHERE DELETED_AT IS NULL;
71
+ ```
72
+
73
+ ### Comments
74
+
75
+ - Explain _why_, not _what_
76
+ - Highlight performance implications
77
+ - Point out common pitfalls
78
+
79
+ ### Language Tags
80
+
81
+ - `sql` - Standard SQL queries
82
+ - `plpgsql` - Stored procedures/functions
83
+ - `typescript` - Application code (when needed)
84
+ - `python` - Application code (when needed)
85
+
86
+ ---
87
+
88
+ ## When to Include Application Code
89
+
90
+ **Default: SQL Only**
91
+
92
+ Most references should focus on pure SQL patterns. This keeps examples portable.
93
+
94
+ **Include Application Code When:**
95
+
96
+ - Connection pooling configuration
97
+ - Transaction management in application context
98
+ - ORM anti-patterns (N+1 in Prisma/TypeORM)
99
+ - Prepared statement usage
100
+
101
+ **Format for Mixed Examples:**
102
+
103
+ ````markdown
104
+ **Incorrect (N+1 in application):**
105
+
106
+ ```typescript
107
+ for (const user of users) {
108
+ const posts = await db.query("SELECT * FROM posts WHERE user_id = $1", [
109
+ user.id,
110
+ ]);
111
+ }
112
+ ```
113
+ ````
114
+
115
+ **Correct (batch query):**
116
+
117
+ ```typescript
118
+ const posts = await db.query("SELECT * FROM posts WHERE user_id = ANY($1)", [
119
+ userIds,
120
+ ]);
121
+ ```
122
+
123
+ ---
124
+
125
+ ## Impact Level Guidelines
126
+
127
+ | Level | Improvement | Use When |
128
+ |-------|-------------|----------|
129
+ | **CRITICAL** | 10-100x | Missing indexes, connection exhaustion, sequential scans on large tables |
130
+ | **HIGH** | 5-20x | Wrong index types, poor partitioning, missing covering indexes |
131
+ | **MEDIUM-HIGH** | 2-5x | N+1 queries, inefficient pagination, RLS optimization |
132
+ | **MEDIUM** | 1.5-3x | Redundant indexes, query plan instability |
133
+ | **LOW-MEDIUM** | 1.2-2x | VACUUM tuning, configuration tweaks |
134
+ | **LOW** | Incremental | Advanced patterns, edge cases |
135
+
136
+ ---
137
+
138
+ ## Reference Standards
139
+
140
+ **Primary Sources:**
141
+
142
+ - Official Postgres documentation
143
+ - Supabase documentation
144
+ - Postgres wiki
145
+ - Established blogs (2ndQuadrant, Crunchy Data)
146
+
147
+ **Format:**
148
+
149
+ ```markdown
150
+ Reference:
151
+ [Postgres Indexes](https://www.postgresql.org/docs/current/indexes.html)
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Review Checklist
157
+
158
+ Before submitting a reference:
159
+
160
+ - [ ] Title is clear and action-oriented
161
+ - [ ] Impact level matches the performance gain
162
+ - [ ] impactDescription includes quantification
163
+ - [ ] Explanation is concise (1-2 sentences)
164
+ - [ ] Has at least 1 **Incorrect** SQL example
165
+ - [ ] Has at least 1 **Correct** SQL example
166
+ - [ ] SQL uses semantic naming
167
+ - [ ] Comments explain _why_, not _what_
168
+ - [ ] Trade-offs mentioned if applicable
169
+ - [ ] Reference links included
170
+ - [ ] `mise run test` passes
@@ -0,0 +1,39 @@
1
+ # Section Definitions
2
+
3
+ This file defines the rule categories for Postgres best practices. Rules are automatically assigned to sections based on their filename prefix.
4
+
5
+ Take the examples below as pure demonstrative. Replace each section with the actual rule categories for Postgres best practices.
6
+
7
+ ---
8
+
9
+ ## 1. Query Performance (query)
10
+ **Impact:** CRITICAL
11
+ **Description:** Slow queries, missing indexes, inefficient query plans. The most common source of Postgres performance issues.
12
+
13
+ ## 2. Connection Management (conn)
14
+ **Impact:** CRITICAL
15
+ **Description:** Connection pooling, limits, and serverless strategies. Critical for applications with high concurrency or serverless deployments.
16
+
17
+ ## 3. Security & RLS (security)
18
+ **Impact:** CRITICAL
19
+ **Description:** Row-Level Security policies, privilege management, and authentication patterns.
20
+
21
+ ## 4. Schema Design (schema)
22
+ **Impact:** HIGH
23
+ **Description:** Table design, index strategies, partitioning, and data type selection. Foundation for long-term performance.
24
+
25
+ ## 5. Concurrency & Locking (lock)
26
+ **Impact:** MEDIUM-HIGH
27
+ **Description:** Transaction management, isolation levels, deadlock prevention, and lock contention patterns.
28
+
29
+ ## 6. Data Access Patterns (data)
30
+ **Impact:** MEDIUM
31
+ **Description:** N+1 query elimination, batch operations, cursor-based pagination, and efficient data fetching.
32
+
33
+ ## 7. Monitoring & Diagnostics (monitor)
34
+ **Impact:** LOW-MEDIUM
35
+ **Description:** Using pg_stat_statements, EXPLAIN ANALYZE, metrics collection, and performance diagnostics.
36
+
37
+ ## 8. Advanced Features (advanced)
38
+ **Impact:** LOW
39
+ **Description:** Full-text search, JSONB optimization, PostGIS, extensions, and advanced Postgres features.
@@ -0,0 +1,34 @@
1
+ ---
2
+ title: Clear, Action-Oriented Title (e.g., "Use Partial Indexes for Filtered Queries")
3
+ impact: MEDIUM
4
+ impactDescription: 5-20x query speedup for filtered queries
5
+ tags: indexes, query-optimization, performance
6
+ ---
7
+
8
+ ## [Rule Title]
9
+
10
+ [1-2 sentence explanation of the problem and why it matters. Focus on performance impact.]
11
+
12
+ **Incorrect (describe the problem):**
13
+
14
+ ```sql
15
+ -- Comment explaining what makes this slow/problematic
16
+ CREATE INDEX users_email_idx ON users(email);
17
+
18
+ SELECT * FROM users WHERE email = 'user@example.com' AND deleted_at IS NULL;
19
+ -- This scans deleted records unnecessarily
20
+ ```
21
+
22
+ **Correct (describe the solution):**
23
+
24
+ ```sql
25
+ -- Comment explaining why this is better
26
+ CREATE INDEX users_active_email_idx ON users(email) WHERE deleted_at IS NULL;
27
+
28
+ SELECT * FROM users WHERE email = 'user@example.com' AND deleted_at IS NULL;
29
+ -- Only indexes active users, 10x smaller index, faster queries
30
+ ```
31
+
32
+ [Optional: Additional context, edge cases, or trade-offs]
33
+
34
+ Reference: [Postgres Docs](https://www.postgresql.org/docs/current/)
@@ -0,0 +1,55 @@
1
+ ---
2
+ title: Use tsvector for Full-Text Search
3
+ impact: MEDIUM
4
+ impactDescription: 100x faster than LIKE, with ranking support
5
+ tags: full-text-search, tsvector, gin, search
6
+ ---
7
+
8
+ ## Use tsvector for Full-Text Search
9
+
10
+ LIKE with wildcards can't use indexes. Full-text search with tsvector is orders of magnitude faster.
11
+
12
+ **Incorrect (LIKE pattern matching):**
13
+
14
+ ```sql
15
+ -- Cannot use index, scans all rows
16
+ select * from articles where content like '%postgresql%';
17
+
18
+ -- Case-insensitive makes it worse
19
+ select * from articles where lower(content) like '%postgresql%';
20
+ ```
21
+
22
+ **Correct (full-text search with tsvector):**
23
+
24
+ ```sql
25
+ -- Add tsvector column and index
26
+ alter table articles add column search_vector tsvector
27
+ generated always as (to_tsvector('english', coalesce(title,'') || ' ' || coalesce(content,''))) stored;
28
+
29
+ create index articles_search_idx on articles using gin (search_vector);
30
+
31
+ -- Fast full-text search
32
+ select * from articles
33
+ where search_vector @@ to_tsquery('english', 'postgresql & performance');
34
+
35
+ -- With ranking
36
+ select *, ts_rank(search_vector, query) as rank
37
+ from articles, to_tsquery('english', 'postgresql') query
38
+ where search_vector @@ query
39
+ order by rank desc;
40
+ ```
41
+
42
+ Search multiple terms:
43
+
44
+ ```sql
45
+ -- AND: both terms required
46
+ to_tsquery('postgresql & performance')
47
+
48
+ -- OR: either term
49
+ to_tsquery('postgresql | mysql')
50
+
51
+ -- Prefix matching
52
+ to_tsquery('post:*')
53
+ ```
54
+
55
+ Reference: [Full Text Search](https://supabase.com/docs/guides/database/full-text-search)
@@ -0,0 +1,49 @@
1
+ ---
2
+ title: Index JSONB Columns for Efficient Querying
3
+ impact: MEDIUM
4
+ impactDescription: 10-100x faster JSONB queries with proper indexing
5
+ tags: jsonb, gin, indexes, json
6
+ ---
7
+
8
+ ## Index JSONB Columns for Efficient Querying
9
+
10
+ JSONB queries without indexes scan the entire table. Use GIN indexes for containment queries.
11
+
12
+ **Incorrect (no index on JSONB):**
13
+
14
+ ```sql
15
+ create table products (
16
+ id bigint primary key,
17
+ attributes jsonb
18
+ );
19
+
20
+ -- Full table scan for every query
21
+ select * from products where attributes @> '{"color": "red"}';
22
+ select * from products where attributes->>'brand' = 'Nike';
23
+ ```
24
+
25
+ **Correct (GIN index for JSONB):**
26
+
27
+ ```sql
28
+ -- GIN index for containment operators (@>, ?, ?&, ?|)
29
+ create index products_attrs_gin on products using gin (attributes);
30
+
31
+ -- Now containment queries use the index
32
+ select * from products where attributes @> '{"color": "red"}';
33
+
34
+ -- For specific key lookups, use expression index
35
+ create index products_brand_idx on products ((attributes->>'brand'));
36
+ select * from products where attributes->>'brand' = 'Nike';
37
+ ```
38
+
39
+ Choose the right operator class:
40
+
41
+ ```sql
42
+ -- jsonb_ops (default): supports all operators, larger index
43
+ create index idx1 on products using gin (attributes);
44
+
45
+ -- jsonb_path_ops: only @> operator, but 2-3x smaller index
46
+ create index idx2 on products using gin (attributes jsonb_path_ops);
47
+ ```
48
+
49
+ Reference: [JSONB Indexes](https://www.postgresql.org/docs/current/datatype-json.html#JSON-INDEXING)