
Postgresql Code Review
Review PostgreSQL SQL, schemas, and functions for JSONB, arrays, RLS, and Postgres-specific anti-patterns before merge or release.
Overview
PostgreSQL Code Review is an agent skill most often used in Ship (also Operate, Build) that reviews SQL and schemas for Postgres-specific best practices, anti-patterns, and RLS.
Install
npx skills add https://github.com/github/awesome-copilot --skill postgresql-code-reviewWhat is this skill?
- PostgreSQL-specific review areas: JSONB indexing, array GIN usage, and structured validation
- Schema design, function optimization, and anti-pattern callouts with BAD vs GOOD SQL
- Row Level Security and Postgres-exclusive security features called out in description
- Works on editor selection or entire project when no selection is provided
- Targets unique Postgres quality standards beyond generic SQL linting
Adoption & trust: 10.5k installs on skills.sh; 34.6k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your Postgres queries and schemas pass generic checks but still hide missing indexes on JSONB, sloppy arrays, and weak RLS.
Who is it for?
Builders shipping SaaS or APIs on PostgreSQL who want selection-aware or project-wide DBA-style review from the agent.
Skip if: Greenfield schema generation with zero SQL yet, or teams on MySQL/SQLite-only stacks with no Postgres in production.
When should I use this skill?
Expert PostgreSQL code review for ${selection} or entire project when reviewing SQL, schemas, JSONB, arrays, functions, or RLS.
What do I get? / Deliverables
You get actionable BAD versus GOOD rewrites and index or constraint recommendations aligned with PostgreSQL behavior before merge or deploy.
- PostgreSQL-specific review comments
- Indexed-query and schema improvement suggestions
- Anti-pattern rewrites with GOOD examples
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Canonical shelf is Ship review because the skill is invoked on selections or the project for quality gates before production. Code review subphase matches PostgreSQL-focused assistant behavior on ${selection} or whole-project SQL.
Where it fits
Review a migration that adds JSONB order metadata before merging to main.
Sanity-check new array category filters and propose GIN indexes while modeling products.
Audit hot-path queries and RLS policies after a tenant isolation incident report.
How it compares
Use for Postgres-expert review commentary, not as a replacement for automated migration testing or full security penetration audits.
Common Questions / FAQ
Who is postgresql-code-review for?
Solo builders and indie teams using AI coding agents on Node, Python, or Rust apps backed by PostgreSQL who need deep SQL and schema review.
When should I use postgresql-code-review?
In Ship during PR review of migrations and queries; in Build when designing JSONB-heavy tables; in Operate when tuning slow queries or tightening RLS policies.
Is postgresql-code-review safe to install?
It reviews code you already have and does not require secrets by default; confirm vendor source and read the Security Audits panel on this page.
SKILL.md
READMESKILL.md - Postgresql Code Review
# PostgreSQL Code Review Assistant Expert PostgreSQL code review for ${selection} (or entire project if no selection). Focus on PostgreSQL-specific best practices, anti-patterns, and quality standards that are unique to PostgreSQL. ## 🎯 PostgreSQL-Specific Review Areas ### JSONB Best Practices ```sql -- ❌ BAD: Inefficient JSONB usage SELECT * FROM orders WHERE data->>'status' = 'shipped'; -- No index support -- ✅ GOOD: Indexable JSONB queries CREATE INDEX idx_orders_status ON orders USING gin((data->'status')); SELECT * FROM orders WHERE data @> '{"status": "shipped"}'; -- ❌ BAD: Deep nesting without consideration UPDATE orders SET data = data || '{"shipping":{"tracking":{"number":"123"}}}'; -- ✅ GOOD: Structured JSONB with validation ALTER TABLE orders ADD CONSTRAINT valid_status CHECK (data->>'status' IN ('pending', 'shipped', 'delivered')); ``` ### Array Operations Review ```sql -- ❌ BAD: Inefficient array operations SELECT * FROM products WHERE 'electronics' = ANY(categories); -- No index -- ✅ GOOD: GIN indexed array queries CREATE INDEX idx_products_categories ON products USING gin(categories); SELECT * FROM products WHERE categories @> ARRAY['electronics']; -- ❌ BAD: Array concatenation in loops -- This would be inefficient in a function/procedure -- ✅ GOOD: Bulk array operations UPDATE products SET categories = categories || ARRAY['new_category'] WHERE id IN (SELECT id FROM products WHERE condition); ``` ### PostgreSQL Schema Design Review ```sql -- ❌ BAD: Not using PostgreSQL features CREATE TABLE users ( id INTEGER, email VARCHAR(255), created_at TIMESTAMP ); -- ✅ GOOD: PostgreSQL-optimized schema CREATE TABLE users ( id BIGSERIAL PRIMARY KEY, email CITEXT UNIQUE NOT NULL, -- Case-insensitive email created_at TIMESTAMPTZ DEFAULT NOW(), metadata JSONB DEFAULT '{}', CONSTRAINT valid_email CHECK (email ~* '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$') ); -- Add JSONB GIN index for metadata queries CREATE INDEX idx_users_metadata ON users USING gin(metadata); ``` ### Custom Types and Domains ```sql -- ❌ BAD: Using generic types for specific data CREATE TABLE transactions ( amount DECIMAL(10,2), currency VARCHAR(3), status VARCHAR(20) ); -- ✅ GOOD: PostgreSQL custom types CREATE TYPE currency_code AS ENUM ('USD', 'EUR', 'GBP', 'JPY'); CREATE TYPE transaction_status AS ENUM ('pending', 'completed', 'failed', 'cancelled'); CREATE DOMAIN positive_amount AS DECIMAL(10,2) CHECK (VALUE > 0); CREATE TABLE transactions ( amount positive_amount NOT NULL, currency currency_code NOT NULL, status transaction_status DEFAULT 'pending' ); ``` ## 🔍 PostgreSQL-Specific Anti-Patterns ### Performance Anti-Patterns - **Avoiding PostgreSQL-specific indexes**: Not using GIN/GiST for appropriate data types - **Misusing JSONB**: Treating JSONB like a simple string field - **Ignoring array operators**: Using inefficient array operations - **Poor partition key selection**: Not leveraging PostgreSQL partitioning effectively ### Schema Design Issues - **Not using ENUM types**: Using VARCHAR for limited value sets - **Ignoring constraints**: Missing CHECK constraints for data validation - **Wrong data types**: Using VARCHAR instead of TEXT or CITEXT - **Missing JSONB structure**: Unstructured JSONB without validation ### Function and Trigger Issues ```sql -- ❌ BAD: Inefficient trigger function CREATE OR REPLACE FUNCTION update_modified_time() RETURNS TRIGGER AS $$ BEGIN NEW.updated_at = NOW(); -- Should use TIMESTAMPTZ RETURN NEW; END; $$ LANGUAGE plpgsql; -- ✅ GOOD: Optimized trigger function CREATE OR REPLACE FUNCTION