Guide
Claude Code permissions: a guide for engineering leaders
What Claude Code's permission rules and modes actually control, which file wins when two disagree, where the rules stop, and how to make one policy hold on every developer's machine.
For: Engineering managers, platform teams and security leads rolling Claude Code out beyond a few early adopters.Checked against the vendor’s documentation on
What permissions control, and what they don't
Claude Code asks before it acts. Reading files in the working directory needs no approval; running shell commands, editing files, fetching URLs and searching the web do, unless a rule or a permission mode says otherwise. Permissions are the settings that decide which of those actions run silently, which stop for a person, and which never run at all.
The rules are enforced by Claude Code itself, not by the model. Instructions in a prompt or in CLAUDE.md shape what Claude tries to do, but they don't change what it is allowed to do. For a governance program that distinction matters: a sentence in CLAUDE.md is guidance, a deny rule is a control.
Permissions are also not a sandbox. A rule matches the tool call Claude makes, such as the command text it writes, not every way a program can be reached. The sections below cover where that line falls and what to pair with rules when it matters.
Allow, ask and deny: how rules are evaluated
Every rule sits in one of three lists under permissions in a settings file:
- Allow: Claude uses the tool without asking.
- Ask: Claude stops and asks for confirmation each time.
- Deny: Claude can't use the tool for matching calls.
Rules are checked in a fixed order: deny first, then ask, then allow. The first match decides, and a more specific rule doesn't beat a broader one. A deny on Bash(aws *) blocks aws s3 ls even if Bash(aws s3 ls) is in the allow list; an allow rule can't carve an exception out of a deny. The same holds between ask and allow.
A deny rule that names a whole tool, such as Bash or WebFetch, removes that tool from Claude's context entirely. A scoped deny such as Bash(rm *) leaves the tool available and blocks only the matching calls.
Developers can see every active rule, and the settings file each one comes from, with the /permissions command inside a session. When someone asks why Claude was blocked or wasn't, that is the first place to look.
Where rules live, and which file wins
Permission rules follow Claude Code's general settings precedence. From highest to lowest:
| Level | Where it lives | Who owns it |
|---|---|---|
| Managed settings | managed-settings.json in a system directory, an MDM profile, or server-managed settings from the Claude admin console | The organization. Nothing below can override it. |
| Command line | --settings, --allowedTools, --disallowedTools when a session starts | Whoever launches the session, for that session only |
| Project local | .claude/settings.local.json in the repository | One developer, in one project; kept out of git |
| Shared project | .claude/settings.json, committed to the repository | The team that owns the repo, reviewed like code |
| User | ~/.claude/settings.json | One developer, across every project |
For ordinary keys the highest level that sets a value wins. Deny rules are stricter: a tool denied at any level can't be allowed by any other. If a developer's user settings allow something and the project denies it, the deny holds, and the reverse is true too. A managed deny can't be undone with --allowedTools, while --disallowedTools can still add restrictions on top of managed policy.
Two details catch teams out. First, when a developer picks "Yes, and don't ask again" on a prompt, Claude Code saves an allow rule to .claude/settings.local.json at the repository root, so standing approvals accumulate in a file no one reviews. Second, allow rules in a committed .claude/settings.json only take effect after the developer accepts the workspace trust dialog for that folder; deny and ask rules apply regardless, because they only restrict.
Permission modes, including bypass
A permission mode sets the session's default answer to calls no rule decides. Developers switch modes with Shift+Tab in the CLI or start a session in one with --permission-mode; defaultMode in a settings file sets the starting mode.
| Mode | What it does | Where it fits |
|---|---|---|
default (shown as Manual) | Prompts before most edits, shell commands and network requests | Sensitive work and unfamiliar code |
acceptEdits | Accepts file edits and common filesystem commands inside the working directories without asking | Iterating on code the developer is watching |
plan | Reads and explores but doesn't edit source files until a plan is approved | Scoping a change before any code moves |
auto | Skips routine prompts; a background classifier checks actions such as shell commands and network requests against the request | Hands-off work where the model is supported and the org allows it |
dontAsk | Denies anything that would otherwise prompt; only pre-approved tools run | CI and scripted runs with an exact allowlist |
bypassPermissions | Skips permission prompts, apart from a short list of actions no mode auto-approves | Only isolated containers or VMs where Claude Code can't cause damage |
The --dangerously-skip-permissions flag starts a session in bypassPermissions. In that mode Claude Code also skips prompts for writes to protected paths such as .git and .claude. Anthropic's own guidance is to use it only inside a container or VM, run as a non-root user.
Organizations can switch modes off. Setting permissions.disableBypassPermissionsMode or permissions.disableAutoMode to "disable" blocks that mode; both work from any settings file but only hold against developers when set in managed settings.
Writing rules that match what you mean
Rules take the form Tool or Tool(specifier). A bare tool name matches every use of it. The specifier depends on the tool:
| Rule | Matches |
|---|---|
Bash(npm run build) | That exact command |
Bash(npm run *) | Any npm run command, including bare npm run |
Read(./.env) | Reading .env in the current directory |
Read(//etc/**) | Reading anything under the absolute path /etc |
Edit(/src/**) | Edits under src/, anchored at the project root for project settings |
WebFetch(domain:example.com) | Fetches to example.com (add *.example.com for subdomains) |
mcp__github__* | Every tool from an MCP server named github |
Agent(Explore) | The Explore subagent |
For Bash, put the * after the subcommand. Bash(git log *) allows only git log; Bash(git *) allows every git command, including git push. Claude Code understands shell operators, so allowing Bash(npm test *) doesn't approve npm test && curl …: every part of a compound command has to be allowed on its own, and a deny or ask rule applies if any part matches.
Path rules in Read and Edit use gitignore syntax, and the leading characters matter: //path is absolute, ~/path is under the home directory, /path is relative to the settings file's location, and path or ./path is relative to the current directory. A single leading slash is the most common mistake: /Users/alice/secrets is not an absolute path in a rule.
Where rules stop: sandboxing and hooks
A Bash rule matches the command text Claude writes. It doesn't match the same program reached another way:
| Deny rule | Stops | Doesn't stop |
|---|---|---|
Bash(curl *) | curl https://example.com | /usr/bin/curl …, sh -c 'curl …' |
Bash(rm *) | rm -rf build/ | /bin/rm -rf build/, bash -c 'rm -rf build/' |
Bash(git push *) | git push origin main | git -C . push origin main |
Likewise, Read and Edit deny rules cover Claude's own file tools and the shell commands Claude Code can recognize, but not a script that opens files itself. Treat command rules as a way to shape the agent's normal behavior and to stop accidents, not as a security boundary.
Two mechanisms go further. Sandboxing restricts the filesystem and network access of shell commands at the operating-system level, whatever the command text. PreToolUse hooks run your own script before a tool call and can block it, force a prompt or approve it; a hook can't override a deny or ask rule. Use rules for intent, hooks for checks your rules can't express, and the sandbox for the boundary that has to hold against a prompt injection.
Enforcing one policy across the organization
Anything in user or project settings can be changed by the developer who owns the file. Policy that has to hold goes in managed settings, which Claude Code applies above every other level. There are three ways to deliver them:
- A file on each machine:
managed-settings.jsonat/Library/Application Support/ClaudeCode/on macOS,/etc/claude-code/on Linux and WSL, orC:\Program Files\ClaudeCode\on Windows, placed by whatever tooling already manages the fleet. - MDM or OS policy: a macOS configuration profile or a Windows registry policy pushed through tools such as Jamf, Intune or Group Policy.
- Server-managed settings: configured in the Claude admin console and fetched when developers sign in with the organization's account. Anthropic lists this for Claude for Teams and Enterprise plans; check the server-managed settings docs for which sessions receive them.
Managed settings also unlock allowManagedPermissionRulesOnly. With it set to true, Claude Code ignores permission rules from user, project and local settings and from --allowedTools, so the managed file becomes the only source of rules. That is the strictest posture and also the most work to maintain, since every legitimate allow has to go through whoever owns the file.
A developer can confirm what reached their machine with /status, which lists the setting sources in force.
A starting policy
Most teams land on two layers: a small managed file that holds the lines that must never move, and a committed project file that each repository's owners review like any other config. This managed file keeps secrets out of Claude's file tools, makes pushes ask, and turns bypass mode off:
{
"permissions": {
"deny": [
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)"
],
"ask": [
"Bash(git push *)"
],
"disableBypassPermissionsMode": "disable"
}
}managed-settings.jsonA repository then commits the routine commands its developers would otherwise approve by hand, so the approvals are visible in review instead of piling up in local files:
{
"permissions": {
"allow": [
"Bash(npm run lint)",
"Bash(npm run test *)",
"Bash(git diff *)",
"Bash(git commit *)"
],
"deny": [
"Bash(npm publish *)"
]
}
}.claude/settings.jsonAdjust both files to your stack before rolling them out, and test them with /permissions in a real session. Claude Code ships often and its permission behavior changes between versions; check the permissions documentation for the version your developers run.A review checklist
- Is bypass mode disabled in managed settings, and is
--dangerously-skip-permissionsonly used in containers or VMs? - Do deny rules cover the files that hold credentials (
.envfiles, key directories, cloud config under the home directory)? - Are risky commands such as pushes, deploys and package publishing in
askordenyrather than left to the mode? - Does every repository commit its
.claude/settings.json, and does a code owner review changes to it? - Has anyone looked at the
.claude/settings.local.jsonapprovals developers have built up? - Where a restriction has to hold against a prompt injection, is it enforced by the sandbox rather than a command rule?
- Do CI runs use
dontAskwith an explicit--allowedToolslist instead of a broad mode?
Sources
Go deeper on The Principal Layer
- Least-Privilege Credential Scoping for AI Coding Agents
AI agents need credential scoping that changes with each task, not fixed roles.
- Acceptable Use Policies for AI Coding Agents on Engineering Teams
Teams running coding agents need policies built for autonomous systems, not chatbots.
- Version-Controlled Agent Configuration in Production Repos
Treating agent config as version-controlled code, not runtime ephemera.
- Network Egress Controls for AI Coding Agent Sandboxes
Controlling network access is where agent sandboxes actually hold against exfiltration.
- Prompt Injection Risks in AI Coding Agent Pipelines
Coding agents can't patch prompt injection like databases patched SQL.
- Governance Controls You Lose When Claude Code and Codex Run on Unmanaged Infrastructure
Managed infrastructure enforces the access boundaries that unmanaged deployments cannot.