Source profileQuality 84/100

Jeffallan/claude-skills/skills/postgres-pro/SKILL.md

postgres-pro

Use when optimizing PostgreSQL queries, configuring replication, or implementing advanced database features. Invoke for EXPLAIN analysis, JSONB operations, extension usage, VACUUM tuning, performance monitoring.

Source repository stars
10,762
Declared platforms
0
Static risk flags
0
Last source update
2026-05-20
Source checked
2026-07-28

Decision brief

What it does—and where it fits

Senior PostgreSQL expert with deep expertise in database administration, performance optimization, and advanced PostgreSQL features.

Best for

  • Analyzing and optimizing slow queries with EXPLAIN
  • Implementing JSONB storage and indexing strategies
  • Setting up streaming or logical replication

Not for

  • Tasks that require unconfirmed production actions or broad system permissions.
  • Environments where the pinned source and install steps cannot be inspected.

Compatibility matrix

Platform support, with evidence labels

PlatformStatusEvidenceWhat to check
CodexNot declaredNo explicit evidencePortability before use
Claude CodeNot declaredNo explicit evidencePortability before use
CursorNot declaredNo explicit evidencePortability before use
Gemini CLINot declaredNo explicit evidencePortability before use
Open the compatibility checker

Installation

Inspect first. Install second.

The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.

Source-detected install commandSource
npx skills add https://github.com/Jeffallan/claude-skills --skill "skills/postgres-pro"
Safe inspection promptEditorial

Inspect the Agent Skill "postgres-pro" from https://github.com/Jeffallan/claude-skills/blob/e8be415bc94d8d6ebddc2fb50e5d03c6e27d4319/skills/postgres-pro/SKILL.md at commit e8be415bc94d8d6ebddc2fb50e5d03c6e27d4319. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.

Workflow

What the source asks the agent to do

  1. 01

    Core Workflow

    1. Analyze performance — Run EXPLAIN (ANALYZE, BUFFERS) to identify bottlenecks 2. Design indexes — Choose B-tree, GIN, GiST, or BRIN based on workload; verify with EXPLAIN before deploying 3. Optimize queries — Rewrite inefficient queries, run ANALYZE to refresh statistics 4. S…

    Analyze performance — Run EXPLAIN (ANALYZE, BUFFERS) to identify bottlenecksDesign indexes — Choose B-tree, GIN, GiST, or BRIN based on workload; verify with EXPLAIN before deployingOptimize queries — Rewrite inefficient queries, run ANALYZE to refresh statistics
  2. 02

    End-to-End Example: Slow Query → Fix → Verification

    Review the “End-to-End Example: Slow Query → Fix → Verification” section in the pinned source before continuing.

    Review and apply the “End-to-End Example: Slow Query → Fix → Verification” source section.
  3. 03

    When to Use This Skill

    Analyzing and optimizing slow queries with EXPLAIN

    Analyzing and optimizing slow queries with EXPLAINImplementing JSONB storage and indexing strategiesSetting up streaming or logical replication
  4. 04

    Reference Guide

    Load detailed guidance based on context:

    Load detailed guidance based on context:
  5. 05

    Common Patterns

    Review the “Common Patterns” section in the pinned source before continuing.

    Review and apply the “Common Patterns” source section.

Permission review

Static risk signals and limitations

No configured static risk pattern was detected

This is not proof of safety. Runtime behavior, indirect dependencies, and hidden external systems are outside the static scan.

Evidence record

Why each signal appears

EvidenceSourceComputedTestedEditorial
SignalValueEvidence typeMeaning
Quality score84/100ComputedDocumentation, specificity, maintenance, and trust rules
Repository stars10,762SourceRepository attention, not individual Skill quality
Compatibility0 platformsSourceDeclared in the catalog source record
Usage guideautomated source guideEditorialGenerated or reviewed according to the visible evidence level

Pinned source

Provenance and original SKILL.md

Repository
Jeffallan/claude-skills
Skill path
skills/postgres-pro/SKILL.md
Commit
e8be415bc94d8d6ebddc2fb50e5d03c6e27d4319
License
MIT
Collected
2026-07-28
Default branch
main
View the original SKILL.md

PostgreSQL Pro

Senior PostgreSQL expert with deep expertise in database administration, performance optimization, and advanced PostgreSQL features.

When to Use This Skill

  • Analyzing and optimizing slow queries with EXPLAIN
  • Implementing JSONB storage and indexing strategies
  • Setting up streaming or logical replication
  • Configuring and using PostgreSQL extensions
  • Tuning VACUUM, ANALYZE, and autovacuum
  • Monitoring database health with pg_stat views
  • Designing indexes for optimal performance

Core Workflow

  1. Analyze performance — Run EXPLAIN (ANALYZE, BUFFERS) to identify bottlenecks
  2. Design indexes — Choose B-tree, GIN, GiST, or BRIN based on workload; verify with EXPLAIN before deploying
  3. Optimize queries — Rewrite inefficient queries, run ANALYZE to refresh statistics
  4. Setup replication — Streaming or logical based on requirements; monitor lag continuously
  5. Monitor and maintain — Track VACUUM, bloat, and autovacuum via pg_stat views; verify improvements after each change

End-to-End Example: Slow Query → Fix → Verification

-- Step 1: Identify slow queries
SELECT query, mean_exec_time, calls
FROM pg_stat_statements
ORDER BY mean_exec_time DESC
LIMIT 10;

-- Step 2: Analyze a specific slow query
EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT)
SELECT * FROM orders WHERE customer_id = 42 AND status = 'pending';
-- Look for: Seq Scan (bad on large tables), high Buffers hit, nested loops on large sets

-- Step 3: Create a targeted index
CREATE INDEX CONCURRENTLY idx_orders_customer_status
  ON orders (customer_id, status)
  WHERE status = 'pending';  -- partial index reduces size

-- Step 4: Verify the index is used
EXPLAIN (ANALYZE, BUFFERS)
SELECT * FROM orders WHERE customer_id = 42 AND status = 'pending';
-- Confirm: Index Scan on idx_orders_customer_status, lower actual time

-- Step 5: Update statistics if needed after bulk changes
ANALYZE orders;

Reference Guide

Load detailed guidance based on context:

TopicReferenceLoad When
Performancereferences/performance.mdEXPLAIN ANALYZE, indexes, statistics, query tuning
JSONBreferences/jsonb.mdJSONB operators, indexing, GIN indexes, containment
Extensionsreferences/extensions.mdPostGIS, pg_trgm, pgvector, uuid-ossp, pg_stat_statements
Replicationreferences/replication.mdStreaming replication, logical replication, failover
Maintenancereferences/maintenance.mdVACUUM, ANALYZE, pg_stat views, monitoring, bloat

Common Patterns

JSONB — GIN Index and Query

-- Create GIN index for containment queries
CREATE INDEX idx_events_payload ON events USING GIN (payload);

-- Efficient JSONB containment query (uses GIN index)
SELECT * FROM events WHERE payload @> '{"type": "login", "success": true}';

-- Extract nested value
SELECT payload->>'user_id', payload->'meta'->>'ip'
FROM events
WHERE payload @> '{"type": "login"}';

VACUUM and Bloat Monitoring

-- Check tables with high dead tuple counts
SELECT relname, n_dead_tup, n_live_tup,
       round(n_dead_tup::numeric / NULLIF(n_live_tup + n_dead_tup, 0) * 100, 2) AS dead_pct,
       last_autovacuum
FROM pg_stat_user_tables
ORDER BY n_dead_tup DESC
LIMIT 20;

-- Manually vacuum a high-churn table and verify
VACUUM (ANALYZE, VERBOSE) orders;

Replication Lag Monitoring

-- On primary: check standby lag
SELECT client_addr, state, sent_lsn, write_lsn, flush_lsn, replay_lsn,
       (sent_lsn - replay_lsn) AS replication_lag_bytes
FROM pg_stat_replication;

Constraints

MUST DO

  • Use EXPLAIN (ANALYZE, BUFFERS) for query optimization
  • Verify indexes are actually used with EXPLAIN before and after creation
  • Use CREATE INDEX CONCURRENTLY to avoid table locks in production
  • Run ANALYZE after bulk data changes to refresh statistics
  • Monitor autovacuum; tune autovacuum_vacuum_scale_factor for high-churn tables
  • Use connection pooling (pgBouncer, pgPool)
  • Monitor replication lag via pg_stat_replication
  • Use prepared statements to prevent SQL injection
  • Use uuid type for UUIDs, not text

MUST NOT DO

  • Disable autovacuum globally
  • Create indexes without first analyzing query patterns
  • Use SELECT * in production queries
  • Ignore replication lag alerts
  • Skip VACUUM on high-churn tables
  • Store large BLOBs in the database (use object storage)
  • Deploy index changes without verifying the planner uses them

Output Templates

When implementing PostgreSQL solutions, provide:

  1. Query with EXPLAIN (ANALYZE, BUFFERS) output and interpretation
  2. Index definitions with rationale and pre/post verification
  3. Configuration changes with before/after values
  4. Monitoring queries for ongoing health checks
  5. Brief explanation of performance impact

Knowledge Reference

PostgreSQL 12-16, EXPLAIN ANALYZE, B-tree/GIN/GiST/BRIN indexes, JSONB operators, streaming replication, logical replication, VACUUM/ANALYZE, pg_stat views, PostGIS, pgvector, pg_trgm, WAL archiving, PITR

Documentation

Alternatives

Compare before choosing