Skip to main content
Module 3: Real Architecture 6 / 6
Advanced S18 Permissions Security Sandbox

Permission Models & Security

Choose the right Claude Code permission mode, write precise rules, and combine permissions with sandboxing and policy controls.

March 20, 2026 22 min read

What You’ll Learn

Claude Code security is not one switch. It combines:

  1. A permission mode that sets the session baseline
  2. allow, ask, and deny rules for specific tool calls
  3. Protected paths and organization policy
  4. Optional OS-level sandboxing for shell commands and their child processes
  5. Hooks for deterministic checks around tool execution

This session focuses on choosing controls deliberately, especially the difference between Auto mode and bypassing permissions.

The Permission Modes

UI labelConfiguration valueWithout routine approvalBest fit
Manualdefault (manual alias)ReadsSensitive or unfamiliar work
Edit automaticallyacceptEditsReads, file edits, common filesystem commandsReviewed local iteration
PlanplanReads, plus classifier-approved commands when auto mode is availableDesign before implementation
AutoautoActions that pass background safety checksTrusted direction, fewer interruptions
Don’t askdontAskPre-approved and built-in read-only actionsLocked-down CI and scripts
Bypass permissionsbypassPermissionsAlmost everythingIsolated containers and VMs only

Which Mode a Session Starts In

A new session takes its mode from the first of these that applies: the --permission-mode flag (or --dangerously-skip-permissions), then permissions.defaultMode in a settings file, then the built-in default:

  • Interactive terminal and VS Code sessions start in auto on v2.1.283 or later when auto mode is available to the session; otherwise they start in Manual.
  • claude -p and Agent SDK runs start in Manual (default) on v2.1.302 or later. Calls that need approval are denied unless an allow rule, a hook, or a permission handler such as --permission-prompt-tool approves them.
  • Organizations can remove auto mode with disableAutoMode: "disable" in managed settings, and sessions under the HIPAA configuration don’t start in auto.

A repository can’t start you in the riskier modes: auto and bypassPermissions don’t take effect from a project’s .claude/settings.json or .claude/settings.local.json. To start every terminal session in Manual instead, set defaultMode to "default" under permissions in ~/.claude/settings.json. In an interactive session, the status bar shows the active mode.

Manual / default

Manual is the current UI label; default remains the configuration value used by settings, hooks, and SDK integrations. The CLI also accepts manual as an alias in v2.1.200 or later.

Inside the working directory, reads normally proceed without asking. File edits and non-read-only Bash commands normally prompt. This is the safest general-purpose starting point because the user reviews side effects as they arise.

claude --permission-mode default
# v2.1.200+
claude --permission-mode manual

Plan / plan

Plan mode is for investigation and design. Claude can read files and explore with shell commands, but it does not edit source files until you approve a plan. When auto mode is available and useAutoModeDuringPlan is on (the default), the classifier reviews planning-time shell commands instead of prompting you; otherwise, commands outside the built-in read-only set prompt.

claude --permission-mode plan

Plan mode does not mean “approve every read.” It creates a checkpoint before implementation: review the proposed plan, keep refining it, or approve it and choose the mode used for execution.

Auto / auto

Auto mode removes routine permission prompts but keeps background safety checks. A separate classifier evaluates actions that are not already resolved by explicit rules or safe local behavior. Explicit deny and ask rules still apply, and the classifier can block actions that exceed the request, target unfamiliar infrastructure, or appear driven by hostile content.

claude --permission-mode auto

Auto mode reduces prompt fatigue; it is not a guarantee of safety and not a replacement for review on sensitive operations. Availability depends on model, provider, and organization settings. If the classifier keeps blocking routine work against your own infrastructure, describe that infrastructure in autoMode.environment: /auto-mode-setup drafts entries from your project for you to review, and claude auto-mode defaults prints the built-in rules.

Don’t ask / dontAsk

dontAsk never waits for permission input. Calls that would normally prompt are denied. It runs only pre-approved actions, built-in read-only Bash commands, and calls approved by an applicable hook.

claude --permission-mode dontAsk

Use it for CI or scripts where waiting for a human would deadlock the run and the allowed surface is defined in advance.

Bypass permissions / bypassPermissions

Bypass mode skips ordinary permission prompts and safety checks. Use it only inside an isolated container or VM that has no valuable credentials and cannot damage the host or production systems.

claude --permission-mode bypassPermissions
# Equivalent flag:
claude --dangerously-skip-permissions

The dangerous flag is not Auto mode. A few circuit breakers and externally required consent prompts can still fire, but bypass mode provides no general protection against prompt injection or unintended actions. On Linux and macOS, Claude Code refuses this mode when it runs as root or under sudo outside a recognized sandbox, and administrators can block it with permissions.disableBypassPermissionsMode. In an interactive terminal session where bypass is available, plan mode’s edit blocks are not enforced either.

Rules: Deny, Then Ask, Then Allow

Put rules under permissions.allow, permissions.ask, and permissions.deny:

{
  "permissions": {
    "defaultMode": "default",
    "allow": [
      "Bash(npm test *)",
      "Read(/docs/**)",
      "WebFetch(domain:docs.example.com)"
    ],
    "ask": [
      "Bash(git push *)"
    ],
    "deny": [
      "Read(./.env)",
      "Read(~/.ssh/**)",
      "WebFetch(domain:paste.example)"
    ]
  }
}

Rules use Tool or Tool(specifier) syntax and are evaluated deny → ask → allow. Specificity does not override that order. If Bash(aws *) is denied, a narrower allow for Bash(aws s3 ls) cannot punch through it.

In Read and Edit rules, /path is relative to the settings file that defines it (the project root for project settings), //path is an absolute path, and ~/path starts at your home directory. In project settings, Read(/docs/**) above therefore means the project’s docs/ folder.

Use /permissions to inspect and edit effective rules. Keep allow patterns narrow: Bash(npm test *) is easier to reason about than blanket Bash access.

Fence Reads Outside the Working Directories

Reads outside the working directories prompt in Manual mode, while auto mode asks once at the first such read and then lets them run unless you choose to block them. To make Claude’s file tools refuse those reads in every mode, including bypassPermissions, set this in any settings file (v2.1.257 or later):

{
  "permissions": {
    "blockReadsOutsideWorkingDirectories": true
  }
}

A true from any settings file applies, so a repository can turn the block on for itself but can’t lift yours. Add directories Claude legitimately needs with --add-dir or /add-dir. Shell commands that read outside the working directories prompt instead; for OS-level enforcement, use the sandbox.

Permissions and Sandboxing Are Different

Permissions govern whether Claude Code may invoke a tool. Sandboxing, when enabled, enforces operating-system filesystem and network boundaries on shell commands (Bash, PowerShell, and Monitor) and their child processes. Turn it on with /sandbox or "sandbox": { "enabled": true }; it runs on macOS, Linux, and WSL2.

Model proposes Bash command
        ↓
Permission mode + rules + hooks
        ↓ allowed
Optional OS sandbox boundary
        ↓
Operating system executes or blocks the effect

Sandboxing is not automatically synonymous with any permission mode. Configure it separately, and do not assume a permission rule alone stops an arbitrary Python or Node subprocess from reading a file. Use both layers when the threat model includes untrusted code or prompt injection.

Know the sandbox’s defaults. It limits writes and network access, but sandboxed commands can still read most of the machine, including ~/.ssh and ~/.aws/credentials, until you add sandbox.filesystem.denyRead entries or configure sandbox.credentials. It also covers shell commands only: Claude’s file tools follow permission rules, and hooks and local MCP servers run outside it.

Explicit deny rules still apply when sandboxing auto-allows a command. Protected paths also receive special treatment in every mode except bypass, where most protected-path checks are skipped.

Hooks and Organization Policy

A PreToolUse hook can inspect a pending action and block it before execution. Hooks are useful for deterministic requirements such as rejecting production targets or enforcing an approved command wrapper. They complement permission rules; they do not override a matching deny or ask rule.

Organizations can ship managed settings that users and projects cannot override. Because deny rules from any settings scope win, a project allow rule cannot override an organization-level deny.

Mods, the plugin hook modules added in v2.1.287, need separate attention: a mod’s tool.check handler can approve a call after hooks run. With managed settings or a Team or Enterprise login, deny rules, ask rules, and PreToolUse blocks hold by default; without either, a mod can approve calls they would stop. Installing a mod means trusting code that runs with your permissions.

Harden Unattended and Shared-Machine Runs

Two newer flags tighten non-interactive use:

  • --permission-prompts none (v2.1.259 or later) denies anything that would prompt instead of waiting for a permission host; the permission mode still decides everything else.
  • --restricted (v2.1.248 or later) is for evaluation harnesses on shared machines. It removes the tools that run commands or code, and WebFetch, unless you name them in --tools; it loads only managed settings and --settings, confines the file tools to the working directories, and refuses bypassPermissions.
claude -p "Update the dependency pins and run the tests" \
  --permission-mode auto --permission-prompts none
claude --restricted -p "Review this diff for security issues"

Choosing a Mode

Need to understand before editing?       → plan
Want to review each side effect?         → default / Manual
Trust local edits, review commands?      → acceptEdits
Want fewer prompts with safety checks?   → auto
Need non-interactive allowlisted CI?     → dontAsk
Fully isolated disposable environment?   → bypassPermissions

For durable human checkpoints, encode an ask or deny rule. A conversational instruction such as “do not push” helps Auto mode’s classifier, but it can be lost after context compaction; a permission rule is the stronger boundary.

Security Checklist

  • Start with the least permissive mode that still lets the workflow progress, and confirm the mode a session actually started in: interactive sessions default to auto on v2.1.283 or later.
  • Keep secrets and production credentials out of autonomous environments.
  • Use narrow allow patterns and explicit ask rules for publication or deployment.
  • Add deny rules for paths and commands that must never be touched.
  • Enable sandboxing when executing untrusted code, and deny sandboxed reads of credential paths.
  • Treat MCP servers, fetched content, and repository instructions as potential prompt-injection sources.
  • Install plugins and mods only from sources you trust.
  • Verify effects—tests, diffs, deployment state—not merely Claude’s claim that a task completed.

Official sources

Last verified: 2026-10-21.