postgres-patterns — ai-agents postgres-patterns, everything-claude-code, official, ai-agents, ide skills, anthropic, claude-code, developer-tools, Claude Code, Cursor, Windsurf

Verified
v1.0.0
GitHub

About this Skill

Perfect for Database Analysis Agents needing advanced PostgreSQL optimization and security patterns. PostgreSQL database patterns for query optimization, schema design, indexing, and security. Based on Supabase best practices.

# Core Topics

affaan-m affaan-m
[60.6k]
[7501]
Updated: 3/5/2026

Agent Capability Analysis

The postgres-patterns skill by affaan-m is an open-source official AI agent skill for Claude Code and other IDE workflows, helping agents execute tasks with better context, repeatability, and domain-specific guidance. Optimized for ai-agents, anthropic, claude-code.

Ideal Agent Persona

Perfect for Database Analysis Agents needing advanced PostgreSQL optimization and security patterns.

Core Value

Empowers agents to optimize SQL queries, design efficient database schemas, and implement Row Level Security using B-tree indexing and connection pooling, following Supabase best practices.

Capabilities Granted for postgres-patterns

Optimizing slow queries using index cheat sheets
Designing secure database schemas with Row Level Security
Troubleshooting query performance issues using PostgreSQL patterns

! Prerequisites & Limits

  • Requires PostgreSQL database access
  • Limited to PostgreSQL-specific features and best practices
Labs Demo

Browser Sandbox Environment

⚡️ Ready to unleash?

Experience this Agent in a zero-setup browser environment powered by WebContainers. No installation required.

Boot Container Sandbox

postgres-patterns

Install postgres-patterns, an AI agent skill for AI agent workflows and automation. Works with Claude Code, Cursor, and Windsurf with one-command setup.

SKILL.md
Readonly

PostgreSQL Patterns

Quick reference for PostgreSQL best practices. For detailed guidance, use the database-reviewer agent.

When to Activate

  • Writing SQL queries or migrations
  • Designing database schemas
  • Troubleshooting slow queries
  • Implementing Row Level Security
  • Setting up connection pooling

Quick Reference

Index Cheat Sheet

Query PatternIndex TypeExample
WHERE col = valueB-tree (default)CREATE INDEX idx ON t (col)
WHERE col > valueB-treeCREATE INDEX idx ON t (col)
WHERE a = x AND b > yCompositeCREATE INDEX idx ON t (a, b)
WHERE jsonb @> '{}'GINCREATE INDEX idx ON t USING gin (col)
WHERE tsv @@ queryGINCREATE INDEX idx ON t USING gin (col)
Time-series rangesBRINCREATE INDEX idx ON t USING brin (col)

Data Type Quick Reference

Use CaseCorrect TypeAvoid
IDsbigintint, random UUID
Stringstextvarchar(255)
Timestampstimestamptztimestamp
Moneynumeric(10,2)float
Flagsbooleanvarchar, int

Common Patterns

Composite Index Order:

sql
1-- Equality columns first, then range columns 2CREATE INDEX idx ON orders (status, created_at); 3-- Works for: WHERE status = 'pending' AND created_at > '2024-01-01'

Covering Index:

sql
1CREATE INDEX idx ON users (email) INCLUDE (name, created_at); 2-- Avoids table lookup for SELECT email, name, created_at

Partial Index:

sql
1CREATE INDEX idx ON users (email) WHERE deleted_at IS NULL; 2-- Smaller index, only includes active users

RLS Policy (Optimized):

sql
1CREATE POLICY policy ON orders 2 USING ((SELECT auth.uid()) = user_id); -- Wrap in SELECT!

UPSERT:

sql
1INSERT INTO settings (user_id, key, value) 2VALUES (123, 'theme', 'dark') 3ON CONFLICT (user_id, key) 4DO UPDATE SET value = EXCLUDED.value;

Cursor Pagination:

sql
1SELECT * FROM products WHERE id > $last_id ORDER BY id LIMIT 20; 2-- O(1) vs OFFSET which is O(n)

Queue Processing:

sql
1UPDATE jobs SET status = 'processing' 2WHERE id = ( 3 SELECT id FROM jobs WHERE status = 'pending' 4 ORDER BY created_at LIMIT 1 5 FOR UPDATE SKIP LOCKED 6) RETURNING *;

Anti-Pattern Detection

sql
1-- Find unindexed foreign keys 2SELECT conrelid::regclass, a.attname 3FROM pg_constraint c 4JOIN pg_attribute a ON a.attrelid = c.conrelid AND a.attnum = ANY(c.conkey) 5WHERE c.contype = 'f' 6 AND NOT EXISTS ( 7 SELECT 1 FROM pg_index i 8 WHERE i.indrelid = c.conrelid AND a.attnum = ANY(i.indkey) 9 ); 10 11-- Find slow queries 12SELECT query, mean_exec_time, calls 13FROM pg_stat_statements 14WHERE mean_exec_time > 100 15ORDER BY mean_exec_time DESC; 16 17-- Check table bloat 18SELECT relname, n_dead_tup, last_vacuum 19FROM pg_stat_user_tables 20WHERE n_dead_tup > 1000 21ORDER BY n_dead_tup DESC;

Configuration Template

sql
1-- Connection limits (adjust for RAM) 2ALTER SYSTEM SET max_connections = 100; 3ALTER SYSTEM SET work_mem = '8MB'; 4 5-- Timeouts 6ALTER SYSTEM SET idle_in_transaction_session_timeout = '30s'; 7ALTER SYSTEM SET statement_timeout = '30s'; 8 9-- Monitoring 10CREATE EXTENSION IF NOT EXISTS pg_stat_statements; 11 12-- Security defaults 13REVOKE ALL ON SCHEMA public FROM public; 14 15SELECT pg_reload_conf();
  • Agent: database-reviewer - Full database review workflow
  • Skill: clickhouse-io - ClickHouse analytics patterns
  • Skill: backend-patterns - API and backend patterns

Based on Supabase Agent Skills (credit: Supabase team) (MIT License)

FAQ & Installation Steps

These questions and steps mirror the structured data on this page for better search understanding.

? Frequently Asked Questions

What is postgres-patterns?

Perfect for Database Analysis Agents needing advanced PostgreSQL optimization and security patterns. PostgreSQL database patterns for query optimization, schema design, indexing, and security. Based on Supabase best practices.

How do I install postgres-patterns?

Run the command: npx killer-skills add affaan-m/everything-claude-code/postgres-patterns. It works with Cursor, Windsurf, VS Code, Claude Code, and 19+ other IDEs.

What are the use cases for postgres-patterns?

Key use cases include: Optimizing slow queries using index cheat sheets, Designing secure database schemas with Row Level Security, Troubleshooting query performance issues using PostgreSQL patterns.

Which IDEs are compatible with postgres-patterns?

This skill is compatible with Cursor, Windsurf, VS Code, Trae, Claude Code, OpenClaw, Aider, Codex, OpenCode, Goose, Cline, Roo Code, Kiro, Augment Code, Continue, GitHub Copilot, Sourcegraph Cody, and Amazon Q Developer. Use the Killer-Skills CLI for universal one-command installation.

Are there any limitations for postgres-patterns?

Requires PostgreSQL database access. Limited to PostgreSQL-specific features and best practices.

How To Install

  1. 1. Open your terminal

    Open the terminal or command line in your project directory.

  2. 2. Run the install command

    Run: npx killer-skills add affaan-m/everything-claude-code/postgres-patterns. The CLI will automatically detect your IDE or AI agent and configure the skill.

  3. 3. Start using the skill

    The skill is now active. Your AI agent can use postgres-patterns immediately in the current project.

Related Skills

Looking for an alternative to postgres-patterns or another official skill for your workflow? Explore these related open-source skills.

View All

flags

Logo of facebook
facebook

Use when you need to check feature flag states, compare channels, or debug why a feature behaves differently across release channels.

243.6k
0
Developer

extract-errors

Logo of facebook
facebook

Use when adding new error messages to React, or seeing unknown error code warnings.

243.6k
0
Developer

fix

Logo of facebook
facebook

Use when you have lint errors, formatting issues, or before committing code to ensure it passes CI.

243.6k
0
Developer

flow

Logo of facebook
facebook

Use when you need to run Flow type checking, or when seeing Flow type errors in React code.

243.6k
0
Developer