Skip to content
affaan-m avatar

Postgres Patterns

PostgreSQL reference covering index selection, data types, RLS policies, and slow-query diagnosis in one quick-reference sheet.

CCM score
71 of 100
skills.sh installs
15.2K
GitHub stars
312.6K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers index type choice (B-tree, GIN, BRIN, composite, covering, partial), data type picks, and common query patterns like UPSERT and cursor pagination
  • Includes ready-to-run SQL for finding unindexed foreign keys, slow queries via pg_stat_statements, and table bloat
  • Provides a configuration template setting max_connections, work_mem, and statement and idle-transaction timeouts, plus a REVOKE on the public schema
  • Designed for developers writing schemas, migrations, or RLS policies, or troubleshooting slow queries

Install

$ npx -y skills add affaan-m/ecc --skill postgres-patterns -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

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

Details

Repository
github.com/affaan-m/ecc
Category
Databases
First seen
Jul 14, 2026

Questions

What does the postgres-patterns skill help with?

The postgres-patterns skill gives an agent PostgreSQL patterns for query optimization, schema design, indexing, and security. It includes quick references for index types, data type choices, cursor pagination, queue processing, and Row Level Security policies.

Is postgres-patterns a good fit for debugging slow PostgreSQL queries?

Yes, the skill is meant to be used when a query is too slow or when designing PostgreSQL schemas, indexes, or RLS policies. It includes anti-pattern detection queries that find unindexed foreign keys, slow statements through pg_stat_statements, and table bloat.

How do I install the postgres-patterns skill?

Run npx -y skills add affaan-m/ecc --skill postgres-patterns -y inside your project. Once installed, the agent can use the PostgreSQL index cheat sheet, data type guidance, and configuration template in its work.

Which skills lead the Databases category where postgres-patterns ranks?

postgres-patterns ranks in the top 50 of the Databases category on Claude Marketplaces. Its neighbors there include supabase-postgres-best-practices and several Prisma skills, while postgres-patterns focuses on raw PostgreSQL tuning and Row Level Security.

More from affaan-m/ecc

All 257

Similar to Postgres Patterns

More Databases