Permission Model

Claude Code gates tool execution through a tiered permission system with multiple modes, allow/deny rules, and tool-specific checks.

Permission Modes

Defined in src/types/permissions.ts. Seven user-addressable modes:

ModeBehavior
defaultAsk before sensitive tool actions (read/write/bash/network). Safe default.
askAlways ask before any tool execution.
planPrefer planning mode — AI must present a plan before executing tools.
autoAuto-approve low-risk actions using transcript classifier (requires TRANSCRIPT_CLASSIFIER feature). Prompt for risky operations.
acceptEditsAuto-approve file edit operations. Useful for rapid iteration.
bypassPermissionsSkip all permission prompts. Use only in trusted sandboxes.
dontAskNever ask — auto-deny anything that would require permission.

Permission Rules

Granular allow/deny rules control specific tools and their arguments:

/permissions     # Open interactive permission rule manager

Rules can target specific tools with pattern matching:

Rule Sources

Permission rules come from multiple sources (evaluated in order, with later sources overriding earlier ones):

Tool Permission Flow

1. Tool input validation (validateInput)
2. Tool-specific checkPermissions()
3. Deny rule check (permissions.ts → getDenyRuleForTool)
4. Permission mode evaluation (mode-based auto decision)
5. Plugin hooks (PreToolUse → PostToolUse)
6. Classifier-based auto-approval (auto mode)
7. User permission dialog (if needed)

CLI Flags for Permissions

FlagDescription
--permission-mode <mode>Set session permission mode
--dangerously-skip-permissionsBypass all checks (sandbox only)
--allow-dangerously-skip-permissionsEnable bypass as optional mode
--allowedTools, --allowed-tools <tools...>Allowlist specific tools with patterns
--disallowedTools, --disallowed-tools <tools...>Denylist specific tools with patterns

Security Best Practices

Use Caution bypassPermissions mode executes all tool actions without prompting. Restrict to trusted, sandboxed environments.