Answer ad-hoc business questions without touching SQL
When to use: You have a question about your data ('how many users came back this week?') and the BI dashboard doesn't have it.
Prerequisites
- Read-only
postgres://connection string to a replica — Most managed PG (RDS, Neon, Supabase) lets you create read-only credentials - Network access from where Claude runs to the DB — VPN or IP allowlist your machine
Flow
-
Have Claude introspect the relevant tables firstList all tables in our DB. For tables related to users, orders, or sessions, describe their schemas.✓ Copied→ Schema overview before any query
-
Ask the actual questionHow many users signed up in the last 30 days but haven't placed an order yet? Group by signup week.✓ Copied→ Claude writes SQL, runs it, returns results table
-
Probe for caveatsAre there any reasons this number could be misleading? Soft deletes? Timezone in created_at? Specific user types we should exclude?✓ Copied→ Honest call-out of data quirks
Outcome: A defensible answer to a business question with the SQL, the result, and the caveats — in 2 minutes instead of waiting 2 days for the data team.
Pitfalls
- Claude writes a query that scans your largest table without limits — Set
statement_timeout = '30s'on the connection, and add 'always include LIMIT 1000 by default' to your system prompt - Counting 'users' depends on what counts as a user (deleted? bot? test?) — Tell Claude your conventions upfront: 'exclude rows where deleted_at IS NOT NULL' etc.