/postgres-intelligence:postgres-intelligencefrom postgres-intelligence
PostgreSQL for LLM agents: inspect schemas, run safe SQL, translate natural language to queries. Use when connecting to a PostgreSQL database, exploring an unfamiliar schema, debugging a SQL error, or investigating query performance.
Ships in postgres-intelligence. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Credential-safe PostgreSQL access for LLM coding agents. The scripts load credentials from .env at runtime and print only safe summaries, schema metadata, query results, and errors. The agent writes SQL, calls the scripts, and reads that output; it never opens or prints .env itself.
.env, scripts/, and schema_metadata.json all live in the skill directory. Run every command in this file from there.
cd postgres-intelligence # repo root
python3 -m venv .venv
. .venv/bin/activate
python -m pip install -r requirements.txt
cd skills/postgres-intelligence # the skill directory
cp ../../.env.example .env
python scripts/config.py
python scripts/db_connector.py
python scripts/schema_extractor.py
Fill .env from the keys in ../../.env.example, the public template: connections DB1_ through DB10_, or DB1_DSN, which takes precedence over the host/port fields. DB*_NAME is the connection key --db expects. Keep real .env, .venv, and schema_metadata.json out of git.
# Validate loaded config; prints host, user, and database, never passwords or DSNs
python scripts/config.py
# Test all configured connections
python scripts/db_connector.py
# Extract schema metadata for every connection into schema_metadata.json
python scripts/schema_extractor.py
# Run a read-only query against the default connection
python scripts/query_executor.py "SELECT current_database(), current_schema();"
# Select a named connection
python scripts/query_executor.py --db analytics "SELECT count(*) FROM public.events;"
# Agent-friendly JSON output
python scripts/query_executor.py --json-only "SELECT now();"
# Raise the 30000 ms statement_timeout for a long analytical query
python scripts/query_executor.py --statement-timeout-ms 120000 "SELECT count(*) FROM public.events;"
# Writes require explicit user approval
python scripts/query_executor.py --allow-write "UPDATE table_name SET flag = true WHERE id = 1;"
# DDL requires explicit user approval
python scripts/query_executor.py --allow-ddl "CREATE INDEX CONCURRENTLY idx_name ON table_name (col);"
python scripts/config.py to confirm the connection is configured; it validates .env without printing secrets.schema_metadata.json in the skill directory before generating SQL; if it is absent or stale, run python scripts/schema_extractor.py to rewrite it.information_schema or pg_catalog for it first.SELECT *; add LIMIT for exploratory reads.sqlstate and suggestions to refine the query, with a maximum of three attempts.SELECT, WITH, SHOW, and EXPLAIN run with no flag.--allow-write.--allow-ddl.UPDATE and DELETE without WHERE are blocked.statement_timeout of 30000 ms unless --statement-timeout-ms raises it.EXPLAIN (ANALYZE, BUFFERS) for performance work.CREATE INDEX CONCURRENTLY for large production tables when appropriate.ANALYZE after bulk data changes.Read ../../references/postgres_best_practices.md before recommending an index, a partitioning or schema change, or a maintenance job.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub cskwork/postgres-intelligence --plugin postgres-intelligence