Directory Compare FCRS-1.0 /llms.txt
← Back to Directory

pgcli

$ pgcli Community High Risk
dbcli · Database & Data · BSD-3-Clause · macos / linux / windows

pgcli is a popular human-ergonomic PostgreSQL terminal client featuring prompt-toolkit autocomplete and syntax highlighting. While it supports -c single-query execution and --csv, it is built primarily as an interactive TUI REPL rather than a headless automation binary.

FCRS-1.0 Score
74 /100
Usable w/ Caveats
Medium Confidence
Zero-Friction Install
brew install pgcli
CLI vs MCP Decision CLI Preferred vs MCP

Agents should prefer psql over pgcli for non-interactive SQL pipelines because pgcli adds Python startup overhead and interactive REPL defaults.

Agent-Readiness Checklist

— JSON Output
— Field Filtering
✓ Non-Interactive
— Dry-Run
— Read-Only Mode
— NO_COLOR Clean
✓ Self-Describing
— Official SKILL.md

Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.

FCRS-1.0 6-Dimension Breakdown

Agent-Readiness 14 / 25

Interactive-first prompt-toolkit REPL; supports -c and --csv / --table-format, but lacks native --json and adds TUI baggage.

  • Designed as interactive REPL; supports -c and --csv
Trust & Safety 18 / 25

Inherits PostgreSQL PGOPTIONS='-c default_transaction_read_only=on' when passed, but has no agent dry-run or JSON contract.

  • Relies on server-side PGOPTIONS for read-only safety
Setup & Portability 12 / 15

Available via Homebrew, PyPI, and uvx, though psycopg binary/libpq dependencies can complicate source installs.

  • Installable via brew and pip (dbcli/pgcli)
Utility & Efficiency 13 / 15

Loved by human developers for autocomplete, though redundant for AI agents when psql exists.

  • Human-centric SQL autocomplete and syntax highlighting
Maintenance & Lineage 9 / 10

Well-maintained dbcli/pgcli open-source project under BSD-3-Clause.

  • Active dbcli/pgcli repository
Docs & Verifiability 8 / 10

Clear documentation at pgcli.com/docs and --help.

  • Official docs at pgcli.com/docs

Security, Auth & Guardrails

Auth Modes
Env API Key Config File
Credential Storage

Reads standard PGPASSWORD / DATABASE_URL env vars and ~/.pgpass; stores preferences in ~/.config/pgcli/config.

Side Effects
Read-Only Remote Write Destructive
Cost & Quotas

100% free and BSD-3-Clause open-source.

Copyable Guardrail for CLAUDE.md / AGENTS.md
# pgcli Agent Rules
- Prefer `psql` for automated SQL tasks; only use `pgcli` if `psql` is unavailable.
- Always pass `-c "<sql>"` and `PGOPTIONS='-c default_transaction_read_only=on'`—never launch the interactive REPL.
- Pipe or disable pagers (`PAGER=cat`) to avoid terminal stalls.

Agent-Ready Command Recipes

Safe Read-Only Queries

Run a one-shot query via pgcli
PGOPTIONS='-c default_transaction_read_only=on' pgcli "$DATABASE_URL" -c "SELECT current_database(), current_user;" --csv

Executes a single SQL statement non-interactively with CSV output.

Strengths for Agents

  • + Excellent human interactive UX with context-aware SQL completion.
  • + Supports -c one-shot queries and --csv output when needed.

Caveats & Pitfalls

  • ! Interactive REPL by default; psql is faster, lighter, and more predictable for agents.
  • ! Python startup and prompt-toolkit initialization add unnecessary overhead in scripts.

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI