pgcli
$ pgcli Community High Riskpgcli 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.
brew install pgcli Agents should prefer psql over pgcli for non-interactive SQL pipelines because pgcli adds Python startup overhead and interactive REPL defaults.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Interactive-first prompt-toolkit REPL; supports -c and --csv / --table-format, but lacks native --json and adds TUI baggage.
- Designed as interactive REPL; supports
-cand--csv
Inherits PostgreSQL PGOPTIONS='-c default_transaction_read_only=on' when passed, but has no agent dry-run or JSON contract.
- Relies on server-side
PGOPTIONSfor read-only safety
Available via Homebrew, PyPI, and uvx, though psycopg binary/libpq dependencies can complicate source installs.
- Installable via
brewandpip(dbcli/pgcli)
Loved by human developers for autocomplete, though redundant for AI agents when psql exists.
- Human-centric SQL autocomplete and syntax highlighting
Well-maintained dbcli/pgcli open-source project under BSD-3-Clause.
- Active
dbcli/pgclirepository
Clear documentation at pgcli.com/docs and --help.
- Official docs at pgcli.com/docs
Security, Auth & Guardrails
Reads standard PGPASSWORD / DATABASE_URL env vars and ~/.pgpass; stores preferences in ~/.config/pgcli/config.
100% free and BSD-3-Clause open-source.
# 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
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
-cone-shot queries and--csvoutput when needed.
Caveats & Pitfalls
- ! Interactive REPL by default;
psqlis faster, lighter, and more predictable for agents. - ! Python startup and prompt-toolkit initialization add unnecessary overhead in scripts.