agentleFS
abdullahkhawerabdullahkhawer/devops-skills/skills/postgresql-cli/SKILL.md

postgresql-cli

Skill8 starsChanged 6 months agoApache-2.0View on GitHub

Perform PostgreSQL operations using the psql CLI. Use for inspecting schemas, running read-only queries, and troubleshooting databases across environments.

  • Deletes or force-pushes
  • Installs packages

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 3 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use the connection table and rules below when constructing all psql commands.

    line 8
  2. Distinctive:

    Update the table below with your connection details before using this skill:

    line 12
  3. Distinctive:

    If the target environment is unclear, ask the user before running any command.

    line 19
  4. Very specific:

    If psql is not installed or no connection service is configured, inform the user that setup is required and ask them to complete the …

    line 23
  5. Very specific:

    Always use service=<name> from ~/.pg_service.conf — never pass raw host/user/password on the command line, where they could leak into shell …

    line 33
  6. Distinctive:

    NEVER target a connection service not listed in the configuration table above.

    line 85
  7. Very specific:

    NEVER pass -h, -U, or a password directly on the command line — always use a service= connection string backed by ~/.pg_service.conf and …

    line 86
  8. Very specific:

    NEVER print, display, or store the contents of .pgpass or any credential value.

    line 87
  9. Very specific:

    NEVER run DELETE, DROP, TRUNCATE, GRANT, or REVOKE without explicit user instruction — these are destructive or security-sensitive.

    line 88
  10. Very specific:

    Always run EXPLAIN on unfamiliar or complex queries before executing them against a large table, to catch missing indexes or full table …

    line 89

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

PostgreSQL CLI Skill

Use the connection table and rules below when constructing all psql commands.

Configuration

Update the table below with your connection details before using this skill:

EnvironmentConnection Service NameCredential File
Production<your-prod-service>~/.postgresql/prod.pgpass
Staging / Non-Prod<your-nonprod-service>~/.postgresql/staging.pgpass

If the target environment is unclear, ask the user before running any command.

Prerequisites (one-time setup by user)

If psql is not installed or no connection service is configured, inform the user that setup is required and ask them to complete the following steps manually. Do not perform these steps yourself.

brew install libpq && brew link --force libpq

Configure ~/.pg_service.conf with a named [service] section per environment, and store credentials in a .pgpass file (hostname:port:database:username:password, chmod 600). Never share credential file contents with the assistant.

Command Format

Always use service=<name> from ~/.pg_service.conf — never pass raw host/user/password on the command line, where they could leak into shell history or process listings:

psql "service=<connection-service-name>" -c "<SQL>"

Examples

# Non-Prod — list tables
psql "service=<your-nonprod-service>" -c "\dt"

# Non-Prod — describe a table
psql "service=<your-nonprod-service>" -c "\d <table_name>"

Available Commands

Read-only (safe, no confirmation needed)

CommandDescription
\lList databases
\dt [pattern]List tables
\d <table>Describe a table's schema
\dnList schemas
\duList roles/users
\diList indexes
SELECT ...Any read-only query
EXPLAIN <query>Show a query plan without executing it
\timingToggle query timing (informational)

Mutating operations (confirm with user before running)

CommandDescription
INSERT / UPDATEInsert or update rows
CREATE TABLE / CREATE INDEXCreate new schema objects
ALTER TABLEModify an existing table's structure

Never run — requires explicit human approval

CommandReason
DELETE FROM ... (without a WHERE reviewed by the user)Can irreversibly remove rows at scale
DROP TABLE / DROP DATABASE / DROP SCHEMAIrreversible destruction of data or structure
TRUNCATEIrreversibly wipes all rows from a table
GRANT / REVOKEAlters access control, security-sensitive
Any DDL/DML against the production serviceA human must execute changes against production data

Rules

  • NEVER target a connection service not listed in the configuration table above. If a command references an unfamiliar service, stop and ask the user to confirm.
  • NEVER pass -h, -U, or a password directly on the command line — always use a service= connection string backed by ~/.pg_service.conf and .pgpass, so credentials never appear in shell history.
  • NEVER print, display, or store the contents of .pgpass or any credential value.
  • NEVER run DELETE, DROP, TRUNCATE, GRANT, or REVOKE without explicit user instruction — these are destructive or security-sensitive.
  • Always run EXPLAIN on unfamiliar or complex queries before executing them against a large table, to catch missing indexes or full table scans.
  • For any UPDATE/DELETE, always show the equivalent SELECT ... WHERE ... first and confirm the row count before proceeding.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.