postgresql-code-review

Reviews PostgreSQL code for best practices, anti-patterns, and security issues.

Updated Jul 25, 2026
One-click install
npx skills add https://github.com/kaannakiin/turborepo_template --skill postgresql-code-review-kaannakiin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgresql-code-review
Source: https://github.com/kaannakiin/turborepo_template/tree/main/.agents/skills/postgresql-code-review
Command: npx skills add https://github.com/kaannakiin/turborepo_template --skill postgresql-code-review-kaannakiin

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Reviewing PostgreSQL code with generic SQL knowledge misses database-specific issues like inefficient JSONB queries, missing GIN indexes, wrong data types, and absent Row Level Security, leading to slow queries and insecure schemas. ## Core Features & Use Cases - PostgreSQL-Specific Review: Checks JSONB operations, array usage, custom types, ENUMs, domains, and schema design against PostgreSQL best practices. - Performance & Index Analysis: Identifies missing GIN/GiST indexes, inefficient array operators, and poorly written PL/pgSQL functions and triggers. - Security Review: Validates Row Level Security policies, granular privilege grants, and proper use of extensions like pgcrypto. - Use Case: Before merging a migration that adds JSONB columns and new tables, run this review to catch unindexed JSONB queries, missing CHECK constraints, and overly broad GRANT statements. ## Quick Start Review my PostgreSQL schema and queries for PostgreSQL-specific best practices, performance issues, and security problems.

Frequently Asked Questions about postgresql-code-review

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I review PostgreSQL code for performance issues?

Check that JSONB and array columns use GIN indexes, queries use containment operators like @> instead of unindexed key lookups, and triggers fire only when rows actually change. Also verify TIMESTAMPTZ is used instead of TIMESTAMP and window functions or CTEs replace inefficient patterns.

What are common PostgreSQL JSONB anti-patterns?

Common JSONB anti-patterns include querying with data->>'key' without a supporting index, treating JSONB as an unstructured string, and deep nesting without validation. Use containment queries with GIN indexes and add CHECK constraints to validate JSONB structure.

Does PostgreSQL Row Level Security replace application permissions?

Row Level Security enforces per-row access at the database level using policies tied to roles or session settings. It complements application-level authorization but still requires granular GRANT statements for table and sequence privileges.

When should I use ENUM types instead of VARCHAR in PostgreSQL?

Use ENUM types when a column has a fixed, limited set of values such as status or currency codes. ENUMs enforce validity at the database level and avoid the inconsistency and wasted space of free-form VARCHAR values.

Why is my PostgreSQL array query slow?

Array queries are slow when using = ANY() without an index. Create a GIN index on the array column and rewrite the query with the containment operator @> so PostgreSQL can use the index for lookups.