postgres-cli is a Postgres command runner for agent and CI workflows.
V2 is a clean-break release with:
- subcommands (
query,explain,introspect,schema-cache,targets,config,doctor) - JSON output by default with a stable envelope
- explicit write safety (
query --mode write+allow_write=true) - JSON-first schema cache artifacts for progressive context loading
- tri-platform skill launcher support (macOS arm64, Linux x86_64, Windows x86_64)
.agents/skills/postgres-cli/scripts/postgres-cli --project-root /path/to/repo --target local-read query --sql "SELECT now();".agents/skills/postgres-cli/scripts/postgres-cli --project-root /path/to/repo --target local-read introspect --kind tables.agents/skills/postgres-cli/scripts/postgres-cli --project-root /path/to/repo --target local-read schema-cache update --all-tables- Agents must use the installed skill launcher for DB operations.
- Canonical installed path:
.agents/skills/postgres-cli/scripts/postgres-cli. - If the consuming repo provides a root wrapper, prefer
scripts/postgres-cli. - Agents must not run
psqldirectly. - Agents must not read
.agents/.agentpostgres.tomlor.envfiles directly.
- If the user provides a connection name, pass
--target <name>. - If
--targetis omitted, CLI falls back todefault_target. - If no target is provided and no
default_targetexists, CLI returnsTARGET_MISSING.
Global --format supports:
json(default)textcsvtsv
csv/tsv are available for tabular commands only.
Config, dotenv, and schema-cache artifacts are now stored under .agents/postgres-cli/.
For compatibility, the CLI still reads legacy config from .agent/postgres-cli/postgres.toml.
.agents/postgres-cli/schema/
├── index.json
├── relations.json
└── tables/
└── <table>.json (or <schema>.<table>.json)
Optional markdown (with schema-cache update --with-markdown):
.agents/postgres-cli/schema/
├── README.md
├── relations.md
└── tables/
└── <table>.md
src/main.rsV2 Rust CLI implementationskills/postgres-cli/SKILL.mdskill instructions for agentsskills/postgres-cli/scripts/postgres-cliplatform launcher scriptskills/postgres-cli/scripts/bin/prebuilt binariesskills/postgres-cli/scripts/build-release-binary.shlocal maintainer build helperskills/postgres-cli/scripts/refresh-binaries-from-release.shmaintainer release refresh helperskills/postgres-cli/references/postgres.toml.examplestarter configskills/postgres-cli/references/SETUP.mdsetup and usage guide.github/workflows/build-release.ymlCI + release pipeline