Polygres CLI
Operate a user's Polygres project through the installed polygres command.
Treat the CLI as the operational and security boundary. Do not call private
control-plane routes or infer undocumented request payloads.
Prefer an available MCP connection
When Polygres MCP tools are available in the current session, read
references/mcp-tool-contract.md and use the discovered compatible tools for
interactive project operations. Call whoami, respect the fixed-project or
multi-project boundary, and treat the discovered catalog as authoritative.
Use the CLI workflow in this skill when the user explicitly asks for CLI, when
MCP is absent or incompatible, or when the operation belongs to the CLI surface,
such as migrations, Runtime keys, interactive database access, import start,
and legacy vector or text configuration. Never invent an MCP tool to mirror a
CLI command.
Start safely
- Run
polygres --version and polygres --help before live or end-to-end
testing, and whenever availability or command compatibility is unknown.
- If the command is missing, tell the user how to install
polygres-cli and
let them approve or perform the installation. Do not install packages
silently.
- For live tests from a Polygres source checkout, create an isolated test
environment, reinstall both
polygres-cli and polygres-sdk from that
checkout under its dependency-installation policy, and verify their versions
and import origins before testing. Do not substitute PyPI packages for the
checkout under test.
- Outside a source checkout, compare installed CLI and SDK versions with the
versions required by the application or current skill compatibility record.
Do not call an installation current merely because the command exists.
Obtain approval before changing installed packages.
- Run
polygres whoami before a mutation when identity or active organization
is uncertain. Use polygres login when authentication is required.
- Resolve the project with
polygres projects list, an explicit --project,
or polygres projects use <project>. State the resolved project before a
destructive, secret-producing, or schema-mutating operation.
- Resolve
project_mode. When it is synced, read
references/synced-projects.md before choosing any command.
- Prefer
polygres --json ... for output the agent must parse. Treat stdout as
the JSON channel and stderr as diagnostics.
If bundled examples differ from the installed --help, follow the installed
command surface and explain the version mismatch. Never guess a replacement.
Route the request
Read only the references needed for the task:
| User intent |
Reference |
| Login, logout, identity, organization, project selection or status |
references/authentication-and-projects.md |
| Synced-project creation, capabilities, lifecycle handoff, and permission boundaries |
references/synced-projects.md |
Environment, Postgres metadata, psql, Runtime API keys |
references/database-and-keys.md |
| Dataset or backfill from CSV, TSV, a JSON array, or JSONL/NDJSON |
references/data-imports.md |
| Validate, insert, upsert, or ignore one JSON object or runtime event |
references/rows.md |
| Migration list/apply and SQL safety |
references/migrations.md |
| Graph, text, existing vector configurations, and general retrieval readiness |
references/retrieval.md |
| Execute an approved graph plan through MCP or fall back to CLI |
references/mcp-graph-retrieval.md |
| Polygres AI Context collections, filters, points, operations, and retrieval |
references/context.md |
| JSON output, polling, exit codes, retry and recovery |
references/automation-and-errors.md |
Execute an operation
- Classify the request as read-only, mutating, destructive,
schema-mutating, or secret-producing.
- Load the relevant reference and validate local inputs.
- Resolve authentication and project context.
- Resolve project mode and stop any command that is unavailable for that mode.
- For a mutation, show the target project, affected resource, important
options, and reversibility.
- Obtain explicit approval when required. Accept an existing consolidated
pipeline approval when it names this exact project, source scope, action,
and unchanged plan digest.
- Run the narrowest documented command.
- Retain project, job, migration, configuration, key, and request IDs from the
result.
- Report only the observed terminal state. If work is still running, say so
and provide the status command.
Require consent
Obtain explicit user approval before:
replace_existing imports;
- applying a SQL migration;
- creating or updating a text configuration, including a generated TSVector
column or managed text index;
- reindexing a text configuration;
- revoking a Runtime API key;
- deleting existing vector or text configurations;
- every durable pgContext mutation, including collection create, update,
set-default, vector addition, default-vector change, reindex, or delete;
filter registration; point
reconciliation; and operation cancellation or retry;
- pgContext point upsert or delete when it will become a durable operation or
when deleting mappings is destructive for the user's serving behavior;
- any command that uses
--yes;
- any other operation that is destructive or difficult to reverse.
Add --yes only after approval for that exact operation and target.
Do not add a second confirmation to an explicit rows insert, rows upsert,
or rows ignore command that is already authorized by the user's command or a
matching consolidated pipeline approval.
Before approval for add-column or new-table collection creation, also show
the preflight DDL, affected schema objects, and ownership boundaries.
Protect secrets
- Never request, retrieve, store, log, or pass a native database password.
- Never request, print, or place a synced source connection in an argument,
generated file, or transcript. Prefer the CLI's hidden interactive URL prompt.
For approved non-interactive work, reference a user-populated environment
variable with
--connection-env; never inspect its value.
- Let
psql prompt the user for the database password.
- If an agent terminal cannot maintain an interactive TTY, give the user the
passwordless command or ask them to run
polygres db psql directly.
- Never ask a user for
POLYGRES_ACCESS_TOKEN. It is a development and test
override, not a public authentication workflow.
- Warn before
polygres keys create <name> because the Runtime API-key secret
is shown once and can enter terminal or agent history.
- Offer to let the user run key creation in their own terminal so the secret
does not enter the agent transcript.
- Never place tokens, keys, or passwords in source files, examples, command
arguments, logs, or final summaries.
Prepare non-CSV data locally
For TSV, JSON arrays, and JSONL/NDJSON datasets, read
references/data-imports.md and use scripts/prepare_import.py. Route one JSON
object intended as an individual write to references/rows.md instead. Resolve
the script path from this skill directory instead of assuming the repository
contains scripts/.
The converter is local-only and produces a reviewed CSV artifact. It does not
call Polygres. Never silently flatten nested JSON, rename columns, or collapse
null and empty-string values without explaining the result and obtaining the
required approval.
Do not present SQL migrations as a generic row-import mechanism. Do not call
the backend SQL-import or pg_dump routes because those commands are not in
the current public CLI.
Handle failures
Use references/automation-and-errors.md to interpret exit codes. In
particular:
- Fix validation before retrying exit
2.
- Reauthenticate on exit
3.
- Explain missing permission on exit
4.
- Resolve missing resources on exit
5.
- Resolve conflicts or ambiguous project selection on exit
6.
- Respect rate-limit guidance on exit
7.
- Treat exit
8 as remote failure or timeout.
- Install or hand off a missing local dependency such as
psql on exit 9.
After an import or provisioning timeout, check the known resource or job status
before resubmitting. A timed-out client does not prove the server operation
failed.
1---2name: polygres-cli3description: Use available Polygres MCP tools or the Polygres CLI to authenticate, operate standard or synchronized projects, import data, apply migrations, configure retrieval, manage Runtime keys and durable operations, and check readiness. Use the CLI for explicit command-line work and as the documented fallback for operations outside the MCP catalog.4---56# Polygres CLI78Operate a user's Polygres project through the installed `polygres` command.9Treat the CLI as the operational and security boundary. Do not call private10control-plane routes or infer undocumented request payloads.1112## Prefer an available MCP connection1314When Polygres MCP tools are available in the current session, read15`references/mcp-tool-contract.md` and use the discovered compatible tools for16interactive project operations. Call `whoami`, respect the fixed-project or17multi-project boundary, and treat the discovered catalog as authoritative.1819Use the CLI workflow in this skill when the user explicitly asks for CLI, when20MCP is absent or incompatible, or when the operation belongs to the CLI surface,21such as migrations, Runtime keys, interactive database access, import start,22and legacy vector or text configuration. Never invent an MCP tool to mirror a23CLI command.2425## Start safely26271. Run `polygres --version` and `polygres --help` before live or end-to-end28 testing, and whenever availability or command compatibility is unknown.292. If the command is missing, tell the user how to install `polygres-cli` and30 let them approve or perform the installation. Do not install packages31 silently.323. For live tests from a Polygres source checkout, create an isolated test33 environment, reinstall both `polygres-cli` and `polygres-sdk` from that34 checkout under its dependency-installation policy, and verify their versions35 and import origins before testing. Do not substitute PyPI packages for the36 checkout under test.374. Outside a source checkout, compare installed CLI and SDK versions with the38 versions required by the application or current skill compatibility record.39 Do not call an installation current merely because the command exists.40 Obtain approval before changing installed packages.415. Run `polygres whoami` before a mutation when identity or active organization42 is uncertain. Use `polygres login` when authentication is required.436. Resolve the project with `polygres projects list`, an explicit `--project`,44 or `polygres projects use <project>`. State the resolved project before a45 destructive, secret-producing, or schema-mutating operation.467. Resolve `project_mode`. When it is `synced`, read47 `references/synced-projects.md` before choosing any command.488. Prefer `polygres --json ...` for output the agent must parse. Treat stdout as49 the JSON channel and stderr as diagnostics.5051If bundled examples differ from the installed `--help`, follow the installed52command surface and explain the version mismatch. Never guess a replacement.5354## Route the request5556Read only the references needed for the task:5758| User intent | Reference |59| --- | --- |60| Login, logout, identity, organization, project selection or status | `references/authentication-and-projects.md` |61| Synced-project creation, capabilities, lifecycle handoff, and permission boundaries | `references/synced-projects.md` |62| Environment, Postgres metadata, `psql`, Runtime API keys | `references/database-and-keys.md` |63| Dataset or backfill from CSV, TSV, a JSON array, or JSONL/NDJSON | `references/data-imports.md` |64| Validate, insert, upsert, or ignore one JSON object or runtime event | `references/rows.md` |65| Migration list/apply and SQL safety | `references/migrations.md` |66| Graph, text, existing vector configurations, and general retrieval readiness | `references/retrieval.md` |67| Execute an approved graph plan through MCP or fall back to CLI | `references/mcp-graph-retrieval.md` |68| Polygres AI Context collections, filters, points, operations, and retrieval | `references/context.md` |69| JSON output, polling, exit codes, retry and recovery | `references/automation-and-errors.md` |7071## Execute an operation72731. Classify the request as read-only, mutating, destructive,74 schema-mutating, or secret-producing.752. Load the relevant reference and validate local inputs.763. Resolve authentication and project context.774. Resolve project mode and stop any command that is unavailable for that mode.785. For a mutation, show the target project, affected resource, important79 options, and reversibility.806. Obtain explicit approval when required. Accept an existing consolidated81 pipeline approval when it names this exact project, source scope, action,82 and unchanged plan digest.837. Run the narrowest documented command.848. Retain project, job, migration, configuration, key, and request IDs from the85 result.869. Report only the observed terminal state. If work is still running, say so87 and provide the status command.8889## Require consent9091Obtain explicit user approval before:9293- `replace_existing` imports;94- applying a SQL migration;95- creating or updating a text configuration, including a generated TSVector96 column or managed text index;97- reindexing a text configuration;98- revoking a Runtime API key;99- deleting existing vector or text configurations;100- every durable pgContext mutation, including collection create, update,101 set-default, vector addition, default-vector change, reindex, or delete;102 filter registration; point103 reconciliation; and operation cancellation or retry;104- pgContext point upsert or delete when it will become a durable operation or105 when deleting mappings is destructive for the user's serving behavior;106- any command that uses `--yes`;107- any other operation that is destructive or difficult to reverse.108109Add `--yes` only after approval for that exact operation and target.110Do not add a second confirmation to an explicit `rows insert`, `rows upsert`,111or `rows ignore` command that is already authorized by the user's command or a112matching consolidated pipeline approval.113Before approval for `add-column` or `new-table` collection creation, also show114the preflight DDL, affected schema objects, and ownership boundaries.115116## Protect secrets117118- Never request, retrieve, store, log, or pass a native database password.119- Never request, print, or place a synced source connection in an argument,120 generated file, or transcript. Prefer the CLI's hidden interactive URL prompt.121 For approved non-interactive work, reference a user-populated environment122 variable with `--connection-env`; never inspect its value.123- Let `psql` prompt the user for the database password.124- If an agent terminal cannot maintain an interactive TTY, give the user the125 passwordless command or ask them to run `polygres db psql` directly.126- Never ask a user for `POLYGRES_ACCESS_TOKEN`. It is a development and test127 override, not a public authentication workflow.128- Warn before `polygres keys create <name>` because the Runtime API-key secret129 is shown once and can enter terminal or agent history.130- Offer to let the user run key creation in their own terminal so the secret131 does not enter the agent transcript.132- Never place tokens, keys, or passwords in source files, examples, command133 arguments, logs, or final summaries.134135## Prepare non-CSV data locally136137For TSV, JSON arrays, and JSONL/NDJSON datasets, read138`references/data-imports.md` and use `scripts/prepare_import.py`. Route one JSON139object intended as an individual write to `references/rows.md` instead. Resolve140the script path from this skill directory instead of assuming the repository141contains `scripts/`.142143The converter is local-only and produces a reviewed CSV artifact. It does not144call Polygres. Never silently flatten nested JSON, rename columns, or collapse145null and empty-string values without explaining the result and obtaining the146required approval.147148Do not present SQL migrations as a generic row-import mechanism. Do not call149the backend SQL-import or `pg_dump` routes because those commands are not in150the current public CLI.151152## Handle failures153154Use `references/automation-and-errors.md` to interpret exit codes. In155particular:156157- Fix validation before retrying exit `2`.158- Reauthenticate on exit `3`.159- Explain missing permission on exit `4`.160- Resolve missing resources on exit `5`.161- Resolve conflicts or ambiguous project selection on exit `6`.162- Respect rate-limit guidance on exit `7`.163- Treat exit `8` as remote failure or timeout.164- Install or hand off a missing local dependency such as `psql` on exit `9`.165166After an import or provisioning timeout, check the known resource or job status167before resubmitting. A timed-out client does not prove the server operation168failed.