supabase-postgres-best-practices
This skill provides a comprehensive guide to Postgres optimization and best practices maintained by Supabase.
Identity proven by GitHub's verified organisation badge (supabase)
- Agents
- Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, claude.ai and API
- License
- MIT (permissive)
- Pin
- c9be0e9pinned Oct 9, 2026
- Context cost
- about 440 tokenswhen the skill loads
- GitHub stars
- 2,708on supabase/agent-skills
- Scripts
- None found
What it does
“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.”
Generated summary from the skill's own text
This skill provides a comprehensive guide to Postgres optimization and best practices maintained by Supabase. It covers query performance, connection management, security with Row-Level Security, schema design, locking, data access patterns, monitoring, and advanced features through categorized rules with SQL examples and explanations.
When to use it
- Writing SQL queries or designing database schemas
- Implementing indexes or diagnosing slow query performance
- Configuring connection pooling or database scaling
- Setting up Row-Level Security policies and access control
When not to
- Working with non-Postgres database systems
- Seeking vendor-specific Supabase platform configuration advice
Install
These commands install from the publisher's repository and need no account.
skills CLI
npx skills add supabase/agent-skills --skill supabase-postgres-best-practicesInstalls from the repository's default branch, which may have changed since the commit we checked.
GitHub CLI 2.90 or later
gh skill install supabase/agent-skills supabase-postgres-best-practices@c9be0e931b7930f7d02126d04774d904c381e7d7Installs the commit we checked (c9be0e9).
Copy by hand
Download the folder at c9be0e9 and put it in .claude/skills/supabase-postgres-best-practices for Claude Code and in .agents/skills/supabase-postgres-best-practices for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.
Claude Code plugin
/plugin install supabase@claude-plugins-officialThe publisher's plugin in Claude's official marketplace. It may hold more than this skill, and we have not pinned it.
Copy for your agent
A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.
Prompt
Install the agent skill "supabase-postgres-best-practices" by Supabase. Source, pinned to commit c9be0e931b7930f7d02126d04774d904c381e7d7: https://github.com/supabase/agent-skills/tree/c9be0e931b7930f7d02126d04774d904c381e7d7/skills/supabase-postgres-best-practices 1. Download that folder at exactly this commit. Do not use the default branch. 2. Copy every file unchanged, keeping the folder structure, into .claude/skills/supabase-postgres-best-practices/ for Claude Code and .agents/skills/supabase-postgres-best-practices/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist. 3. Do not edit the files, and do not run any script in the folder unless I ask you to. 4. When you are done, list the files you copied and where you put them. Listing and checks: https://www.agentnative.dev/skills/supabase/supabase-postgres-best-practices-agent-skills
SKILL.md at the pin
--- 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
From supabase/agent-skills at c9be0e9, shown as plain text under its license: MIT (permissive). The license text is in skills/supabase-postgres-best-practices/SKILL.md.
View SKILL.md on GitHub at c9be0e9Files
- SKILL.md3.2 KB · ad65e776f45e
- CHANGELOG.md5.7 KB · 751ad110037c
- references/
- _contributing.md4.1 KB · 191e039e7d94
- _sections.md1.7 KB · c9e992612b42
- _template.md1.0 KB · 6299954250f2
- advanced-full-text-search.md1.5 KB · 40c2606bbb4c
- advanced-jsonb-indexing.md1.4 KB · 24cacf6a8bc3
- conn-idle-timeout.md1.3 KB · 630588902c00
- conn-limits.md1.3 KB · 11b2a67a7c76
- conn-pooling.md1.4 KB · 88cf086bf98b
- conn-prepared-statements.md1.5 KB · 174e9332fe3d
- data-batch-inserts.md1.3 KB · 531933b82d6a
- data-n-plus-one.md1.4 KB · 21a44905e5b1
- data-pagination.md1.4 KB · 73c9fa10a3d4
- data-upsert.md1.4 KB · 2612af83b20a
- lock-advisory.md1.5 KB · c88d259dbf81
- lock-deadlock-prevention.md1.9 KB · 09aee46f51d7
- lock-short-transactions.md1.4 KB · 5aa7f6109591
- lock-skip-locked.md1.4 KB · 6c45077f430f
- monitor-explain-analyze.md1.4 KB · 4cb67ffbf8e5
- monitor-pg-stat-statements.md1.4 KB · 89dca99d4e89
- monitor-vacuum-analyze.md1.5 KB · 289227201171
- query-composite-indexes.md1.5 KB · 73e42424e671
- query-covering-indexes.md1.3 KB · daf2a7f0477f
- query-index-types.md1.5 KB · 472a74f22c2d
- query-missing-indexes.md1.2 KB · 91ad8b0ff436
- query-partial-indexes.md1.3 KB · 6448982bc855
- schema-constraints.md1.9 KB · 90e8efda3e9e
- schema-data-types.md1.5 KB · e01b58c14c7f
- schema-foreign-key-indexes.md1.7 KB · 7587713d12a6
- schema-lowercase-identifiers.md1.7 KB · 4bc80f70865f
- schema-partitioning.md1.5 KB · 541e13fbeaf4
- schema-primary-keys.md1.8 KB · 3c8beabef820
- security-privileges.md1.6 KB · 095909274a4f
- security-rls-basics.md1.4 KB · e04dd1a3a382
- security-rls-performance.md2.1 KB · 2e1faeca7d57
36 files, 62 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.
Skill folder on GitHub at c9be0e9Also in
The same SKILL.md content appears in these places too. We list it once and credit the oldest public source.
More from Supabase
supabase
This skill enables the agent to work with Supabase products including Database, Auth, Edge Functions, Realtime, Storage, and Vectors.
Claude Code, Codex, Cursor +4 · about 3.3K tokens · pinned 6 days ago
supabase
This skill enables agents to work with Supabase across databases, authentication, edge functions, storage, realtime services, and related client libraries.
Claude Code, Codex, Cursor +4 · about 3.3K tokens · pinned 6 days ago
Related in Data and databases
prisma-8
This skill helps agents work with Prisma 8, a contract-first data layer for TypeScript projects.
by PrismaOfficial publisher
Contains scripts
Claude Code, Codex, Cursor +3 · about 3.5K tokens · pinned 6 days ago
infra-postgres
This skill sets up and manages Postgres databases using the clickhousectl CLI.
by ClickHouseOfficial publisher
Contains scripts
Claude Code, Codex, Cursor +3 · about 570 tokens · pinned 6 days ago
prisma-next-contract
This skill enables editing the Prisma Next data contract, the single source of truth for your data layer.
by PrismaOfficial publisher
Claude Code, Codex, Cursor +4 · about 6.9K tokens · pinned 6 days ago
vercel-storage
This skill guides agents through Vercel's storage ecosystem, including Blob for file uploads, Global Config for edge-accessible configuration, and Marketplace…
by VercelOfficial publisher
Claude Code, Codex, Cursor +3 · about 3.4K tokens · pinned 6 days ago
netlify-database
This skill enables agents to set up and manage zero-config managed Postgres databases on Netlify via the @netlify/database package.
by NetlifyOfficial publisher
Claude Code, Codex, Cursor +4 · about 4.7K tokens · pinned 6 days ago
dsql
This skill enables agents to build and manage Aurora DSQL, a serverless PostgreSQL-compatible distributed SQL database.
by Amazon (AWS)Official publisher
Contains scripts
Claude Code, Codex, Cursor +3 · about 6.5K tokens · pinned 6 days ago
Open roles at Supabase
1 open role on the jobs board
- Edge Functions Engineer
Remote, Global (Remote)