# psql for PostgreSQL inspection and query workflows
Query PostgreSQL databases and inspect schemas from terminal and agent workflows.
Agent Readiness Score: 75/100
psql is useful for agents when usage is constrained to predictable commands and documented output.
## Install

- Recommended: `brew install libpq`

## Structured output

Supported output formats: csv, text, json.
Prefer structured output flags such as `--json`, `--format json`, or equivalent when available.

## Safe commands

- Show help: `libpq --help` — Inspect command surface before automation.
- Check version: `libpq --version` — Verify the installed CLI.

## Agent instructions

- Claude Code / Codex CLI / Gemini CLI: Use psql only with non-interactive commands. Prefer structured output: csv, text, json. Ask before destructive operations.

## Safety notes

- Prefer non-interactive usage and explicit output flags when an agent runs this command.
- Treat commands that deploy, delete, charge money, or mutate production data as approval-required.
- Record the exact command, output format, and scope before adding it to an agent workflow.

## Metadata

Official URL: https://www.postgresql.org/docs/current/app-psql.html
Docs: https://www.postgresql.org/docs/current/app-psql.html
