postgresql-code-review

Reviews existing PostgreSQL SQL, schemas, and functions for antipatterns, quality, and security.

Updated Sep 10, 2026
One-click install
npx skills add https://github.com/serpro-workshop-fortaleza/sifap-modernization-paula --skill postgresql-code-review-serpro-workshop-fortaleza
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgresql-code-review
Source: https://github.com/serpro-workshop-fortaleza/sifap-modernization-paula/tree/main/.github/skills/postgresql-code-review
Command: npx skills add https://github.com/serpro-workshop-fortaleza/sifap-modernization-paula --skill postgresql-code-review-serpro-workshop-fortaleza

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Existing PostgreSQL code often hides antipatterns like unindexed JSONB queries, inefficient array operations, wrong data types, and missing Row Level Security that only surface as production incidents. This Skill audits existing SQL, migrations, and PL/pgSQL functions against PostgreSQL-specific best practices and returns a structured verdict with paste-ready fixes. ## Core Features & Use Cases - PostgreSQL-specific review areas: Audits JSONB indexing and operators, array operations, schema design (CITEXT, ENUM, domains, TIMESTAMPTZ), custom types, extensions, and trigger functions. - Security and privilege checks: Verifies Row Level Security policies, granular GRANT statements, and confirms no user input is concatenated into SQL (JPQL, derived queries, or bound native parameters only). - Structured output: Delivers a verdict (Approved, Correction needed, or Rejected), a severity-ranked findings table with evidence, and corrected SQL ready to paste. - Use Case: Before merging a Flyway migration in backend/src/main/resources/db/migration/, ask for a review and receive findings such as a missing GIN index on a JSONB containment query plus the exact CREATE INDEX statement to fix it. ## Quick Start Review this PostgreSQL migration for antipatterns, JSONB indexing, and RLS security before I merge it.

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 antipatterns?

Submit the existing SQL, migration, or function for review against PostgreSQL-specific checks covering JSONB indexing, array operators, data types, constraints, and security. The output is a verdict, a severity-ranked findings table with evidence, and corrected SQL ready to paste.

What is the difference between postgresql-code-review and postgresql-optimization?

postgresql-code-review audits existing PostgreSQL code and migrations for antipatterns, quality, and security. postgresql-optimization is for creating or tuning new PostgreSQL features rather than reviewing existing ones.

How should JSONB queries be indexed in PostgreSQL?

JSONB containment queries using the @> operator should be backed by a GIN index, for example CREATE INDEX idx_orders_data ON orders USING gin(data). Queries like data->>'status' = 'x' cannot use standard indexes and should be rewritten with containment operators.

Does this review check Row Level Security policies?

Yes. The review verifies RLS is enabled on sensitive tables, that policies use appropriate roles and settings like current_setting('app.current_user_id'), and that privileges are granted granularly instead of broad GRANT ALL statements.

When should I use TIMESTAMPTZ instead of TIMESTAMP in PostgreSQL?

Use TIMESTAMPTZ for any column storing points in time, such as created_at or updated_at, because it stores timezone-aware values. Plain TIMESTAMP loses timezone context and causes bugs across servers in different zones.

Why is concatenating user input into SQL flagged during review?

Concatenated input enables SQL injection. The review requires all parameters to be bound through JPQL, Spring Data derived queries, or parameterized native queries, and flags any string-built SQL as a high-severity finding.