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.
npx skills add personamanagmentlayer/pcl --skill postgresql-expert -a claude-codeWhat 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 ANALYZEand find the bottleneck - pick indexes for specific
WHEREandJOINclauses - 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-code2Manually: put the files in place
~/.claude/skills/postgresql-expert/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/postgresql-expert/
1Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill postgresql-expert -a codex2Manually: put the files in place
.agents/skills/postgresql-expert/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill postgresql-expert -a cursor2Manually: put the files in place
.cursor/skills/postgresql-expert/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install personamanagmentlayer/pcl postgresql-expert2Manually: put the files in place
.github/skills/postgresql-expert/SKILL.md1Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill postgresql-expert -a gemini-cli2Platform CLI
gemini skills install https://github.com/personamanagmentlayer/pcl --path stdlib/data/postgresql-expertManually: put the files in place
.devin/skills/postgresql-expert/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill postgresql-expert -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
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