Agent skill

PostgreSQL Pro

by Jeffallan in Jeffallan/claude-skills

Tunes and administers PostgreSQL: EXPLAIN-driven query tuning, index choice, JSONB, extensions, streaming or logical replication, VACUUM and pg_stat monitoring.

MITAuto-check passedDatabases

Install PostgreSQL Pro

skills CLI
$ npx skills add Jeffallan/claude-skills --skill postgres-pro -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install Jeffallan/claude-skills postgres-pro --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/Jeffallan/claude-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/postgres-pro .claude/skills/postgres-pro && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
postgres-pro
GitHub stars
12k
Token cost
~1.5k tokens
SKILL.md length
392 words
Files
6 (incl. references)
Skills in repo
58
Repo updated
First seen
Licence
MIT

At a glance

Tunes and administers PostgreSQL: EXPLAIN-driven query tuning, index choice, JSONB, extensions, streaming or logical replication, VACUUM and pg_stat monitoring.

  • Works in 5 steps: Analyze performance — Run EXPLAIN… → Design indexes — Choose B-tree, GIN,… → Optimize queries — Rewrite inefficient… → …
  • Finding out why a query is slow using EXPLAIN ANALYZE
  • SKILL.md covers When to Use This Skill, Core Workflow, Reference Guide and Common Patterns, plus 3 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

The agent begins with EXPLAIN (ANALYZE, BUFFERS) to find bottlenecks, picks B-tree, GIN, GiST or BRIN indexes to fit the workload and checks them with EXPLAIN before deployment, then rewrites inefficient queries and refreshes statistics with ANALYZE. For replication it sets up streaming or logical replication and watches lag. For maintenance it tracks VACUUM, bloat and autovacuum through pg_stat views and verifies the result after each change.

An end-to-end example goes from finding slow queries in pg_stat_statements to a fix and its verification. Reference files cover performance, JSONB operators and GIN indexing, extensions such as PostGIS, pg_trgm, pgvector and uuid-ossp, replication and failover, and maintenance. SQL snippets show a GIN index for containment queries, a dead-tuple check for bloat and a replication lag query on the primary.

When your agent uses it

  • Finding out why a query is slow using EXPLAIN ANALYZE
  • Choosing between B-tree, GIN, GiST and BRIN indexes
  • Storing and indexing JSONB documents
  • Setting up streaming or logical replication and watching lag
  • Tuning VACUUM and autovacuum on tables with many dead tuples

Example prompts

  • “Run EXPLAIN ANALYZE on the monthly report query and tell me which index would help.”
  • “Add a GIN index for searching the payload JSONB column by containment.”
  • “Check which tables have the most dead tuples and suggest autovacuum settings.”
  • “Plan logical replication to a reporting replica and show how to monitor lag.”

Requirements

  • Access to a PostgreSQL database

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  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

What it can do on your machine

Read from SKILL.md and the folder at commit 1be15d8. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are sql).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • github.com
    • synergetic.solutions
    • jeffallan.github.io

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

PostgreSQL Pro loads about 1.5k tokens when it runs, and up to ~13k if it reads all its reference files. Until then it costs about 56 tokens; SKILL.md has 392 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~56
When it runs · the whole SKILL.md, loaded when a task matches
~1.5k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~13k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from Jeffallan/claude-skills at commit 1be15d8, republished under its MIT licence (© Jeffallan). 392 words, ~1,496 tokens.

Download SKILL.mdSave it as .claude/skills/postgres-pro/SKILL.md (or your agent's skills folder). This skill also uses 5 other files; get the full folder from GitHub.
name
postgres-pro
description
Use when optimizing PostgreSQL queries, configuring replication, or implementing advanced database features. Invoke for EXPLAIN analysis, JSONB operations, extension usage, VACUUM tuning, performance monitoring.
license
MIT
metadata.author
https://github.com/Jeffallan
metadata.company
https://synergetic.solutions
metadata.version
1.1.0
metadata.domain
infrastructure
metadata.triggers
PostgreSQL, Postgres, EXPLAIN ANALYZE, pg_stat, JSONB, streaming replication, logical replication, VACUUM, PostGIS, pgvector
metadata.role
specialist
metadata.scope
implementation
metadata.output-format
code
metadata.related-skills
database-optimizer, devops-engineer, sre-engineer

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
sql
-- 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
sql
-- 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
sql
-- 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
sql
-- 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

Show full SKILL.md (190 more words)Show less
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

Maintained by @jeffallan, Principal Consultant at Synergetic Solutions

Documentation

© Jeffallan, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 5 other files (references) in skills/postgres-pro of Jeffallan/claude-skills.

  • SKILL.md
  • references/extensions.md
  • references/jsonb.md
  • references/maintenance.md
  • references/performance.md
  • references/replication.md

Open the folder on GitHubat commit 1be15d8

Compare with similar skills

PostgreSQL Pro next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

PostgreSQL Pro compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
PostgreSQL Pro this skillJeffallan/claude-skills12k—~1.5kAutomated safety check: PassMIT
Supabase Postgres Best Practicessupabase/agent-skills2.7k24 repos~808Automated safety check: PassMIT
PostgreSQL Documentation Reference2025Emma/vibe-coding-cn23k1 repos~19kAutomated safety check: PassMIT
Discover Databaserand/cc-polymath181—~2kAutomated safety check: PassMIT
Postgresdbericrisco/rsc-harness156—~4.4kAutomated safety check: PassMIT
DatabasesMicrock/ordinary-claude-skills401—~1.9kAutomated safety check: NotesMIT

Similar skills

  • Official

    Gives the agent Postgres rules to consult before writing or changing tables, queries, indexes, RLS policies or migrations, and when diagnosing slow queries.

    2.7k GitHub starsUsed in 24 repos~808 tokens
    DatabasesAuto-check passed
  • PostgreSQL Documentation Reference

    2025Emma/vibe-coding-cn

    PostgreSQL database documentation - SQL queries, database design, administration, performance tuning, and advanced features. Use when working with PostgreSQL…

    23k GitHub starsUsed in 1 repo~19k tokens
    DatabasesAuto-check passed
  • Discover Database

    rand/cc-polymath

    Automatically discover database skills when working with SQL, PostgreSQL, MongoDB, Redis, database schema design, query optimization, migrations, connection pooling, ORMs, or database selection.

    181 GitHub stars~2k tokensUpdated 7 mo ago
    DatabasesAuto-check passed
  • Postgresdb

    ericrisco/rsc-harness

    A skill your agent uses when PostgreSQL engine behaviour decides the answer — schema and type design, index choice, reading EXPLAIN on a slow query, zero-downtime DDL and backfills, or ops (roles…

    156 GitHub stars~4.4k tokensUpdated today
    DatabasesAuto-check passed
  • Databases

    Microck/ordinary-claude-skills

    Work with MongoDB (document database, BSON documents, aggregation pipelines, Atlas cloud) and PostgreSQL (relational database, SQL queries, psql CLI, pgAdmin).

    401 GitHub stars~1.9k tokensUpdated 1 mo ago
    DatabasesAuto-check: notes
  • Postgresql Expert

    theneoai/awesome-skills

    PostgreSQL expert with advanced SQL, JSONB, indexing, performance tuning, replication, and extensions.

    183 GitHub stars~3.5k tokensUpdated 4 mo ago
    DatabasesAuto-check passed

More from Jeffallan/claude-skills

All 58 skills in this repo
  • API Designer

    Jeffallan/claude-skills

    Designs REST and GraphQL APIs from resource modeling to an OpenAPI 3.1 contract, with versioning, pagination and RFC 7807 error handling.

    12k GitHub starsUsed in 2 repos~2k tokens
    Auto-check passed
  • CLI Developer

    Jeffallan/claude-skills

    Walks through designing, building and polishing a command-line tool: user workflow and command hierarchy, implementation in commander, click, typer or cobra, completions and cross-platform testing.

    12k GitHub starsUsed in 1 repo~1.2k tokens
    Auto-check passed
  • Fine-Tuning Expert

    Jeffallan/claude-skills

    Guides LLM fine-tuning with LoRA and QLoRA through Hugging Face PEFT, from dataset validation and training checks to adapter merging, quantization and deployment.

    12k GitHub starsUsed in 1 repo~1.7k tokens
    Auto-check passed
  • GraphQL Architect

    Jeffallan/claude-skills

    Designs GraphQL schemas and Apollo Federation graphs, with DataLoader resolvers, subscriptions, query complexity limits and caching.

    12k GitHub starsUsed in 1 repo~1.3k tokens
    Auto-check passed
  • Kubernetes Specialist

    Jeffallan/claude-skills

    Creates and checks Kubernetes manifests, Helm charts, RBAC and network policies, and helps debug pod problems, with kubectl checks and rollback steps.

    12k GitHub starsUsed in 1 repo~2.1k tokens
    Auto-check passed
  • Laravel Specialist

    Jeffallan/claude-skills

    Builds Laravel 10+ applications with Eloquent models, Sanctum authentication, Horizon queues, API resources and Livewire components, tested with Pest or PHPUnit.

    12k GitHub starsUsed in 1 repo~2.1k tokens
    Auto-check passed

Categories

Questions about PostgreSQL Pro

What does PostgreSQL Pro do?

Tunes and administers PostgreSQL: EXPLAIN-driven query tuning, index choice, JSONB, extensions, streaming or logical replication, VACUUM and pg_stat monitoring. The agent begins with EXPLAIN (ANALYZE, BUFFERS) to find bottlenecks, picks B-tree, GIN, GiST or BRIN indexes to fit the workload and checks them with EXPLAIN before deployment, then rewrites inefficient queries and refreshes statistics with ANALYZE. For replication it sets up streaming or logical replication and watches lag.

When should I use PostgreSQL Pro?

PostgreSQL Pro fits situations like: finding out why a query is slow using EXPLAIN ANALYZE; choosing between B-tree, GIN, GiST and BRIN indexes; storing and indexing JSONB documents; setting up streaming or logical replication and watching lag.

How do I install PostgreSQL Pro in Claude Code?

Run `npx skills add Jeffallan/claude-skills --skill postgres-pro -a claude-code`. Or copy the skill folder (skills/postgres-pro in Jeffallan/claude-skills) into .claude/skills/postgres-pro in your project. Claude Code loads it when a task matches its description.

How do I install PostgreSQL Pro in Codex?

Run `npx skills add Jeffallan/claude-skills --skill postgres-pro -a codex`. Or copy the skill folder (skills/postgres-pro in Jeffallan/claude-skills) into .agents/skills/postgres-pro in your project. Codex loads it when a task matches its description.

Can I use PostgreSQL Pro in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add Jeffallan/claude-skills --skill postgres-pro -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/postgres-pro, .gemini/skills/postgres-pro, .github/skills/postgres-pro and .opencode/skills/postgres-pro in your project.

What does PostgreSQL Pro need to run?

SKILL.md names no scripts, command-line tools or credentials: PostgreSQL Pro is instructions for the agent only. Our summary lists: Access to a PostgreSQL database.

Does PostgreSQL Pro access the network?

SKILL.md names 3 domains. As links in the text: github.com, synergetic.solutions and jeffallan.github.io. This is read from the text; nothing was executed.

Is PostgreSQL Pro safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does PostgreSQL Pro use?

PostgreSQL Pro is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does PostgreSQL Pro use?

About 1.5k tokens (SKILL.md is roughly 6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 12k tokens, read only when the agent opens those files.

What are the alternatives to PostgreSQL Pro?

Skills that share tags, products or a category with PostgreSQL Pro: Supabase Postgres Best Practices (supabase/agent-skills, 2.7k stars), PostgreSQL Documentation Reference (2025Emma/vibe-coding-cn, 23k stars), Discover Database (rand/cc-polymath, 181 stars) and Postgresdb (ericrisco/rsc-harness, 156 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains PostgreSQL Pro?

Jeffallan (a GitHub user) maintains it in Jeffallan/claude-skills, which has 11,754 GitHub stars. The repository holds 58 skills in this directory. The repository was last updated on October 3, 2026.

Source: Jeffallan/claude-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.