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

  1. Hard wall — grants. The role gets SELECT and nothing else. Writes are impossible, not just discouraged.
  2. 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 the auth schema. Future tables are auto-readable by design; new sensitive tables need a manual revoke.
  3. Soft guardrails. default_transaction_read_only = on plus statement_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.

Workflow

Installs
61
GitHub Stars
2.7K
First Seen
Jul 10, 2026
create-readonly-db-role — davidondrej/skills