supabase-postgres-best-practices

Postgres performance optimization rules across 8 priority categories, from query tuning to advanced features. Organized into 8 rule categories prioritized by impact: query performance and connection management (critical), security and RLS, schema design, concurrency, data access patterns, monitoring, and advanced features Each rule includes detailed explanations, incorrect vs. correct SQL examples, EXPLAIN output analysis, and performance metrics to guide optimization decisions Covers query...

npx skills add https://github.com/supabase/agent-skills --skill supabase-postgres-best-practices

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

PriorityCategoryImpactPrefix
1Query PerformanceCRITICALquery-
2Connection ManagementCRITICALconn-
3Security & RLSCRITICALsecurity-
4Schema DesignHIGHschema-
5Concurrency & LockingMEDIUM-HIGHlock-
6Data Access PatternsMEDIUMdata-
7Monitoring & DiagnosticsLOW-MEDIUMmonitor-
8Advanced FeaturesLOWadvanced-

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

More skills from supabase

skill-creator
supabase
Comprehensive guide for creating modular skills that extend Claude's capabilities with specialized knowledge and workflows. Skills consist of a required SKILL.md file with YAML frontmatter and markdown instructions, plus optional bundled resources (scripts, references, assets) organized by purpose and loaded progressively to conserve context Design skills around concrete usage examples; identify reusable scripts for deterministic tasks, reference files for domain knowledge, and assets for...
official
supabase
supabase
Use when doing ANY task involving Supabase. Triggers: Supabase products (Database, Auth, Edge Functions, Realtime, Storage, Vectors, Cron, Queues); client…
official
supabase-server
supabase
Use when writing server-side code with Supabase β€” Edge Functions, Hono apps, webhook handlers, or any backend that needs Supabase auth and client creation.…
official
dev-toolbar-review
supabase
Use when reviewing PRs that touch packages/dev-tools/, packages/common/posthog-client.ts,
official
e2e-studio-tests
supabase
Run e2e tests in the Studio app. Use when asked to run e2e tests, run studio tests, playwright tests, or test the feature.
official
studio-best-practices
supabase
React and TypeScript best practices for Supabase Studio. Use when writing
official
studio-e2e-tests
supabase
Write and run Playwright E2E tests for Supabase Studio. Use when asked
official
studio-error-handling
supabase
Error display and troubleshooting pattern for Supabase Studio. Use when
official