
Postgresql Code Review
- 11.4k installs
- 37.1k repo stars
- Updated July 28, 2026
- github/awesome-copilot
PostgreSQL code review assistant that identifies schema design issues, inefficient query patterns, missing indexes, underutilized types, and security policy gaps specific to PostgreSQL.
About
PostgreSQL Code Review Assistant analyzes SQL code and schema definitions for PostgreSQL-specific anti-patterns, performance issues, and missed optimization opportunities. Developers use it to catch inefficient JSONB queries, array operations, index strategies, and privilege management before deployment. Key workflows include reviewing JSONB containment operators vs text operators, validating GIN/GiST index usage, checking ENUM type adoption over VARCHAR, auditing Row Level Security policies, and ensuring TIMESTAMPTZ usage in temporal columns. The tool identifies patterns like unindexed JSONB text extraction, missing CHECK constraints, generic permissions, and inefficient trigger functions.
- Reviews JSONB operations for indexability and operator choice (containment vs extraction)
- Validates PostgreSQL schema design: ENUM types, CITEXT, TIMESTAMPTZ, custom domains, and constraints
- Audits array query patterns and GIN index usage for efficient set operations
- Checks Row Level Security (RLS) policies and role privilege granularity
- Identifies PL/pgSQL function inefficiencies and extension usage patterns
Postgresql Code Review by the numbers
- 11,413 all-time installs (skills.sh)
- +140 installs in the week ending Jul 28, 2026 (Skillselion tracking)
- Ranked #27 of 1,382 Code Review & Quality skills by installs in the Skillselion catalog
- Security screen: MEDIUM risk (skills.sh audit)
- Data as of Jul 28, 2026 (Skillselion catalog sync)
postgresql-code-review capabilities & compatibility
- Capabilities
- jsonb query pattern analysis and indexing valida · array operation review and gin index strategy · schema design audit for type choices and constra · rls policy review and privilege granularity chec · pl/pgsql function efficiency evaluation · anti pattern detection and refactoring suggestio
- Use cases
- code review · database
What postgresql-code-review says it does
PostgreSQL-specific code review assistant focusing on PostgreSQL best practices, anti-patterns, and unique quality standards. Covers JSONB operations, array usage, custom types, schema design, functio
Focus on PostgreSQL's unique capabilities and ensure the code leverages what makes PostgreSQL special rather than treating it as a generic SQL database.
npx skills add https://github.com/github/awesome-copilot --skill postgresql-code-reviewAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 11.4k |
|---|---|
| repo stars | ★ 37.1k |
| Security audit | 3 / 3 scanners passed |
| Last updated | July 28, 2026 |
| Repository | github/awesome-copilot ↗ |
What it does
Review PostgreSQL code for schema design, indexing strategy, JSONB patterns, and RLS implementation against PostgreSQL-specific best practices.
Who is it for?
Teams building PostgreSQL databases, APIs with complex data models, applications using JSONB, systems requiring row-level access control.
Skip if: Non-PostgreSQL databases (MySQL, SQLite, Oracle); generic SQL code review without database-specific context.
When should I use this skill?
Before merging SQL schema changes, stored procedures, migration scripts, or when adding JSONB/array columns.
What you get
Reviewed code follows PostgreSQL best practices: proper data types, appropriate indexes, efficient JSONB/array queries, security policies, and leverages PostgreSQL-exclusive features.
- PostgreSQL review findings
- JSONB optimization suggestions
- RLS and schema recommendations
By the numbers
- Covers 7 PostgreSQL-specific review areas: JSONB, arrays, schema, custom types, functions, extensions, RLS
- Includes 40+ code examples (bad vs good patterns)
- Provides checklist covering schema design, performance, features, and security
Files
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
-- ❌ 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
-- ❌ 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
-- ❌ 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
-- ❌ 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
-- ❌ 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 update_modified_time()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = CURRENT_TIMESTAMP;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
-- Set trigger to fire only when needed
CREATE TRIGGER update_modified_time_trigger
BEFORE UPDATE ON table_name
FOR EACH ROW
WHEN (OLD.* IS DISTINCT FROM NEW.*)
EXECUTE FUNCTION update_modified_time();📊 PostgreSQL Extension Usage Review
Extension Best Practices
-- ✅ Check if extension exists before creating
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
CREATE EXTENSION IF NOT EXISTS "pg_trgm";
-- ✅ Use extensions appropriately
-- UUID generation
SELECT uuid_generate_v4();
-- Password hashing
SELECT crypt('password', gen_salt('bf'));
-- Fuzzy text matching
SELECT word_similarity('postgres', 'postgre');🛡️ PostgreSQL Security Review
Row Level Security (RLS)
-- ✅ GOOD: Implementing RLS
ALTER TABLE sensitive_data ENABLE ROW LEVEL SECURITY;
CREATE POLICY user_data_policy ON sensitive_data
FOR ALL TO application_role
USING (user_id = current_setting('app.current_user_id')::INTEGER);Privilege Management
-- ❌ BAD: Overly broad permissions
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO app_user;
-- ✅ GOOD: Granular permissions
GRANT SELECT, INSERT, UPDATE ON specific_table TO app_user;
GRANT USAGE ON SEQUENCE specific_table_id_seq TO app_user;🎯 PostgreSQL Code Quality Checklist
Schema Design
- [ ] Using appropriate PostgreSQL data types (CITEXT, JSONB, arrays)
- [ ] Leveraging ENUM types for constrained values
- [ ] Implementing proper CHECK constraints
- [ ] Using TIMESTAMPTZ instead of TIMESTAMP
- [ ] Defining custom domains for reusable constraints
Performance Considerations
- [ ] Appropriate index types (GIN for JSONB/arrays, GiST for ranges)
- [ ] JSONB queries using containment operators (@>, ?)
- [ ] Array operations using PostgreSQL-specific operators
- [ ] Proper use of window functions and CTEs
- [ ] Efficient use of PostgreSQL-specific functions
PostgreSQL Features Utilization
- [ ] Using extensions where appropriate
- [ ] Implementing stored procedures in PL/pgSQL when beneficial
- [ ] Leveraging PostgreSQL's advanced SQL features
- [ ] Using PostgreSQL-specific optimization techniques
- [ ] Implementing proper error handling in functions
Security and Compliance
- [ ] Row Level Security (RLS) implementation where needed
- [ ] Proper role and privilege management
- [ ] Using PostgreSQL's built-in encryption functions
- [ ] Implementing audit trails with PostgreSQL features
📝 PostgreSQL-Specific Review Guidelines
1. Data Type Optimization: Ensure PostgreSQL-specific types are used appropriately 2. Index Strategy: Review index types and ensure PostgreSQL-specific indexes are utilized 3. JSONB Structure: Validate JSONB schema design and query patterns 4. Function Quality: Review PL/pgSQL functions for efficiency and best practices 5. Extension Usage: Verify appropriate use of PostgreSQL extensions 6. Performance Features: Check utilization of PostgreSQL's advanced features 7. Security Implementation: Review PostgreSQL-specific security features
Focus on PostgreSQL's unique capabilities and ensure the code leverages what makes PostgreSQL special rather than treating it as a generic SQL database.
Related skills
How it compares
Pick postgresql-code-review for Postgres-native JSONB, RLS, and schema review; use generic SQL linters when the database engine is not PostgreSQL or review scope is language-agnostic.
FAQ
How do I make JSONB queries use indexes efficiently?
Use containment operator @> instead of text extraction (->>'key' = 'value'), create GIN indexes: CREATE INDEX idx ON table USING gin(data), and structure JSONB with consistent schemas.
When should I use ENUM vs VARCHAR in PostgreSQL?
Use ENUM for fixed, known value sets (status, currency, roles) - they save space, enforce type safety, and are faster than VARCHAR. Use VARCHAR only for unbounded text.
What's the difference between TIMESTAMP and TIMESTAMPTZ?
TIMESTAMPTZ stores timezone info and is UTC-aware, recommended for all temporal columns to avoid ambiguity. TIMESTAMP omits timezone and can cause bugs in multi-region systems.
Is Postgresql Code Review safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.