How to Configure Gemini CLI Supabase Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up gemini cli supabase read only access by creating a restricted Postgres role. Then you pass that role login string to the agent tool in your shell. Many teams skip this step and use the default admin role for speed. Broad permissions let an AI agent change or delete live data by mistake. Giving an agent admin rights puts every table in your project at risk. How to set up gemini cli supabase read only access Every Supabase project starts with a default postgres role that holds admin

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up gemini cli supabase read only access by creating a restricted Postgres role. Then you pass that role login string to the agent tool in your shell. Many teams skip this step and use the default admin role for speed. Broad permissions let an AI agent change or delete live data by mistake. Giving an agent admin rights puts every table in your project at risk.

How to set up gemini cli supabase read only access

Every Supabase project starts with a default postgres role that holds admin rights. The vendor docs say you should never give this main password to external tools. Instead, you should make a new database user for each external service or tool. You can run statements in the web dashboard to create this new role. Note that queries in the web dashboard run as the default postgres admin role.

Your new role needs permission to read your schema and select from chosen tables. Do not grant insert, update, or delete rights to this role. You also need to alter default privileges for any future tables in that schema. Without that step, the role will miss read rights on tables you create later. Once the role is ready, you store its login string in your local shell.

Gemini CLI runs commands and connects to tools using the variables in your shell. When the agent runs a database tool, it logs in as your read-only role. The database engine then blocks any attempt to drop tables or alter rows. This setup keeps the agent from writing bad data during a coding task.

What native read-only roles solve and what they miss

A native read-only Postgres role stops an agent from changing or deleting your data. It solves the problem of accidental writes during debugging or schema checks. Postgres enforces these rules at the engine level for every session using that role. If Gemini CLI tries to run an update statement, Postgres rejects it right away.

Still, a database role only decides who logs in and which tables they read. It does not inspect what individual statements or requests do in flight. A read-only role can still read every column in an allowed table by default. If a table holds emails, phone numbers, or card numbers, the agent gets them. The database sends those raw values straight back to the terminal and the model.

Auditor Read-Only Access + Customer Support Access to Production: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Static roles also mean you leave a long-lived password sitting on a laptop. Any local script or process can read that shell variable and use it. You also lack a clear audit trail that links queries to a specific person. Every agent session shares the same database role name in your Postgres logs. Native roles cannot rewrite matched fields in results or require approval for sensitive reads.

Managing schema drift and table permissions

Database schemas change fast when teams ship new features every week. When an engineer adds a new table, custom roles might not get access right away. Or worse, broad select grants on a whole schema might expose a secret table. You have to check your role grants each time you run a migration.

Row Level Security can filter rows, but it requires extra policies for each role. Writing and testing those rules takes time away from building your product. Even with row filters, any allowed row still returns all of its columns. A column with national IDs or phone numbers stays exposed to the agent prompt. Teams need a way to control queries and mask fields in real time.

Add query and result controls beside Postgres

Grants and pools govern who logs into PostgreSQL. Yet every query in an open session still runs with that role's full scope. In practice, hoop.dev sits inline in the wire protocol beside your database as a sidecar for your Postgres. For every plain or prepared query an agent or human runs against production, hoop.dev decides to pass, mask, block, or escalate it for review.

When a tool or agent sends SQL, hoop.dev Postgres controls block banned statements before execution or hold risky ones for human approval via an AI Analyzer you configure. Matched sensitive columns in result rows are masked in memory before they reach the caller. Each query and decision is logged per listener, which generates evidence for SOC 2, HIPAA, and GDPR audits. View the binary on GitHub.

Frequently asked questions

Should I give Gemini CLI the default postgres role password?

No, the default postgres role has admin rights across your whole project. You should always create a separate role with select rights for external tools.

Does a read-only Postgres role hide sensitive columns from Gemini CLI?

No, table-level select grants return every column in that table to the caller by default. Emails, phone numbers, and card numbers will still pass into the agent context.

How do queries run when I set up roles in the Supabase dashboard?

Queries run in the web dashboard execute as the default postgres admin role. This gives you the rights needed to create new users and grant permissions.

The query runs. The emails stay hidden.