You Set the Boundaries, Claude Code Enforces

A close read of the permission system — modes, rules, Auto mode, sandboxing, hooks, and the settings that govern them.

You  define the boundaries Claude Code  applies the controls Current Claude Code model · 2026
01The core question

Execution Is a Six-Stage Decision

Prompts and CLAUDE.md shape what Claude attempts. Claude Code applies a fixed enforcement flow before a requested tool can execute.

1 · Hooksintercept first 2 · Denyblock matches 3 · Askrequire approval 4 · Modeapply baseline 5 · Allowpre-approve 6 · canUseToolresolve leftovers first decisive outcome wins · critical and interaction-required calls retain extra checks
A PreToolUse hook can block a call, but its allow result cannot override a matching deny or ask rule. Enforcement remains outside the working model.
02Baseline

Six Modes, One Risk Ladder

A permission mode sets the baseline for every session. Rules and hooks layer on top of whichever one is active.

ModeRuns without askingBest for
default (Manual)Reads onlySensitive work, reviewing every action
acceptEditsReads, file edits, common filesystem commandsIterating on code you're reviewing
planReads, classifier-approved commands where availableExploring before you change anything
autoEverything, with background safety checksLong tasks, fewer prompts
dontAskOnly pre-approved tools — denies instead of askingLocked-down CI and scripts
bypassPermissionsEverythingIsolated containers and VMs, nothing else
Modes are not a perfect risk ladder: plan, dontAsk, and auto solve different control problems. Protected-path writes are not auto-approved except in bypass, or in Plan sessions where bypass was enabled at launch.
03auto mode

Auto Mode Reviews What Is Not Already Resolved

A separate classifier reviews unresolved shell, network, protected-path, and higher-risk actions. Routine reads and working-directory edits normally skip it.

blocks by default

High-consequence actions

Piping to a shell (curl | bash), production deploys, mass deletions, IAM changes, terraform destroy, force pushes.

allows by default

In-scope work

Working-directory edits, dependencies declared in manifests or lock files, read-only HTTP, and ordinary pushes within the current repository.

Auto is the built-in starting mode on Pro, Max, and Team when supported. Deploy-like branches such as production or gh-pages receive extra scrutiny. Critical-path rm/rmdir also routes to the classifier.
04Fine-grained control

Tool or Tool(specifier)

The shared shape hides different matchers: tool-specific specifiers, top-level parameter rules, and MCP tool-name wildcards do not have identical semantics.

RuleUseMatches
Bash(npm run *)allow / ask / denynpm scripts, not npm install
Read(./.env)allow / ask / denyThat path under the rule's anchor
WebFetch(domain:*.example.com)allow / ask / denySubdomains of example.com
mcp__github__get_*tool-name wildcardGitHub MCP tools beginning get_
Agent(model:opus)ask / deny parameter ruleCalls explicitly requesting Opus
Compound shell commands are checked one subcommand at a time. Primary content fields cannot use generic parameter matching: write Bash(rm *), Read(path), or WebFetch(domain:host). Parenthesized MCP parameter rules in settings are rejected.
05Evaluation order

Deny, Then Ask, Then Allow

Inside the declarative rule lists, the order is fixed and specificity does not change it: deny precedes ask, which precedes allow.

call: Bash(aws s3 ls) deny: Bash(aws *) allow: Bash(aws s3 ls) blocked deny checked first — never reached
A broad deny cannot contain a narrower allow exception. A bare tool-name deny such as Bash removes the tool from Claude's context; a scoped deny such as Bash(rm *) leaves other Bash calls available.
06Where rules live

Five Sources, One Precedence

Highest wins for a single value; array-type keys like permissions.allow merge across every level instead.

1 · highest

Managed settings

MDM, org console. Locks a rule so nothing below can override it.

2

Command line

claude --settings, for one run.

3

Project local

.claude/settings.local.json — personal, gitignored.

4

Shared project

.claude/settings.json — checked in, whole team.

Level 5, lowest: ~/.claude/settings.json, user-wide. Permanent Bash and WebFetch approvals are stored as repository-scoped local rules; ordinary file-edit approval lasts only for the session.
07The risky one

Bypass Removes Prompts, Not Every Guardrail

bypassPermissions executes almost everything immediately, including protected-path writes. A short list still requires separate handling.

still separately gated

Five standing exceptions

Explicit ask rules · critical-path rm/rmdir · interaction-required tools · organization-gated connectors · cross-session messaging safeguards.

the warning is not boilerplate

Isolated environments only

Prompt injection or model error can trigger destructive action without review. Protected paths such as .git and .claude are writable in this mode.

Use only inside a genuinely isolated, non-root container or VM. Claude Code refuses bypass under --restricted, generally refuses it under root/sudo, and cloud sessions ignore repository defaults that request it.
08A different layer

What Runs vs. What It Can Reach

Permission modes decide whether a call happens. The Bash sandbox — Seatbelt on macOS, bubblewrap on Linux/WSL2 — decides what it can touch once it does. The two are independent.

filesystem, by default

Working directory only

By default, writes stay inside the working directory, session temp directory, and added directories. Broader access requires explicit sandbox configuration.

network, by default

No domains at all

First request to a new domain prompts — or in auto mode, goes to the classifier. Nothing is reachable until it's explicitly allowed.

Sandbox auto-allow runs eligible commands without prompting, independently of the permission mode except in Plan. Deny rules, critical-path removal checks, and command-scoped ask rules still apply. Unsandboxed fallback is visibly labeled Bash command (unsandboxed).
09Agent SDK

canUseTool Resolves the Remaining Prompt

In the Agent SDK, canUseTool replaces the interactive permission prompt. Calls approved earlier normally never reach it.

canUseTool (TypeScript)
type CanUseTool = (
  toolName: string,
  input: Record<string, unknown>,
  options: {
    signal: AbortSignal;
    blockedPath?: string;
    decisionReason?: string;
  }
) => Promise<PermissionResult>;
when it's actually reached
// return one structured result
return { behavior: "allow",
  updatedInput: input };

return { behavior: "deny",
  message: "Reason",
  interrupt: false };

// dontAsk skips this callback
Interaction-required tools and critical-path calls can still reach the callback despite an allow rule. For logic that must inspect every tool call, use a PreToolUse hook.
10Two kinds of "no"

Protected Paths vs. Critical Paths

Protected paths resist silent writes. Critical paths add a special circuit breaker for Unix rm/rmdir.

 ExamplesIn bypassPermissions
Protected paths.git, .claude, .mcp.json, shell rc filesWrite proceeds without the normal protected-path prompt
Critical pathsFilesystem root, top-level directories, home, working-directory parentsrm/rmdir still asks for approval
An allow rule or PreToolUse allow cannot clear a critical-path removal. The user, Auto classifier, or a PermissionRequest hook may still resolve the resulting approval path. PowerShell Remove-Item follows separate rules.
11For an organization

Locking It Down at the Org Level

Managed settings are the only layer nothing downstream can override — the actual governance surface.

disable bypass

permissions.disableBypassPermissionsMode

Removes the highest-risk permission mode from governed sessions.

disable auto

permissions.disableAutoMode

Removes classifier-based Auto mode; other modes remain independently configurable.

force sandboxing

sandbox.enabled + failIfUnavailable

Makes the sandbox a hard requirement, not a best-effort fallback.

lock rule sources

allowManagedPermissionRulesOnly

Uses managed sources only for allow, ask, and deny permission rules.

12The model

Four Layers Bound Agentic Execution

Instructionsshape intent Rules + Modesauthorize execution Hooksintercept calls Sandbox + Isolationconstrain impact

No single control is the whole safety model. Authorization determines whether a requested call executes; interception and isolation limit what that execution can do.

01 / 13
use ← → or click the edges to navigate