supabase

supabase-postgres-best-practices

767
42
# Install this skill:
npx skills add supabase/agent-skills

Or install specific skill: npx add-skill https://github.com/supabase/agent-skills/tree/main/skills/supabase-postgres-best-practices

# Description

Postgres performance optimization and best practices from Supabase. Use this skill when writing, reviewing, or optimizing Postgres queries, schema designs, or database configurations.

# SKILL.md


name: supabase-postgres-best-practices
description: Postgres performance optimization and best practices from Supabase. Use this skill when writing, reviewing, or optimizing Postgres queries, schema designs, or database configurations.
license: MIT
metadata:
author: supabase
version: "1.1.0"
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/schema-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)

Full Compiled Document

For the complete guide with all rules expanded: AGENTS.md

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

# README.md

Supabase Agent Skills

Supabase Agent Skills

Agent Skills to help developers using AI agents with Supabase. Agent Skills are
folders of instructions, scripts, and resources that agents like Claude Code,
Cursor, Github Copilot, etc... can discover and use to do things more accurately
and efficiently.

The skills in this repo follow the Agent Skills
format.

Installation

npx skills add supabase/agent-skills

Claude Code Plugin

You can also install the skills in this repo as Claude Code plugins

/plugin marketplace add supabase/agent-skills
/plugin install postgres-best-practices@supabase-agent-skills

Available Skills

supabase-postgres-best-practices Postgres performance optimization guidelines from Supabase. Contains references across 8 categories, prioritized by impact. **Use when:** - Writing SQL queries or designing schemas - Implementing indexes or query optimization - Reviewing database performance issues - Configuring connection pooling or scaling - Working with Row-Level Security (RLS) **Categories covered:** - Query Performance (Critical) - Connection Management (Critical) - Schema Design (High) - Concurrency & Locking (Medium-High) - Security & RLS (Medium-High) - Data Access Patterns (Medium) - Monitoring & Diagnostics (Low-Medium) - Advanced Features (Low)

Usage

Skills are automatically available once installed. The agent will use them when
relevant tasks are detected.

Examples:

Optimize this Postgres query
Review my schema for performance issues
Help me add proper indexes to this table

Skill Structure

Each skill follows the Agent Skills Open Standard:

  • SKILL.md - Required skill manifest with frontmatter (name, description, metadata)
  • AGENTS.md - Compiled references document (generated)
  • references/ - Individual reference files

License

MIT

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.