DATABASES / Supabase
Supabase Postgres Best Practices
Connects Postgres schema and query decisions to worked SQL examples, connection guidance and row-level security checks.
“Postgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres database: creating or altering tables and columns (including choosing column types), schema design, migrations and declarative schema files, RLS policies and the tests that verify them, indexes, triggers, database functions, queues and scheduled jobs (pg_cron, pgmq), vector/semantic search (pgvector), and restoring dumps (pg_restore) or importing data. Also load it when diagnosing slow queries, high CPU, timeouts, EXPLAIN plans, connection exhaustion, locking, bloat, or rows visible to the wrong user or tenant. This is not just a performance guide — schema, migration, security, and SQL authoring tasks need these rules too, even for a one-column change or a single query.”
01 / THE REASONING
Why this made the selection.
- Pairs incorrect and corrected SQL with query-plan examples instead of offering only generic database advice.
- Treats row-level security, privileges and connection management as part of database work rather than a separate performance afterthought.
02 / THE REVIEW RECORD
What we actually inspected.
Source review has boundaries.
A clear record is more useful than a “safe” badge.
Material inspected
- skills/supabase-postgres-best-practices/SKILL.md
- skills/supabase-postgres-best-practices/references/query-missing-indexes.md
- skills/supabase-postgres-best-practices/references/security-rls-performance.md
- skills/supabase-postgres-best-practices/references/_sections.md
- skills/supabase-postgres-best-practices/CHANGELOG.md
- skills/supabase-postgres-best-practices/references/ (all 34 bundled files scanned for shell blocks and URLs: SQL examples and supabase.com or postgresql.org links only)
- README.md installation section
- LICENSE
Our findings
- The definition routes work to named rules for queries, connections, schema, locking and RLS.
- The inspected missing-index rule contrasts sequential and index scans using a concrete WHERE/JOIN example.
- The RLS reference warns that security-definer functions bypass table policies and calls for caller checks, a non-exposed schema and restricted execution.
- Frontmatter metadata says version 1.1.1, while CHANGELOG.md in the same directory tops out at 1.6.0 (2026-07-30).
- The rule files carry publisher impact figures such as 100-1000x for missing indexes and 5-10x for RLS patterns; none is a measurement of your workload.
- Re-pinned from 8331f910845103c08d51f6ca1d86ebb7d1f745e3 to c9be0e931b7930f7d02126d04774d904c381e7d7: GitHub's compare lists four changed files, none under skills/supabase-postgres-best-practices, and LICENSE and README.md are unchanged. The earlier upstreamDescription was cut mid-sentence and now carries the full frontmatter text.
Not established by this review
- No SQL was executed against a database.
- Workload performance and tenant-isolation behavior were not measured.
The review applies to the material and revision named here. A newer upstream release can change its behavior.
03 / PUT IT TO WORK
Add a skill to your workflow.
DOCUMENTED COMMAND
npx skills add supabase/agent-skills/skills/supabase-postgres-best-practices Run in your terminal to choose your AI tools, project or global scope, and installation method. This short command follows the current upstream version; the review covers the revision shown above.
Optional: install the reviewed revision
Keeps the original source and installer version where recorded, while leaving your AI tools and installation scope for you to choose.
npx skills add https://github.com/supabase/agent-skills/tree/c9be0e931b7930f7d02126d04774d904c381e7d7/skills/supabase-postgres-best-practices - Install the complete skill directory with its references and helpers; a copied SKILL.md alone may be incomplete.
- Choose your AI tools and project or global scope in the installer, then review its permissions before using the skill.
- For manual installation instead, download the complete bundle from https://undominated.ai/resources/skills/supabase-supabase-postgres-best-practices/bundle.zip and extract it into a new directory. It holds SKILL.md and 35 supporting files unchanged at revision c9be0e93, the upstream licence and an attribution file.
- Place the extracted directory in your host's documented skills directory, named supabase-postgres-best-practices. Keep SKILL.md and the licence together.
Before you start
- Node.js/npm for this installer
- An agent that supports the Agent Skills format
- Access to the relevant schema and query plans; database credentials only if you choose to run checks
THE COMPLETE REVIEWED DEFINITION
Read it before you reuse it.
Original source bytes, with attribution.
Review the host-specific setup notes above.
---
name: supabase-postgres-best-practices
description: "Postgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres database: creating or altering tables and columns (including choosing column types), schema design, migrations and declarative schema files, RLS policies and the tests that verify them, indexes, triggers, database functions, queues and scheduled jobs (pg_cron, pgmq), vector/semantic search (pgvector), and restoring dumps (pg_restore) or importing data. Also load it when diagnosing slow queries, high CPU, timeouts, EXPLAIN plans, connection exhaustion, locking, bloat, or rows visible to the wrong user or tenant. This is not just a performance guide — schema, migration, security, and SQL authoring tasks need these rules too, even for a one-column change or a single query."
license: MIT
metadata:
author: supabase
version: "1.1.1"
organization: Supabase
date: January 2026
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.
---
# Supabase Postgres Best Practices
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.
## When to Apply
Reference these guidelines when:
- Writing SQL queries or designing schemas
- Implementing indexes or query optimization
- Reviewing database performance issues
- Configuring connection pooling or scaling
- Optimizing for Postgres-specific features
- Working with Row-Level Security (RLS)
## Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|----------|----------|--------|--------|
| 1 | Query Performance | CRITICAL | `query-` |
| 2 | Connection Management | CRITICAL | `conn-` |
| 3 | Security & RLS | CRITICAL | `security-` |
| 4 | Schema Design | HIGH | `schema-` |
| 5 | Concurrency & Locking | MEDIUM-HIGH | `lock-` |
| 6 | Data Access Patterns | MEDIUM | `data-` |
| 7 | Monitoring & Diagnostics | LOW-MEDIUM | `monitor-` |
| 8 | Advanced Features | LOW | `advanced-` |
## How to Use
Read individual rule files for detailed explanations and SQL examples:
```
references/query-missing-indexes.md
references/query-partial-indexes.md
references/_sections.md
```
Each rule file contains:
- Brief explanation of why it matters
- Incorrect SQL example with explanation
- Correct SQL example with explanation
- Optional EXPLAIN output or metrics
- Additional context and references
- Supabase-specific notes (when applicable)
## References
- https://www.postgresql.org/docs/current/
- https://supabase.com/docs
- https://wiki.postgresql.org/wiki/Performance_Optimization
- https://supabase.com/docs/guides/database/overview
- https://supabase.com/docs/guides/auth/row-level-security
The download contains SKILL.md. Extract the whole bundle; the supporting files are required. Inspect the included MANIFEST.json for file hashes.
By Supabase. Exact upstream source ↗ · Licence · Attribution
SHA-256 ad65e776f45e761bafc609d3f506c77c1032225aa65e0c4c02f241b8071e5855
Read the applicable licence
MIT License Copyright (c) 2026 Supabase Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
04 / FOLLOW THE EVIDENCE
The source trail.
Our notes are separate from the original resource.
Check upstream before adopting a new version.
https://github.com/supabase/agent-skills/blob/c9be0e931b7930f7d02126d04774d904c381e7d7/skills/supabase-postgres-best-practices/SKILL.md
Supports: summary, upstreamDescription, whySelected, bestFor, limitations, review, compatibility, access
https://github.com/supabase/agent-skills/blob/c9be0e931b7930f7d02126d04774d904c381e7d7/skills/supabase-postgres-best-practices/references/query-missing-indexes.md
Supports: review, limitations, access
https://github.com/supabase/agent-skills/blob/c9be0e931b7930f7d02126d04774d904c381e7d7/skills/supabase-postgres-best-practices/references/security-rls-performance.md
Supports: review, limitations, access, bestFor
https://github.com/supabase/agent-skills/blob/c9be0e931b7930f7d02126d04774d904c381e7d7/LICENSE
Supports: license
https://github.com/supabase/agent-skills/blob/c9be0e931b7930f7d02126d04774d904c381e7d7/README.md
Supports: install, compatibility, access
https://github.com/vercel-labs/skills/blob/7407f3893ad4dceab546ac002c3ef806e4000c73/README.md
Supports: install
https://github.com/vercel-labs/skills/blob/7407f3893ad4dceab546ac002c3ef806e4000c73/src/git.ts
Supports: install