agentleFS
existential-birdsexistential-birds/beagle/skills/postgres-code-review/SKILL.md

postgres-code-review

Skill91 starsChanged 4 days agoApache-2.0View on GitHub

Reviews PostgreSQL code for indexing strategies, JSONB operations, connection pooling, and transaction safety. Use when reviewing SQL queries, database schemas, JSONB usage, or connection management.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this sequence so conclusions stay evidence-bound:

    line 33

≈ “Common” is an estimate: at least 1 in 5 of the 383,637 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

PostgreSQL Code Review

Quick Reference

Issue TypeReference
Missing indexes, wrong index type, query performancereferences/indexes.md
JSONB queries, operators, GIN indexesreferences/jsonb.md
Connection leaks, psycopg_pool/asyncpg, PgBouncer, timeoutsreferences/connections.md
Isolation levels, deadlocks, advisory locks, savepointsreferences/transactions.md

Review Checklist

  • WHERE/JOIN columns have appropriate indexes
  • Composite indexes match query patterns (column order matters)
  • JSONB columns use GIN indexes when queried
  • Using proper JSONB operators (->, ->>, @>, ?)
  • Connection pool (psycopg_pool / asyncpg) configured with limits and timeouts
  • Connections properly released (context managers, async with)
  • PgBouncer transaction-mode settings (scram-sha-256, prepare_threshold=None / statement_cache_size=0 when needed)
  • Appropriate transaction isolation level for use case
  • No long-running transactions holding locks during external I/O
  • Advisory locks use pg_*_xact_lock under transaction pooling
  • Queries use parameterized statements (no SQL injection)

Gates (before reporting findings)

Use this sequence so conclusions stay evidence-bound:

  1. Scope — Record the concrete paths (and line ranges or symbols if helpful) for the SQL, DDL/migrations, and connection code under review. Pass: every subsystem you critique (queries, JSONB, pool, transactions) has at least one cited path.
  2. SQL/DDL citation for performance claims — Index, sequential-scan, JSONB-operator, and plan-related findings must point to the exact statement or schema (quoted excerpt or file:line). Pass: each such finding includes that citation.
  3. Binding check before injection flags — Only assert SQL-injection risk after locating how SQL and values are combined (bound parameters vs string concat/format/f-strings). Pass: you name the mechanism you saw in code for each flagged callsite.

Then load the relevant reference doc from Quick Reference and walk the Review Checklist.

When to Load References

  • Reviewing SELECT queries with WHERE/JOIN → references/indexes.md
  • Reviewing JSONB columns or JSON operations → references/jsonb.md
  • Reviewing database connection code → references/connections.md
  • Reviewing BEGIN/COMMIT, savepoints, or concurrent updates → references/transactions.md

Review Questions

  1. Will this query use an index or perform a sequential scan?
  2. Are JSONB operations using appropriate operators and indexes?
  3. Are database connections properly pooled, timed out, and released?
  4. Is the transaction isolation level appropriate for this operation?
  5. Could this cause deadlocks, lock contention, or PgBouncer session-state leaks?

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.