mcpField
S
supabase-postgres-best-practices

supabase-postgres-best-practices

github.com/laguaguData & databases71138 installsUpdated 1d ago
Repository

About supabase-postgres-best-practices

Supabase Postgres Best Practices is a reference skill maintained by Supabase for query optimization and database design. Its prioritized rules cover performance, connections, security, schema, and other Postgres concerns, with SQL examples for individual recommendations.

Key features

  1. 01Eight categories of Postgres guidance
  2. 02Rules prioritized by impact
  3. 03SQL examples for each rule
  4. 04Coverage of RLS and connection pooling
  5. 05Diagnostics for queries and vacuuming

Use cases

  1. 01Optimizing slow SQL queries
  2. 02Designing indexes and schemas
  3. 03Reviewing RLS and database security
  4. 04Troubleshooting connection or vacuum issues

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/laguagu/claude-code-nextjs-skills --skill supabase-postgres-best-practices

After installing, type/supabase-postgres-best-practicesin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

CHANGELOG.md
references/
_contributing.md
_sections.md
_template.md
advanced-full-text-search.md
advanced-jsonb-indexing.md
conn-idle-timeout.md
conn-limits.md
conn-pooling.md
conn-prepared-statements.md
data-batch-inserts.md
data-n-plus-one.md
data-pagination.md
data-upsert.md
lock-advisory.md
lock-deadlock-prevention.md
lock-short-transactions.md
lock-skip-locked.md
monitor-explain-analyze.md
monitor-pg-stat-statements.md
monitor-vacuum-analyze.md
query-composite-indexes.md
query-covering-indexes.md
query-index-types.md
query-missing-indexes.md
query-partial-indexes.md
schema-constraints.md
schema-data-types.md
schema-foreign-key-indexes.md
schema-lowercase-identifiers.md

Details

From the project README

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)

Quick Decision Tree

Problem?
├─ Slow query → query-missing-indexes, query-composite-indexes, monitor-explain-analyze
├─ Connection errors / timeouts → conn-pooling, conn-limits, conn-idle-timeout
├─ Deadlocks / long transactions → lock-short-transactions, lock-deadlock-prevention
├─ Bulk load slow → data-batch-inserts, data-upsert
├─ Table bloat / VACUUM issues → monitor-vacuum-analyze
├─ JSONB queries slow → advanced-jsonb-indexing
├─ FTS / search quality → advanced-full-text-search (pair with /postgres-semantic-search for BM25 + vector)
└─ Security / multi-tenant → security-* rules, RLS

Related Skills

  • /postgres-semantic-search — Vector search (pgvector), hybrid BM25 + semantic, ParadeDB
  • /nextjs-chatbot — Chatbot orchestration, session DB, feedback, HITL
  • /ai-sdk — AI SDK patterns for backend integration

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

Comments

Markdown supported