How to Configure Codex CockroachDB Approval
You set up codex cockroachdb approval by pairing narrow database roles with agent shell prompts. This setup stops the AI agent from running write queries without a human check. Many teams start by giving their coding agent a full admin database login. That shortcut creates high risk because the agent can drop tables or alter rows. When roles are too broad, one bad prompt can break a live cluster. How codex cockroachdb approval works in practice AI coding agents reach databases in two main way
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 codex cockroachdb approval by pairing narrow database roles with agent shell prompts. This setup stops the AI agent from running write queries without a human check. Many teams start by giving their coding agent a full admin database login. That shortcut creates high risk because the agent can drop tables or alter rows. When roles are too broad, one bad prompt can break a live cluster.
How codex cockroachdb approval works in practice
AI coding agents reach databases in two main ways during a coding session. First, the agent can run command line tools inside a local shell. Second, the agent can talk to a local server using the Model Context Protocol. Both paths need a database login string to reach your CockroachDB cluster. The database checks who the user is when the session starts. Then, the database checks its own role rules to allow or block table reads.
To keep data safe, you must build a read-only user in CockroachDB first. You grant this user permission to read specific tables and nothing else. Next, you set the coding agent to ask for human sign-off before running shell commands. When the agent wants to inspect a table, it drafts a command. The developer reads the command on screen and approves or denies the action. If approved, the command runs using that read-only database role.
Why native roles and local prompts fall short
Native database roles and local agent prompts solve the first layer of risk. Database roles decide which user can log in and which tables they can read. Local agent prompts let a developer check a shell command before it runs. Together, they stop an AI tool from making blind changes with admin rights. This setup works well for small test databases with fake data.
Still, this native setup leaves a major gap during live operations. Once a session logs in, the database does not require sign-off for each single query. If a developer approves a script or grants write roles for a fix, everything runs. A local prompt only checks the shell command on one laptop. It does not let a lead engineer review a risky query from another room. Also, a read-only role still lets the agent pull raw emails, phone numbers, or card numbers. Native roles cannot rewrite matched fields in results to hide private user data from the model.
Approval Chains & Escalation + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
How to tighten database checks for AI agents
Teams need a clear split between safe read tasks and risky write tasks. For daily coding, the agent should only use a role that reads schema and safe tables. You should never store a write-capable login string in a local agent file. Keep write logins out of local shells so the agent cannot use them by mistake.
When an agent needs to run a data fix, treat that query like code. Have the agent write the SQL statement into a plain text file first. Then, a human teammate can check the exact statement before anyone runs it. You should also remove sensitive columns from the views that the agent role can read. This keeps national IDs and card numbers out of the AI context window.
Govern statements and responses across databases and APIs
Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev sits inline in the protocol beside each supported service as an open-source proxy, a sidecar for your database or API. For every query or command an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human approval.
First, hoop.dev guardrails block banned queries before they run or hold risky ones for review, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.
Frequently asked questions
Can an AI coding agent change CockroachDB data on its own?
Yes, if you give it a write role and turn off command prompts. You can prevent this by using a read-only database user and keeping manual command checks on.
Should I put database login strings in my project files for the agent?
No, you should never save database passwords in plain text project files. Store login details in safe local variables and only use accounts with narrow read rights.
Do read-only roles stop the agent from seeing private customer data?
No, a standard read-only role still returns all columns in a table by default. Unless masking rewrites matched fields in results, the agent will read emails and phone numbers.
Related guides
In this post