Skip to content

PgStack Access records SQL queries executed by an AI coding agent through a temporary PostgreSQL connection. The session's queries can be reviewed in the project's Access view.

The upstream PostgreSQL user determines the database permissions available to the agent. Sessions can have a short duration and use read-only mode when the task does not require writes.

Sign in interactively with pgstack auth login, then start a session for the agent:

Terminal window
pgstack access start --env production --duration 15m --read-only --reason "ENG-142 Investigate delayed orders" --json

The JSON result includes the session's connectionUrl and slug. Keep the URL private and use it only for the intended task. The flag does not grant the agent any additional database permissions.

Adapt this prompt for your project and configured role:

Use PgStack Access whenever you connect to the project database.
Start a 15-minute read-only session with --env production and a reason
summarizing this investigation. Use --json and connect using the returned
connectionUrl. Keep the URL private; do not include it in commits,
shared logs, or your final response. Query only the data needed for the task.
Revoke the returned session slug when finished. If access expires,
request a new session rather than using permanent database credentials.

Review the recorded queries in the project's Access view. Revoke the session when the agent finishes:

Terminal window
pgstack access revoke <session-slug> --reason "Agent investigation complete"

Revocation closes existing connections within one minute.