Solid reference for the PostgreSQL patterns you'll actually need when building production apps. Covers the index cheat sheet everyone wishes they had bookmarked (composite vs GIN vs BRIN), common gotchas like RLS policy wrapping and cursor pagination over OFFSET, and those diagnostic queries for finding unindexed foreign keys or table bloat. The data type guide alone saves you from the classic varchar(255) and float-for-money mistakes. It's based on Supabase's internal patterns, so the recommendations come from teams running Postgres at scale. Activate this when writing migrations or debugging slow queries, then escalate to the database-reviewer agent if you need deeper analysis.

skills.sh installs
7.1K
GitHub stars
229.1K
last updated
Jul 14, 2026

Install

$ npx -y skills add affaan-m/everything-claude-code --skill postgres-patterns --agent claude-code

Installs into .claude/skills of the current project.

Files

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

Sponsors

Details

Repository
github.com/affaan-m/everything-claude-code
Category
Databases

More from affaan-m/everything-claude-code

All 256

Recommended

More Databases
1affaan-m avatardatabase-migrationsaffaan-m/everything-claude-codedatabase migrations5.9Kskills.sh installs
2yaklang avatarsqli-sql-injectionyaklang/hack-skillsSQL injection playbook. Use when input reaches SQL queries, authentication logic, sorting, filtering, reporting, or DB-specific blind and out-of-band execution 4.2Kskills.sh installs
3sickn33 avatarprisma-expertsickn33/antigravity-awesome-skillsprisma expert3.8Kskills.sh installs
4sickn33 avatardatabase-designsickn33/antigravity-awesome-skillsdatabase design1.7Kskills.sh installs
5lobehub avatardrizzlelobehub/lobe-chatdrizzle1.4Kskills.sh installs
6firebase avatarfirebase-data-connectfirebase/skillsfirebase data connect895skills.sh installs