Generated banner for Supabase Postgres Best Practices
Generated logo for Supabase Postgres Best Practices

Supabase Postgres Best Practices

OpenAIOfficialCreated by supabaseDistributed by OpenAI

  • Skill
  • Guidelines
  • Software development
  • MIT
  • No issues found

From the author

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

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides a structured set of guidelines for optimizing Postgres database performance, schema design, and connection management. It is organized into eight priority-based categories, ranging from critical query performance and connection handling to advanced features. Each rule follows a standardized format featuring concrete transformation patterns, error-first examples, and quantified performance impacts to assist developers in writing efficient, scalable SQL.

What it does

  • Provides actionable SQL transformation patterns to replace inefficient anti-patterns.
  • Categorizes performance rules by impact level from critical to incremental.
  • Offers guidance on connection pooling, RLS, and transaction management.
  • Includes standardized templates for analyzing query plans and performance metrics.
  • Focuses on semantic naming and clear, portable SQL examples.
  • Supplies best practices for schema design and indexing strategies.

When to use it

  • When writing or refactoring SQL queries for better performance.
  • During database schema design to ensure long-term scalability.
  • When troubleshooting slow queries or high database load.
  • When configuring connection limits or implementing row-level security.
  • When auditing existing database code for common performance anti-patterns.

Advantages

  • Standardized format makes it easy for AI agents to parse and apply rules.
  • Prioritized impact levels help developers focus on the most critical bottlenecks first.
  • Concrete before-and-after examples reduce ambiguity in optimization tasks.
  • Maintained by experts with a focus on real-world Postgres performance.
  • Promotes clean, maintainable, and efficient SQL coding standards.

Usage examples

“How can I optimize my N+1 query issue in Postgres?”
The agent identifies the N+1 pattern and suggests replacing sequential queries with a single batched query using the ANY operator or JOINs, referencing the data-n-plus-one guide.
“Review this SQL query for potential performance improvements.”
The agent analyzes the query against the provided guidelines, identifying missing indexes or inefficient scan patterns and proposing a corrected SQL version with an explanation of the expected performance gain.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/openai/supabase-postgres-best-practices-lhfb/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip supabase-postgres-best-practices.zip -d .agents/skills

Documentation by supabase

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

Files

references/schema-lowercase-identifiers.md


title: Use Lowercase Identifiers for Compatibility impact: MEDIUM impactDescription: Avoid case-sensitivity bugs with tools, ORMs, and AI assistants tags: naming, identifiers, case-sensitivity, schema, conventions

Use Lowercase Identifiers for Compatibility

PostgreSQL folds unquoted identifiers to lowercase. Quoted mixed-case identifiers require quotes forever and cause issues with tools, ORMs, and AI assistants that may not recognize them.

Incorrect (mixed-case identifiers):

-- Quoted identifiers preserve case but require quotes everywhere
CREATE TABLE "Users" (
  "userId" bigint PRIMARY KEY,
  "firstName" text,
  "lastName" text
);

-- Must always quote or queries fail
SELECT "firstName" FROM "Users" WHERE "userId" = 1;

-- This fails - Users becomes users without quotes
SELECT firstName FROM Users;
-- ERROR: relation "users" does not exist

Correct (lowercase snake_case):

-- Unquoted lowercase identifiers are portable and tool-friendly
CREATE TABLE users (
  user_id bigint PRIMARY KEY,
  first_name text,
  last_name text
);

-- Works without quotes, recognized by all tools
SELECT first_name FROM users WHERE user_id = 1;

Common sources of mixed-case identifiers:

-- ORMs often generate quoted camelCase - configure them to use snake_case
-- Migrations from other databases may preserve original casing
-- Some GUI tools quote identifiers by default - disable this

-- If stuck with mixed-case, create views as a compatibility layer
CREATE VIEW users AS SELECT "userId" AS user_id, "firstName" AS first_name FROM "Users";

Reference: Identifiers and Key Words

Requirements and compatibility

Written for: OpenAI Codex

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
supabase
Publisher
OpenAI (Official)
Distributed by
OpenAI
Source
openai/plugins · plugins/supabase/skills/supabase-postgres-best-practices · commit d420d13
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from plugins/supabase/LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by supabase or OpenAI.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download supabase-postgres-best-practices.zip