Skip to main content
skill CX Codex

postgresql-expert — Claude Code skill: PostgreSQL administration

A skill that turns the agent into a PostgreSQL expert: advanced queries, indexes, performance tuning and production operations. Useful whenever a task touches schema, SQL or query plans.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add personamanagmentlayer/pcl --skill postgresql-expert -a claude-code
Open on GitHub

What postgresql-expert does

The skill plugs into your agent and sets it up as a PostgreSQL specialist. Inside are practices for picking data types, adding constraints, wrapping changes in transactions, indexing columns used in WHERE, JOIN and ORDER BY, and running regular VACUUM ANALYZE. The agent gets Read, Write, Edit, Glob, Grep, plus psql, pg_dump, pg_restore, createdb and dropdb through Bash.

The workflow runs in steps: design the schema first, then read the plan with EXPLAIN ANALYZE, watch slow queries, set up backups with point-in-time recovery, add PgBouncer for connection pooling and replication for read scaling. JSONB, full-text search and arrays get their own mention. Longer material sits next to the skill in references/CORE_CONCEPTS.md and is read on demand.

PostgreSQL 15.0 or newer is required. On older servers the skill leans on features that are not there, so check your version before installing. For Claude the skill file lands at ~/.claude/skills/postgresql-expert/SKILL.md.

What it helps with

  • read a query plan with EXPLAIN ANALYZE and find the bottleneck
  • pick indexes for specific WHERE and JOIN clauses
  • design a schema with constraints and sensible types
  • set up replication and connection pooling for production
  • lay out backups with point-in-time recovery

Example prompts for the agent

  • run EXPLAIN ANALYZE on this query and suggest indexes
  • design an orders table with constraints and foreign keys
  • why is this query slow in production? walk me through it

How to install postgresql-expert

1Skills CLI (Vercel)

npx skills add personamanagmentlayer/pcl --skill postgresql-expert -a claude-code

2Manually: put the files in place

~/.claude/skills/postgresql-expert/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/postgresql-expert/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about postgresql-expert

How do I install postgresql-expert in Claude?

Run npx skills add personamanagmentlayer/pcl --skill postgresql-expert -a claude-code. The skill file then sits at ~/.claude/skills/postgresql-expert/SKILL.md.

What does postgresql-expert do?

It gives the agent PostgreSQL administration expertise: advanced queries, indexes, performance tuning, replication and production operations. It triggers when a task mentions a database, SQL or performance.

Which PostgreSQL version is required?

PostgreSQL 15.0 or newer. On older versions some of the techniques in the skill will not work.

Source text

SKILL.md · Apache-2.0
---
name: postgresql-expert
version: 1.1.0
description: >-
  Expert-level PostgreSQL database administration, advanced queries, performance tuning,
  and production operations. Use when the user mentions database, SQL, or performance, or
  when the task involves Advanced Data Types, Full-Text Search, Advanced Indexes, or
  Advanced Queries.
category: data
author: PCL Team
license: Apache-2.0
tags:
  - postgresql
  - postgres
  - database
  - sql
  - performance
allowed-tools:
  - Read
  - Write
  - Edit
  - Bash(psql:*, pg_dump:*, pg_restore:*, createdb:*, dropdb:*)
  - Glob
  - Grep
requirements:
  postgresql: '>=15.0'
---

# PostgreSQL Expert

You are an expert in PostgreSQL with deep knowledge of advanced queries, indexing, performance tuning, replication, and database administration. You design and manage production PostgreSQL databases that are performant, reliable, and scalable.

## Best Practices

### 1. Use Proper Data Types

```sql
-- Use specific types
-- Bad: VARCHAR(255) for everything
-- Good: Use appropriate types
email VARCHAR(255)
age INTEGER
price NUMERIC(10,2)
is_active BOOLEAN
created_at TIMESTAMP WITH TIME ZONE
```

### 2. Add Constraints

```sql
CREATE TABLE users (
    id SERIAL PRIMARY KEY,
    email VARCHAR(255) UNIQUE NOT NULL,
    age INTEGER CHECK (age >= 0 AND age <= 150),
    status VARCHAR(20) DEFAULT 'active' CHECK (status IN ('active', 'inactive', 'banned'))
);
```

### 3. Use Transactions

```sql
BEGIN;
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
UPDATE accounts SET balance = balance + 100 WHERE id = 2;
COMMIT;
```

### 4. Index Appropriately

```sql
-- Index foreign keys
CREATE INDEX idx_orders_user_id ON orders(user_id);

-- Index columns used in WHERE, JOIN, ORDER BY
CREATE INDEX idx_users_created_at ON users(created_at);

-- Don't over-index (slows writes)
```

### 5. Regular Maintenance

```sql
-- Schedule regular VACUUM ANALYZE
-- Monitor slow queries
-- Check for bloat
-- Update statistics
```

## Approach

When working with PostgreSQL:

1. **Design Schema Carefully**: Normalize, use constraints, plan indexes
2. **Use EXPLAIN ANALYZE**: Understand query performance
3. **Monitor Production**: Track slow queries, connection counts
4. **Backup Regularly**: Automated backups with point-in-time recovery
5. **Use Connection Pooling**: PgBouncer for better resource usage
6. **Leverage PostgreSQL Features**: JSONB, full-text search, arrays
7. **Set Up Replication**: High availability and read scaling
8. **Regular Maintenance**: VACUUM, ANALYZE, reindex

Always design PostgreSQL databases that are performant, reliable, and maintainable at scale.

## Reference Documentation

Detailed material lives alongside this skill and is read on demand:

- [Core Expertise](references/CORE_CONCEPTS.md) — Advanced Data Types, Full-Text Search, Advanced Indexes, Advanced Queries, Performance Optimization, Transactions and Locking, Database Administration

© PCL Team · Apache-2.0 · personamanagmentlayer/pcl

Similar skills

All skills for Data and databases →

From the same set14

gcp-expert A skill that hands your agent working GCP examples: Cloud Functions, BigQuery, Firestore, Pub/Sub and gcloud commands. Useful when the code targets Google Cloud. CX Codex +1 547installs argocd-expert A skill that turns your agent into an ArgoCD operator: GitOps deploys, app sync, AppProject and ApplicationSet. Useful when your deployment lives in Git. CX Codex +1 509installs automotive-expert A skill that gives your agent automotive domain knowledge: connected vehicles, telemetry, ADAS, OBD-II diagnostics. Useful when the project touches fleet software or in-vehicle systems. CX Codex +1 467installs dart-expert A skill that gives your coding agent Dart and Flutter reference material: widgets, state management, async patterns. CX Codex +1 462installs education-expert Gives your agent a working frame for LMS design, assessment and learning standards. Useful when you build a course platform. CX Codex +1 428installs powerbi-expert A skill that turns your agent into a Power BI specialist: DAX, M language, data modeling, Power Query and report design. Handy when measures or the model need fixing. CX Codex +1 376installs docker-expert A skill that gives your coding agent Docker expertise: image builds, Dockerfile cleanups, Compose setups. Useful when a container balloons or dies on boot. CX Codex +1 365installs r-expert An R skill covering statistical analysis, tidyverse data wrangling, ggplot2 charts and R Markdown reports. Useful when your project runs on R. CX Codex +1 323installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor