Read-only PostgreSQL lookup skill for this repository using DATABASE_URL and direct psql execution. Use when the user asks to inspect data, verify records, or answer questions from the DB. Always draft SQL and command first, ask for confirmation, then run inside a READ ONLY transaction.
Use this skill for repository-scoped database lookups.
SELECT or WITH ... SELECT).packages/db/prisma/schema.prisma before drafting SQL.psql command first.packages/db/prisma/schema.prisma.information_schema lookup query first, then draft the final query.Reject SQL containing these case-insensitive keywords:
insertupdatedeletedropaltercreatetruncategrantrevokecopycalldovacuumanalyzeAlso reject semicolon-chained statements.
LIMIT, append LIMIT 50.LIMIT exceeds 500, reduce to 500.Before any execution, provide:
Then ask: Run this query? (yes/no)
Do not execute until the user confirms.
Preferred command (loads repo .env first, then runs read-only transaction):
set -a; source .env >/dev/null 2>&1; set +a; psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -X -P pager=off -c "BEGIN READ ONLY; <SQL>; ROLLBACK;"
For single-value counts, prefer machine-friendly output:
set -a; source .env >/dev/null 2>&1; set +a; psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -X -At -c "SELECT COUNT(*)::int FROM <table>;"
Before execution:
DATABASE_URL is set after loading .env.apps/web/.envapps/chainworker/.envIf connection fails, run a quick host diagnostic:
node -e "const u=new URL(process.env.DATABASE_URL||''); console.log(u.host)"
If DNS/network fails in sandbox, rerun the query outside sandbox (with approval) rather than changing SQL.