The settings, tool by tool.
Claude Code evaluates permission rules in a fixed order, deny,
then ask, then allow, so a deny always beats a saved approval. Rules checked into
.claude/settings.json apply to everyone who opens the repo:
{
"permissions": {
"deny": [
"Read(./.env)",
"Read(./.env.*)"
],
"ask": [
"Bash(psql *)",
"Bash(supabase *)",
"Bash(railway *)"
]
}
}
Deny what the agent must never see; ask for what it must never do silently. Two
caveats from the documentation itself: file deny rules cover the built-in file
tools and the file commands recognised inside Bash, not an arbitrary script that
opens the file itself, so the strongest version of a secret the agent cannot read
is a secret that is not on disk at all. And the bypass-permissions mode that
skips prompting is documented as being for isolated environments, containers or
VMs, where the agent cannot cause damage; take the hint.
Cursor requires approval for terminal commands by default, and
its run modes range from a simple allowlist to an automatic reviewer. Its own
security documentation calls these best-effort guardrails rather than a hard
security boundary, which is the correct way to treat every approval gate in this
section: a seatbelt, not a roll cage. Use .cursorignore to keep
secret files out of the agent's reach, and keep production secrets out of the
workspace entirely.
Replit shipped its lessons as features: development and
production databases are now separated automatically, and a planning-only chat
mode lets you talk through changes with the agent while it is structurally unable
to make any. That mode is the correct setting for a code freeze, since the
incident that created it proved an instruction is not.
The database gets its own guardrail for the cases where the
agent genuinely needs to look at production to debug. Do not hand it the owner
connection string; create a role that can read and cannot destroy:
create role agent_ro login password 'use-a-long-generated-password';
grant usage on schema public to agent_ro;
grant select on all tables in schema public to agent_ro;
alter default privileges in schema public
grant select on tables to agent_ro;
The agent's environment gets the agent_ro connection string and no
other. It can diagnose the slow query and read the schema; it cannot drop, update,
or truncate anything. If your tables hold personal information, prefer the
data-less branch from rule one, both for safety and because
POPIA does not have an exemption
for debugging.
Permissions are the only instruction an agent cannot ignore
Every incident in this guide featured a clear instruction and a credential that
contradicted it, and the credential won every time. Write your real rules where
they are enforced: in token scopes, database roles, environment boundaries, and
permission files. The line in the prompt is a courtesy copy.