create-readonly-db-role
Installation
SKILL.md
Create a Read-Only DB Role for Agents
Battle-tested pattern (DeepAPI ADR 0093). A SELECT-only role kills catastrophic writes at the permission level. Residual risks (data leaks, heavy queries) are handled by a denylist and timeouts. Agents stop being blind on prod; the human stops being the SQL bottleneck.
The pattern — 3 layers
- Hard wall — grants. The role gets SELECT and nothing else. Writes are impossible, not just discouraged.
- Denylist, not allowlist. Grant SELECT on ALL current + future tables in
public(via default privileges), then revoke the crown jewels (API keys, webhook payloads, secrets). Never grant theauthschema. Future tables are auto-readable by design; new sensitive tables need a manual revoke. - Soft guardrails.
default_transaction_read_only = onplusstatement_timeout = '10s'.
RLS trap: if prod tables have Row Level Security and no policy mentions the new role, every SELECT returns 0 rows. Fix with alter role ... bypassrls — safe, because bypass only skips row filtering; the SELECT-only grants and denylist still apply.