postgresql-cli

postgresql-cli is a skill for Claude Code, Codex from chaunsin/agent-skills. It costs 148 tokens per session (6,206 once invoked), scanned B, original, Apache-2.0.

A command-line reference for psql, the tool used to connect to and work with PostgreSQL databases from a terminal.

In plain words
What is it for?
Use it when writing SQL scripts, checking tables and other database objects, importing or exporting data, or formatting query results.
Why use it?
It helps developers query databases, inspect their structure, and move data without relying on a graphical interface.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: positional $N argument.

Good fit Use it when writing SQL scripts, checking tables and other database objects, importing or exporting data, or formatting query results.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/chaunsin/agent-skills/postgresql-cli
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add chaunsin/agent-skills --skill postgresql-cli
Clone the repo
git clone --depth 1 https://github.com/chaunsin/agent-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for postgresql-cli

README.md
[![agentmods](https://agentmods.dev/badge/skills/chaunsin/agent-skills/postgresql-cli/github.svg)](https://agentmods.dev/skills/chaunsin/agent-skills/postgresql-cli)
Your own site
<a href="https://agentmods.dev/skills/chaunsin/agent-skills/postgresql-cli"><img src="https://agentmods.dev/badge/skills/chaunsin/agent-skills/postgresql-cli/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for postgresql-cli

Your own site · 80×15
<a href="https://agentmods.dev/skills/chaunsin/agent-skills/postgresql-cli"><img src="https://agentmods.dev/badge/skills/chaunsin/agent-skills/postgresql-cli.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 148 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 6,206 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00148 $0.06206
Opus 5.5 $0.00059 $0.02482
Sonnet 5.5 $0.00030 $0.01241
Haiku 4.5 $0.00015 $0.00621

Measured 1mo ago against content hash 45591fe90a22, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade B, and why

postgresql-cli scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Asks for rootmediumPrivilege escalation

A mod that escalates privileges can change anything on the machine, not only the project.

sudo apt install postgresql-client
skills/postgresql-cli/SKILL.md · 496 lines

How it starts

The opening of the file, as written. The whole thing — 496 lines — stays where its author put it; the contents beside it link to each section on GitHub.

psql — PostgreSQL Interactive Terminal

psql is PostgreSQL's feature-rich interactive terminal. It lets you write and execute queries, inspect database objects, import/export data, script batch operations, and customize output formatting — all from the command line.

Prerequisites

Before using psql, verify it is installed and available:

# Check if psql is installed
psql --version

# If not found, install PostgreSQL client tools:

# macOS (Homebrew)
brew install libpq
brew link --force libpq

# Ubuntu / Debian
sudo apt install postgresql-client

# CentOS / RHEL
sudo yum install postgresql

# Alpine
apk add postgresql-client

# Windows — install PostgreSQL via the official installer or use WSL

psql ships as part of the postgresql-client package. The server (postgresql) is not required — you only need the client to connect to a remote PostgreSQL instance.

Quick Reference

Connecting

# 1. CLI flags
psql -h host -p port -U user -d dbname

# 2. Connection URI
# WARNING: Password in URI is visible in shell history and process listings.
#          Prefer ~/.pgpass for production use (see method 4 below).
psql "postgresql://user:YOUR_PASSWORD@host:port/dbname"

# 3. Environment variables (no flags needed)
export PGHOST=localhost
export PGPORT=5432
export PGDATABASE=mydb
export PGUSER=postgres
# WARNING: PGPASSWORD is visible in process listings (e.g. `ps aux`).
#          Use ~/.pgpass in production instead.
export PGPASSWORD=YOUR_PASSWORD
psql                       # picks up all params from env

# 4. ~/.pgpass file (RECOMMENDED for passwords)
#    Format: hostname:port:database:username:password
touch ~/.pgpass && chmod 600 ~/.pgpass
# Then manually edit ~/.pgpass and add entries (avoids password in shell history):
# hostname:port:database:username:password
# Example: localhost:5432:mydb:postgres:YOUR_PASSWORD
psql -h localhost -U postgres -d mydb   # no password prompt

# 5. Execute and exit
psql -f script.sql dbname                        # execute file then exit
psql -c "SELECT 1" dbname                        # run single command then exit
psql -1 -f migration.sql dbname                  # run in single transaction

# 6. Service connection (reads from pg_service.conf)
psql service=mydb_prod

# 7. Reconnect within a session
\c dbname                                       # reconnect to different db
\c -reuse-previous=on sslmode=require           # change only sslmode
\c "host=newhost port=5432 dbname=mydb"         # conninfo string

Read the full file on GitHub · 496 lines

Files

What ships with it

6 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 496 lines · 148 tokens per session scan B 45591fe90a22

Subscribe to this mod's changes

postgresql-cli is a skill published in the GitHub repository chaunsin/agent-skills (2 stars, last pushed 24d ago), licensed Apache-2.0. It adds 148 tokens to every session and 6,206 once invoked, about $0.0006 per session on Opus 5.5. A static security scan graded it B with 1 finding (asks for root). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

yida-db-seq-fix

A tool for checking and correcting PostgreSQL sequences, which generate automatic numeric IDs for new rows. It is designed for Yida databases after automatic table creation or data migration.

openyida/openyida · 73 tokens

azure-database-postgresql

Expert knowledge for Azure Database for PostgreSQL development including troubleshooting, best practices, decision making, architecture & design patterns, limits & quotas, security, configuration, integrations & coding patterns, and deployment. Use when using Flexible Server, pgvector search, managed identities…

MicrosoftDocs/Agent-Skills · 136 tokens

azure-horizondb

Expert knowledge for Azure Horizondb development including troubleshooting, best practices, decision making, architecture & design patterns, limits & quotas, security, configuration, integrations & coding patterns, and deployment. Use when tuning pgvector, azureai SQL functions, LangChain vector stores, Apache AGE…

MicrosoftDocs/Agent-Skills · 110 tokens

rds-postgres

Single-node managed Postgres. Default choice for relational data — and often replaces other nodes (see "Built-ins"). Config knobs: instanceClass, storageGB, encrypted, multiAz, publiclyAccessible, dbName.

AlexK020908/infra-designer · 0 tokens

database

A managed Postgres with a public, pooled, TLS endpoint — plus auth, storage, and realtime if you want them. The serverless-friendly database that pairs with a Vercel frontend or any external/edge compute. Provisioned in the Supabase dashboard, not IaC.

AlexK020908/infra-designer · 0 tokens

alloydb-basics

Manages clusters, instances, and backups for AlloyDB for PostgreSQL, and integrates with AlloyDB Model Context Protocol (MCP) tools for automated database operations. Use when creating, configuring, or administering AlloyDB databases. Do NOT use for general PostgreSQL instances (e.g. Cloud SQL) or other GCP databases.

google/skills · 72 tokens