modified
--- a/permissions.md +++ b/permissions.md @@ -1,4 +1,4 @@ -The Claude Agent SDK provides permission controls to manage how Claude uses tools. Use permission modes and rules to define what’s allowed automatically, and the [`canUseTool` callback](</docs/en/agent-sdk/user-input>) to handle everything else at runtime. +The Claude Agent SDK provides permission controls to manage how Claude uses tools. Use permission modes and rules to define what’s allowed automatically, and the [`canUseTool` callback](</docs/en/agent-sdk/user-input>) to handle calls that still need approval. ## How permissions are evaluated
modified
--- a/permissions.md +++ b/permissions.md @@ -16,7 +16,7 @@ Deny rules -If a deny rule from `disallowed_tools` or from a settings file the SDK loads matches, the call is denied and [`canUseTool`](</docs/en/agent-sdk/user-input>) isn’t called. The call is denied this way even in `bypassPermissions` mode and when a hook returned `allow`.In the TypeScript SDK, if you set the `permission_policy` of a [custom tool](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>) to [`always_deny`](</docs/en/agent-sdk/typescript#mcpservertoolpolicy>), a call to that tool is denied at this step. +If a deny rule from `disallowed_tools` or from a settings file the SDK loads matches, the call is denied and [`canUseTool`](</docs/en/agent-sdk/user-input>) isn’t called. The call is denied this way even in `bypassPermissions` mode and when a hook returned `allow`. 3
modified
Show diff (161 lines)
--- a/permissions.md +++ b/permissions.md @@ -1,10 +1,6 @@ The Claude Agent SDK provides permission controls to manage how Claude uses tools. Use permission modes and rules to define what’s allowed automatically, and the [`canUseTool` callback](</docs/en/agent-sdk/user-input>) to handle everything else at runtime. -## - -​ - -How permissions are evaluated +## How permissions are evaluated If you load a plugin that contains a [mod](</docs/en/plugins/mods/overview>), see [where a mod’s decisions fit among rules and hooks](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). @@ -62,11 +58,7 @@ * **Hooks:** run custom code to allow, deny, or modify tool requests. See [Control execution with hooks](</docs/en/agent-sdk/hooks>). * **canUseTool callback:** prompt users for approval at runtime, when no earlier step resolves the call. See [Handle approvals and user input](</docs/en/agent-sdk/user-input>). -## - -​ - -Allow and deny rules +## Allow and deny rules When you set `allowedTools` and `disallowedTools` (TypeScript) or `allowed_tools` and `disallowed_tools` (Python), Claude Code adds their entries to the allow and deny rule lists in the permission evaluation flow. Any other tool not listed in `allowed_tools` is still available to Claude, and a call to it that needs approval falls through to the permission mode. @@ -102,11 +94,7 @@ You can also configure allow, deny, and ask rules declaratively in `.claude/settings.json`. These rules are read when the `project` setting source is enabled, which it is for default `query()` options. If you set `setting_sources` (TypeScript: `settingSources`) explicitly, include `"project"` for them to apply. See [Permission settings](</docs/en/settings-reference#permission-settings>) for the rule syntax. For when allow rules in a project’s `.claude/settings.json` apply, see [Project allow rules and workspace trust](</docs/en/permissions#project-allow-rules-and-workspace-trust>). -### - -​ - -Path patterns in rules +### Path patterns in rules Scoped rules for `Read` and `Edit` take a path pattern. `Edit(path)` rules govern all built-in tools that write files, including `Write` and `NotebookEdit`, so write a path rule for any of them as `Edit(path)`. If you write a path rule as `Write(path)` or `NotebookEdit(path)`, it [matches no call](</docs/en/permissions#path-rules-that-never-match>) and has no effect. In `allowed_tools` and `disallowed_tools`, start a path pattern with `//` for an absolute path, or with a single `/` for a path inside the session’s working directory: @@ -115,19 +103,11 @@ For other ways to start a path pattern, see [Read and Edit rules](</docs/en/permissions#read-and-edit>). -## - -​ - -Permission modes +## Permission modes Permission modes provide global control over how Claude uses tools. You can set the permission mode when calling `query()` or change it dynamically during streaming sessions. With Claude Code v2.1.302 or later, your app starts in `default` mode unless you set a permission mode or it gets one from [`permissions.defaultMode`](</docs/en/settings-reference#permissions-defaultmode>) in its settings files. In `default` mode, Claude Code denies any tool call needing approval unless you approve it through an allow rule, hook, `canUseTool` callback, or permission prompt tool. If tool calls are denied, see [Tool calls denied in `claude -p` and Agent SDK runs](</docs/en/permission-modes#which-mode-a-non-interactive-run-starts-in>). -### - -​ - -Available modes +### Available modes The SDK supports these permission modes: @@ -142,11 +122,7 @@ **Subagent inheritance:** If your main session is in [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), a subagent whose [`AgentDefinition`](</docs/en/agent-sdk/typescript#agentdefinition>) sets `permissionMode: "acceptEdits"` still runs in plan mode. That subagent’s `Edit` and `Write` calls on your source files still go to your `canUseTool` callback. Plan mode holds for the subagents you define too, so that handing work to one doesn’t get around reviewing the plan first.The subagent inherits `plan`, `acceptEdits`, `auto`, or `bypassPermissions` from the main session, and under a `default`\- or `dontAsk`-mode main session it runs in the mode you set. Even then, Claude Code never applies a `"bypassPermissions"` value, and applies an `"auto"` value only when [auto mode is available](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) to that subagent. The `bypassPermissions` exception requires Claude Code v2.1.267 or later.Subagents may have different system prompts and less constrained behavior than your main agent, so inheriting `bypassPermissions` grants them full, autonomous system access. The [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) still apply. -### - -​ - -Set permission mode +### Set permission mode You can set the permission mode once when starting a query, or change it dynamically while the session is active. @@ -242,17 +218,9 @@ main(); -### - -​ - -Mode details - -#### - -​ - -Accept edits mode (`acceptEdits`) +### Mode details + +#### Accept edits mode (`acceptEdits`) Auto-approves file operations so Claude can edit code without prompting. Other tools (like Bash commands that aren’t filesystem operations) still require normal permissions. **Auto-approved operations:** @@ -268,11 +236,7 @@ **Use when:** you trust Claude’s edits and want faster iteration, such as during prototyping or when working in an isolated directory. -#### - -​ - -Don’t ask mode (`dontAsk`) +#### Don’t ask mode (`dontAsk`) Converts any permission prompt into a denial, without calling `canUseTool`, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some of those calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). Tools pre-approved by `allowed_tools`, `settings.json` allow rules, or a hook run as normal. Calls that need no approval in `default` mode also run as normal, such as file reads inside your working directories and calls to `Agent`. These calls are denied even when an allow rule matches: @@ -284,11 +248,7 @@ If your `PreToolUse` hook returns `allow` for a recognized critical-path removal, a read from a network path, or a call to a tool marked `always_ask`, the call is still denied. The check that recognizes these removals [can miss some commands](</docs/en/permission-modes#critical-paths>). **Use when:** you run a headless agent and want a hard deny for each call that would otherwise prompt. -#### - -​ - -Bypass permissions mode (`bypassPermissions`) +#### Bypass permissions mode (`bypassPermissions`) Auto-approves tool uses without prompting, except the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>). Hooks still execute and can block operations if needed. On Linux and macOS, Claude Code refuses to start in this mode as root or under `sudo` outside a [recognized sandbox](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>), and the query fails before the first turn. @@ -298,11 +258,7 @@ * Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, recognized [critical-path removals](</docs/en/permission-modes#critical-paths>), and Bash commands flagged [`Dangerous rm operation not ruled out`](</docs/en/permission-modes#dangerous-rm-operation-not-ruled-out>) still fall through to your `canUseTool` callback. The check that recognizes critical-path removals [can miss some commands](</docs/en/permission-modes#critical-paths>), and you can [turn off the critical-path removal prompt](</docs/en/permission-modes#turn-off-the-critical-path-removal-prompt-in-bypasspermissions-mode>). Outside a [cloud session](</docs/en/claude-code-on-the-web>), calls to custom tools your application [marks `always_ask`](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>) fall through to the callback too. * The [cross-session messaging safeguards](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) still apply. -#### - -​ - -Plan mode (`plan`) +#### Plan mode (`plan`) Claude explores the codebase and produces a plan. During planning, edits made with Claude’s file tools outside [protected paths](</docs/en/permission-modes#protected-paths>) reach your `canUseTool` callback, even when an allow rule matches or a `PreToolUse` hook returns `allow`. [`AskUserQuestion`](</docs/en/agent-sdk/user-input#handle-clarifying-questions>) calls reach your callback too, even when an allow rule names the tool. When [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) is available, Claude Code sends these calls during planning to [auto mode’s classifier](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) for review instead of to your callback, when no allow rule approves them: @@ -326,11 +282,7 @@ **Use when:** you want Claude to produce a plan first, such as during code review or before a large change. -#### - -​ - -Auto mode (`auto`) +#### Auto mode (`auto`) A classifier model reviews actions such as shell commands and network requests before they run, and allows or blocks each one it reviews. For the models and providers auto mode requires and the order it evaluates actions in, see [Eliminate permission prompts with auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>). If you switch a session that’s in auto mode to a model that auto mode doesn’t support, using [`set_model()`](</docs/en/agent-sdk/python#claudesdkclient>), [`setModel()`](</docs/en/agent-sdk/typescript#query-object>), or [`applyFlagSettings()`](</docs/en/agent-sdk/typescript#applyflagsettings>), the session changes to `default` mode: @@ -339,11 +291,7 @@ The change to `default` mode after a `set_model()`, `setModel()`, or `applyFlagSettings()` call requires Claude Code v2.1.299 or later. -## - -​ - -Related resources +## Related resources For the other steps in the permission evaluation flow:
modified
--- a/permissions.md +++ b/permissions.md @@ -14,7 +14,7 @@ Hooks -Run [hooks](</docs/en/agent-sdk/hooks>). A hook can deny the call outright or pass it on. A hook that returns `allow` doesn’t skip the deny and ask rules below, which are evaluated regardless of the hook result.A `PreToolUse` hook that returns `allow` also can’t approve an `rm` or `rmdir` command whose target Claude Code recognizes as a [critical path](</docs/en/permission-modes#critical-paths>), such as `rm -rf ~`. For what that `allow` does in plan mode, see [Hook approvals in plan mode](</docs/en/permissions#hook-approvals-in-plan-mode>). +Run [hooks](</docs/en/agent-sdk/hooks>). A hook can deny the call outright or pass it on. A hook that returns `allow` doesn’t skip the deny-rule and ask-rule steps, which are evaluated regardless of the hook result.A `PreToolUse` hook that returns `allow` also can’t approve an `rm` or `rmdir` command whose target Claude Code recognizes as a [critical path](</docs/en/permission-modes#critical-paths>), such as `rm -rf ~`. For what that `allow` does in plan mode, see [Hook approvals in plan mode](</docs/en/permissions#hook-approvals-in-plan-mode>). 2 @@ -50,7 +50,7 @@ canUseTool callback -If not resolved by any of the above, call your [`canUseTool` callback](</docs/en/agent-sdk/user-input>) for a decision. In `dontAsk` mode, this step is skipped and the tool is denied, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some such calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>).In the TypeScript SDK, if you set [`permissionPrompts: 'none'`](</docs/en/agent-sdk/typescript#options>), your callback isn’t called at this step. A [`PermissionRequest` hook](</docs/en/hooks#permissionrequest>) still gets a chance to decide, and if it doesn’t, Claude Code denies the call. The option requires Claude Code v2.1.259 or later. +If no earlier step resolves the request, call your [`canUseTool` callback](</docs/en/agent-sdk/user-input>) for a decision. In `dontAsk` mode, this step is skipped and the tool is denied, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some such calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>).In the TypeScript SDK, if you set [`permissionPrompts: 'none'`](</docs/en/agent-sdk/typescript#options>), your callback isn’t called at this step. A [`PermissionRequest` hook](</docs/en/hooks#permissionrequest>) still gets a chance to decide, and if it doesn’t, Claude Code denies the call. The option requires Claude Code v2.1.259 or later. If you pass a `canUseTool` callback in a configuration where the TypeScript SDK expects the evaluation order to auto-approve calls before the callback is consulted, the SDK emits a Node.js process warning once when the query is constructed. The warning’s code is `CLAUDE_SDK_CAN_USE_TOOL_SHADOWED`. Two configurations trigger it: @@ -68,14 +68,14 @@ Allow and deny rules -`allowed_tools` and `disallowed_tools` (TypeScript: `allowedTools` / `disallowedTools`) add entries to the allow and deny rule lists in the evaluation flow above. If you name one of the [task-tracking tools](</docs/en/agent-sdk/todo-tracking#model-availability>) in `allowed_tools`, Claude Code also opts the session in. Any other tool not listed in `allowed_tools` is still available to Claude, and a call to it that needs approval falls through to the permission mode. Deny rules behave differently depending on whether they name a tool or scope a pattern within one. +When you set `allowedTools` and `disallowedTools` (TypeScript) or `allowed_tools` and `disallowed_tools` (Python), Claude Code adds their entries to the allow and deny rule lists in the permission evaluation flow. Any other tool not listed in `allowed_tools` is still available to Claude, and a call to it that needs approval falls through to the permission mode. Option| Effect ---|--- `allowed_tools=["Read", "Grep"]`| `Read` and `Grep` are auto-approved, apart from [reads from network paths](</docs/en/permissions#network-paths>). Other tools not listed here still exist, and calls to them that need approval fall through to the permission mode and `canUseTool`. -`disallowed_tools=["Bash"]`| The `Bash` tool definition is removed from the request. Claude does not see the tool and cannot attempt it. +`disallowed_tools=["Bash"]`| The `Bash` tool definition is removed from the request. `disallowed_tools=["Bash(rm *)"]`| `Bash` stays available. Calls matching `rm *` [as written](</docs/en/permissions#bash-rule-limits>) are denied in every permission mode, including `bypassPermissions`. Other `Bash` calls, including `/bin/rm`, fall through to the permission mode. -`disallowed_tools=["*"]`| Every tool definition is removed from the request. Tool-name globs are supported in deny rules: `"*"` matches every tool and `"mcp__*"` matches every MCP tool across all servers. +`disallowed_tools=["*"]`| Tool-name globs are supported in deny rules: `"*"` matches every tool and `"mcp__*"` matches every MCP tool across all servers. Allow rules accept tool-name globs only after a literal `mcp__<server>__` prefix. The server segment must be glob-free so the rule names a specific server you configured: `mcp__puppeteer__*` matches every tool from the `puppeteer` server, and `mcp__github__get_*` matches its `get_` tools. An unanchored entry like `allowed_tools=["*"]` or `allowed_tools=["mcp__*"]` is ignored and doesn’t auto-approve anything.
modified
Show diff (178 lines)
--- a/permissions.md +++ b/permissions.md @@ -8,25 +8,25 @@ If you load a plugin that contains a [mod](</docs/en/plugins/mods/overview>), see [where a mod’s decisions fit among rules and hooks](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). -When Claude requests a tool, the SDK checks permissions in this order: +When Claude requests a tool, Claude Code checks the call at these steps. Each step can decide the call, send it to your `canUseTool` callback, or pass it on: 1 Hooks -Run [hooks](</docs/en/agent-sdk/hooks>) first. A hook can deny the call outright or pass it on. A hook that returns `allow` doesn’t skip the deny and ask rules below, which are evaluated regardless of the hook result.A `PreToolUse` hook that returns `allow` also can’t approve an `rm` or `rmdir` command whose target Claude Code recognizes as a [critical path](</docs/en/permission-modes#critical-paths>), such as `rm -rf ~`. For what that `allow` does in plan mode, see [Hook approvals in plan mode](</docs/en/permissions#hook-approvals-in-plan-mode>). +Run [hooks](</docs/en/agent-sdk/hooks>). A hook can deny the call outright or pass it on. A hook that returns `allow` doesn’t skip the deny and ask rules below, which are evaluated regardless of the hook result.A `PreToolUse` hook that returns `allow` also can’t approve an `rm` or `rmdir` command whose target Claude Code recognizes as a [critical path](</docs/en/permission-modes#critical-paths>), such as `rm -rf ~`. For what that `allow` does in plan mode, see [Hook approvals in plan mode](</docs/en/permissions#hook-approvals-in-plan-mode>). 2 Deny rules -If a deny rule from `disallowed_tools` or [settings.json](</docs/en/settings-reference#permission-settings>) matches, the call is denied and [`canUseTool`](</docs/en/agent-sdk/user-input>) isn’t called, even in `bypassPermissions` mode and even when a hook returned `allow`.In the TypeScript SDK, if you set the `permission_policy` of a [custom tool](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>) to [`always_deny`](</docs/en/agent-sdk/typescript#mcpservertoolpolicy>), a call to that tool is denied at this step. +If a deny rule from `disallowed_tools` or from a settings file the SDK loads matches, the call is denied and [`canUseTool`](</docs/en/agent-sdk/user-input>) isn’t called. The call is denied this way even in `bypassPermissions` mode and when a hook returned `allow`.In the TypeScript SDK, if you set the `permission_policy` of a [custom tool](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>) to [`always_deny`](</docs/en/agent-sdk/typescript#mcpservertoolpolicy>), a call to that tool is denied at this step. 3 Ask rules -Check `ask` rules from [settings.json](</docs/en/settings-reference#permission-settings>). If an ask rule matches, the call falls through to your [`canUseTool` callback](</docs/en/agent-sdk/user-input>) for confirmation, even in `bypassPermissions` mode.Tools that require user interaction behave the same way: `AskUserQuestion` and MCP tools whose server sets [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>) always fall through to the callback, even when an allow rule matches. In `dontAsk` mode both cases are denied instead, because that mode never prompts. The MCP annotation requires Claude Code v2.1.199 or later.[claude.ai connector](</docs/en/mcp#organization-controls-on-connector-tools>) tools your organization has set to `ask` also leave the flow at this step. Every call falls through to the callback, even in `bypassPermissions` mode and even when an allow rule matches. The callback receives the reason `Your organization requires approval for this tool`. In `dontAsk` mode the call is denied instead, because that mode never prompts.In the TypeScript SDK, if you set a custom tool’s `permission_policy` to [`always_ask`](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>), no allow rule approves its calls, not even an `allowedTools` entry. In `dontAsk` mode Claude Code denies those calls, and in `auto`, `plan`, or `bypassPermissions` mode it [can approve them](</docs/en/agent-sdk/typescript#permission-modes-that-can-approve-an-always_ask-call>) before your callback runs. +Check `ask` rules from [settings.json](</docs/en/settings-reference#permission-settings>). If an ask rule matches, the call falls through to your [`canUseTool` callback](</docs/en/agent-sdk/user-input>) for confirmation, even in `bypassPermissions` mode.Tools that require user interaction behave the same way. `AskUserQuestion` and MCP tools whose server sets [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>) fall through to the callback, even when an allow rule matches. In `dontAsk` mode both cases are denied instead, because that mode turns each prompt into a denial. The MCP annotation requires Claude Code v2.1.199 or later.[claude.ai connector](</docs/en/mcp#organization-controls-on-connector-tools>) tools your organization has set to `ask` also leave the flow at this step. Every call falls through to the callback, even in `bypassPermissions` mode and even when an allow rule matches. The callback receives the reason `Your organization requires approval for this tool`. In `dontAsk` mode the call is denied instead, because that mode never prompts.In the TypeScript SDK, if you set a custom tool’s `permission_policy` to [`always_ask`](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>), no allow rule approves its calls, not even an `allowedTools` entry. In `dontAsk` mode Claude Code denies those calls, and in `auto`, `plan`, or `bypassPermissions` mode it [can approve them](</docs/en/agent-sdk/typescript#permission-modes-that-can-approve-an-always_ask-call>) before your callback runs. 4 @@ -34,11 +34,11 @@ Apply the active permission mode: - * In `bypassPermissions` mode, Claude Code approves everything that reaches this step except recognized [critical-path removals](</docs/en/permission-modes#critical-paths>) and Bash commands flagged [`Dangerous rm operation not ruled out`](</docs/en/permission-modes#dangerous-rm-operation-not-ruled-out>), which fall through instead. - * To run those removals with no prompt, see [Turn off the critical-path removal prompt](</docs/en/permission-modes#turn-off-the-critical-path-removal-prompt-in-bypasspermissions-mode>). + * In `bypassPermissions` mode, Claude Code approves each call that reaches this step unless it’s one of the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>). For which of those actions go to your `canUseTool` callback, see Bypass permissions mode. * In `acceptEdits` mode, Claude Code approves the file operations listed under Accept edits mode. - * In `plan` mode, Claude Code sends file-edit tools to your `canUseTool` callback regardless of allow rules. - * In other modes, the request falls through. + * In `plan` mode, some calls reach your callback, and when auto mode is available, others go to its classifier instead. For more information, see Plan mode. + * In `default` and `dontAsk` mode, the call goes on to the allow rules. + * For `auto` mode, see Auto mode. 5 @@ -77,17 +77,17 @@ `disallowed_tools=["Bash(rm *)"]`| `Bash` stays available. Calls matching `rm *` [as written](</docs/en/permissions#bash-rule-limits>) are denied in every permission mode, including `bypassPermissions`. Other `Bash` calls, including `/bin/rm`, fall through to the permission mode. `disallowed_tools=["*"]`| Every tool definition is removed from the request. Tool-name globs are supported in deny rules: `"*"` matches every tool and `"mcp__*"` matches every MCP tool across all servers. -Allow rules accept tool-name globs only after a literal `mcp__<server>__` prefix. The server segment must be glob-free so the rule names a specific server you configured: `mcp__puppeteer__*` matches every tool from the `puppeteer` server, and `mcp__github__get_*` matches its `get_` tools. An unanchored entry like `allowed_tools=["*"]` or `allowed_tools=["mcp__*"]` is ignored and doesn’t auto-approve anything. Scoped rules for `Read` and `Edit` take a path pattern. `Edit(path)` rules govern all built-in tools that write files, including `Write` and `NotebookEdit`; a `Write(path)` rule is never matched by the file permission checks. Use `//path` for an absolute filesystem path: a deny rule of `Edit(//secrets/**)` blocks writes anywhere under `/secrets` on disk. With a single leading slash, `Edit(/secrets/**)` anchors at the rule’s source instead. For rules passed through `allowed_tools` or `disallowed_tools`, that means the session’s working directory, so the rule doesn’t block `/secrets` on disk. See [Read and Edit rules](</docs/en/permissions#read-and-edit>) for the four anchor forms and how rules from settings files resolve. +Allow rules accept tool-name globs only after a literal `mcp__<server>__` prefix. The server segment must be glob-free so the rule names a specific server you configured: `mcp__puppeteer__*` matches every tool from the `puppeteer` server, and `mcp__github__get_*` matches its `get_` tools. An unanchored entry like `allowed_tools=["*"]` or `allowed_tools=["mcp__*"]` is ignored and doesn’t auto-approve anything. **Auto-approved tools never reach`canUseTool`.** A tool call approved at any earlier step, by `acceptEdits` or `bypassPermissions`, or by an allow rule, skips your `canUseTool` callback, so permission checks you put there are silently bypassed for that tool.If calls to a tool in `allowed_tools` still reach your `canUseTool` callback, or are denied in `dontAsk` mode, check whether they’re [reads from network paths](</docs/en/permissions#network-paths>) or among the following calls. No allow rule approves these calls. In `dontAsk` mode, which never prompts, Claude Code denies them without calling `canUseTool`, and in the other permission modes you handle them as each item says: * `AskUserQuestion`, MCP tools marked [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>), and connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>): answer them in the callback. [Handle clarifying questions](</docs/en/agent-sdk/user-input#handle-clarifying-questions>) shows how to answer `AskUserQuestion`, and a connector call arrives with the reason `Your organization requires approval for this tool` * Custom tools your application marks [`always_ask`](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>): decide the call in the callback. To stop these calls arriving, [change the policy mid-session](</docs/en/agent-sdk/typescript#mcpsdkserverconfigwithinstance>). In `auto`, `plan`, and `bypassPermissions` mode the call can instead be approved before the callback, in the cases listed under [Permission modes that can approve an `always_ask` call](</docs/en/agent-sdk/typescript#permission-modes-that-can-approve-an-always_ask-call>) - * Recognized `rm` and `rmdir` [critical-path removals](</docs/en/permission-modes#critical-paths>): in `default`, `acceptEdits`, and `bypassPermissions` mode, allow or deny the removal in the callback, where [`decisionReason`](</docs/en/agent-sdk/typescript#canusetool>) starts with `Dangerous rm`. For `auto` and `plan` mode, see [Critical-path removals in each permission mode](</docs/en/permission-modes#critical-path-removals-in-each-permission-mode>). The check that recognizes these removals [can miss some commands](</docs/en/permission-modes#critical-paths>) + * Recognized `rm` and `rmdir` [critical-path removals](</docs/en/permission-modes#critical-paths>): in `default`, `acceptEdits`, and `bypassPermissions` mode, allow or deny the removal in the callback, where [`decisionReason`](</docs/en/agent-sdk/typescript#canusetool>) starts with `Dangerous rm`. For `auto` and `plan` mode, see [Critical-path removals in each permission mode](</docs/en/permission-modes#critical-path-removals-in-each-permission-mode>) * **Bare name** : an entry like `Read` or `mcp__github__get_issue` auto-approves every call to that tool apart from the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) and [reads from network paths](</docs/en/permissions#network-paths>). - * **Scoped rule** : an entry like `Bash(npm test *)` auto-approves only matching calls, and other `Bash` calls that need approval still fall through to the callback. - -For checks that must run on every tool call, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>): hooks run before every other step, and a hook deny applies even in `bypassPermissions` mode. + * **Scoped rule** : an entry like `Bash(npm test *)` auto-approves calls that match it, and other `Bash` calls that need approval fall through to the permission mode. + +To check calls that an allow rule, `acceptEdits`, or `bypassPermissions` approves, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>), which runs for those calls too. A hook deny applies even in `bypassPermissions` mode. For a locked-down agent, pair `allowedTools` with `permissionMode: "dontAsk"`: @@ -98,9 +98,22 @@ The listed `Read`, `Glob`, and `Grep` calls are approved, apart from the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) and [reads from network paths](</docs/en/permissions#network-paths>). Every other call that would prompt is denied instead, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some of those calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). Calls that need no approval in `default` mode run whether or not you list them. These include [read-only Bash commands](</docs/en/permissions#read-only-commands>), tools like `Agent` that don’t ask before running, and file reads inside your working directories. To hide a built-in tool from Claude entirely rather than deny its calls, add its bare name to `disallowedTools`. -**`allowed_tools` does not constrain `bypassPermissions`.** `allowed_tools` pre-approves the tools you list. Other unlisted tools are not matched by any allow rule and fall through to the permission mode, where `bypassPermissions` approves them. Setting `allowed_tools=["Read"]` alongside `permission_mode="bypassPermissions"` still approves every tool, including `Bash`, `Write`, and `Edit`. If you need `bypassPermissions` but want specific tools blocked, use `disallowed_tools`. - -You can also configure allow, deny, and ask rules declaratively in `.claude/settings.json`. These rules are read when the `project` setting source is enabled, which it is for default `query()` options. If you set `setting_sources` (TypeScript: `settingSources`) explicitly, include `"project"` for them to apply. See [Permission settings](</docs/en/settings-reference#permission-settings>) for the rule syntax. +**`allowed_tools` does not constrain `bypassPermissions`.** `allowed_tools` pre-approves the tools you list. In `bypassPermissions` mode, Claude Code approves a call to an unlisted tool unless it’s one of the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>).If you set `allowed_tools=["Read"]` with `permission_mode="bypassPermissions"`, Claude Code still approves calls to tools such as `Bash`, `Write`, and `Edit`. If you need `bypassPermissions` but want specific tools blocked, use `disallowed_tools`. For the calls that still reach your `canUseTool` callback in this mode, see Bypass permissions mode. + +You can also configure allow, deny, and ask rules declaratively in `.claude/settings.json`. These rules are read when the `project` setting source is enabled, which it is for default `query()` options. If you set `setting_sources` (TypeScript: `settingSources`) explicitly, include `"project"` for them to apply. See [Permission settings](</docs/en/settings-reference#permission-settings>) for the rule syntax. For when allow rules in a project’s `.claude/settings.json` apply, see [Project allow rules and workspace trust](</docs/en/permissions#project-allow-rules-and-workspace-trust>). + +### + +​ + +Path patterns in rules + +Scoped rules for `Read` and `Edit` take a path pattern. `Edit(path)` rules govern all built-in tools that write files, including `Write` and `NotebookEdit`, so write a path rule for any of them as `Edit(path)`. If you write a path rule as `Write(path)` or `NotebookEdit(path)`, it [matches no call](</docs/en/permissions#path-rules-that-never-match>) and has no effect. In `allowed_tools` and `disallowed_tools`, start a path pattern with `//` for an absolute path, or with a single `/` for a path inside the session’s working directory: + + * **`//path`** : with a deny rule of `Edit(//secrets/**)`, Claude Code blocks writes under `/secrets` on disk from Claude’s file tools and from [Bash commands such as `tee` and `> file` redirection](</docs/en/permissions#what-read-and-edit-rules-cover>). A script that Claude runs and that opens files itself can still write under `/secrets`. For enforcement by the operating system, see [Configure the sandboxed Bash tool](</docs/en/sandboxing>). + * **`/path`** : `Edit(/secrets/**)` matches the `secrets` directory inside the working directory. + +For other ways to start a path pattern, see [Read and Edit rules](</docs/en/permissions#read-and-edit>). ## @@ -122,9 +135,9 @@ ---|---|--- `default`| Standard permission behavior| No mode-based auto-approvals; calls that need approval and match no allow rule trigger your `canUseTool` callback `dontAsk`| Deny instead of prompting| Any call that would otherwise prompt is denied without calling `canUseTool`, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some of those calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). Calls approved by `allowed_tools` or `settings.json` allow rules run, and so do calls that need no approval in `default` mode. Some calls, such as [reads from network paths](</docs/en/permissions#network-paths>), are denied even when `allowed_tools` or an allow rule matches them. For the list, see Don’t ask mode -`acceptEdits`| Auto-accept file edits| File edits and filesystem operations (`mkdir`, `rm`, `mv`, etc.) are automatically approved +`acceptEdits`| Auto-accept file edits| File edits and filesystem operations (`mkdir`, `rm`, `mv`, etc.) inside your [working directories](</docs/en/permissions#working-directories>) are automatically approved `bypassPermissions`| Bypass permission checks| Tools run without permission prompts, except for the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) and, outside a [cloud session](</docs/en/claude-code-on-the-web>), custom tools your application [marks `always_ask`](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>). Use with caution -`plan`| Planning mode| Claude explores and plans without editing your source files; file edits are never auto-approved and prompt through your `canUseTool` callback +`plan`| Planning mode| Claude explores and plans. Edits made with Claude’s file tools go to your `canUseTool` callback even when an allow rule matches them `auto`| Model-classified approvals| A model classifier reviews actions such as shell commands and network requests, allowing or blocking each one it reviews. See [Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) for availability and the decision order **Subagent inheritance:** If your main session is in [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), a subagent whose [`AgentDefinition`](</docs/en/agent-sdk/typescript#agentdefinition>) sets `permissionMode: "acceptEdits"` still runs in plan mode. That subagent’s `Edit` and `Write` calls on your source files still go to your `canUseTool` callback. Plan mode holds for the subagents you define too, so that handing work to one doesn’t get around reviewing the plan first.The subagent inherits `plan`, `acceptEdits`, `auto`, or `bypassPermissions` from the main session, and under a `default`\- or `dontAsk`-mode main session it runs in the mode you set. Even then, Claude Code never applies a `"bypassPermissions"` value, and applies an `"auto"` value only when [auto mode is available](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) to that subagent. The `bypassPermissions` exception requires Claude Code v2.1.267 or later.Subagents may have different system prompts and less constrained behavior than your main agent, so inheriting `bypassPermissions` grants them full, autonomous system access. The [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) still apply. @@ -243,13 +256,13 @@ Auto-approves file operations so Claude can edit code without prompting. Other tools (like Bash commands that aren’t filesystem operations) still require normal permissions. **Auto-approved operations:** - * File edits (Edit, Write tools) + * File edits with the Edit, Write, and NotebookEdit tools * Filesystem commands: `mkdir`, `touch`, `rm`, `rmdir`, `mv`, `cp`, `sed` -Both apply only to paths inside the working directory or `additionalDirectories`. In `acceptEdits` mode, Claude Code doesn’t auto-approve the request when Claude: +Both apply to paths inside the working directory or a directory you add. In Python, add one with `add_dirs`, and in TypeScript with `additionalDirectories`. In `acceptEdits` mode, Claude Code doesn’t auto-approve the request when Claude: * Works on a path outside that scope - * Writes to a protected path + * Writes to a [protected path](</docs/en/permission-modes#protected-paths>) * Removes a path that Claude Code recognizes as a [critical path](</docs/en/permission-modes#critical-paths>) with `rm` or `rmdir` * Runs [`touch`](</docs/en/permission-modes#auto-approve-file-edits-with-acceptedits-mode>) with, for example, an option, a glob, or a `timeout 5` or `LANG=C` prefix @@ -269,7 +282,7 @@ * [Reads from network paths](</docs/en/permissions#network-paths>) * Recognized [critical-path removals](</docs/en/permission-modes#critical-paths>) -If your `PreToolUse` hook returns `allow` for a recognized critical-path removal, a read from a network path, or a call to a tool marked `always_ask`, the call is still denied. The check that recognizes these removals [can miss some commands](</docs/en/permission-modes#critical-paths>). **Use when:** you want a fixed, explicit tool surface for a headless agent and prefer a hard deny over silent reliance on `canUseTool` being absent. +If your `PreToolUse` hook returns `allow` for a recognized critical-path removal, a read from a network path, or a call to a tool marked `always_ask`, the call is still denied. The check that recognizes these removals [can miss some commands](</docs/en/permission-modes#critical-paths>). **Use when:** you run a headless agent and want a hard deny for each call that would otherwise prompt. #### @@ -279,10 +292,10 @@ Auto-approves tool uses without prompting, except the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>). Hooks still execute and can block operations if needed. On Linux and macOS, Claude Code refuses to start in this mode as root or under `sudo` outside a [recognized sandbox](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>), and the query fails before the first turn. -Use with extreme caution. Claude has full system access in this mode. Only use in controlled environments where you trust all possible operations.`allowed_tools` does not constrain this mode. Every tool is approved, not just the ones you listed. These controls still apply: +Use with extreme caution. Claude has full system access in this mode. Only use in controlled environments where you trust all possible operations.`allowed_tools` doesn’t constrain this mode, and calls to tools you didn’t list are approved too. These controls still apply: * Deny rules, explicit `ask` rules, and hooks are evaluated before the mode check and can still block a tool. - * Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, and recognized [critical-path removals](</docs/en/permission-modes#critical-paths>) still fall through to your `canUseTool` callback. The check that recognizes these removals [can miss some commands](</docs/en/permission-modes#critical-paths>), and you can [turn off the critical-path removal prompt](</docs/en/permission-modes#turn-off-the-critical-path-removal-prompt-in-bypasspermissions-mode>). Outside a [cloud session](</docs/en/claude-code-on-the-web>), calls to custom tools your application [marks `always_ask`](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>) fall through to the callback too. + * Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, recognized [critical-path removals](</docs/en/permission-modes#critical-paths>), and Bash commands flagged [`Dangerous rm operation not ruled out`](</docs/en/permission-modes#dangerous-rm-operation-not-ruled-out>) still fall through to your `canUseTool` callback. The check that recognizes critical-path removals [can miss some commands](</docs/en/permission-modes#critical-paths>), and you can [turn off the critical-path removal prompt](</docs/en/permission-modes#turn-off-the-critical-path-removal-prompt-in-bypasspermissions-mode>). Outside a [cloud session](</docs/en/claude-code-on-the-web>), calls to custom tools your application [marks `always_ask`](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>) fall through to the callback too. * The [cross-session messaging safeguards](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) still apply. #### @@ -291,11 +304,27 @@ Plan mode (`plan`) -Claude explores the codebase and produces a plan without editing your source files. File edits are never auto-approved in plan mode, even when an allow rule matches or a `PreToolUse` hook returns `allow`. They prompt through your `canUseTool` callback instead. While auto mode is available to the session, commands Claude runs during planning don’t reach your callback by default, because the classifier model that [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) uses [reviews them instead](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>). With that review on, the classifier can also approve read-only calls that would otherwise reach your callback, such as a `WebFetch` call with no allow rule. +Claude explores the codebase and produces a plan. During planning, edits made with Claude’s file tools outside [protected paths](</docs/en/permission-modes#protected-paths>) reach your `canUseTool` callback, even when an allow rule matches or a `PreToolUse` hook returns `allow`. [`AskUserQuestion`](</docs/en/agent-sdk/user-input#handle-clarifying-questions>) calls reach your callback too, even when an allow rule names the tool. When [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) is available, Claude Code sends these calls during planning to [auto mode’s classifier](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) for review instead of to your callback, when no allow rule approves them: + + * Shell commands + * Web fetches + * Web searches + * Calls to MCP tools that their server marks read-only + +This review is on by default. To turn it off, set [`useAutoModeDuringPlan`](</docs/en/settings-reference#useautomodeduringplan>) to `false` in the `settings` option you pass to `query()`, or in your user settings. While the review is off, web searches and calls to MCP tools marked read-only reach your callback. For shell commands and web fetches, the table shows whether each call reaches your callback: + +Call during planning| Review on| Review off, or auto mode not available +---|---|--- +A [read-only](</docs/en/permissions#read-only-commands>) shell command, such as `ls`| Runs without reaching your callback| Runs without reaching your callback +Any other shell command that no allow rule approves, except a [critical-path removal](</docs/en/permission-modes#critical-paths>)| Goes to the classifier, which approves or refuses it without your callback| Reaches your callback +A `WebFetch` call to a [preapproved documentation domain](</docs/en/tools-reference#webfetch-tool-behavior>)| Runs without reaching your callback| Runs without reaching your callback +Any other `WebFetch` call that no allow rule approves| Goes to the classifier, which approves or refuses it without your callback| Reaches your callback + +For what happens after the classifier refuses several calls in a row, see [Repeated-block thresholds](</docs/en/permission-modes#repeated-block-thresholds>). In the TypeScript SDK, if you set `allowDangerouslySkipPermissions: true` alongside `permissionMode: 'plan'`, file edits still reach your `canUseTool` callback. To switch a session that starts in plan mode to `bypassPermissions` later with `setPermissionMode()`, you need `allowDangerouslySkipPermissions` set from the start. -Claude may use `AskUserQuestion` to clarify requirements before finalizing the plan. See [Handle approvals and user input](</docs/en/agent-sdk/user-input#handle-clarifying-questions>) for handling these prompts. **Use when:** you want Claude to propose changes without executing them, such as during code review or when you need to approve changes before they’re made. +**Use when:** you want Claude to produce a plan first, such as during code review or before a large change. ####
modified
--- a/permissions.md +++ b/permissions.md @@ -35,6 +35,7 @@ Apply the active permission mode: * In `bypassPermissions` mode, Claude Code approves everything that reaches this step except recognized [critical-path removals](</docs/en/permission-modes#critical-paths>) and Bash commands flagged [`Dangerous rm operation not ruled out`](</docs/en/permission-modes#dangerous-rm-operation-not-ruled-out>), which fall through instead. + * To run those removals with no prompt, see [Turn off the critical-path removal prompt](</docs/en/permission-modes#turn-off-the-critical-path-removal-prompt-in-bypasspermissions-mode>). * In `acceptEdits` mode, Claude Code approves the file operations listed under Accept edits mode. * In `plan` mode, Claude Code sends file-edit tools to your `canUseTool` callback regardless of allow rules. * In other modes, the request falls through. @@ -281,7 +282,7 @@ Use with extreme caution. Claude has full system access in this mode. Only use in controlled environments where you trust all possible operations.`allowed_tools` does not constrain this mode. Every tool is approved, not just the ones you listed. These controls still apply: * Deny rules, explicit `ask` rules, and hooks are evaluated before the mode check and can still block a tool. - * Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, and recognized [critical-path removals](</docs/en/permission-modes#critical-paths>) still fall through to your `canUseTool` callback. The check that recognizes these removals [can miss some commands](</docs/en/permission-modes#critical-paths>). Outside a [cloud session](</docs/en/claude-code-on-the-web>), calls to custom tools your application [marks `always_ask`](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>) fall through to the callback too. + * Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, and recognized [critical-path removals](</docs/en/permission-modes#critical-paths>) still fall through to your `canUseTool` callback. The check that recognizes these removals [can miss some commands](</docs/en/permission-modes#critical-paths>), and you can [turn off the critical-path removal prompt](</docs/en/permission-modes#turn-off-the-critical-path-removal-prompt-in-bypasspermissions-mode>). Outside a [cloud session](</docs/en/claude-code-on-the-web>), calls to custom tools your application [marks `always_ask`](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>) fall through to the callback too. * The [cross-session messaging safeguards](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) still apply. ####
modified
Show diff (150 lines)
--- a/permissions.md +++ b/permissions.md @@ -6,6 +6,8 @@ How permissions are evaluated +If you load a plugin that contains a [mod](</docs/en/plugins/mods/overview>), see [where a mod’s decisions fit among rules and hooks](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). + When Claude requests a tool, the SDK checks permissions in this order: 1 @@ -18,13 +20,13 @@ Deny rules -Check `deny` rules (from `disallowed_tools` and [settings.json](</docs/en/settings-reference#permission-settings>)). If a deny rule matches, the tool is blocked, even in `bypassPermissions` mode. Bare-name deny rules like `Bash` remove the tool from Claude’s context before this evaluation begins, so only scoped rules like `Bash(rm *)` are checked at this step. +If a deny rule from `disallowed_tools` or [settings.json](</docs/en/settings-reference#permission-settings>) matches, the call is denied and [`canUseTool`](</docs/en/agent-sdk/user-input>) isn’t called, even in `bypassPermissions` mode and even when a hook returned `allow`.In the TypeScript SDK, if you set the `permission_policy` of a [custom tool](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>) to [`always_deny`](</docs/en/agent-sdk/typescript#mcpservertoolpolicy>), a call to that tool is denied at this step. 3 Ask rules -Check `ask` rules from [settings.json](</docs/en/settings-reference#permission-settings>). If an ask rule matches, the call falls through to your [`canUseTool` callback](</docs/en/agent-sdk/user-input>) for confirmation, even in `bypassPermissions` mode.Tools that require user interaction behave the same way: `AskUserQuestion` and MCP tools whose server sets [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>) always fall through to the callback, even when an allow rule matches. In `dontAsk` mode both cases are denied instead, because that mode never prompts. The MCP annotation requires Claude Code v2.1.199 or later.[claude.ai connector](</docs/en/mcp#organization-controls-on-connector-tools>) tools your organization has set to `ask` also leave the flow at this step. Every call falls through to the callback, even in `bypassPermissions` mode and even when an allow rule matches. The callback receives the reason `Your organization requires approval for this tool`. In `dontAsk` mode the call is denied instead, because that mode never prompts. +Check `ask` rules from [settings.json](</docs/en/settings-reference#permission-settings>). If an ask rule matches, the call falls through to your [`canUseTool` callback](</docs/en/agent-sdk/user-input>) for confirmation, even in `bypassPermissions` mode.Tools that require user interaction behave the same way: `AskUserQuestion` and MCP tools whose server sets [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>) always fall through to the callback, even when an allow rule matches. In `dontAsk` mode both cases are denied instead, because that mode never prompts. The MCP annotation requires Claude Code v2.1.199 or later.[claude.ai connector](</docs/en/mcp#organization-controls-on-connector-tools>) tools your organization has set to `ask` also leave the flow at this step. Every call falls through to the callback, even in `bypassPermissions` mode and even when an allow rule matches. The callback receives the reason `Your organization requires approval for this tool`. In `dontAsk` mode the call is denied instead, because that mode never prompts.In the TypeScript SDK, if you set a custom tool’s `permission_policy` to [`always_ask`](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>), no allow rule approves its calls, not even an `allowedTools` entry. In `dontAsk` mode Claude Code denies those calls, and in `auto`, `plan`, or `bypassPermissions` mode it [can approve them](</docs/en/agent-sdk/typescript#permission-modes-that-can-approve-an-always_ask-call>) before your callback runs. 4 @@ -32,16 +34,16 @@ Apply the active permission mode: - * In `bypassPermissions` mode, Claude Code approves everything that reaches this step except recognized [critical-path removals](</docs/en/permission-modes#critical-paths>), which fall through instead. + * In `bypassPermissions` mode, Claude Code approves everything that reaches this step except recognized [critical-path removals](</docs/en/permission-modes#critical-paths>) and Bash commands flagged [`Dangerous rm operation not ruled out`](</docs/en/permission-modes#dangerous-rm-operation-not-ruled-out>), which fall through instead. * In `acceptEdits` mode, Claude Code approves the file operations listed under Accept edits mode. - * In `plan` mode, Claude Code sends file-edit and shell-write tools to your `canUseTool` callback regardless of allow rules, so write operations can’t be auto-approved while planning. + * In `plan` mode, Claude Code sends file-edit tools to your `canUseTool` callback regardless of allow rules. * In other modes, the request falls through. 5 Allow rules -Check `allow` rules (from `allowed_tools` and settings.json). If a rule matches, the tool is approved. A call the tool approves on its own is resolved at this step too, with no rule needed: for example a file read inside your working directories or a [read-only Bash command](</docs/en/permissions#read-only-commands>).Recognized [critical-path removals](</docs/en/permission-modes#critical-paths>) aren’t approved by an allow rule. Whether they then reach your callback depends on the permission mode: in an Agent SDK session in `auto` mode, for example, Claude Code denies them by default without calling it. The [Critical paths mode table](</docs/en/permission-modes#critical-path-removals-in-each-permission-mode>) lists what each mode does with them.An allow rule doesn’t approve a read from a [network path](</docs/en/permissions#network-paths>). +Check `allow` rules (from `allowed_tools` and settings.json). If a rule matches, the tool is approved. A call the tool approves on its own is resolved at this step too, with no rule needed: for example a file read inside your working directories or a [read-only Bash command](</docs/en/permissions#read-only-commands>).Recognized [critical-path removals](</docs/en/permission-modes#critical-paths>) aren’t approved by an allow rule, and commands flagged `Dangerous rm operation not ruled out` aren’t approved by a `Bash` or `Bash(*)` rule. Whether they then reach your callback depends on the permission mode: in an Agent SDK session in `auto` mode, for example, Claude Code denies them by default without calling it. The [Critical paths mode table](</docs/en/permission-modes#critical-path-removals-in-each-permission-mode>) lists what each mode does with them.An allow rule doesn’t approve a read from a [network path](</docs/en/permissions#network-paths>). 6 @@ -51,10 +53,10 @@ If you pass a `canUseTool` callback in a configuration where the TypeScript SDK expects the evaluation order to auto-approve calls before the callback is consulted, the SDK emits a Node.js process warning once when the query is constructed. The warning’s code is `CLAUDE_SDK_CAN_USE_TOOL_SHADOWED`. Two configurations trigger it: - * `permissionMode: 'bypassPermissions'`, which auto-approves every call that reaches the permission mode step apart from the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) - * Each bare `allowedTools` entry such as `"Read"`, which auto-approves that whole tool before the callback is consulted, apart from the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) and [reads from network paths](</docs/en/permissions#network-paths>) - -Entries with a specifier such as `Bash(ls *)` and the `acceptEdits` mode don’t trigger it, and allow rules coming from settings files aren’t visible to the check. Listen with `process.on('warning', ...)` and match the code to log or suppress it. To gate every tool call regardless of mode and rules, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>) instead. This page focuses on **allow and deny rules** and **permission modes**. For the other steps: + * `permissionMode: 'bypassPermissions'`: the warning text starts with `canUseTool will not be invoked: permissionMode 'bypassPermissions'`. Tool calls are approved before `canUseTool` is consulted, so your callback runs for only a few calls, such as the calls listed under Bypass permissions mode. To check the approved calls too, put your callback’s checks in a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>) + * An `allowedTools` entry that is only a tool name, such as `"Read"`: the warning lists each such entry after `canUseTool will not be invoked for:`. Calls to a listed tool are approved before `canUseTool` is consulted, apart from the calls an allow rule never approves. To have your callback run for a listed tool’s calls that need approval, remove that tool’s entry from `allowedTools` + +Entries with a specifier such as `Bash(ls *)` and the `acceptEdits` mode don’t trigger it, and allow rules coming from settings files aren’t visible to the check. The warning doesn’t block any call or change any option. If your callback already receives every call you want to check, leave your configuration as it is. To log the warning, listen with `process.on('warning', ...)` and match the `CLAUDE_SDK_CAN_USE_TOOL_SHADOWED` code. This page focuses on **allow and deny rules** and **permission modes**. For the other steps: * **Hooks:** run custom code to allow, deny, or modify tool requests. See [Control execution with hooks](</docs/en/agent-sdk/hooks>). * **canUseTool callback:** prompt users for approval at runtime, when no earlier step resolves the call. See [Handle approvals and user input](</docs/en/agent-sdk/user-input>). @@ -76,7 +78,15 @@ Allow rules accept tool-name globs only after a literal `mcp__<server>__` prefix. The server segment must be glob-free so the rule names a specific server you configured: `mcp__puppeteer__*` matches every tool from the `puppeteer` server, and `mcp__github__get_*` matches its `get_` tools. An unanchored entry like `allowed_tools=["*"]` or `allowed_tools=["mcp__*"]` is ignored and doesn’t auto-approve anything. Scoped rules for `Read` and `Edit` take a path pattern. `Edit(path)` rules govern all built-in tools that write files, including `Write` and `NotebookEdit`; a `Write(path)` rule is never matched by the file permission checks. Use `//path` for an absolute filesystem path: a deny rule of `Edit(//secrets/**)` blocks writes anywhere under `/secrets` on disk. With a single leading slash, `Edit(/secrets/**)` anchors at the rule’s source instead. For rules passed through `allowed_tools` or `disallowed_tools`, that means the session’s working directory, so the rule doesn’t block `/secrets` on disk. See [Read and Edit rules](</docs/en/permissions#read-and-edit>) for the four anchor forms and how rules from settings files resolve. -**Auto-approved tools never reach`canUseTool`.** A tool call approved at any earlier step, by `acceptEdits` or `bypassPermissions`, or by an allow rule, skips your `canUseTool` callback, so permission checks you put there are silently bypassed for that tool.No allow rule auto-approves `AskUserQuestion`, MCP tools marked [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>), connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), or recognized `rm` and `rmdir` [critical-path removals](</docs/en/permission-modes#critical-paths>). In `dontAsk` mode Claude Code denies these calls without invoking the callback. In other modes the first three reach the callback. The [Critical paths mode table](</docs/en/permission-modes#critical-path-removals-in-each-permission-mode>) lists what each mode does with a critical-path removal. The check that recognizes these removals [can miss some commands](</docs/en/permission-modes#critical-paths>).Coverage depends on the entry’s form: a bare name like `Read` or `mcp__github__get_issue` auto-approves every call to that tool apart from those exceptions and [reads from network paths](</docs/en/permissions#network-paths>), while a scoped rule like `Bash(npm test *)` auto-approves only matching calls, and other `Bash` calls that need approval still fall through to the callback. For checks that must run on every tool call, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>): hooks run before every other step, and a hook deny applies even in `bypassPermissions` mode. +**Auto-approved tools never reach`canUseTool`.** A tool call approved at any earlier step, by `acceptEdits` or `bypassPermissions`, or by an allow rule, skips your `canUseTool` callback, so permission checks you put there are silently bypassed for that tool.If calls to a tool in `allowed_tools` still reach your `canUseTool` callback, or are denied in `dontAsk` mode, check whether they’re [reads from network paths](</docs/en/permissions#network-paths>) or among the following calls. No allow rule approves these calls. In `dontAsk` mode, which never prompts, Claude Code denies them without calling `canUseTool`, and in the other permission modes you handle them as each item says: + + * `AskUserQuestion`, MCP tools marked [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>), and connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>): answer them in the callback. [Handle clarifying questions](</docs/en/agent-sdk/user-input#handle-clarifying-questions>) shows how to answer `AskUserQuestion`, and a connector call arrives with the reason `Your organization requires approval for this tool` + * Custom tools your application marks [`always_ask`](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>): decide the call in the callback. To stop these calls arriving, [change the policy mid-session](</docs/en/agent-sdk/typescript#mcpsdkserverconfigwithinstance>). In `auto`, `plan`, and `bypassPermissions` mode the call can instead be approved before the callback, in the cases listed under [Permission modes that can approve an `always_ask` call](</docs/en/agent-sdk/typescript#permission-modes-that-can-approve-an-always_ask-call>) + * Recognized `rm` and `rmdir` [critical-path removals](</docs/en/permission-modes#critical-paths>): in `default`, `acceptEdits`, and `bypassPermissions` mode, allow or deny the removal in the callback, where [`decisionReason`](</docs/en/agent-sdk/typescript#canusetool>) starts with `Dangerous rm`. For `auto` and `plan` mode, see [Critical-path removals in each permission mode](</docs/en/permission-modes#critical-path-removals-in-each-permission-mode>). The check that recognizes these removals [can miss some commands](</docs/en/permission-modes#critical-paths>) + * **Bare name** : an entry like `Read` or `mcp__github__get_issue` auto-approves every call to that tool apart from the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) and [reads from network paths](</docs/en/permissions#network-paths>). + * **Scoped rule** : an entry like `Bash(npm test *)` auto-approves only matching calls, and other `Bash` calls that need approval still fall through to the callback. + +For checks that must run on every tool call, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>): hooks run before every other step, and a hook deny applies even in `bypassPermissions` mode. For a locked-down agent, pair `allowedTools` with `permissionMode: "dontAsk"`: @@ -85,7 +95,7 @@ permissionMode: "dontAsk" }; -Listed tools are approved, apart from the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) and [reads from network paths](</docs/en/permissions#network-paths>). Every other call that would prompt is denied instead, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some of those calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). Calls that need no approval in `default` mode run whether or not you list them. They include [read-only Bash commands](</docs/en/permissions#read-only-commands>), tools like `Agent` that don’t ask before running, and file reads inside your working directories. To remove a tool from the request entirely, add its bare name to `disallowedTools`. +The listed `Read`, `Glob`, and `Grep` calls are approved, apart from the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) and [reads from network paths](</docs/en/permissions#network-paths>). Every other call that would prompt is denied instead, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some of those calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). Calls that need no approval in `default` mode run whether or not you list them. These include [read-only Bash commands](</docs/en/permissions#read-only-commands>), tools like `Agent` that don’t ask before running, and file reads inside your working directories. To hide a built-in tool from Claude entirely rather than deny its calls, add its bare name to `disallowedTools`. **`allowed_tools` does not constrain `bypassPermissions`.** `allowed_tools` pre-approves the tools you list. Other unlisted tools are not matched by any allow rule and fall through to the permission mode, where `bypassPermissions` approves them. Setting `allowed_tools=["Read"]` alongside `permission_mode="bypassPermissions"` still approves every tool, including `Bash`, `Write`, and `Edit`. If you need `bypassPermissions` but want specific tools blocked, use `disallowed_tools`. @@ -112,7 +122,7 @@ `default`| Standard permission behavior| No mode-based auto-approvals; calls that need approval and match no allow rule trigger your `canUseTool` callback `dontAsk`| Deny instead of prompting| Any call that would otherwise prompt is denied without calling `canUseTool`, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some of those calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). Calls approved by `allowed_tools` or `settings.json` allow rules run, and so do calls that need no approval in `default` mode. Some calls, such as [reads from network paths](</docs/en/permissions#network-paths>), are denied even when `allowed_tools` or an allow rule matches them. For the list, see Don’t ask mode `acceptEdits`| Auto-accept file edits| File edits and filesystem operations (`mkdir`, `rm`, `mv`, etc.) are automatically approved -`bypassPermissions`| Bypass permission checks| Tools run without permission prompts, except for the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>). Use with caution +`bypassPermissions`| Bypass permission checks| Tools run without permission prompts, except for the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) and, outside a [cloud session](</docs/en/claude-code-on-the-web>), custom tools your application [marks `always_ask`](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>). Use with caution `plan`| Planning mode| Claude explores and plans without editing your source files; file edits are never auto-approved and prompt through your `canUseTool` callback `auto`| Model-classified approvals| A model classifier reviews actions such as shell commands and network requests, allowing or blocking each one it reviews. See [Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) for availability and the decision order @@ -240,6 +250,7 @@ * Works on a path outside that scope * Writes to a protected path * Removes a path that Claude Code recognizes as a [critical path](</docs/en/permission-modes#critical-paths>) with `rm` or `rmdir` + * Runs [`touch`](</docs/en/permission-modes#auto-approve-file-edits-with-acceptedits-mode>) with, for example, an option, a glob, or a `timeout 5` or `LANG=C` prefix **Use when:** you trust Claude’s edits and want faster iteration, such as during prototyping or when working in an isolated directory. @@ -249,7 +260,15 @@ Don’t ask mode (`dontAsk`) -Converts any permission prompt into a denial, without calling `canUseTool`, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some of those calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). Tools pre-approved by `allowed_tools`, `settings.json` allow rules, or a hook run as normal. Calls that need no approval in `default` mode also run, such as file reads inside your working directories and calls to `Agent`. Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, [reads from network paths](</docs/en/permissions#network-paths>), and recognized [critical-path removals](</docs/en/permission-modes#critical-paths>) are denied even when an allow rule matches. A `PreToolUse` hook allow doesn’t clear a recognized critical-path removal or a read from a network path either. The check that recognizes these removals [can miss some commands](</docs/en/permission-modes#critical-paths>). **Use when:** you want a fixed, explicit tool surface for a headless agent and prefer a hard deny over silent reliance on `canUseTool` being absent. +Converts any permission prompt into a denial, without calling `canUseTool`, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some of those calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). Tools pre-approved by `allowed_tools`, `settings.json` allow rules, or a hook run as normal. Calls that need no approval in `default` mode also run as normal, such as file reads inside your working directories and calls to `Agent`. These calls are denied even when an allow rule matches: + + * Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) + * Tools that require user interaction, such as `AskUserQuestion` and MCP tools whose server sets [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>) + * Custom tools whose `permission_policy` your application sets to [`always_ask`](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>) + * [Reads from network paths](</docs/en/permissions#network-paths>) + * Recognized [critical-path removals](</docs/en/permission-modes#critical-paths>) + +If your `PreToolUse` hook returns `allow` for a recognized critical-path removal, a read from a network path, or a call to a tool marked `always_ask`, the call is still denied. The check that recognizes these removals [can miss some commands](</docs/en/permission-modes#critical-paths>). **Use when:** you want a fixed, explicit tool surface for a headless agent and prefer a hard deny over silent reliance on `canUseTool` being absent. #### @@ -257,12 +276,12 @@ Bypass permissions mode (`bypassPermissions`) -Auto-approves tool uses without prompting, except the cases listed in the warning below. Hooks still execute and can block operations if needed. On Linux and macOS, Claude Code refuses to start in this mode as root or under `sudo` outside a [recognized sandbox](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>), and the query fails before the first turn. +Auto-approves tool uses without prompting, except the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>). Hooks still execute and can block operations if needed. On Linux and macOS, Claude Code refuses to start in this mode as root or under `sudo` outside a [recognized sandbox](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>), and the query fails before the first turn. Use with extreme caution. Claude has full system access in this mode. Only use in controlled environments where you trust all possible operations.`allowed_tools` does not constrain this mode. Every tool is approved, not just the ones you listed. These controls still apply: * Deny rules, explicit `ask` rules, and hooks are evaluated before the mode check and can still block a tool. - * Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, and recognized [critical-path removals](</docs/en/permission-modes#critical-paths>) still fall through to your `canUseTool` callback. The check that recognizes these removals [can miss some commands](</docs/en/permission-modes#critical-paths>). + * Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, and recognized [critical-path removals](</docs/en/permission-modes#critical-paths>) still fall through to your `canUseTool` callback. The check that recognizes these removals [can miss some commands](</docs/en/permission-modes#critical-paths>). Outside a [cloud session](</docs/en/claude-code-on-the-web>), calls to custom tools your application [marks `always_ask`](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>) fall through to the callback too. * The [cross-session messaging safeguards](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) still apply. #### @@ -271,7 +290,11 @@ Plan mode (`plan`) -Claude explores the codebase and produces a plan without editing your source files. Read-only tools run as they do in the `default` permission mode. File edits are never auto-approved in plan mode, even when an allow rule matches or a `PreToolUse` hook returns `allow`. They prompt through your `canUseTool` callback instead. On Claude Code v2.1.212 or later, shell commands that modify files, such as `touch` and `rm`, reach your `canUseTool` callback the same way. In the TypeScript SDK, if you set `allowDangerouslySkipPermissions: true` alongside `permissionMode: 'plan'`, file edits and shell commands that modify files still reach your `canUseTool` callback. The option lets you switch to `bypassPermissions` later with `setPermissionMode()`. Claude may use `AskUserQuestion` to clarify requirements before finalizing the plan. See [Handle approvals and user input](</docs/en/agent-sdk/user-input#handle-clarifying-questions>) for handling these prompts. **Use when:** you want Claude to propose changes without executing them, such as during code review or when you need to approve changes before they’re made. +Claude explores the codebase and produces a plan without editing your source files. File edits are never auto-approved in plan mode, even when an allow rule matches or a `PreToolUse` hook returns `allow`. They prompt through your `canUseTool` callback instead. While auto mode is available to the session, commands Claude runs during planning don’t reach your callback by default, because the classifier model that [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) uses [reviews them instead](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>). With that review on, the classifier can also approve read-only calls that would otherwise reach your callback, such as a `WebFetch` call with no allow rule. + +In the TypeScript SDK, if you set `allowDangerouslySkipPermissions: true` alongside `permissionMode: 'plan'`, file edits still reach your `canUseTool` callback. To switch a session that starts in plan mode to `bypassPermissions` later with `setPermissionMode()`, you need `allowDangerouslySkipPermissions` set from the start. + +Claude may use `AskUserQuestion` to clarify requirements before finalizing the plan. See [Handle approvals and user input](</docs/en/agent-sdk/user-input#handle-clarifying-questions>) for handling these prompts. **Use when:** you want Claude to propose changes without executing them, such as during code review or when you need to approve changes before they’re made. ####
modified
--- a/permissions.md +++ b/permissions.md @@ -116,7 +116,7 @@ `plan`| Planning mode| Claude explores and plans without editing your source files; file edits are never auto-approved and prompt through your `canUseTool` callback `auto`| Model-classified approvals| A model classifier reviews actions such as shell commands and network requests, allowing or blocking each one it reviews. See [Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) for availability and the decision order -**Subagent inheritance:** A subagent runs in the parent session’s permission mode unless you set `permissionMode` on its [`AgentDefinition`](</docs/en/agent-sdk/typescript#agentdefinition>) and the parent session is in `default`, `dontAsk`, or `plan` mode. Even then, Claude Code never applies a `"bypassPermissions"` value, and applies an `"auto"` value only when [auto mode is available](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) to that subagent. A subagent runs in `bypassPermissions` mode only when the parent session itself does. The `bypassPermissions` exception requires Claude Code v2.1.267 or later.Subagents may have different system prompts and less constrained behavior than your main agent, so inheriting `bypassPermissions` grants them full, autonomous system access. The [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) still apply. +**Subagent inheritance:** If your main session is in [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), a subagent whose [`AgentDefinition`](</docs/en/agent-sdk/typescript#agentdefinition>) sets `permissionMode: "acceptEdits"` still runs in plan mode. That subagent’s `Edit` and `Write` calls on your source files still go to your `canUseTool` callback. Plan mode holds for the subagents you define too, so that handing work to one doesn’t get around reviewing the plan first.The subagent inherits `plan`, `acceptEdits`, `auto`, or `bypassPermissions` from the main session, and under a `default`\- or `dontAsk`-mode main session it runs in the mode you set. Even then, Claude Code never applies a `"bypassPermissions"` value, and applies an `"auto"` value only when [auto mode is available](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) to that subagent. The `bypassPermissions` exception requires Claude Code v2.1.267 or later.Subagents may have different system prompts and less constrained behavior than your main agent, so inheriting `bypassPermissions` grants them full, autonomous system access. The [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) still apply. ###
modified
--- a/permissions.md +++ b/permissions.md @@ -12,7 +12,7 @@ Hooks -Run [hooks](</docs/en/agent-sdk/hooks>) first. A hook can deny the call outright or pass it on. A hook that returns `allow` does not skip the deny and ask rules below; those are evaluated regardless of the hook result. A `PreToolUse` hook that returns `allow` also can’t approve an `rm` or `rmdir` removal targeting a [critical path](</docs/en/permission-modes#critical-paths>). For what that `allow` does in plan mode, see [Hook approvals in plan mode](</docs/en/permissions#hook-approvals-in-plan-mode>). +Run [hooks](</docs/en/agent-sdk/hooks>) first. A hook can deny the call outright or pass it on. A hook that returns `allow` doesn’t skip the deny and ask rules below, which are evaluated regardless of the hook result.A `PreToolUse` hook that returns `allow` also can’t approve an `rm` or `rmdir` command whose target Claude Code recognizes as a [critical path](</docs/en/permission-modes#critical-paths>), such as `rm -rf ~`. For what that `allow` does in plan mode, see [Hook approvals in plan mode](</docs/en/permissions#hook-approvals-in-plan-mode>). 2 @@ -32,7 +32,7 @@ Apply the active permission mode: - * In `bypassPermissions` mode, Claude Code approves everything that reaches this step except `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>), which fall through instead. + * In `bypassPermissions` mode, Claude Code approves everything that reaches this step except recognized [critical-path removals](</docs/en/permission-modes#critical-paths>), which fall through instead. * In `acceptEdits` mode, Claude Code approves the file operations listed under Accept edits mode. * In `plan` mode, Claude Code sends file-edit and shell-write tools to your `canUseTool` callback regardless of allow rules, so write operations can’t be auto-approved while planning. * In other modes, the request falls through. @@ -41,7 +41,7 @@ Allow rules -Check `allow` rules (from `allowed_tools` and settings.json). If a rule matches, the tool is approved. A call the tool approves on its own is resolved at this step too, with no rule needed: for example a file read inside your working directories or a [read-only Bash command](</docs/en/permissions#read-only-commands>).`rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) are never approved by an allow rule. Whether they then reach your callback depends on the permission mode: in an Agent SDK session in `auto` mode, for example, Claude Code denies them by default without calling it. The [Critical paths](</docs/en/permission-modes#critical-paths>) mode table lists what each mode does with them.An allow rule doesn’t approve a read from a [network path](</docs/en/permissions#network-paths>). +Check `allow` rules (from `allowed_tools` and settings.json). If a rule matches, the tool is approved. A call the tool approves on its own is resolved at this step too, with no rule needed: for example a file read inside your working directories or a [read-only Bash command](</docs/en/permissions#read-only-commands>).Recognized [critical-path removals](</docs/en/permission-modes#critical-paths>) aren’t approved by an allow rule. Whether they then reach your callback depends on the permission mode: in an Agent SDK session in `auto` mode, for example, Claude Code denies them by default without calling it. The [Critical paths mode table](</docs/en/permission-modes#critical-path-removals-in-each-permission-mode>) lists what each mode does with them.An allow rule doesn’t approve a read from a [network path](</docs/en/permissions#network-paths>). 6 @@ -76,7 +76,7 @@ Allow rules accept tool-name globs only after a literal `mcp__<server>__` prefix. The server segment must be glob-free so the rule names a specific server you configured: `mcp__puppeteer__*` matches every tool from the `puppeteer` server, and `mcp__github__get_*` matches its `get_` tools. An unanchored entry like `allowed_tools=["*"]` or `allowed_tools=["mcp__*"]` is ignored and doesn’t auto-approve anything. Scoped rules for `Read` and `Edit` take a path pattern. `Edit(path)` rules govern all built-in tools that write files, including `Write` and `NotebookEdit`; a `Write(path)` rule is never matched by the file permission checks. Use `//path` for an absolute filesystem path: a deny rule of `Edit(//secrets/**)` blocks writes anywhere under `/secrets` on disk. With a single leading slash, `Edit(/secrets/**)` anchors at the rule’s source instead. For rules passed through `allowed_tools` or `disallowed_tools`, that means the session’s working directory, so the rule doesn’t block `/secrets` on disk. See [Read and Edit rules](</docs/en/permissions#read-and-edit>) for the four anchor forms and how rules from settings files resolve. -**Auto-approved tools never reach`canUseTool`.** A tool call approved at any earlier step, by `acceptEdits` or `bypassPermissions`, or by an allow rule, skips your `canUseTool` callback, so permission checks you put there are silently bypassed for that tool.An allow rule never auto-approves `AskUserQuestion`, MCP tools marked [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>), connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), or `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>). In `dontAsk` mode Claude Code denies these calls without invoking the callback. In other modes the first three reach the callback. Depending on the [permission mode](</docs/en/permission-modes#critical-paths>), a critical-path removal reaches the callback too or Claude Code denies it without calling it, as it does by default for an Agent SDK session in `auto` mode.Coverage depends on the entry’s form: a bare name like `Read` or `mcp__github__get_issue` auto-approves every call to that tool apart from those exceptions and [reads from network paths](</docs/en/permissions#network-paths>), while a scoped rule like `Bash(npm test *)` auto-approves only matching calls, and other `Bash` calls that need approval still fall through to the callback. For checks that must run on every tool call, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>): hooks run before every other step, and a hook deny applies even in `bypassPermissions` mode. +**Auto-approved tools never reach`canUseTool`.** A tool call approved at any earlier step, by `acceptEdits` or `bypassPermissions`, or by an allow rule, skips your `canUseTool` callback, so permission checks you put there are silently bypassed for that tool.No allow rule auto-approves `AskUserQuestion`, MCP tools marked [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>), connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), or recognized `rm` and `rmdir` [critical-path removals](</docs/en/permission-modes#critical-paths>). In `dontAsk` mode Claude Code denies these calls without invoking the callback. In other modes the first three reach the callback. The [Critical paths mode table](</docs/en/permission-modes#critical-path-removals-in-each-permission-mode>) lists what each mode does with a critical-path removal. The check that recognizes these removals [can miss some commands](</docs/en/permission-modes#critical-paths>).Coverage depends on the entry’s form: a bare name like `Read` or `mcp__github__get_issue` auto-approves every call to that tool apart from those exceptions and [reads from network paths](</docs/en/permissions#network-paths>), while a scoped rule like `Bash(npm test *)` auto-approves only matching calls, and other `Bash` calls that need approval still fall through to the callback. For checks that must run on every tool call, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>): hooks run before every other step, and a hook deny applies even in `bypassPermissions` mode. For a locked-down agent, pair `allowedTools` with `permissionMode: "dontAsk"`: @@ -110,7 +110,7 @@ Mode| Description| Tool behavior ---|---|--- `default`| Standard permission behavior| No mode-based auto-approvals; calls that need approval and match no allow rule trigger your `canUseTool` callback -`dontAsk`| Deny instead of prompting| Any call that would otherwise prompt is denied, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some of those calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). Calls approved by `allowed_tools` or rules run, and so do calls that need no approval in `default` mode. Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) and tools that require user interaction are denied even if you’ve pre-approved them. [Reads from network paths](</docs/en/permissions#network-paths>) and `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) are also denied even if you’ve pre-approved them. `canUseTool` is never called +`dontAsk`| Deny instead of prompting| Any call that would otherwise prompt is denied without calling `canUseTool`, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some of those calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). Calls approved by `allowed_tools` or `settings.json` allow rules run, and so do calls that need no approval in `default` mode. Some calls, such as [reads from network paths](</docs/en/permissions#network-paths>), are denied even when `allowed_tools` or an allow rule matches them. For the list, see Don’t ask mode `acceptEdits`| Auto-accept file edits| File edits and filesystem operations (`mkdir`, `rm`, `mv`, etc.) are automatically approved `bypassPermissions`| Bypass permission checks| Tools run without permission prompts, except for the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>). Use with caution `plan`| Planning mode| Claude explores and plans without editing your source files; file edits are never auto-approved and prompt through your `canUseTool` callback @@ -239,7 +239,7 @@ * Works on a path outside that scope * Writes to a protected path - * Removes a [critical path](</docs/en/permission-modes#critical-paths>) with `rm` or `rmdir` + * Removes a path that Claude Code recognizes as a [critical path](</docs/en/permission-modes#critical-paths>) with `rm` or `rmdir` **Use when:** you trust Claude’s edits and want faster iteration, such as during prototyping or when working in an isolated directory. @@ -249,7 +249,7 @@ Don’t ask mode (`dontAsk`) -Converts any permission prompt into a denial, without calling `canUseTool`, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some of those calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). Tools pre-approved by `allowed_tools`, `settings.json` allow rules, or a hook run as normal. Calls that need no approval in `default` mode also run, such as file reads inside your working directories and calls to `Agent`. Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, [reads from network paths](</docs/en/permissions#network-paths>), and `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) are denied even when an allow rule matches. A `PreToolUse` hook allow doesn’t clear a critical-path removal or a read from a network path either. **Use when:** you want a fixed, explicit tool surface for a headless agent and prefer a hard deny over silent reliance on `canUseTool` being absent. +Converts any permission prompt into a denial, without calling `canUseTool`, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some of those calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). Tools pre-approved by `allowed_tools`, `settings.json` allow rules, or a hook run as normal. Calls that need no approval in `default` mode also run, such as file reads inside your working directories and calls to `Agent`. Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, [reads from network paths](</docs/en/permissions#network-paths>), and recognized [critical-path removals](</docs/en/permission-modes#critical-paths>) are denied even when an allow rule matches. A `PreToolUse` hook allow doesn’t clear a recognized critical-path removal or a read from a network path either. The check that recognizes these removals [can miss some commands](</docs/en/permission-modes#critical-paths>). **Use when:** you want a fixed, explicit tool surface for a headless agent and prefer a hard deny over silent reliance on `canUseTool` being absent. #### @@ -262,7 +262,7 @@ Use with extreme caution. Claude has full system access in this mode. Only use in controlled environments where you trust all possible operations.`allowed_tools` does not constrain this mode. Every tool is approved, not just the ones you listed. These controls still apply: * Deny rules, explicit `ask` rules, and hooks are evaluated before the mode check and can still block a tool. - * Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, and `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) still fall through to your `canUseTool` callback. + * Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, and recognized [critical-path removals](</docs/en/permission-modes#critical-paths>) still fall through to your `canUseTool` callback. The check that recognizes these removals [can miss some commands](</docs/en/permission-modes#critical-paths>). * The [cross-session messaging safeguards](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) still apply. ####
modified
--- a/permissions.md +++ b/permissions.md @@ -74,7 +74,7 @@ `disallowed_tools=["Bash(rm *)"]`| `Bash` stays available. Calls matching `rm *` [as written](</docs/en/permissions#bash-rule-limits>) are denied in every permission mode, including `bypassPermissions`. Other `Bash` calls, including `/bin/rm`, fall through to the permission mode. `disallowed_tools=["*"]`| Every tool definition is removed from the request. Tool-name globs are supported in deny rules: `"*"` matches every tool and `"mcp__*"` matches every MCP tool across all servers. -Allow rules accept tool-name globs only after a literal `mcp__<server>__` prefix. The server segment must be glob-free so the rule names a specific server you configured: `mcp__puppeteer__*` matches every tool from the `puppeteer` server, and `mcp__github__get_*` matches its `get_` tools. An unanchored entry like `allowed_tools=["*"]` or `allowed_tools=["mcp__*"]` is ignored with a startup warning and does not auto-approve anything. Scoped rules for `Read` and `Edit` take a path pattern. `Edit(path)` rules govern all built-in tools that write files, including `Write` and `NotebookEdit`; a `Write(path)` rule is never matched by the file permission checks. Use `//path` for an absolute filesystem path: a deny rule of `Edit(//secrets/**)` blocks writes anywhere under `/secrets` on disk. With a single leading slash, `Edit(/secrets/**)` anchors at the rule’s source instead. For rules passed through `allowed_tools` or `disallowed_tools`, that means the session’s working directory, so the rule doesn’t block `/secrets` on disk. See [Read and Edit rules](</docs/en/permissions#read-and-edit>) for the four anchor forms and how rules from settings files resolve. +Allow rules accept tool-name globs only after a literal `mcp__<server>__` prefix. The server segment must be glob-free so the rule names a specific server you configured: `mcp__puppeteer__*` matches every tool from the `puppeteer` server, and `mcp__github__get_*` matches its `get_` tools. An unanchored entry like `allowed_tools=["*"]` or `allowed_tools=["mcp__*"]` is ignored and doesn’t auto-approve anything. Scoped rules for `Read` and `Edit` take a path pattern. `Edit(path)` rules govern all built-in tools that write files, including `Write` and `NotebookEdit`; a `Write(path)` rule is never matched by the file permission checks. Use `//path` for an absolute filesystem path: a deny rule of `Edit(//secrets/**)` blocks writes anywhere under `/secrets` on disk. With a single leading slash, `Edit(/secrets/**)` anchors at the rule’s source instead. For rules passed through `allowed_tools` or `disallowed_tools`, that means the session’s working directory, so the rule doesn’t block `/secrets` on disk. See [Read and Edit rules](</docs/en/permissions#read-and-edit>) for the four anchor forms and how rules from settings files resolve. **Auto-approved tools never reach`canUseTool`.** A tool call approved at any earlier step, by `acceptEdits` or `bypassPermissions`, or by an allow rule, skips your `canUseTool` callback, so permission checks you put there are silently bypassed for that tool.An allow rule never auto-approves `AskUserQuestion`, MCP tools marked [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>), connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), or `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>). In `dontAsk` mode Claude Code denies these calls without invoking the callback. In other modes the first three reach the callback. Depending on the [permission mode](</docs/en/permission-modes#critical-paths>), a critical-path removal reaches the callback too or Claude Code denies it without calling it, as it does by default for an Agent SDK session in `auto` mode.Coverage depends on the entry’s form: a bare name like `Read` or `mcp__github__get_issue` auto-approves every call to that tool apart from those exceptions and [reads from network paths](</docs/en/permissions#network-paths>), while a scoped rule like `Bash(npm test *)` auto-approves only matching calls, and other `Bash` calls that need approval still fall through to the callback. For checks that must run on every tool call, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>): hooks run before every other step, and a hook deny applies even in `bypassPermissions` mode.
modified
--- a/permissions.md +++ b/permissions.md @@ -47,7 +47,7 @@ canUseTool callback -If not resolved by any of the above, call your [`canUseTool` callback](</docs/en/agent-sdk/user-input>) for a decision. In `dontAsk` mode, this step is skipped and the tool is denied.In the TypeScript SDK, if you set [`permissionPrompts: 'none'`](</docs/en/agent-sdk/typescript#options>), your callback isn’t called at this step. A [`PermissionRequest` hook](</docs/en/hooks#permissionrequest>) still gets a chance to decide, and if it doesn’t, Claude Code denies the call. The option requires Claude Code v2.1.259 or later. +If not resolved by any of the above, call your [`canUseTool` callback](</docs/en/agent-sdk/user-input>) for a decision. In `dontAsk` mode, this step is skipped and the tool is denied, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some such calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>).In the TypeScript SDK, if you set [`permissionPrompts: 'none'`](</docs/en/agent-sdk/typescript#options>), your callback isn’t called at this step. A [`PermissionRequest` hook](</docs/en/hooks#permissionrequest>) still gets a chance to decide, and if it doesn’t, Claude Code denies the call. The option requires Claude Code v2.1.259 or later. If you pass a `canUseTool` callback in a configuration where the TypeScript SDK expects the evaluation order to auto-approve calls before the callback is consulted, the SDK emits a Node.js process warning once when the query is constructed. The warning’s code is `CLAUDE_SDK_CAN_USE_TOOL_SHADOWED`. Two configurations trigger it: @@ -85,7 +85,7 @@ permissionMode: "dontAsk" }; -Listed tools are approved, apart from the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) and [reads from network paths](</docs/en/permissions#network-paths>), and every other call that would prompt is denied instead. Calls that need no approval in `default` mode run whether or not you list them, such as [read-only Bash commands](</docs/en/permissions#read-only-commands>), tools like `Agent` that don’t ask before running, and file reads inside your working directories. To remove a tool from the request entirely, add its bare name to `disallowedTools`. +Listed tools are approved, apart from the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) and [reads from network paths](</docs/en/permissions#network-paths>). Every other call that would prompt is denied instead, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some of those calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). Calls that need no approval in `default` mode run whether or not you list them. They include [read-only Bash commands](</docs/en/permissions#read-only-commands>), tools like `Agent` that don’t ask before running, and file reads inside your working directories. To remove a tool from the request entirely, add its bare name to `disallowedTools`. **`allowed_tools` does not constrain `bypassPermissions`.** `allowed_tools` pre-approves the tools you list. Other unlisted tools are not matched by any allow rule and fall through to the permission mode, where `bypassPermissions` approves them. Setting `allowed_tools=["Read"]` alongside `permission_mode="bypassPermissions"` still approves every tool, including `Bash`, `Write`, and `Edit`. If you need `bypassPermissions` but want specific tools blocked, use `disallowed_tools`. @@ -97,12 +97,7 @@ Permission modes -Permission modes provide global control over how Claude uses tools. You can set the permission mode when calling `query()` or change it dynamically during streaming sessions. If you don’t set one, Claude Code picks the starting permission mode by the rules in [Which mode a session starts in](</docs/en/permission-modes#which-mode-a-session-starts-in>): - - * A `permissions.defaultMode` from the session’s [settings files](</docs/en/settings#where-settings-live>) when one applies - * Otherwise the built-in default, which can be [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) - -A session that starts in auto mode drops broad allow rules such as a bare `Bash` entry, as [How auto mode evaluates actions](</docs/en/permission-modes#how-auto-mode-evaluates-actions>) describes. If your application relies on the `default` mode or on such a rule, pass `default` explicitly. Before TypeScript Agent SDK v0.3.286, omitting `permissionMode` was the same as passing `default`. +Permission modes provide global control over how Claude uses tools. You can set the permission mode when calling `query()` or change it dynamically during streaming sessions. With Claude Code v2.1.302 or later, your app starts in `default` mode unless you set a permission mode or it gets one from [`permissions.defaultMode`](</docs/en/settings-reference#permissions-defaultmode>) in its settings files. In `default` mode, Claude Code denies any tool call needing approval unless you approve it through an allow rule, hook, `canUseTool` callback, or permission prompt tool. If tool calls are denied, see [Tool calls denied in `claude -p` and Agent SDK runs](</docs/en/permission-modes#which-mode-a-non-interactive-run-starts-in>). ### @@ -115,7 +110,7 @@ Mode| Description| Tool behavior ---|---|--- `default`| Standard permission behavior| No mode-based auto-approvals; calls that need approval and match no allow rule trigger your `canUseTool` callback -`dontAsk`| Deny instead of prompting| Any call that would otherwise prompt is denied. Calls approved by `allowed_tools` or rules run, and so do calls that need no approval in `default` mode; connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) and tools that require user interaction are denied even if you’ve pre-approved them, as are [reads from network paths](</docs/en/permissions#network-paths>) and `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>). `canUseTool` is never called +`dontAsk`| Deny instead of prompting| Any call that would otherwise prompt is denied, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some of those calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). Calls approved by `allowed_tools` or rules run, and so do calls that need no approval in `default` mode. Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) and tools that require user interaction are denied even if you’ve pre-approved them. [Reads from network paths](</docs/en/permissions#network-paths>) and `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) are also denied even if you’ve pre-approved them. `canUseTool` is never called `acceptEdits`| Auto-accept file edits| File edits and filesystem operations (`mkdir`, `rm`, `mv`, etc.) are automatically approved `bypassPermissions`| Bypass permission checks| Tools run without permission prompts, except for the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>). Use with caution `plan`| Planning mode| Claude explores and plans without editing your source files; file edits are never auto-approved and prompt through your `canUseTool` callback @@ -254,7 +249,7 @@ Don’t ask mode (`dontAsk`) -Converts any permission prompt into a denial, without calling `canUseTool`. Tools pre-approved by `allowed_tools`, `settings.json` allow rules, or a hook run as normal, and so do calls that need no approval in `default` mode, such as file reads inside your working directories and calls to `Agent`. Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, [reads from network paths](</docs/en/permissions#network-paths>), and `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) are denied even when an allow rule matches. A `PreToolUse` hook allow doesn’t clear a critical-path removal or a read from a network path either. **Use when:** you want a fixed, explicit tool surface for a headless agent and prefer a hard deny over silent reliance on `canUseTool` being absent. +Converts any permission prompt into a denial, without calling `canUseTool`, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some of those calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). Tools pre-approved by `allowed_tools`, `settings.json` allow rules, or a hook run as normal. Calls that need no approval in `default` mode also run, such as file reads inside your working directories and calls to `Agent`. Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, [reads from network paths](</docs/en/permissions#network-paths>), and `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) are denied even when an allow rule matches. A `PreToolUse` hook allow doesn’t clear a critical-path removal or a read from a network path either. **Use when:** you want a fixed, explicit tool surface for a headless agent and prefer a hard deny over silent reliance on `canUseTool` being absent. ####
modified
--- a/permissions.md +++ b/permissions.md @@ -12,7 +12,7 @@ Hooks -Run [hooks](</docs/en/agent-sdk/hooks>) first. A hook can deny the call outright or pass it on. A hook that returns `allow` does not skip the deny and ask rules below; those are evaluated regardless of the hook result. A `PreToolUse` hook allow also can’t approve an `rm` or `rmdir` removal targeting a [critical path](</docs/en/permission-modes#critical-paths>). +Run [hooks](</docs/en/agent-sdk/hooks>) first. A hook can deny the call outright or pass it on. A hook that returns `allow` does not skip the deny and ask rules below; those are evaluated regardless of the hook result. A `PreToolUse` hook that returns `allow` also can’t approve an `rm` or `rmdir` removal targeting a [critical path](</docs/en/permission-modes#critical-paths>). For what that `allow` does in plan mode, see [Hook approvals in plan mode](</docs/en/permissions#hook-approvals-in-plan-mode>). 2 @@ -135,7 +135,7 @@ * During streaming -Pass `permission_mode` (Python) or `permissionMode` (TypeScript) when creating a query. This mode applies for the entire session unless changed dynamically. +Pass `permission_mode` (Python) or `permissionMode` (TypeScript) when creating a query. Python @@ -276,7 +276,20 @@ Plan mode (`plan`) -Claude explores the codebase and produces a plan without editing your source files. Read-only tools run as they do in the `default` permission mode. File edits are never auto-approved in plan mode, even when an allow rule matches. They prompt through your `canUseTool` callback instead. On Claude Code v2.1.212 or later, shell commands that modify files, such as `touch` and `rm`, reach your `canUseTool` callback the same way. In the TypeScript SDK, if you set `allowDangerouslySkipPermissions: true` alongside `permissionMode: 'plan'`, file edits and shell commands that modify files still reach your `canUseTool` callback. The option lets you switch to `bypassPermissions` later with `setPermissionMode()`. Claude may use `AskUserQuestion` to clarify requirements before finalizing the plan. See [Handle approvals and user input](</docs/en/agent-sdk/user-input#handle-clarifying-questions>) for handling these prompts. **Use when:** you want Claude to propose changes without executing them, such as during code review or when you need to approve changes before they’re made. +Claude explores the codebase and produces a plan without editing your source files. Read-only tools run as they do in the `default` permission mode. File edits are never auto-approved in plan mode, even when an allow rule matches or a `PreToolUse` hook returns `allow`. They prompt through your `canUseTool` callback instead. On Claude Code v2.1.212 or later, shell commands that modify files, such as `touch` and `rm`, reach your `canUseTool` callback the same way. In the TypeScript SDK, if you set `allowDangerouslySkipPermissions: true` alongside `permissionMode: 'plan'`, file edits and shell commands that modify files still reach your `canUseTool` callback. The option lets you switch to `bypassPermissions` later with `setPermissionMode()`. Claude may use `AskUserQuestion` to clarify requirements before finalizing the plan. See [Handle approvals and user input](</docs/en/agent-sdk/user-input#handle-clarifying-questions>) for handling these prompts. **Use when:** you want Claude to propose changes without executing them, such as during code review or when you need to approve changes before they’re made. + +#### + +​ + +Auto mode (`auto`) + +A classifier model reviews actions such as shell commands and network requests before they run, and allows or blocks each one it reviews. For the models and providers auto mode requires and the order it evaluates actions in, see [Eliminate permission prompts with auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>). If you switch a session that’s in auto mode to a model that auto mode doesn’t support, using [`set_model()`](</docs/en/agent-sdk/python#claudesdkclient>), [`setModel()`](</docs/en/agent-sdk/typescript#query-object>), or [`applyFlagSettings()`](</docs/en/agent-sdk/typescript#applyflagsettings>), the session changes to `default` mode: + + * **What you see** : a `system` message with subtype `status` and `permissionMode` set to `"default"`, which the TypeScript SDK types as [`SDKStatusMessage`](</docs/en/agent-sdk/typescript#sdkstatusmessage>). From then on, calls that need approval and match no allow rule reach your `canUseTool` callback. + * **To return to auto mode** : switch to a supported model, then call `set_permission_mode("auto")` or `setPermissionMode("auto")`. If you switch the model back without making that call, the session stays in `default` mode. While the unsupported model is active, the call fails with `Cannot set permission mode to auto: auto mode unavailable for this model`. + +The change to `default` mode after a `set_model()`, `setModel()`, or `applyFlagSettings()` call requires Claude Code v2.1.299 or later. ##
modified
--- a/permissions.md +++ b/permissions.md @@ -41,7 +41,7 @@ Allow rules -Check `allow` rules (from `allowed_tools` and settings.json). If a rule matches, the tool is approved. A call the tool approves on its own is resolved at this step too, with no rule needed: for example a file read inside your working directories or a [read-only Bash command](</docs/en/permissions#read-only-commands>).`rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) are never approved by an allow rule. Whether they then reach your callback depends on the permission mode: in an Agent SDK session in `auto` mode, for example, Claude Code denies them by default without calling it. The [Critical paths](</docs/en/permission-modes#critical-paths>) mode table lists what each mode does with them. +Check `allow` rules (from `allowed_tools` and settings.json). If a rule matches, the tool is approved. A call the tool approves on its own is resolved at this step too, with no rule needed: for example a file read inside your working directories or a [read-only Bash command](</docs/en/permissions#read-only-commands>).`rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) are never approved by an allow rule. Whether they then reach your callback depends on the permission mode: in an Agent SDK session in `auto` mode, for example, Claude Code denies them by default without calling it. The [Critical paths](</docs/en/permission-modes#critical-paths>) mode table lists what each mode does with them.An allow rule doesn’t approve a read from a [network path](</docs/en/permissions#network-paths>). 6 @@ -52,7 +52,7 @@ If you pass a `canUseTool` callback in a configuration where the TypeScript SDK expects the evaluation order to auto-approve calls before the callback is consulted, the SDK emits a Node.js process warning once when the query is constructed. The warning’s code is `CLAUDE_SDK_CAN_USE_TOOL_SHADOWED`. Two configurations trigger it: * `permissionMode: 'bypassPermissions'`, which auto-approves every call that reaches the permission mode step apart from the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) - * Each bare `allowedTools` entry such as `"Read"`, which auto-approves that whole tool before the callback is consulted, apart from the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) + * Each bare `allowedTools` entry such as `"Read"`, which auto-approves that whole tool before the callback is consulted, apart from the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) and [reads from network paths](</docs/en/permissions#network-paths>) Entries with a specifier such as `Bash(ls *)` and the `acceptEdits` mode don’t trigger it, and allow rules coming from settings files aren’t visible to the check. Listen with `process.on('warning', ...)` and match the code to log or suppress it. To gate every tool call regardless of mode and rules, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>) instead. This page focuses on **allow and deny rules** and **permission modes**. For the other steps: @@ -69,14 +69,14 @@ Option| Effect ---|--- -`allowed_tools=["Read", "Grep"]`| `Read` and `Grep` are auto-approved. Other tools not listed here still exist, and calls to them that need approval fall through to the permission mode and `canUseTool`. +`allowed_tools=["Read", "Grep"]`| `Read` and `Grep` are auto-approved, apart from [reads from network paths](</docs/en/permissions#network-paths>). Other tools not listed here still exist, and calls to them that need approval fall through to the permission mode and `canUseTool`. `disallowed_tools=["Bash"]`| The `Bash` tool definition is removed from the request. Claude does not see the tool and cannot attempt it. `disallowed_tools=["Bash(rm *)"]`| `Bash` stays available. Calls matching `rm *` [as written](</docs/en/permissions#bash-rule-limits>) are denied in every permission mode, including `bypassPermissions`. Other `Bash` calls, including `/bin/rm`, fall through to the permission mode. `disallowed_tools=["*"]`| Every tool definition is removed from the request. Tool-name globs are supported in deny rules: `"*"` matches every tool and `"mcp__*"` matches every MCP tool across all servers. Allow rules accept tool-name globs only after a literal `mcp__<server>__` prefix. The server segment must be glob-free so the rule names a specific server you configured: `mcp__puppeteer__*` matches every tool from the `puppeteer` server, and `mcp__github__get_*` matches its `get_` tools. An unanchored entry like `allowed_tools=["*"]` or `allowed_tools=["mcp__*"]` is ignored with a startup warning and does not auto-approve anything. Scoped rules for `Read` and `Edit` take a path pattern. `Edit(path)` rules govern all built-in tools that write files, including `Write` and `NotebookEdit`; a `Write(path)` rule is never matched by the file permission checks. Use `//path` for an absolute filesystem path: a deny rule of `Edit(//secrets/**)` blocks writes anywhere under `/secrets` on disk. With a single leading slash, `Edit(/secrets/**)` anchors at the rule’s source instead. For rules passed through `allowed_tools` or `disallowed_tools`, that means the session’s working directory, so the rule doesn’t block `/secrets` on disk. See [Read and Edit rules](</docs/en/permissions#read-and-edit>) for the four anchor forms and how rules from settings files resolve. -**Auto-approved tools never reach`canUseTool`.** A tool call approved at any earlier step, by `acceptEdits` or `bypassPermissions`, or by an allow rule, skips your `canUseTool` callback, so permission checks you put there are silently bypassed for that tool.An allow rule never auto-approves `AskUserQuestion`, MCP tools marked [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>), connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), or `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>). In `dontAsk` mode Claude Code denies these calls without invoking the callback. In other modes the first three reach the callback. Depending on the [permission mode](</docs/en/permission-modes#critical-paths>), a critical-path removal reaches the callback too or Claude Code denies it without calling it, as it does by default for an Agent SDK session in `auto` mode.Coverage depends on the entry’s form: a bare name like `Read` or `mcp__github__get_issue` auto-approves every call to that tool apart from the exceptions above, while a scoped rule like `Bash(npm test *)` auto-approves only matching calls, and other `Bash` calls that need approval still fall through to the callback. For checks that must run on every tool call, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>): hooks run before every other step, and a hook deny applies even in `bypassPermissions` mode. +**Auto-approved tools never reach`canUseTool`.** A tool call approved at any earlier step, by `acceptEdits` or `bypassPermissions`, or by an allow rule, skips your `canUseTool` callback, so permission checks you put there are silently bypassed for that tool.An allow rule never auto-approves `AskUserQuestion`, MCP tools marked [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>), connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), or `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>). In `dontAsk` mode Claude Code denies these calls without invoking the callback. In other modes the first three reach the callback. Depending on the [permission mode](</docs/en/permission-modes#critical-paths>), a critical-path removal reaches the callback too or Claude Code denies it without calling it, as it does by default for an Agent SDK session in `auto` mode.Coverage depends on the entry’s form: a bare name like `Read` or `mcp__github__get_issue` auto-approves every call to that tool apart from those exceptions and [reads from network paths](</docs/en/permissions#network-paths>), while a scoped rule like `Bash(npm test *)` auto-approves only matching calls, and other `Bash` calls that need approval still fall through to the callback. For checks that must run on every tool call, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>): hooks run before every other step, and a hook deny applies even in `bypassPermissions` mode. For a locked-down agent, pair `allowedTools` with `permissionMode: "dontAsk"`: @@ -85,7 +85,7 @@ permissionMode: "dontAsk" }; -Listed tools are approved, apart from the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>), and every other call that would prompt is denied instead. Calls that need no approval in `default` mode run whether or not you list them, such as [read-only Bash commands](</docs/en/permissions#read-only-commands>), tools like `Agent` that don’t ask before running, and file reads inside your working directories. To put a tool out of Claude’s reach entirely, add its bare name to `disallowedTools`. +Listed tools are approved, apart from the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) and [reads from network paths](</docs/en/permissions#network-paths>), and every other call that would prompt is denied instead. Calls that need no approval in `default` mode run whether or not you list them, such as [read-only Bash commands](</docs/en/permissions#read-only-commands>), tools like `Agent` that don’t ask before running, and file reads inside your working directories. To remove a tool from the request entirely, add its bare name to `disallowedTools`. **`allowed_tools` does not constrain `bypassPermissions`.** `allowed_tools` pre-approves the tools you list. Other unlisted tools are not matched by any allow rule and fall through to the permission mode, where `bypassPermissions` approves them. Setting `allowed_tools=["Read"]` alongside `permission_mode="bypassPermissions"` still approves every tool, including `Bash`, `Write`, and `Edit`. If you need `bypassPermissions` but want specific tools blocked, use `disallowed_tools`. @@ -115,7 +115,7 @@ Mode| Description| Tool behavior ---|---|--- `default`| Standard permission behavior| No mode-based auto-approvals; calls that need approval and match no allow rule trigger your `canUseTool` callback -`dontAsk`| Deny instead of prompting| Any call that would otherwise prompt is denied. Calls approved by `allowed_tools` or rules run, and so do calls that need no approval in `default` mode; connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) and tools that require user interaction are denied even if you’ve pre-approved them, as are `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>). `canUseTool` is never called +`dontAsk`| Deny instead of prompting| Any call that would otherwise prompt is denied. Calls approved by `allowed_tools` or rules run, and so do calls that need no approval in `default` mode; connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) and tools that require user interaction are denied even if you’ve pre-approved them, as are [reads from network paths](</docs/en/permissions#network-paths>) and `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>). `canUseTool` is never called `acceptEdits`| Auto-accept file edits| File edits and filesystem operations (`mkdir`, `rm`, `mv`, etc.) are automatically approved `bypassPermissions`| Bypass permission checks| Tools run without permission prompts, except for the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>). Use with caution `plan`| Planning mode| Claude explores and plans without editing your source files; file edits are never auto-approved and prompt through your `canUseTool` callback @@ -254,7 +254,7 @@ Don’t ask mode (`dontAsk`) -Converts any permission prompt into a denial, without calling `canUseTool`. Tools pre-approved by `allowed_tools`, `settings.json` allow rules, or a hook run as normal, and so do calls that need no approval in `default` mode, such as file reads inside your working directories and calls to `Agent`. Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, and `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) are denied even when an allow rule matches. A `PreToolUse` hook allow doesn’t clear a critical-path removal either. **Use when:** you want a fixed, explicit tool surface for a headless agent and prefer a hard deny over silent reliance on `canUseTool` being absent. +Converts any permission prompt into a denial, without calling `canUseTool`. Tools pre-approved by `allowed_tools`, `settings.json` allow rules, or a hook run as normal, and so do calls that need no approval in `default` mode, such as file reads inside your working directories and calls to `Agent`. Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, [reads from network paths](</docs/en/permissions#network-paths>), and `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) are denied even when an allow rule matches. A `PreToolUse` hook allow doesn’t clear a critical-path removal or a read from a network path either. **Use when:** you want a fixed, explicit tool surface for a headless agent and prefer a hard deny over silent reliance on `canUseTool` being absent. ####
modified
--- a/permissions.md +++ b/permissions.md @@ -121,7 +121,7 @@ `plan`| Planning mode| Claude explores and plans without editing your source files; file edits are never auto-approved and prompt through your `canUseTool` callback `auto`| Model-classified approvals| A model classifier reviews actions such as shell commands and network requests, allowing or blocking each one it reviews. See [Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) for availability and the decision order -**Subagent inheritance:** A subagent runs in the parent session’s permission mode unless you set `permissionMode` on its [`AgentDefinition`](</docs/en/agent-sdk/typescript#agentdefinition>) and the parent session is in `default`, `dontAsk`, or `plan` mode. Even then, Claude Code never applies a `"bypassPermissions"` value. A subagent runs in `bypassPermissions` mode only when the parent session itself does. The `bypassPermissions` exception requires Claude Code v2.1.267 or later.Subagents may have different system prompts and less constrained behavior than your main agent, so inheriting `bypassPermissions` grants them full, autonomous system access. The [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) still apply. +**Subagent inheritance:** A subagent runs in the parent session’s permission mode unless you set `permissionMode` on its [`AgentDefinition`](</docs/en/agent-sdk/typescript#agentdefinition>) and the parent session is in `default`, `dontAsk`, or `plan` mode. Even then, Claude Code never applies a `"bypassPermissions"` value, and applies an `"auto"` value only when [auto mode is available](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) to that subagent. A subagent runs in `bypassPermissions` mode only when the parent session itself does. The `bypassPermissions` exception requires Claude Code v2.1.267 or later.Subagents may have different system prompts and less constrained behavior than your main agent, so inheriting `bypassPermissions` grants them full, autonomous system access. The [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) still apply. ###
modified
--- a/permissions.md +++ b/permissions.md @@ -97,7 +97,12 @@ Permission modes -Permission modes provide global control over how Claude uses tools. You can set the permission mode when calling `query()` or change it dynamically during streaming sessions. +Permission modes provide global control over how Claude uses tools. You can set the permission mode when calling `query()` or change it dynamically during streaming sessions. If you don’t set one, Claude Code picks the starting permission mode by the rules in [Which mode a session starts in](</docs/en/permission-modes#which-mode-a-session-starts-in>): + + * A `permissions.defaultMode` from the session’s [settings files](</docs/en/settings#where-settings-live>) when one applies + * Otherwise the built-in default, which can be [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) + +A session that starts in auto mode drops broad allow rules such as a bare `Bash` entry, as [How auto mode evaluates actions](</docs/en/permission-modes#how-auto-mode-evaluates-actions>) describes. If your application relies on the `default` mode or on such a rule, pass `default` explicitly. Before TypeScript Agent SDK v0.3.286, omitting `permissionMode` was the same as passing `default`. ### @@ -114,7 +119,7 @@ `acceptEdits`| Auto-accept file edits| File edits and filesystem operations (`mkdir`, `rm`, `mv`, etc.) are automatically approved `bypassPermissions`| Bypass permission checks| Tools run without permission prompts, except for the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>). Use with caution `plan`| Planning mode| Claude explores and plans without editing your source files; file edits are never auto-approved and prompt through your `canUseTool` callback -`auto`| Model-classified approvals| A model classifier approves or denies permission prompts. See [Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) for availability +`auto`| Model-classified approvals| A model classifier reviews actions such as shell commands and network requests, allowing or blocking each one it reviews. See [Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) for availability and the decision order **Subagent inheritance:** A subagent runs in the parent session’s permission mode unless you set `permissionMode` on its [`AgentDefinition`](</docs/en/agent-sdk/typescript#agentdefinition>) and the parent session is in `default`, `dontAsk`, or `plan` mode. Even then, Claude Code never applies a `"bypassPermissions"` value. A subagent runs in `bypassPermissions` mode only when the parent session itself does. The `bypassPermissions` exception requires Claude Code v2.1.267 or later.Subagents may have different system prompts and less constrained behavior than your main agent, so inheriting `bypassPermissions` grants them full, autonomous system access. The [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) still apply.
modified
--- a/permissions.md +++ b/permissions.md @@ -271,7 +271,7 @@ Plan mode (`plan`) -Claude explores the codebase and produces a plan without editing your source files. Read-only tools run as they do in the `default` permission mode. File edits are never auto-approved in plan mode, even when an allow rule matches. They prompt through your `canUseTool` callback instead. On Claude Code v2.1.212 or later, shell commands that modify files, such as `touch` and `rm`, reach your `canUseTool` callback the same way. If you set `allowDangerouslySkipPermissions: true` alongside `permissionMode: 'plan'`, file edits and shell commands that modify files still reach your `canUseTool` callback. The option lets you switch to `bypassPermissions` later with `setPermissionMode()`. Claude may use `AskUserQuestion` to clarify requirements before finalizing the plan. See [Handle approvals and user input](</docs/en/agent-sdk/user-input#handle-clarifying-questions>) for handling these prompts. **Use when:** you want Claude to propose changes without executing them, such as during code review or when you need to approve changes before they’re made. +Claude explores the codebase and produces a plan without editing your source files. Read-only tools run as they do in the `default` permission mode. File edits are never auto-approved in plan mode, even when an allow rule matches. They prompt through your `canUseTool` callback instead. On Claude Code v2.1.212 or later, shell commands that modify files, such as `touch` and `rm`, reach your `canUseTool` callback the same way. In the TypeScript SDK, if you set `allowDangerouslySkipPermissions: true` alongside `permissionMode: 'plan'`, file edits and shell commands that modify files still reach your `canUseTool` callback. The option lets you switch to `bypassPermissions` later with `setPermissionMode()`. Claude may use `AskUserQuestion` to clarify requirements before finalizing the plan. See [Handle approvals and user input](</docs/en/agent-sdk/user-input#handle-clarifying-questions>) for handling these prompts. **Use when:** you want Claude to propose changes without executing them, such as during code review or when you need to approve changes before they’re made. ##
modified
--- a/permissions.md +++ b/permissions.md @@ -41,7 +41,7 @@ Allow rules -Check `allow` rules (from `allowed_tools` and settings.json). If a rule matches, the tool is approved. A call the tool approves on its own is resolved at this step too, with no rule needed: for example a file read inside your working directories or a [read-only Bash command](</docs/en/permissions#read-only-commands>). `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) are never approved by an allow rule: they reach your callback in the modes that prompt, go to the [classifier](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) in `auto` mode on Claude Code v2.1.218 or later, and are denied in `dontAsk` mode. +Check `allow` rules (from `allowed_tools` and settings.json). If a rule matches, the tool is approved. A call the tool approves on its own is resolved at this step too, with no rule needed: for example a file read inside your working directories or a [read-only Bash command](</docs/en/permissions#read-only-commands>).`rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) are never approved by an allow rule. Whether they then reach your callback depends on the permission mode: in an Agent SDK session in `auto` mode, for example, Claude Code denies them by default without calling it. The [Critical paths](</docs/en/permission-modes#critical-paths>) mode table lists what each mode does with them. 6 @@ -76,7 +76,7 @@ Allow rules accept tool-name globs only after a literal `mcp__<server>__` prefix. The server segment must be glob-free so the rule names a specific server you configured: `mcp__puppeteer__*` matches every tool from the `puppeteer` server, and `mcp__github__get_*` matches its `get_` tools. An unanchored entry like `allowed_tools=["*"]` or `allowed_tools=["mcp__*"]` is ignored with a startup warning and does not auto-approve anything. Scoped rules for `Read` and `Edit` take a path pattern. `Edit(path)` rules govern all built-in tools that write files, including `Write` and `NotebookEdit`; a `Write(path)` rule is never matched by the file permission checks. Use `//path` for an absolute filesystem path: a deny rule of `Edit(//secrets/**)` blocks writes anywhere under `/secrets` on disk. With a single leading slash, `Edit(/secrets/**)` anchors at the rule’s source instead. For rules passed through `allowed_tools` or `disallowed_tools`, that means the session’s working directory, so the rule doesn’t block `/secrets` on disk. See [Read and Edit rules](</docs/en/permissions#read-and-edit>) for the four anchor forms and how rules from settings files resolve. -**Auto-approved tools never reach`canUseTool`.** A tool call approved at any earlier step, by `acceptEdits` or `bypassPermissions`, or by an allow rule, skips your `canUseTool` callback, so permission checks you put there are silently bypassed for that tool. `AskUserQuestion`, MCP tools marked [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>), connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) still reach the callback, even when an allow rule matches. In `auto` mode, critical-path removals go to the [classifier](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) instead of the callback, while the other calls listed here still reach it; the classifier routing requires Claude Code v2.1.218 or later. In `dontAsk` mode these calls are denied instead, without invoking the callback.Coverage depends on the entry’s form: a bare name like `Read` or `mcp__github__get_issue` auto-approves every call to that tool apart from the exceptions above, while a scoped rule like `Bash(npm test *)` auto-approves only matching calls, and other `Bash` calls that need approval still fall through to the callback. For checks that must run on every tool call, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>): hooks run before every other step, and a hook deny applies even in `bypassPermissions` mode. +**Auto-approved tools never reach`canUseTool`.** A tool call approved at any earlier step, by `acceptEdits` or `bypassPermissions`, or by an allow rule, skips your `canUseTool` callback, so permission checks you put there are silently bypassed for that tool.An allow rule never auto-approves `AskUserQuestion`, MCP tools marked [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>), connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), or `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>). In `dontAsk` mode Claude Code denies these calls without invoking the callback. In other modes the first three reach the callback. Depending on the [permission mode](</docs/en/permission-modes#critical-paths>), a critical-path removal reaches the callback too or Claude Code denies it without calling it, as it does by default for an Agent SDK session in `auto` mode.Coverage depends on the entry’s form: a bare name like `Read` or `mcp__github__get_issue` auto-approves every call to that tool apart from the exceptions above, while a scoped rule like `Bash(npm test *)` auto-approves only matching calls, and other `Bash` calls that need approval still fall through to the callback. For checks that must run on every tool call, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>): hooks run before every other step, and a hook deny applies even in `bypassPermissions` mode. For a locked-down agent, pair `allowedTools` with `permissionMode: "dontAsk"`:
modified
--- a/permissions.md +++ b/permissions.md @@ -257,7 +257,7 @@ Bypass permissions mode (`bypassPermissions`) -Auto-approves tool uses without prompting, except the cases listed in the warning below. Hooks still execute and can block operations if needed. +Auto-approves tool uses without prompting, except the cases listed in the warning below. Hooks still execute and can block operations if needed. On Linux and macOS, Claude Code refuses to start in this mode as root or under `sudo` outside a [recognized sandbox](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>), and the query fails before the first turn. Use with extreme caution. Claude has full system access in this mode. Only use in controlled environments where you trust all possible operations.`allowed_tools` does not constrain this mode. Every tool is approved, not just the ones you listed. These controls still apply:
modified
--- a/permissions.md +++ b/permissions.md @@ -271,7 +271,7 @@ Plan mode (`plan`) -Claude explores the codebase and produces a plan without editing your source files. Read-only tools run as they do in the `default` permission mode. File edits are never auto-approved in plan mode, even when an allow rule matches. They prompt through your `canUseTool` callback instead. On Claude Code v2.1.212 or later, shell commands that modify files, such as `touch` and `rm`, reach your `canUseTool` callback the same way. Claude may use `AskUserQuestion` to clarify requirements before finalizing the plan. See [Handle approvals and user input](</docs/en/agent-sdk/user-input#handle-clarifying-questions>) for handling these prompts. **Use when:** you want Claude to propose changes without executing them, such as during code review or when you need to approve changes before they’re made. +Claude explores the codebase and produces a plan without editing your source files. Read-only tools run as they do in the `default` permission mode. File edits are never auto-approved in plan mode, even when an allow rule matches. They prompt through your `canUseTool` callback instead. On Claude Code v2.1.212 or later, shell commands that modify files, such as `touch` and `rm`, reach your `canUseTool` callback the same way. If you set `allowDangerouslySkipPermissions: true` alongside `permissionMode: 'plan'`, file edits and shell commands that modify files still reach your `canUseTool` callback. The option lets you switch to `bypassPermissions` later with `setPermissionMode()`. Claude may use `AskUserQuestion` to clarify requirements before finalizing the plan. See [Handle approvals and user input](</docs/en/agent-sdk/user-input#handle-clarifying-questions>) for handling these prompts. **Use when:** you want Claude to propose changes without executing them, such as during code review or when you need to approve changes before they’re made. ##
modified
--- a/permissions.md +++ b/permissions.md @@ -41,7 +41,7 @@ Allow rules -Check `allow` rules (from `allowed_tools` and settings.json). If a rule matches, the tool is approved. `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) are never approved by an allow rule: they reach your callback in the modes that prompt, go to the [classifier](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) in `auto` mode on Claude Code v2.1.218 or later, and are denied in `dontAsk` mode. +Check `allow` rules (from `allowed_tools` and settings.json). If a rule matches, the tool is approved. A call the tool approves on its own is resolved at this step too, with no rule needed: for example a file read inside your working directories or a [read-only Bash command](</docs/en/permissions#read-only-commands>). `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) are never approved by an allow rule: they reach your callback in the modes that prompt, go to the [classifier](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) in `auto` mode on Claude Code v2.1.218 or later, and are denied in `dontAsk` mode. 6 @@ -65,26 +65,28 @@ Allow and deny rules -`allowed_tools` and `disallowed_tools` (TypeScript: `allowedTools` / `disallowedTools`) add entries to the allow and deny rule lists in the evaluation flow above. If you name one of the [task-tracking tools](</docs/en/agent-sdk/todo-tracking#model-availability>) in `allowed_tools`, Claude Code also opts the session in. Any other tool not listed in `allowed_tools` is still available to Claude and falls through to the permission mode. Deny rules behave differently depending on whether they name a tool or scope a pattern within one. +`allowed_tools` and `disallowed_tools` (TypeScript: `allowedTools` / `disallowedTools`) add entries to the allow and deny rule lists in the evaluation flow above. If you name one of the [task-tracking tools](</docs/en/agent-sdk/todo-tracking#model-availability>) in `allowed_tools`, Claude Code also opts the session in. Any other tool not listed in `allowed_tools` is still available to Claude, and a call to it that needs approval falls through to the permission mode. Deny rules behave differently depending on whether they name a tool or scope a pattern within one. Option| Effect ---|--- -`allowed_tools=["Read", "Grep"]`| `Read` and `Grep` are auto-approved. Other tools not listed here still exist and fall through to the permission mode and `canUseTool`. +`allowed_tools=["Read", "Grep"]`| `Read` and `Grep` are auto-approved. Other tools not listed here still exist, and calls to them that need approval fall through to the permission mode and `canUseTool`. `disallowed_tools=["Bash"]`| The `Bash` tool definition is removed from the request. Claude does not see the tool and cannot attempt it. `disallowed_tools=["Bash(rm *)"]`| `Bash` stays available. Calls matching `rm *` [as written](</docs/en/permissions#bash-rule-limits>) are denied in every permission mode, including `bypassPermissions`. Other `Bash` calls, including `/bin/rm`, fall through to the permission mode. `disallowed_tools=["*"]`| Every tool definition is removed from the request. Tool-name globs are supported in deny rules: `"*"` matches every tool and `"mcp__*"` matches every MCP tool across all servers. Allow rules accept tool-name globs only after a literal `mcp__<server>__` prefix. The server segment must be glob-free so the rule names a specific server you configured: `mcp__puppeteer__*` matches every tool from the `puppeteer` server, and `mcp__github__get_*` matches its `get_` tools. An unanchored entry like `allowed_tools=["*"]` or `allowed_tools=["mcp__*"]` is ignored with a startup warning and does not auto-approve anything. Scoped rules for `Read` and `Edit` take a path pattern. `Edit(path)` rules govern all built-in tools that write files, including `Write` and `NotebookEdit`; a `Write(path)` rule is never matched by the file permission checks. Use `//path` for an absolute filesystem path: a deny rule of `Edit(//secrets/**)` blocks writes anywhere under `/secrets` on disk. With a single leading slash, `Edit(/secrets/**)` anchors at the rule’s source instead. For rules passed through `allowed_tools` or `disallowed_tools`, that means the session’s working directory, so the rule doesn’t block `/secrets` on disk. See [Read and Edit rules](</docs/en/permissions#read-and-edit>) for the four anchor forms and how rules from settings files resolve. -**Auto-approved tools never reach`canUseTool`.** A tool call approved at any earlier step, by `acceptEdits` or `bypassPermissions`, or by an allow rule, skips your `canUseTool` callback, so permission checks you put there are silently bypassed for that tool. `AskUserQuestion`, MCP tools marked [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>), connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) still reach the callback, even when an allow rule matches. In `auto` mode, critical-path removals go to the [classifier](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) instead of the callback, while the other calls listed here still reach it; the classifier routing requires Claude Code v2.1.218 or later. In `dontAsk` mode these calls are denied instead, without invoking the callback.Coverage depends on the entry’s form: a bare name like `Read` or `mcp__github__get_issue` auto-approves every call to that tool apart from the exceptions above, while a scoped rule like `Bash(ls *)` auto-approves only matching calls and other `Bash` calls still fall through to the callback. For checks that must run on every tool call, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>): hooks run before every other step, and a hook deny applies even in `bypassPermissions` mode. - -For a locked-down agent, pair `allowedTools` with `permissionMode: "dontAsk"`. Listed tools are approved, apart from the always-prompt tools in the Warning above; anything else is denied outright instead of prompting: +**Auto-approved tools never reach`canUseTool`.** A tool call approved at any earlier step, by `acceptEdits` or `bypassPermissions`, or by an allow rule, skips your `canUseTool` callback, so permission checks you put there are silently bypassed for that tool. `AskUserQuestion`, MCP tools marked [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>), connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) still reach the callback, even when an allow rule matches. In `auto` mode, critical-path removals go to the [classifier](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) instead of the callback, while the other calls listed here still reach it; the classifier routing requires Claude Code v2.1.218 or later. In `dontAsk` mode these calls are denied instead, without invoking the callback.Coverage depends on the entry’s form: a bare name like `Read` or `mcp__github__get_issue` auto-approves every call to that tool apart from the exceptions above, while a scoped rule like `Bash(npm test *)` auto-approves only matching calls, and other `Bash` calls that need approval still fall through to the callback. For checks that must run on every tool call, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>): hooks run before every other step, and a hook deny applies even in `bypassPermissions` mode. + +For a locked-down agent, pair `allowedTools` with `permissionMode: "dontAsk"`: const options = { allowedTools: ["Read", "Glob", "Grep"], permissionMode: "dontAsk" }; +Listed tools are approved, apart from the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>), and every other call that would prompt is denied instead. Calls that need no approval in `default` mode run whether or not you list them, such as [read-only Bash commands](</docs/en/permissions#read-only-commands>), tools like `Agent` that don’t ask before running, and file reads inside your working directories. To put a tool out of Claude’s reach entirely, add its bare name to `disallowedTools`. + **`allowed_tools` does not constrain `bypassPermissions`.** `allowed_tools` pre-approves the tools you list. Other unlisted tools are not matched by any allow rule and fall through to the permission mode, where `bypassPermissions` approves them. Setting `allowed_tools=["Read"]` alongside `permission_mode="bypassPermissions"` still approves every tool, including `Bash`, `Write`, and `Edit`. If you need `bypassPermissions` but want specific tools blocked, use `disallowed_tools`. You can also configure allow, deny, and ask rules declaratively in `.claude/settings.json`. These rules are read when the `project` setting source is enabled, which it is for default `query()` options. If you set `setting_sources` (TypeScript: `settingSources`) explicitly, include `"project"` for them to apply. See [Permission settings](</docs/en/settings-reference#permission-settings>) for the rule syntax. @@ -107,8 +109,8 @@ Mode| Description| Tool behavior ---|---|--- -`default`| Standard permission behavior| No auto-approvals; unmatched tools trigger your `canUseTool` callback -`dontAsk`| Deny instead of prompting| Anything not pre-approved by `allowed_tools` or rules is denied; connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) and tools that require user interaction are denied even if you’ve pre-approved them, as are `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>). `canUseTool` is never called +`default`| Standard permission behavior| No mode-based auto-approvals; calls that need approval and match no allow rule trigger your `canUseTool` callback +`dontAsk`| Deny instead of prompting| Any call that would otherwise prompt is denied. Calls approved by `allowed_tools` or rules run, and so do calls that need no approval in `default` mode; connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) and tools that require user interaction are denied even if you’ve pre-approved them, as are `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>). `canUseTool` is never called `acceptEdits`| Auto-accept file edits| File edits and filesystem operations (`mkdir`, `rm`, `mv`, etc.) are automatically approved `bypassPermissions`| Bypass permission checks| Tools run without permission prompts, except for the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>). Use with caution `plan`| Planning mode| Claude explores and plans without editing your source files; file edits are never auto-approved and prompt through your `canUseTool` callback @@ -247,7 +249,7 @@ Don’t ask mode (`dontAsk`) -Converts any permission prompt into a denial. Tools pre-approved by `allowed_tools`, `settings.json` allow rules, or a hook run as normal. Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, and `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) are denied even when an allow rule matches. A `PreToolUse` hook allow doesn’t clear a critical-path removal either. Everything else is denied without calling `canUseTool`. **Use when:** you want a fixed, explicit tool surface for a headless agent and prefer a hard deny over silent reliance on `canUseTool` being absent. +Converts any permission prompt into a denial, without calling `canUseTool`. Tools pre-approved by `allowed_tools`, `settings.json` allow rules, or a hook run as normal, and so do calls that need no approval in `default` mode, such as file reads inside your working directories and calls to `Agent`. Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, and `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) are denied even when an allow rule matches. A `PreToolUse` hook allow doesn’t clear a critical-path removal either. **Use when:** you want a fixed, explicit tool surface for a headless agent and prefer a hard deny over silent reliance on `canUseTool` being absent. ####
modified
--- a/permissions.md +++ b/permissions.md @@ -30,7 +30,12 @@ Permission mode -Apply the active permission mode. `bypassPermissions` approves everything that reaches this step except `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>), which fall through instead. `acceptEdits` approves the file operations listed under Accept edits mode. `plan` routes file-edit and shell-write tools to your `canUseTool` callback regardless of allow rules, so write operations cannot be auto-approved while planning. Other modes fall through. +Apply the active permission mode: + + * In `bypassPermissions` mode, Claude Code approves everything that reaches this step except `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>), which fall through instead. + * In `acceptEdits` mode, Claude Code approves the file operations listed under Accept edits mode. + * In `plan` mode, Claude Code sends file-edit and shell-write tools to your `canUseTool` callback regardless of allow rules, so write operations can’t be auto-approved while planning. + * In other modes, the request falls through. 5 @@ -66,7 +71,7 @@ ---|--- `allowed_tools=["Read", "Grep"]`| `Read` and `Grep` are auto-approved. Other tools not listed here still exist and fall through to the permission mode and `canUseTool`. `disallowed_tools=["Bash"]`| The `Bash` tool definition is removed from the request. Claude does not see the tool and cannot attempt it. -`disallowed_tools=["Bash(rm *)"]`| `Bash` stays available. Calls matching `rm *` are denied in every permission mode, including `bypassPermissions`. Other `Bash` calls fall through to the permission mode. +`disallowed_tools=["Bash(rm *)"]`| `Bash` stays available. Calls matching `rm *` [as written](</docs/en/permissions#bash-rule-limits>) are denied in every permission mode, including `bypassPermissions`. Other `Bash` calls, including `/bin/rm`, fall through to the permission mode. `disallowed_tools=["*"]`| Every tool definition is removed from the request. Tool-name globs are supported in deny rules: `"*"` matches every tool and `"mcp__*"` matches every MCP tool across all servers. Allow rules accept tool-name globs only after a literal `mcp__<server>__` prefix. The server segment must be glob-free so the rule names a specific server you configured: `mcp__puppeteer__*` matches every tool from the `puppeteer` server, and `mcp__github__get_*` matches its `get_` tools. An unanchored entry like `allowed_tools=["*"]` or `allowed_tools=["mcp__*"]` is ignored with a startup warning and does not auto-approve anything. Scoped rules for `Read` and `Edit` take a path pattern. `Edit(path)` rules govern all built-in tools that write files, including `Write` and `NotebookEdit`; a `Write(path)` rule is never matched by the file permission checks. Use `//path` for an absolute filesystem path: a deny rule of `Edit(//secrets/**)` blocks writes anywhere under `/secrets` on disk. With a single leading slash, `Edit(/secrets/**)` anchors at the rule’s source instead. For rules passed through `allowed_tools` or `disallowed_tools`, that means the session’s working directory, so the rule doesn’t block `/secrets` on disk. See [Read and Edit rules](</docs/en/permissions#read-and-edit>) for the four anchor forms and how rules from settings files resolve. @@ -109,7 +114,7 @@ `plan`| Planning mode| Claude explores and plans without editing your source files; file edits are never auto-approved and prompt through your `canUseTool` callback `auto`| Model-classified approvals| A model classifier approves or denies permission prompts. See [Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) for availability -**Subagent inheritance:** Subagents inherit the parent session’s permission mode. An [`AgentDefinition`’s `permissionMode`](</docs/en/agent-sdk/typescript#agentdefinition>) can override it, except when the parent uses `bypassPermissions`, `acceptEdits`, or `auto`: those modes apply to every subagent and can’t be overridden per subagent. Claude Code also ignores a definition’s `permissionMode: "bypassPermissions"` when bypass mode is disabled by [`permissions.disableBypassPermissionsMode`](</docs/en/permissions#managed-settings>), so that subagent runs with the parent session’s mode.Subagents may have different system prompts and less constrained behavior than your main agent, so inheriting `bypassPermissions` grants them full, autonomous system access. The [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) still apply. +**Subagent inheritance:** A subagent runs in the parent session’s permission mode unless you set `permissionMode` on its [`AgentDefinition`](</docs/en/agent-sdk/typescript#agentdefinition>) and the parent session is in `default`, `dontAsk`, or `plan` mode. Even then, Claude Code never applies a `"bypassPermissions"` value. A subagent runs in `bypassPermissions` mode only when the parent session itself does. The `bypassPermissions` exception requires Claude Code v2.1.267 or later.Subagents may have different system prompts and less constrained behavior than your main agent, so inheriting `bypassPermissions` grants them full, autonomous system access. The [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) still apply. ### @@ -228,7 +233,13 @@ * File edits (Edit, Write tools) * Filesystem commands: `mkdir`, `touch`, `rm`, `rmdir`, `mv`, `cp`, `sed` -Both apply only to paths inside the working directory or `additionalDirectories`. Paths outside that scope, writes to protected paths, and `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) still prompt. **Use when:** you trust Claude’s edits and want faster iteration, such as during prototyping or when working in an isolated directory. +Both apply only to paths inside the working directory or `additionalDirectories`. In `acceptEdits` mode, Claude Code doesn’t auto-approve the request when Claude: + + * Works on a path outside that scope + * Writes to a protected path + * Removes a [critical path](</docs/en/permission-modes#critical-paths>) with `rm` or `rmdir` + +**Use when:** you trust Claude’s edits and want faster iteration, such as during prototyping or when working in an isolated directory. ####
modified
--- a/permissions.md +++ b/permissions.md @@ -42,7 +42,7 @@ canUseTool callback -If not resolved by any of the above, call your [`canUseTool` callback](</docs/en/agent-sdk/user-input>) for a decision. In `dontAsk` mode, this step is skipped and the tool is denied. +If not resolved by any of the above, call your [`canUseTool` callback](</docs/en/agent-sdk/user-input>) for a decision. In `dontAsk` mode, this step is skipped and the tool is denied.In the TypeScript SDK, if you set [`permissionPrompts: 'none'`](</docs/en/agent-sdk/typescript#options>), your callback isn’t called at this step. A [`PermissionRequest` hook](</docs/en/hooks#permissionrequest>) still gets a chance to decide, and if it doesn’t, Claude Code denies the call. The option requires Claude Code v2.1.259 or later. If you pass a `canUseTool` callback in a configuration where the TypeScript SDK expects the evaluation order to auto-approve calls before the callback is consulted, the SDK emits a Node.js process warning once when the query is constructed. The warning’s code is `CLAUDE_SDK_CAN_USE_TOOL_SHADOWED`. Two configurations trigger it:
modified
--- a/permissions.md +++ b/permissions.md @@ -18,13 +18,13 @@ Deny rules -Check `deny` rules (from `disallowed_tools` and [settings.json](</docs/en/settings#permission-settings>)). If a deny rule matches, the tool is blocked, even in `bypassPermissions` mode. Bare-name deny rules like `Bash` remove the tool from Claude’s context before this evaluation begins, so only scoped rules like `Bash(rm *)` are checked at this step. +Check `deny` rules (from `disallowed_tools` and [settings.json](</docs/en/settings-reference#permission-settings>)). If a deny rule matches, the tool is blocked, even in `bypassPermissions` mode. Bare-name deny rules like `Bash` remove the tool from Claude’s context before this evaluation begins, so only scoped rules like `Bash(rm *)` are checked at this step. 3 Ask rules -Check `ask` rules from [settings.json](</docs/en/settings#permission-settings>). If an ask rule matches, the call falls through to your [`canUseTool` callback](</docs/en/agent-sdk/user-input>) for confirmation, even in `bypassPermissions` mode.Tools that require user interaction behave the same way: `AskUserQuestion` and MCP tools whose server sets [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>) always fall through to the callback, even when an allow rule matches. In `dontAsk` mode both cases are denied instead, because that mode never prompts. The MCP annotation requires Claude Code v2.1.199 or later.[claude.ai connector](</docs/en/mcp#organization-controls-on-connector-tools>) tools your organization has set to `ask` also leave the flow at this step. Every call falls through to the callback, even in `bypassPermissions` mode and even when an allow rule matches. The callback receives the reason `Your organization requires approval for this tool`. In `dontAsk` mode the call is denied instead, because that mode never prompts. +Check `ask` rules from [settings.json](</docs/en/settings-reference#permission-settings>). If an ask rule matches, the call falls through to your [`canUseTool` callback](</docs/en/agent-sdk/user-input>) for confirmation, even in `bypassPermissions` mode.Tools that require user interaction behave the same way: `AskUserQuestion` and MCP tools whose server sets [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>) always fall through to the callback, even when an allow rule matches. In `dontAsk` mode both cases are denied instead, because that mode never prompts. The MCP annotation requires Claude Code v2.1.199 or later.[claude.ai connector](</docs/en/mcp#organization-controls-on-connector-tools>) tools your organization has set to `ask` also leave the flow at this step. Every call falls through to the callback, even in `bypassPermissions` mode and even when an allow rule matches. The callback receives the reason `Your organization requires approval for this tool`. In `dontAsk` mode the call is denied instead, because that mode never prompts. 4 @@ -82,7 +82,7 @@ **`allowed_tools` does not constrain `bypassPermissions`.** `allowed_tools` pre-approves the tools you list. Other unlisted tools are not matched by any allow rule and fall through to the permission mode, where `bypassPermissions` approves them. Setting `allowed_tools=["Read"]` alongside `permission_mode="bypassPermissions"` still approves every tool, including `Bash`, `Write`, and `Edit`. If you need `bypassPermissions` but want specific tools blocked, use `disallowed_tools`. -You can also configure allow, deny, and ask rules declaratively in `.claude/settings.json`. These rules are read when the `project` setting source is enabled, which it is for default `query()` options. If you set `setting_sources` (TypeScript: `settingSources`) explicitly, include `"project"` for them to apply. See [Permission settings](</docs/en/settings#permission-settings>) for the rule syntax. +You can also configure allow, deny, and ask rules declaratively in `.claude/settings.json`. These rules are read when the `project` setting source is enabled, which it is for default `query()` options. If you set `setting_sources` (TypeScript: `settingSources`) explicitly, include `"project"` for them to apply. See [Permission settings](</docs/en/settings-reference#permission-settings>) for the rule syntax. ## @@ -270,4 +270,4 @@ * [Handle approvals and user input](</docs/en/agent-sdk/user-input>): interactive approval prompts and clarifying questions * [Hooks guide](</docs/en/agent-sdk/hooks>): run custom code at key points in the agent lifecycle - * [Permission rules](</docs/en/settings#permission-settings>): declarative allow/deny rules in `settings.json` + * [Permission rules](</docs/en/settings-reference#permission-settings>): declarative allow/deny rules in `settings.json`
modified
--- a/permissions.md +++ b/permissions.md @@ -12,7 +12,7 @@ Hooks -Run [hooks](</docs/en/agent-sdk/hooks>) first. A hook can deny the call outright or pass it on. A hook that returns `allow` does not skip the deny and ask rules below; those are evaluated regardless of the hook result. +Run [hooks](</docs/en/agent-sdk/hooks>) first. A hook can deny the call outright or pass it on. A hook that returns `allow` does not skip the deny and ask rules below; those are evaluated regardless of the hook result. A `PreToolUse` hook allow also can’t approve an `rm` or `rmdir` removal targeting a [critical path](</docs/en/permission-modes#critical-paths>). 2 @@ -30,13 +30,13 @@ Permission mode -Apply the active permission mode. `bypassPermissions` approves everything that reaches this step. `acceptEdits` approves file operations. `plan` routes file-edit and shell-write tools to your `canUseTool` callback regardless of allow rules, so write operations cannot be auto-approved while planning. Other modes fall through. +Apply the active permission mode. `bypassPermissions` approves everything that reaches this step except `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>), which fall through instead. `acceptEdits` approves the file operations listed under Accept edits mode. `plan` routes file-edit and shell-write tools to your `canUseTool` callback regardless of allow rules, so write operations cannot be auto-approved while planning. Other modes fall through. 5 Allow rules -Check `allow` rules (from `allowed_tools` and settings.json). If a rule matches, the tool is approved. +Check `allow` rules (from `allowed_tools` and settings.json). If a rule matches, the tool is approved. `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) are never approved by an allow rule: they reach your callback in the modes that prompt, go to the [classifier](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) in `auto` mode on Claude Code v2.1.218 or later, and are denied in `dontAsk` mode. 6 @@ -44,10 +44,10 @@ If not resolved by any of the above, call your [`canUseTool` callback](</docs/en/agent-sdk/user-input>) for a decision. In `dontAsk` mode, this step is skipped and the tool is denied. -If you pass a `canUseTool` callback that this evaluation order can never reach, the TypeScript SDK emits a Node.js process warning once when the query is constructed. The warning’s code is `CLAUDE_SDK_CAN_USE_TOOL_SHADOWED`. Two configurations trigger it: - - * `permissionMode: 'bypassPermissions'`, which auto-approves every call that reaches the permission mode step - * Each bare `allowedTools` entry such as `"Read"`, which auto-approves that whole tool before the callback is consulted +If you pass a `canUseTool` callback in a configuration where the TypeScript SDK expects the evaluation order to auto-approve calls before the callback is consulted, the SDK emits a Node.js process warning once when the query is constructed. The warning’s code is `CLAUDE_SDK_CAN_USE_TOOL_SHADOWED`. Two configurations trigger it: + + * `permissionMode: 'bypassPermissions'`, which auto-approves every call that reaches the permission mode step apart from the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) + * Each bare `allowedTools` entry such as `"Read"`, which auto-approves that whole tool before the callback is consulted, apart from the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) Entries with a specifier such as `Bash(ls *)` and the `acceptEdits` mode don’t trigger it, and allow rules coming from settings files aren’t visible to the check. Listen with `process.on('warning', ...)` and match the code to log or suppress it. To gate every tool call regardless of mode and rules, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>) instead. This page focuses on **allow and deny rules** and **permission modes**. For the other steps: @@ -71,7 +71,7 @@ Allow rules accept tool-name globs only after a literal `mcp__<server>__` prefix. The server segment must be glob-free so the rule names a specific server you configured: `mcp__puppeteer__*` matches every tool from the `puppeteer` server, and `mcp__github__get_*` matches its `get_` tools. An unanchored entry like `allowed_tools=["*"]` or `allowed_tools=["mcp__*"]` is ignored with a startup warning and does not auto-approve anything. Scoped rules for `Read` and `Edit` take a path pattern. `Edit(path)` rules govern all built-in tools that write files, including `Write` and `NotebookEdit`; a `Write(path)` rule is never matched by the file permission checks. Use `//path` for an absolute filesystem path: a deny rule of `Edit(//secrets/**)` blocks writes anywhere under `/secrets` on disk. With a single leading slash, `Edit(/secrets/**)` anchors at the rule’s source instead. For rules passed through `allowed_tools` or `disallowed_tools`, that means the session’s working directory, so the rule doesn’t block `/secrets` on disk. See [Read and Edit rules](</docs/en/permissions#read-and-edit>) for the four anchor forms and how rules from settings files resolve. -**Auto-approved tools never reach`canUseTool`.** A tool call approved at any earlier step, by `acceptEdits` or `bypassPermissions`, or by an allow rule, skips your `canUseTool` callback, so permission checks you put there are silently bypassed for that tool. `AskUserQuestion`, MCP tools marked [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>), and connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) still reach the callback, even when an allow rule matches.Coverage depends on the entry’s form: a bare name like `Read` or `mcp__github__get_issue` auto-approves every call to that tool, while a scoped rule like `Bash(ls *)` auto-approves only matching calls and other `Bash` calls still fall through to the callback. For checks that must run on every tool call, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>): hooks run before every other step, and a hook deny applies even in `bypassPermissions` mode. +**Auto-approved tools never reach`canUseTool`.** A tool call approved at any earlier step, by `acceptEdits` or `bypassPermissions`, or by an allow rule, skips your `canUseTool` callback, so permission checks you put there are silently bypassed for that tool. `AskUserQuestion`, MCP tools marked [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>), connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) still reach the callback, even when an allow rule matches. In `auto` mode, critical-path removals go to the [classifier](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) instead of the callback, while the other calls listed here still reach it; the classifier routing requires Claude Code v2.1.218 or later. In `dontAsk` mode these calls are denied instead, without invoking the callback.Coverage depends on the entry’s form: a bare name like `Read` or `mcp__github__get_issue` auto-approves every call to that tool apart from the exceptions above, while a scoped rule like `Bash(ls *)` auto-approves only matching calls and other `Bash` calls still fall through to the callback. For checks that must run on every tool call, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>): hooks run before every other step, and a hook deny applies even in `bypassPermissions` mode. For a locked-down agent, pair `allowedTools` with `permissionMode: "dontAsk"`. Listed tools are approved, apart from the always-prompt tools in the Warning above; anything else is denied outright instead of prompting: @@ -103,13 +103,13 @@ Mode| Description| Tool behavior ---|---|--- `default`| Standard permission behavior| No auto-approvals; unmatched tools trigger your `canUseTool` callback -`dontAsk`| Deny instead of prompting| Anything not pre-approved by `allowed_tools` or rules is denied; connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) and tools that require user interaction are denied even if you’ve pre-approved them. `canUseTool` is never called +`dontAsk`| Deny instead of prompting| Anything not pre-approved by `allowed_tools` or rules is denied; connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) and tools that require user interaction are denied even if you’ve pre-approved them, as are `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>). `canUseTool` is never called `acceptEdits`| Auto-accept file edits| File edits and filesystem operations (`mkdir`, `rm`, `mv`, etc.) are automatically approved -`bypassPermissions`| Bypass permission checks| Tools run without permission prompts, except tools matched by an explicit `ask` rule, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and tools that require user interaction. The [cross-session messaging safeguards](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) still apply. Use with caution +`bypassPermissions`| Bypass permission checks| Tools run without permission prompts, except for the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>). Use with caution `plan`| Planning mode| Claude explores and plans without editing your source files; file edits are never auto-approved and prompt through your `canUseTool` callback `auto`| Model-classified approvals| A model classifier approves or denies permission prompts. See [Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) for availability -**Subagent inheritance:** Subagents inherit the parent session’s permission mode. An [`AgentDefinition`’s `permissionMode`](</docs/en/agent-sdk/typescript#agentdefinition>) can override it, except when the parent uses `bypassPermissions`, `acceptEdits`, or `auto`: those modes apply to every subagent and can’t be overridden per subagent. Claude Code also ignores a definition’s `permissionMode: "bypassPermissions"` when bypass mode is disabled by [`permissions.disableBypassPermissionsMode`](</docs/en/permissions#managed-settings>), so that subagent runs with the parent session’s mode.Subagents may have different system prompts and less constrained behavior than your main agent, so inheriting `bypassPermissions` grants them full, autonomous system access. Explicit `ask` rules, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and tools that require user interaction still force a prompt, as does the [`isolatePeerMachines`](</docs/en/settings#available-settings>) approval for cross-machine messages. +**Subagent inheritance:** Subagents inherit the parent session’s permission mode. An [`AgentDefinition`’s `permissionMode`](</docs/en/agent-sdk/typescript#agentdefinition>) can override it, except when the parent uses `bypassPermissions`, `acceptEdits`, or `auto`: those modes apply to every subagent and can’t be overridden per subagent. Claude Code also ignores a definition’s `permissionMode: "bypassPermissions"` when bypass mode is disabled by [`permissions.disableBypassPermissionsMode`](</docs/en/permissions#managed-settings>), so that subagent runs with the parent session’s mode.Subagents may have different system prompts and less constrained behavior than your main agent, so inheriting `bypassPermissions` grants them full, autonomous system access. The [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) still apply. ### @@ -228,7 +228,7 @@ * File edits (Edit, Write tools) * Filesystem commands: `mkdir`, `touch`, `rm`, `rmdir`, `mv`, `cp`, `sed` -Both apply only to paths inside the working directory or `additionalDirectories`. Paths outside that scope and writes to protected paths still prompt. **Use when:** you trust Claude’s edits and want faster iteration, such as during prototyping or when working in an isolated directory. +Both apply only to paths inside the working directory or `additionalDirectories`. Paths outside that scope, writes to protected paths, and `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) still prompt. **Use when:** you trust Claude’s edits and want faster iteration, such as during prototyping or when working in an isolated directory. #### @@ -236,7 +236,7 @@ Don’t ask mode (`dontAsk`) -Converts any permission prompt into a denial. Tools pre-approved by `allowed_tools`, `settings.json` allow rules, or a hook run as normal. Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) and tools that require user interaction are denied even when an allow rule matches. Everything else is denied without calling `canUseTool`. **Use when:** you want a fixed, explicit tool surface for a headless agent and prefer a hard deny over silent reliance on `canUseTool` being absent. +Converts any permission prompt into a denial. Tools pre-approved by `allowed_tools`, `settings.json` allow rules, or a hook run as normal. Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, and `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) are denied even when an allow rule matches. A `PreToolUse` hook allow doesn’t clear a critical-path removal either. Everything else is denied without calling `canUseTool`. **Use when:** you want a fixed, explicit tool surface for a headless agent and prefer a hard deny over silent reliance on `canUseTool` being absent. #### @@ -249,7 +249,7 @@ Use with extreme caution. Claude has full system access in this mode. Only use in controlled environments where you trust all possible operations.`allowed_tools` does not constrain this mode. Every tool is approved, not just the ones you listed. These controls still apply: * Deny rules, explicit `ask` rules, and hooks are evaluated before the mode check and can still block a tool. - * Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) and tools that require user interaction still fall through to your `canUseTool` callback. + * Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, and `rm` and `rmdir` removals targeting a [critical path](</docs/en/permission-modes#critical-paths>) still fall through to your `canUseTool` callback. * The [cross-session messaging safeguards](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) still apply. ####
modified
--- a/permissions.md +++ b/permissions.md @@ -60,11 +60,11 @@ Allow and deny rules -`allowed_tools` and `disallowed_tools` (TypeScript: `allowedTools` / `disallowedTools`) add entries to the allow and deny rule lists in the evaluation flow above. Allow rules only affect approval: a tool not listed in `allowed_tools` is still available to Claude and falls through to the permission mode. Deny rules behave differently depending on whether they name a tool or scope a pattern within one. +`allowed_tools` and `disallowed_tools` (TypeScript: `allowedTools` / `disallowedTools`) add entries to the allow and deny rule lists in the evaluation flow above. If you name one of the [task-tracking tools](</docs/en/agent-sdk/todo-tracking#model-availability>) in `allowed_tools`, Claude Code also opts the session in. Any other tool not listed in `allowed_tools` is still available to Claude and falls through to the permission mode. Deny rules behave differently depending on whether they name a tool or scope a pattern within one. Option| Effect ---|--- -`allowed_tools=["Read", "Grep"]`| `Read` and `Grep` are auto-approved. Tools not listed here still exist and fall through to the permission mode and `canUseTool`. +`allowed_tools=["Read", "Grep"]`| `Read` and `Grep` are auto-approved. Other tools not listed here still exist and fall through to the permission mode and `canUseTool`. `disallowed_tools=["Bash"]`| The `Bash` tool definition is removed from the request. Claude does not see the tool and cannot attempt it. `disallowed_tools=["Bash(rm *)"]`| `Bash` stays available. Calls matching `rm *` are denied in every permission mode, including `bypassPermissions`. Other `Bash` calls fall through to the permission mode. `disallowed_tools=["*"]`| Every tool definition is removed from the request. Tool-name globs are supported in deny rules: `"*"` matches every tool and `"mcp__*"` matches every MCP tool across all servers. @@ -80,7 +80,7 @@ permissionMode: "dontAsk" }; -**`allowed_tools` does not constrain `bypassPermissions`.** `allowed_tools` only pre-approves the tools you list. Unlisted tools are not matched by any allow rule and fall through to the permission mode, where `bypassPermissions` approves them. Setting `allowed_tools=["Read"]` alongside `permission_mode="bypassPermissions"` still approves every tool, including `Bash`, `Write`, and `Edit`. If you need `bypassPermissions` but want specific tools blocked, use `disallowed_tools`. +**`allowed_tools` does not constrain `bypassPermissions`.** `allowed_tools` pre-approves the tools you list. Other unlisted tools are not matched by any allow rule and fall through to the permission mode, where `bypassPermissions` approves them. Setting `allowed_tools=["Read"]` alongside `permission_mode="bypassPermissions"` still approves every tool, including `Bash`, `Write`, and `Edit`. If you need `bypassPermissions` but want specific tools blocked, use `disallowed_tools`. You can also configure allow, deny, and ask rules declaratively in `.claude/settings.json`. These rules are read when the `project` setting source is enabled, which it is for default `query()` options. If you set `setting_sources` (TypeScript: `settingSources`) explicitly, include `"project"` for them to apply. See [Permission settings](</docs/en/settings#permission-settings>) for the rule syntax.
modified
--- a/permissions.md +++ b/permissions.md @@ -258,7 +258,7 @@ Plan mode (`plan`) -Claude explores the codebase and produces a plan without editing your source files. Read-only tools run as in default mode. File edits are never auto-approved in plan mode, even when an allow rule matches. They prompt through your `canUseTool` callback instead. On Claude Code v2.1.212 or later, shell commands that modify files, such as `touch` and `rm`, reach your `canUseTool` callback the same way. Claude may use `AskUserQuestion` to clarify requirements before finalizing the plan. See [Handle approvals and user input](</docs/en/agent-sdk/user-input#handle-clarifying-questions>) for handling these prompts. **Use when:** you want Claude to propose changes without executing them, such as during code review or when you need to approve changes before they’re made. +Claude explores the codebase and produces a plan without editing your source files. Read-only tools run as they do in the `default` permission mode. File edits are never auto-approved in plan mode, even when an allow rule matches. They prompt through your `canUseTool` callback instead. On Claude Code v2.1.212 or later, shell commands that modify files, such as `touch` and `rm`, reach your `canUseTool` callback the same way. Claude may use `AskUserQuestion` to clarify requirements before finalizing the plan. See [Handle approvals and user input](</docs/en/agent-sdk/user-input#handle-clarifying-questions>) for handling these prompts. **Use when:** you want Claude to propose changes without executing them, such as during code review or when you need to approve changes before they’re made. ##
modified
--- a/permissions.md +++ b/permissions.md @@ -109,7 +109,7 @@ `plan`| Planning mode| Claude explores and plans without editing your source files; file edits are never auto-approved and prompt through your `canUseTool` callback `auto`| Model-classified approvals| A model classifier approves or denies permission prompts. See [Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) for availability -**Subagent inheritance:** Subagents inherit the parent session’s permission mode. An [`AgentDefinition`’s `permissionMode`](</docs/en/agent-sdk/typescript#agentdefinition>) can override it, except when the parent uses `bypassPermissions`, `acceptEdits`, or `auto`: those modes apply to every subagent and can’t be overridden per subagent.Subagents may have different system prompts and less constrained behavior than your main agent, so inheriting `bypassPermissions` grants them full, autonomous system access. Explicit `ask` rules, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and tools that require user interaction still force a prompt, as does the [`isolatePeerMachines`](</docs/en/settings#available-settings>) approval for cross-machine messages. +**Subagent inheritance:** Subagents inherit the parent session’s permission mode. An [`AgentDefinition`’s `permissionMode`](</docs/en/agent-sdk/typescript#agentdefinition>) can override it, except when the parent uses `bypassPermissions`, `acceptEdits`, or `auto`: those modes apply to every subagent and can’t be overridden per subagent. Claude Code also ignores a definition’s `permissionMode: "bypassPermissions"` when bypass mode is disabled by [`permissions.disableBypassPermissionsMode`](</docs/en/permissions#managed-settings>), so that subagent runs with the parent session’s mode.Subagents may have different system prompts and less constrained behavior than your main agent, so inheriting `bypassPermissions` grants them full, autonomous system access. Explicit `ask` rules, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and tools that require user interaction still force a prompt, as does the [`isolatePeerMachines`](</docs/en/settings#available-settings>) approval for cross-machine messages. ###
modified
Show diff (799 lines)
--- a/permissions.md +++ b/permissions.md @@ -1,36 +1,88 @@ -Claude Code supports fine-grained permissions so that you can specify exactly what the agent is allowed to do and what it can’t. You can check permission settings into version control to share them with every developer in your organization, and each developer can customize their own. - -## - -​ - -Permission system - -Claude Code uses a tiered permission system to balance power and safety: - -Tool type| Example| Approval required| ”Yes, don’t ask again” behavior ----|---|---|--- -Read-only| File reads, Grep| No, within the working directory and additional directories| N/A -Bash commands| Shell execution| Yes, except a built-in set of read-only commands| Permanently per repository and command -File modification| Edit/write files| Yes| Until session end - -When you choose “Yes, don’t ask again” and the approval saves permanently, such as for a Bash command, Claude Code saves the rule to `.claude/settings.local.json` at the root of the git repository, resolved through [worktrees](</docs/en/worktrees>) to the main checkout. The rule applies to future sessions anywhere in that repository, including sessions started in subdirectories and in worktrees. A file-modification approval isn’t saved to the file: as the table shows, it lasts until the session ends. Outside a git repository, and when the repository root is your home directory, Claude Code saves the rule in the directory you started it from. Before v2.1.211, Claude Code always saved the rule in the starting directory, so an approval granted in a worktree or subdirectory didn’t apply to the rest of the repository. Rules that earlier versions saved in a subdirectory or worktree still apply to sessions started there. On a Bash or PowerShell permission prompt, press `Ctrl+E` to show an explanation of the command: what it does, why Claude is running it, and what could go wrong, labeled **Low risk** , **Med risk** , or **High risk**. Claude Code sends the command and Claude’s own description of the call to the model to generate the explanation only when you press `Ctrl+E`, not on every prompt. Showing the explanation doesn’t run the command; press `Ctrl+E` again to hide it. To turn the shortcut off, set [`permissionExplainerEnabled`](</docs/en/settings#global-config-settings>) to `false` in `~/.claude.json`. - -## - -​ - -Manage permissions - -You can view and manage Claude Code’s tool permissions with `/permissions`. This UI lists all permission rules and the `settings.json` file each rule comes from. - - * **Allow** rules let Claude Code use the specified tool without manual approval. - * **Ask** rules prompt for confirmation whenever Claude Code tries to use the specified tool. - * **Deny** rules prevent Claude Code from using the specified tool. - -Rules are evaluated in order: deny, then ask, then allow. The first match in that order determines the outcome, and rule specificity doesn’t change the order. A broad deny rule like `Bash(aws *)` blocks every matching call, including calls that also match a narrower allow rule like `Bash(aws s3 ls)`, so a deny rule can’t carry allowlist exceptions. The same precedence applies between ask and allow: a matching ask rule prompts even when a more specific allow rule also matches the same call. Deny rules behave differently depending on whether they name a tool or scope a pattern within one. A bare tool name like `Bash` removes the tool from Claude’s context entirely, so Claude never sees it. Bare-name removal applies to every tool except [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>): a deny rule can’t remove it while any other tool remains, and an ask rule never prompts for it. A scoped rule like `Bash(rm *)` leaves the tool available and blocks matching calls when Claude attempts them. - -Permission rules are enforced by Claude Code, not by the model. Instructions in your prompt or `CLAUDE.md` shape what Claude tries to do, but they don’t change what Claude Code allows. To grant or revoke access, use `/permissions`, the rules described here, a [permission mode](</docs/en/permission-modes>), or a PreToolUse hook. +The Claude Agent SDK provides permission controls to manage how Claude uses tools. Use permission modes and rules to define what’s allowed automatically, and the [`canUseTool` callback](</docs/en/agent-sdk/user-input>) to handle everything else at runtime. + +## + +​ + +How permissions are evaluated + +When Claude requests a tool, the SDK checks permissions in this order: + +1 + +Hooks + +Run [hooks](</docs/en/agent-sdk/hooks>) first. A hook can deny the call outright or pass it on. A hook that returns `allow` does not skip the deny and ask rules below; those are evaluated regardless of the hook result. + +2 + +Deny rules + +Check `deny` rules (from `disallowed_tools` and [settings.json](</docs/en/settings#permission-settings>)). If a deny rule matches, the tool is blocked, even in `bypassPermissions` mode. Bare-name deny rules like `Bash` remove the tool from Claude’s context before this evaluation begins, so only scoped rules like `Bash(rm *)` are checked at this step. + +3 + +Ask rules + +Check `ask` rules from [settings.json](</docs/en/settings#permission-settings>). If an ask rule matches, the call falls through to your [`canUseTool` callback](</docs/en/agent-sdk/user-input>) for confirmation, even in `bypassPermissions` mode.Tools that require user interaction behave the same way: `AskUserQuestion` and MCP tools whose server sets [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>) always fall through to the callback, even when an allow rule matches. In `dontAsk` mode both cases are denied instead, because that mode never prompts. The MCP annotation requires Claude Code v2.1.199 or later.[claude.ai connector](</docs/en/mcp#organization-controls-on-connector-tools>) tools your organization has set to `ask` also leave the flow at this step. Every call falls through to the callback, even in `bypassPermissions` mode and even when an allow rule matches. The callback receives the reason `Your organization requires approval for this tool`. In `dontAsk` mode the call is denied instead, because that mode never prompts. + +4 + +Permission mode + +Apply the active permission mode. `bypassPermissions` approves everything that reaches this step. `acceptEdits` approves file operations. `plan` routes file-edit and shell-write tools to your `canUseTool` callback regardless of allow rules, so write operations cannot be auto-approved while planning. Other modes fall through. + +5 + +Allow rules + +Check `allow` rules (from `allowed_tools` and settings.json). If a rule matches, the tool is approved. + +6 + +canUseTool callback + +If not resolved by any of the above, call your [`canUseTool` callback](</docs/en/agent-sdk/user-input>) for a decision. In `dontAsk` mode, this step is skipped and the tool is denied. + +If you pass a `canUseTool` callback that this evaluation order can never reach, the TypeScript SDK emits a Node.js process warning once when the query is constructed. The warning’s code is `CLAUDE_SDK_CAN_USE_TOOL_SHADOWED`. Two configurations trigger it: + + * `permissionMode: 'bypassPermissions'`, which auto-approves every call that reaches the permission mode step + * Each bare `allowedTools` entry such as `"Read"`, which auto-approves that whole tool before the callback is consulted + +Entries with a specifier such as `Bash(ls *)` and the `acceptEdits` mode don’t trigger it, and allow rules coming from settings files aren’t visible to the check. Listen with `process.on('warning', ...)` and match the code to log or suppress it. To gate every tool call regardless of mode and rules, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>) instead. This page focuses on **allow and deny rules** and **permission modes**. For the other steps: + + * **Hooks:** run custom code to allow, deny, or modify tool requests. See [Control execution with hooks](</docs/en/agent-sdk/hooks>). + * **canUseTool callback:** prompt users for approval at runtime, when no earlier step resolves the call. See [Handle approvals and user input](</docs/en/agent-sdk/user-input>). + +## + +​ + +Allow and deny rules + +`allowed_tools` and `disallowed_tools` (TypeScript: `allowedTools` / `disallowedTools`) add entries to the allow and deny rule lists in the evaluation flow above. Allow rules only affect approval: a tool not listed in `allowed_tools` is still available to Claude and falls through to the permission mode. Deny rules behave differently depending on whether they name a tool or scope a pattern within one. + +Option| Effect +---|--- +`allowed_tools=["Read", "Grep"]`| `Read` and `Grep` are auto-approved. Tools not listed here still exist and fall through to the permission mode and `canUseTool`. +`disallowed_tools=["Bash"]`| The `Bash` tool definition is removed from the request. Claude does not see the tool and cannot attempt it. +`disallowed_tools=["Bash(rm *)"]`| `Bash` stays available. Calls matching `rm *` are denied in every permission mode, including `bypassPermissions`. Other `Bash` calls fall through to the permission mode. +`disallowed_tools=["*"]`| Every tool definition is removed from the request. Tool-name globs are supported in deny rules: `"*"` matches every tool and `"mcp__*"` matches every MCP tool across all servers. + +Allow rules accept tool-name globs only after a literal `mcp__<server>__` prefix. The server segment must be glob-free so the rule names a specific server you configured: `mcp__puppeteer__*` matches every tool from the `puppeteer` server, and `mcp__github__get_*` matches its `get_` tools. An unanchored entry like `allowed_tools=["*"]` or `allowed_tools=["mcp__*"]` is ignored with a startup warning and does not auto-approve anything. Scoped rules for `Read` and `Edit` take a path pattern. `Edit(path)` rules govern all built-in tools that write files, including `Write` and `NotebookEdit`; a `Write(path)` rule is never matched by the file permission checks. Use `//path` for an absolute filesystem path: a deny rule of `Edit(//secrets/**)` blocks writes anywhere under `/secrets` on disk. With a single leading slash, `Edit(/secrets/**)` anchors at the rule’s source instead. For rules passed through `allowed_tools` or `disallowed_tools`, that means the session’s working directory, so the rule doesn’t block `/secrets` on disk. See [Read and Edit rules](</docs/en/permissions#read-and-edit>) for the four anchor forms and how rules from settings files resolve. + +**Auto-approved tools never reach`canUseTool`.** A tool call approved at any earlier step, by `acceptEdits` or `bypassPermissions`, or by an allow rule, skips your `canUseTool` callback, so permission checks you put there are silently bypassed for that tool. `AskUserQuestion`, MCP tools marked [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>), and connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) still reach the callback, even when an allow rule matches.Coverage depends on the entry’s form: a bare name like `Read` or `mcp__github__get_issue` auto-approves every call to that tool, while a scoped rule like `Bash(ls *)` auto-approves only matching calls and other `Bash` calls still fall through to the callback. For checks that must run on every tool call, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>): hooks run before every other step, and a hook deny applies even in `bypassPermissions` mode. + +For a locked-down agent, pair `allowedTools` with `permissionMode: "dontAsk"`. Listed tools are approved, apart from the always-prompt tools in the Warning above; anything else is denied outright instead of prompting: + + const options = { + allowedTools: ["Read", "Glob", "Grep"], + permissionMode: "dontAsk" + }; + +**`allowed_tools` does not constrain `bypassPermissions`.** `allowed_tools` only pre-approves the tools you list. Unlisted tools are not matched by any allow rule and fall through to the permission mode, where `bypassPermissions` approves them. Setting `allowed_tools=["Read"]` alongside `permission_mode="bypassPermissions"` still approves every tool, including `Bash`, `Write`, and `Edit`. If you need `bypassPermissions` but want specific tools blocked, use `disallowed_tools`. + +You can also configure allow, deny, and ask rules declaratively in `.claude/settings.json`. These rules are read when the `project` setting source is enabled, which it is for default `query()` options. If you set `setting_sources` (TypeScript: `settingSources`) explicitly, include `"project"` for them to apply. See [Permission settings](</docs/en/settings#permission-settings>) for the rule syntax. ## @@ -38,514 +90,184 @@ Permission modes -Claude Code supports several permission modes that control how it approves tool calls. See [Permission modes](</docs/en/permission-modes>) for when to use each one. Set the `defaultMode` in your [settings files](</docs/en/settings#settings-files>): - -Mode| Description ----|--- -`default`| Standard behavior: prompts for permission on first use of each tool. Labeled Manual in the CLI, the VS Code and JetBrains extensions, and the desktop app, and Claude Code accepts `manual` as an alias. The label and alias require Claude Code v2.1.200 or later. The desktop app’s label doesn’t depend on your CLI version -`acceptEdits`| Automatically accepts file edits and common filesystem commands such as `mkdir`, `touch`, `mv`, and `cp` for paths in the working directory or `additionalDirectories` -`plan`| Claude reads files and runs read-only shell commands to explore but doesn’t edit your source files; with [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) available, classifier-approved commands also run. Labeled Plan in the CLI and the VS Code extension -`auto`| Auto-approves tool calls with background safety checks that verify actions align with your request -`dontAsk`| Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules. `AskUserQuestion`, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>) are denied even if you’ve allowed them -`bypassPermissions`| Skips permission prompts, except those forced by explicit `ask` rules, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>). Root and home directory removals such as `rm -rf /` also still prompt as a circuit breaker, and the [cross-session messaging safeguards](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) still apply - -`bypassPermissions` mode skips permission prompts, including for writes to [protected paths](</docs/en/permission-modes#protected-paths>) such as `.git` and `.claude`. The [cross-session messaging safeguards](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) still apply. Only use this mode in isolated environments like containers or VMs where Claude Code can’t cause damage.A few prompts still fire in this mode. Explicit `ask` rules, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>) still prompt. Removals targeting the filesystem root or home directory, such as `rm -rf /` and `rm -rf ~`, also prompt as a circuit breaker against model error, including when the command contains command substitution with `$(...)` or backticks, or process substitution with `<(...)`. - -To prevent `bypassPermissions` or `auto` mode from being used, set `permissions.disableBypassPermissionsMode` or `permissions.disableAutoMode` to `"disable"` in any [settings file](</docs/en/settings#settings-files>). These are most useful in managed settings where they can’t be overridden. - -## - -​ - -Permission rule syntax - -Permission rules follow the format `Tool` or `Tool(specifier)`. +Permission modes provide global control over how Claude uses tools. You can set the permission mode when calling `query()` or change it dynamically during streaming sessions. ### ​ -Match all uses of a tool - -To match all uses of a tool, use only the tool name without parentheses: - -Rule| Effect ----|--- -`Bash`| Matches all Bash commands -`WebFetch`| Matches all web fetch requests -`Read`| Matches all file reads - -`Bash(*)` is equivalent to `Bash` and matches all Bash commands. As a deny rule, both forms remove the tool from Claude’s context. +Available modes + +The SDK supports these permission modes: + +Mode| Description| Tool behavior +---|---|--- +`default`| Standard permission behavior| No auto-approvals; unmatched tools trigger your `canUseTool` callback +`dontAsk`| Deny instead of prompting| Anything not pre-approved by `allowed_tools` or rules is denied; connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) and tools that require user interaction are denied even if you’ve pre-approved them. `canUseTool` is never called +`acceptEdits`| Auto-accept file edits| File edits and filesystem operations (`mkdir`, `rm`, `mv`, etc.) are automatically approved +`bypassPermissions`| Bypass permission checks| Tools run without permission prompts, except tools matched by an explicit `ask` rule, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and tools that require user interaction. The [cross-session messaging safeguards](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) still apply. Use with caution +`plan`| Planning mode| Claude explores and plans without editing your source files; file edits are never auto-approved and prompt through your `canUseTool` callback +`auto`| Model-classified approvals| A model classifier approves or denies permission prompts. See [Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) for availability + +**Subagent inheritance:** Subagents inherit the parent session’s permission mode. An [`AgentDefinition`’s `permissionMode`](</docs/en/agent-sdk/typescript#agentdefinition>) can override it, except when the parent uses `bypassPermissions`, `acceptEdits`, or `auto`: those modes apply to every subagent and can’t be overridden per subagent.Subagents may have different system prompts and less constrained behavior than your main agent, so inheriting `bypassPermissions` grants them full, autonomous system access. Explicit `ask` rules, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and tools that require user interaction still force a prompt, as does the [`isolatePeerMachines`](</docs/en/settings#available-settings>) approval for cross-machine messages. ### ​ -Use specifiers for fine-grained control - -Add a specifier in parentheses to match specific tool uses: - -Rule| Effect ----|--- -`Bash(npm run build)`| Matches the exact command `npm run build` -`Read(./.env)`| Matches reading the `.env` file in the current directory -`WebFetch(domain:example.com)`| Matches fetch requests to example.com - -### - -​ - -Match by input parameter - -Deny and ask rules can match a top-level input parameter on any tool with `Tool(param:value)`. The rule matches when Claude calls the tool with that parameter set to that exact value. An allow rule for one parameter value wouldn’t establish that the call is safe overall, so allow rules continue to use each tool’s own specifier syntax. This works for any scalar parameter the tool accepts: - -Rule| Matches ----|--- -`Agent(model:opus)`| Agent calls that request the Opus model tier -`Agent(isolation:worktree)`| Agent calls that request a git worktree -`Bash(run_in_background:true)`| Bash calls that run in the background - -Parameter matching follows these rules: - - * The parameter name must be a direct field of the tool’s input, such as `model` on the Agent tool. Fields nested inside an object or array are not matchable - * Each rule names one parameter. To gate on both `model` and `isolation`, write two rules, `Agent(model:opus)` and `Agent(isolation:worktree)`, rather than combining them in one rule - * The value supports `*` as a wildcard that matches any sequence of characters, so `Agent(isolation:*)` matches any explicit isolation value. Without `*` the match is exact - * A parameter the model omits is never matched, so `Agent(model:*)` doesn’t match a call that leaves `model` unset - * The value is compared against the literal input Claude sends, before any normalization. `Agent(model:opus)` matches the alias `opus` but not a full model ID. Run with [`--verbose`](</docs/en/cli-reference>) to see the exact parameter names and values in each tool call - * Whitespace around the colon is ignored - -You can’t match a tool’s primary content field this way: `command` for Bash and PowerShell, `file_path` for Read, Edit, and Write, `path` for Grep and Glob, `notebook_path` for NotebookEdit, and `url` for WebFetch. A rule like `Bash(command:rm *)` would be bypassable by a compound command, so Claude Code ignores it and emits a startup warning. Use `Bash(rm *)`, `Read(./path)`, or `WebFetch(domain:host)` instead. - -### - -​ - -Wildcard patterns - -Bash rules support glob patterns with `*`. This configuration allows npm and git commit commands while blocking git push: - - { - "permissions": { - "allow": [ - "Bash(npm run *)", - "Bash(git commit *)", - "Bash(git * main)", - "Bash(* --version)", - "Bash(* --help *)" - ], - "deny": [ - "Bash(git push *)" - ] +Set permission mode + +You can set the permission mode once when starting a query, or change it dynamically while the session is active. + + * At query time + + * During streaming + +Pass `permission_mode` (Python) or `permissionMode` (TypeScript) when creating a query. This mode applies for the entire session unless changed dynamically. + +Python + +TypeScript + + import asyncio + from claude_agent_sdk import query, ClaudeAgentOptions + + async def main(): + async for message in query( + prompt="Help me refactor this code", + options=ClaudeAgentOptions( + permission_mode="default", # Set the mode here + ), + ): + if hasattr(message, "result"): + print(message.result) + + asyncio.run(main()) + + import { query } from "@anthropic-ai/claude-agent-sdk"; + + async function main() { + for await (const message of query({ + prompt: "Help me refactor this code", + options: { + permissionMode: "default" // Set the mode here + } + })) { + if ("result" in message) { + console.log(message.result); + } } } -The `:*` suffix is an equivalent way to write a trailing wildcard, so `Bash(ls:*)` matches the same commands as `Bash(ls *)`. The permission dialog writes the space-separated form when you select “Yes, don’t ask again” for a command prefix. The `:*` form is only recognized at the end of a pattern. In a pattern like `Bash(git:* push)`, the colon is treated as a literal character and won’t match git commands. - -### - -​ - -Tool name wildcards - -Deny and ask rules also accept glob patterns in the tool-name position. The pattern must match the full tool name: `"*"` matches every tool, and `"mcp__*"` matches every MCP tool across all servers. A tool matched by a bare-name glob deny rule is removed from Claude’s context, the same as a bare tool name, including the [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>) exception: a glob deny can’t remove it while any other tool remains, and a glob ask never prompts for it. This configuration denies every MCP tool: - - { - "permissions": { - "deny": [ - "mcp__*" - ] + main(); + +Call `set_permission_mode()` (Python) or `setPermissionMode()` (TypeScript) to change the mode mid-session. The new mode takes effect immediately for all subsequent tool requests. This lets you start restrictive and loosen permissions as trust builds, for example switching to `acceptEdits` after reviewing Claude’s initial approach. + +Python + +TypeScript + + import asyncio + from claude_agent_sdk import ClaudeSDKClient, ClaudeAgentOptions + + async def main(): + async with ClaudeSDKClient( + options=ClaudeAgentOptions( + permission_mode="default", # Start in default mode + ) + ) as client: + await client.query("Help me refactor this code") + + # Change mode dynamically mid-session + await client.set_permission_mode("acceptEdits") + + # Process messages with the new permission mode + async for message in client.receive_response(): + if hasattr(message, "result"): + print(message.result) + + asyncio.run(main()) + + import { query } from "@anthropic-ai/claude-agent-sdk"; + + async function main() { + const q = query({ + prompt: "Help me refactor this code", + options: { + permissionMode: "default" // Start in default mode + } + }); + + // Change mode dynamically mid-session + await q.setPermissionMode("acceptEdits"); + + // Process messages with the new permission mode + for await (const message of q) { + if ("result" in message) { + console.log(message.result); + } } } -Allow rules accept tool-name globs only after a literal `mcp__<server>__` prefix. The server segment must be glob-free so the rule names a specific server you configured. `mcp__puppeteer__*` matches every tool from the `puppeteer` server, and `mcp__github__get_*` matches its `get_` tools. An unanchored allow glob such as `"*"`, `"B*"`, or `"mcp__*"` is skipped with a warning and doesn’t auto-approve anything. A deny or ask rule whose tool name matches no known tool produces a startup warning to catch typos. Tool names containing `_` or `*` are exempt from the check. The label shown for a tool in the transcript and permission dialog can differ from its canonical name. For example, the tool labeled `Stop Task` in the transcript has the canonical name `TaskStop`. Permission rules and [hook matchers](</docs/en/hooks>) match the canonical name only, so a rule written as `Stop Task` doesn’t match. For deny and ask rules, the startup warning above catches the mismatch. Use the canonical names listed in the [tools reference](</docs/en/tools-reference>). - -## - -​ - -Tool-specific permission rules + main(); ### ​ -Bash - -Bash permission rules support wildcard matching with `*`. Wildcards can appear at any position in the command, including at the beginning, middle, or end: - - * `Bash(npm run build)` matches the exact Bash command `npm run build` - * `Bash(npm run test *)` matches Bash commands starting with `npm run test` - * `Bash(npm *)` matches any command starting with `npm ` - * `Bash(* install)` matches any command ending with ` install` - * `Bash(git * main)` matches commands like `git checkout main` and `git log --oneline main` - -A single `*` matches any sequence of characters including spaces, so one wildcard can span multiple arguments. `Bash(git *)` matches `git log --oneline --all`, and `Bash(git * main)` matches `git push origin main` as well as `git merge main`. When `*` appears at the end with a space before it (like `Bash(ls *)`), it enforces a word boundary, requiring the prefix to be followed by a space or end-of-string. For example, `Bash(ls *)` matches `ls -la` but not `lsof`. In contrast, `Bash(ls*)` without a space matches both `ls -la` and `lsof` because there’s no word boundary constraint. - -#### - -​ - -Compound commands - -Claude Code is aware of shell operators, so a rule like `Bash(safe-cmd *)` won’t give it permission to run the command `safe-cmd && other-cmd`. The recognized command separators are `&&`, `||`, `;`, `|`, `|&`, `&`, and newlines. A rule must match each subcommand independently. - -When you approve a compound command with “Yes, don’t ask again”, Claude Code saves a separate rule for each subcommand that requires approval, rather than a single rule for the full compound string. For example, approving `git status && npm test` saves a rule for `npm test`, so future `npm test` invocations are recognized regardless of what precedes the `&&`. Subcommands like `cd` into a subdirectory generate their own Read rule for that path. Up to 5 rules may be saved for a single compound command. - -#### - -​ - -Wrappers - -Before matching Bash rules, Claude Code strips a fixed set of wrappers, so a rule like `Bash(npm test *)` also matches `timeout 30 npm test`. The stripped wrappers are `timeout`, `time`, `nice`, `nohup`, and `stdbuf`, plus the shell builtins `command` and `builtin`, and zsh’s `noglob`. Each runs its argument as the actual command. Two related forms aren’t stripped: the query form `command -v`, which looks up a command rather than running one, and zsh’s `nocorrect`. Claude Code also strips a leading assignment of certain known-safe environment variables, so `Bash(npm test *)` matches `NODE_ENV=test npm test`. An allow rule won’t match past an assignment of any other variable. A deny or ask rule matches past any leading assignment, so `Bash(rm *)` in deny still matches `FOO=bar rm -rf tmp/`. Bare `xargs` is also stripped, so `Bash(grep *)` matches `xargs grep pattern`. Stripping applies only when `xargs` has no flags: an invocation like `xargs -n1 grep pattern` is matched as an `xargs` command, so rules written for the inner command do not cover it. This wrapper list is built in and is not configurable. Development environment runners such as `direnv exec`, `devbox run`, `mise exec`, `npx`, and `docker exec` are not in the list. Because these tools execute their arguments as a command, a rule like `Bash(devbox run *)` matches whatever comes after `run`, including `devbox run rm -rf .`. To approve work inside an environment runner, write a specific rule that includes both the runner and the inner command, such as `Bash(devbox run npm test)`. Add one rule per inner command you want to allow. Exec wrappers such as `watch`, `setsid`, `ionice`, and `flock` always prompt and can’t be auto-approved by a prefix rule like `Bash(watch *)`. The same applies to `find` with `-exec` or `-delete`: a `Bash(find *)` rule doesn’t cover these forms. To approve a specific invocation, write an exact-match rule for the full command string. - -#### - -​ - -Read-only commands - -Claude Code recognizes a built-in set of Bash commands as read-only and runs them without a permission prompt in every mode. These include `ls`, `cat`, `echo`, `pwd`, `head`, `tail`, `grep`, `find`, `wc`, `which`, `diff`, `stat`, `du`, `cd`, and read-only forms of `git`. The set is not configurable; to require a prompt for one of these commands, add an `ask` or `deny` rule for it. Unquoted glob patterns are permitted for commands whose every flag is read-only, so `ls *.ts` and `wc -l src/*.py` run without a prompt. Commands from this set still prompt in these cases: - - * **Unquoted globs for commands with write-capable flags** : commands with write-capable or exec-capable flags, such as `find`, `sort`, `sed`, and `git`, prompt when an unquoted glob is present, because the glob could expand to a flag like `-delete`. - * **`docker` pointed at another daemon**: read-only forms of `docker` prompt when the command carries a flag that selects a different daemon, such as `-H`, `--context`, or Podman’s `--url` and `--connection`. - * **`file` with path-opening flags**: `file` prompts when it passes `-m`/`--magic-file` or `-f`/`--files-from`, because those flags make `file` open the paths named in the flag’s value. - * **Network paths on Windows** : a command whose arguments include a network (UNC) path, such as `\\server\share\file`, prompts because accessing a network path can send your Windows credentials to the host it names. The same check applies to [PowerShell tool](</docs/en/tools-reference#powershell-tool>) commands. - * **Commands the analysis can’t parse** : when Claude Code can’t fully parse a command, it asks for approval instead of treating the command as read-only. Commands longer than 10,000 characters always prompt because they exceed what the analysis parses. - -A `cd` into a path inside your working directory or an additional directory is also read-only, and a compound command like `cd packages/api && ls` runs without a prompt when each part qualifies on its own. Two combinations prompt even when each part is read-only: - - * **`cd` with `git`**: prompts when the `cd` changes into a different directory, since running `git` in a new directory can execute that directory’s hooks. A `cd` whose target resolves to the current working directory is a no-op and doesn’t trigger the prompt. - * **`cd` with an output redirect**: prompts when Claude Code can’t determine which directory the redirect target resolves against after the `cd` runs. A command whose only redirect target is `/dev/null`, such as `cd app; grep -r pattern . 2>/dev/null`, doesn’t prompt, because `/dev/null` doesn’t depend on the working directory. - -Bash permission patterns that try to constrain command arguments are fragile. For example, `Bash(curl http://github.com/ *)` intends to restrict curl to GitHub URLs, but won’t match variations like: - - * Options before URL: `curl -X GET http://github.com/...` - * Different protocol: `curl https://github.com/...` - * Redirects: `curl -L http://short.example.com/xyz`, which redirects to GitHub - * Variables: `URL=http://github.com && curl $URL` - * Extra spaces: `curl http://github.com` - -For more reliable URL filtering, consider: - - * **Restrict Bash network tools** : use deny rules to block `curl`, `wget`, and similar commands, then use the WebFetch tool with `WebFetch(domain:github.com)` permission for allowed domains - * **Use PreToolUse hooks** : implement a hook that validates URLs in Bash commands and blocks disallowed domains - * **Add CLAUDE.md guidance** : describe your allowed curl patterns in `CLAUDE.md`. This shapes what Claude tries but doesn’t enforce a boundary, so pair it with one of the options above - -Note that using WebFetch alone doesn’t prevent network access. If Bash is allowed, Claude can still use `curl`, `wget`, or other tools to reach any URL. - -### - -​ - -PowerShell - -PowerShell permission rules use the same shape as Bash rules. Wildcards with `*` match at any position, the `:*` suffix is equivalent to a trailing ` *`, and a bare `PowerShell` or `PowerShell(*)` matches every command. This configuration allows `Get-ChildItem` and `git commit` commands while blocking `Remove-Item`: - - { - "permissions": { - "allow": [ - "PowerShell(Get-ChildItem *)", - "PowerShell(git commit *)" - ], - "deny": [ - "PowerShell(Remove-Item *)" - ] - } - } - -Common aliases are canonicalized before matching. A rule written for the cmdlet name also matches its aliases, so `PowerShell(Get-ChildItem *)` matches `gci`, `ls`, and `dir` as well. Matching is case-insensitive. Claude Code parses the PowerShell AST and checks each command in a compound command independently. Pipeline operators `|`, statement separators `;`, and on PowerShell 7+ the chain operators `&&` and `||` split a compound command into subcommands. A rule must match every subcommand for the compound command to be allowed. - -### - -​ - -Read and Edit - -`Edit` rules apply to all built-in tools that edit files. Claude makes a best-effort attempt to apply `Read` rules to all built-in tools that read files like Grep and Glob, to `@file` mentions in your prompts, and to the selection and open-file context that a connected [IDE](</docs/en/vs-code#the-built-in-ide-mcp-server>) shares with Claude. A `Read` deny rule also blocks the [Edit tool](</docs/en/errors#file-is-covered-by-a-read-deny-rule>) on the same path, including creating a new file there. Write and NotebookEdit aren’t covered, so add an `Edit` deny rule for paths no tool may change. Requires Claude Code v2.1.208 or later. Claude Code checks file permissions against `Edit(path)` and `Read(path)` rules only. If you write a path rule for `Write`, `NotebookEdit`, `Glob`, or the legacy `MultiEdit` tool instead, Claude Code accepts the rule but never consults it, and [warns at startup](</docs/en/errors#is-not-matched-by-file-permission-checks>), except for a `Glob` rule passed in `--allowedTools`. Use `Edit(docs/**)` in place of `Write(docs/**)`, `NotebookEdit(docs/**)`, or `MultiEdit(docs/**)`, and `Read(docs/**)` in place of `Glob(docs/**)`. Claude Code doesn’t warn about a tool-name rule with no path, such as a deny rule for `Write`; it matches that rule at the tool level everywhere. Requires Claude Code v2.1.210 or later. If you put a deny rule `Write(docs/**)` in project settings, Claude Code prints this startup warning: - - Permission deny rule (.claude/settings.json): Write(docs/**) is not matched by file permission checks — only Edit(path) rules are. Use Edit(docs/**) instead (Edit rules cover all file-editing tools). - -Read and Edit deny rules apply to Claude’s built-in file tools and to file commands Claude Code recognizes in Bash, such as `cat`, `head`, `tail`, and `sed`. They don’t apply to arbitrary subprocesses that read or write files indirectly, like a Python or Node script that opens files itself. For OS-level enforcement that blocks all processes from accessing a path, [enable the sandbox](</docs/en/sandboxing>). - -Read and Edit rules both use [gitignore](<https://git-scm.com/docs/gitignore>) pattern syntax with four distinct pattern types; for single-segment directory patterns, the matching depth also depends on the rule type, described later in this section: - -Pattern| Meaning| Example| Matches ----|---|---|--- -`//path`| Absolute path from filesystem root| `Read(//Users/alice/secrets/**)`| `/Users/alice/secrets/**` -`~/path`| Path from home directory| `Read(~/Documents/*.pdf)`| `/Users/alice/Documents/*.pdf` -`/path`| Path relative to the settings source| `Edit(/src/**/*.ts)`| `<project root>/src/**/*.ts` in project settings -`path` or `./path`| Path relative to current directory| `Read(*.env)`| `<cwd>/*.env` - -A pattern like `/Users/alice/file` isn’t an absolute path. The single leading slash anchors at the settings source, not the filesystem root. Use `//Users/alice/file` for absolute paths. - -A `/path` pattern anchors at a directory associated with the settings source that defines it, so the same rule matches different locations depending on where you put it: - -Rule defined in| `/path` resolves to ----|--- -Project settings at `.claude/settings.json`| `<project root>/path` -Local settings at `.claude/settings.local.json`| `<original cwd>/path` -User settings at `~/.claude/settings.json`| `~/.claude/path` -A file passed with `--settings <file>`| `<directory of file>/path` -CLI flags, `/permissions`, or session rules| `<original cwd>/path` - -Local settings rules anchor at the directory you started Claude Code from, not at the repository root where Claude Code stores the file in v2.1.211 and later. In a session started at the repository root, the two directories are the same; in a [worktree](</docs/en/worktrees>) session, a shared rule such as `Edit(/src/**)` matches that worktree’s own `src/` directory. A deny rule such as `Read(/secrets/**)` in user settings blocks `~/.claude/secrets/**`, not a `secrets` directory in your project. To write a rule in user settings that applies inside every project, use a `//` absolute path or a `~/` home-relative path instead. On Windows, paths are normalized to POSIX form before matching. `C:\Users\alice` becomes `/c/Users/alice`, so use `//c/**/.env` to match `.env` files anywhere on that drive. To match across all drives, use `//**/.env`. Examples: - - * `Edit(/docs/**)`: edits in `<project>/docs/`, not `/docs/` or `<project>/.claude/docs/` - * `Read(~/.zshrc)`: reads your home directory’s `.zshrc` - * `Edit(//tmp/scratch.txt)`: edits the absolute path `/tmp/scratch.txt` - * `Read(src/**)`: as an allow rule, reads from `<current-directory>/src/` only; as a deny or ask rule, matches a `src` directory at any depth under the current directory - -A rule only matches files under its anchor; within that bound, matching depth depends on the pattern shape and, for single-segment directory patterns, the rule type, described below. Bare filenames follow gitignore semantics and match at any depth, so `Read(.env)` and `Read(**/.env)` are equivalent: - -Deny rule| Blocks| Does not block ----|---|--- -`Read(.env)` or `Read(**/.env)`| any `.env` at or under the current directory| `.env` in a parent directory or another project -`Read(//**/.env)`| any `.env` anywhere on the filesystem| nothing; the rule is anchored at the filesystem root - -A relative pattern with a single directory segment, such as `src/**`, matches at different depths depending on the rule type: - - * **Allow rules** : `Edit(src/**)` matches only `<cwd>/src` and the files under it. To allow a directory name at any depth, write `Edit(**/src/**)`. - * **Deny and ask rules** : `Read(secrets/**)` matches a directory named `secrets` at any depth under the current directory, so the rule also applies to nested copies. - -Every other pattern shape matches at the same depth in every rule type: `Edit(/src/**)` and `Edit(src/components/**)` match only at their anchored location, while `Edit(**/src/**)` matches at any depth. The following example shows each pattern shape against a project with a top-level `src/` directory and a nested copy under `vendor/`: - - <current-directory>/ - ├── src/ - │ └── app.ts - └── vendor/ - └── pkg/ - └── src/ - └── lib.js - -Rule| Matches `src/app.ts`| Matches `vendor/pkg/src/lib.js` ----|---|--- -`Edit(src/**)` as an allow rule| Yes| No -`Edit(src/**)` as a deny or ask rule| Yes| Yes -`Edit(/src/**)` in any rule type| Yes| No -`Edit(**/src/**)` in any rule type| Yes| Yes - -In gitignore patterns, `*` matches within a single path segment and can appear at any position in the pattern, while `**` matches across directories. To allow all file access, use only the tool name without parentheses: `Read`, `Edit`, or `Write`. - -When you approve a file path with “Yes, don’t ask again”, Claude Code escapes gitignore pattern characters in that path, such as `[`, `]`, and `*`, so the generated rule matches only the literal path you approved. Rules you write yourself aren’t escaped. Before v2.1.202, Claude Code saved the path unescaped, so a generated rule for a directory named `[2024-06] Reports` could fail to match its own path or match unintended sibling directories. When Claude accesses a symlink, permission rules check two paths: the symlink itself and the file it resolves to. Allow and deny rules treat that pair differently: allow rules fall back to prompting you, while deny rules block outright. - - * **Allow rules** : apply only when both the symlink path and its target match. A symlink inside an allowed directory that points outside it still prompts you. - * **Deny rules** : apply when either the symlink path or its target matches. A symlink that points to a denied file is itself denied. - -For example, with `Read(./project/**)` allowed and `Read(~/.ssh/**)` denied, a symlink at `./project/key` pointing to `~/.ssh/id_rsa` is blocked: the target fails the allow rule and matches the deny rule. - -### - -​ - -WebFetch - -WebFetch rules use a `domain:` prefix and match against the hostname of the requested URL. Matching is case-insensitive, supports `*` wildcards, and strips a trailing `.` from both the rule and the hostname so `example.com.` and `example.com` are treated the same. - - * `WebFetch(domain:example.com)` matches requests to `example.com` - * `WebFetch(domain:*.example.com)` matches any subdomain at any depth, such as `api.example.com` or `a.b.example.com`, but not `example.com` itself - * `WebFetch(domain:*)` matches every domain and is equivalent to a bare `WebFetch` rule - -In any position other than a leading `*.` or a bare `*`, the wildcard matches only the text between two dots. `WebFetch(domain:example.*)` matches `example.org`, where `*` becomes `org`, but not `example.evil.com`, where `*` would have to become `evil.com` and cross a dot. This keeps a trailing wildcard from matching domains an attacker could register. - -### - -​ - -MCP - -MCP rules use the server name as configured in Claude Code, optionally followed by the name of a tool from that server. - - * `mcp__puppeteer` matches any tool provided by the `puppeteer` server - * `mcp__puppeteer__*` uses wildcard syntax and also matches all tools from the `puppeteer` server - * `mcp__puppeteer__puppeteer_navigate` matches the `puppeteer_navigate` tool provided by the `puppeteer` server - -If your organization has set a [claude.ai connector](</docs/en/mcp#organization-controls-on-connector-tools>) tool to `ask`, allow rules for that tool don’t take effect: Claude Code prompts on every call, even in `auto` and `bypassPermissions` modes. In `dontAsk` mode, which never prompts, Claude Code denies the call instead. Connector tools appear as `mcp__claude_ai_<server>__<tool>`. - -### - -​ - -Agent (subagents) - -Use `Agent(AgentName)` rules to control which [subagents](</docs/en/sub-agents>) Claude can use: - - * `Agent(Explore)` matches the Explore subagent - * `Agent(Plan)` matches the Plan subagent - * `Agent(my-custom-agent)` matches a custom subagent named `my-custom-agent` - -Add these rules to the `deny` array in your settings or use the `--disallowedTools` CLI flag to disable specific agents. To disable the Explore agent: - - { - "permissions": { - "deny": ["Agent(Explore)"] - } - } - -### - -​ - -Cd - -`Cd` rules control which directories the [`/cd` command](</docs/en/commands>) can move the session to. `Cd` is not a model-invocable tool: Claude can’t call it, and the rules apply only when you run `/cd` yourself. A bare `Cd` deny rule disables `/cd` entirely. A `Cd(<path-pattern>)` deny rule blocks matching targets. Deny rules check every spelling of the target, including each symlink hop it resolves through, so a rule written for one path also blocks targets that resolve to it. Adding any `Cd` allow rule switches `/cd` to allowlist mode: the resolved target directory must match one of your allow rules, or `/cd` refuses. With no `Cd` rules configured, `/cd` keeps its default behavior and prompts you to trust an unfamiliar directory. Path patterns share the `//`, `~/`, and `/` anchors from Read and Edit rules, but matching is anchored to the whole directory path rather than gitignore-style. `*` matches exactly one path segment and `**` matches across segments. A trailing `/**` also matches its named root. - -Rule| Matches| Does not match ----|---|--- -`Cd(~/code/*)`| `~/code/app`| `~/code/app/src`, `~/code` -`Cd(~/code/**)`| `~/code` and any directory under it| directories outside `~/code` -`Cd(**/node_modules)`| any `node_modules` directory at any depth| `node_modules/pkg` - -## - -​ - -Extend permissions with hooks - -[Claude Code hooks](</docs/en/hooks-guide>) let you register custom shell commands that evaluate permissions at runtime. When Claude Code makes a tool call, PreToolUse hooks run before the permission prompt, for every tool except [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>). The hook output can deny the tool call, force a prompt, or skip the prompt to let the call proceed. Hook decisions don’t bypass permission rules. Claude Code evaluates deny and ask rules regardless of what a PreToolUse hook returns: a matching deny rule blocks the call, and a matching ask rule still prompts even when the hook returned `"allow"` or `"ask"`. This preserves the deny-first precedence described in Manage permissions, including deny rules set in managed settings. Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>) also still prompt when a hook returns `"allow"`. A blocking hook also takes precedence over allow rules. A hook that exits with code 2 stops the tool call before permission rules are evaluated, so the block applies even when an allow rule would otherwise let the call proceed. To run all Bash commands without prompts except for a few you want blocked, add `"Bash"` to your allow list and register a PreToolUse hook that rejects those specific commands. See [Block edits to protected files](</docs/en/hooks-guide#block-edits-to-protected-files>) for a hook script you can adapt. - -## - -​ - -Working directories - -By default, Claude has access to files in the directory where you launched it. You can extend this access: - - * **During startup** : use `--add-dir <path>` CLI argument - * **During session** : use `/add-dir` command - * **Persistent configuration** : add to `additionalDirectories` in [settings files](</docs/en/settings#settings-files>) - -Files in additional directories follow the same permission rules as the original working directory: they become readable without prompts, and file editing permissions follow the current permission mode. In background sessions on macOS, the session host requests access to protected folders such as `~/Desktop`, `~/Documents`, and `~/Downloads` separately from your terminal when Claude needs to read or write files there; if reads there fail with `Operation not permitted`, see [how to grant folder access to background sessions](</docs/en/agent-view#background-sessions-can%E2%80%99t-read-desktop-documents-or-downloads-on-macos>). To change the session’s primary working directory instead of adding another, use [`/cd`](</docs/en/commands>). The `/cd` command requires Claude Code v2.1.169 or later. Unlike `/add-dir`, it relocates the session: the new directory’s `CLAUDE.md` is loaded and `--resume` finds the session from there. - -### - -​ - -Additional directories grant file access, not configuration - -Adding a directory extends where Claude can read and edit files. It doesn’t make that directory a full configuration root: most `.claude/` configuration is not discovered from additional directories, though a few types are loaded as exceptions. These exceptions apply only to directories added with the `--add-dir` flag or the `/add-dir` command. Directories listed in `permissions.additionalDirectories` in a settings file grant file access only and don’t load any of the configuration below. The following configuration types are loaded from `--add-dir` directories: - -Configuration| Loaded from `--add-dir` ----|--- -[Skills](</docs/en/skills>) in `.claude/skills/`| Yes, with live reload -[Subagents](</docs/en/sub-agents>) in `.claude/agents/`| Yes -[Settings](</docs/en/settings>) in `.claude/settings.json` and `.claude/settings.local.json`| `enabledPlugins` and `extraKnownMarketplaces` keys only -[CLAUDE.md](</docs/en/memory>) files, `.claude/rules/`, and `CLAUDE.local.md`| Only when `CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1` is set. `CLAUDE.local.md` additionally requires the `local` setting source, which is enabled by default - -Claude Code discovers commands and output styles from the current working directory and its parents, your user directory at `~/.claude/`, and managed settings. Hooks and other `.claude/settings.json` keys load from the current working directory’s `.claude/` folder with no parent-directory fallback, alongside your user `~/.claude/settings.json` and managed settings. `.claude/settings.local.json` loads from the git repository root instead, even when you start Claude Code in a subdirectory; before v2.1.211, it too loaded only from the current working directory. [Agent SDK](</docs/en/agent-sdk/claude-code-features#control-filesystem-settings-with-settingsources>) sessions load it from the working directory in all versions. To share that configuration across projects, use one of these approaches: - - * **User-level configuration** : place files in `~/.claude/agents/`, `~/.claude/output-styles/`, or `~/.claude/settings.json` to make them available in every project - * **Plugins** : package and distribute configuration as a [plugin](</docs/en/plugins>) that teams can install - * **Launch from the config directory** : run Claude Code from the directory containing the `.claude/` configuration you want - -## - -​ - -How permissions interact with sandboxing - -Permissions and [sandboxing](</docs/en/sandboxing>) are complementary security layers: - - * **Permissions** control which tools Claude Code can use and which files or domains it can access. They apply to Bash, Read, Edit, WebFetch, MCP, and every other tool, except that a deny or ask rule can’t block [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>) while any other tool remains. - * **Sandboxing** provides OS-level enforcement that restricts the Bash tool’s filesystem and network access. It applies only to Bash commands and their child processes. - -Use both for defense-in-depth: - - * Permission deny rules block Claude from even attempting to access restricted resources - * Sandbox restrictions prevent Bash commands from reaching resources outside defined boundaries, even if a prompt injection bypasses Claude’s decision-making - * Filesystem restrictions in the sandbox combine the [`sandbox.filesystem`](</docs/en/sandboxing>) settings with Read and Edit deny rules; both are merged into the final sandbox boundary - * Network restrictions combine WebFetch permission rules with the sandbox’s `allowedDomains` and `deniedDomains` lists - -When you enable sandboxing and leave `autoAllowBashIfSandboxed` at its default of `true`, sandboxed Bash commands run without prompting even if your permissions include a bare `Bash` ask rule, or the equivalent `Bash(*)` form: the sandbox boundary substitutes for that whole-tool prompt. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), Claude Code skips this substitution. Without an ask rule, the built-in read-only commands still run without prompting, and any other shell command prompts for approval while you are still planning, or goes to the classifier when [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) is available and `useAutoModeDuringPlan` is on. With a bare `Bash` ask rule, every Bash command prompts, including sandboxed read-only commands, the same as outside sandboxing. Before v2.1.212, the substitution applied in plan mode as well. In v2.1.212 through v2.1.217, those commands prompted even when auto mode was available. These checks still apply: - - * Content-scoped ask rules like `Bash(git push *)` still force a prompt - * Explicit deny rules still apply - * `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a prompt, or a classifier check in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>); the classifier routing requires Claude Code v2.1.218 or later - -Commands that won’t run sandboxed, such as excluded commands, respect the bare `Bash` ask rule as usual. See [sandbox modes](</docs/en/sandboxing#sandbox-modes>) to change this behavior. - -## - -​ - -Managed settings - -For organizations that need centralized control over Claude Code configuration, administrators can deploy managed settings that can’t be overridden by user or project settings, apart from the exceptions listed in the [settings reference’s precedence section](</docs/en/settings#settings-precedence>). These policy settings follow the same format as regular settings files and can be delivered through MDM/OS-level policies, managed settings files, [server-managed settings](</docs/en/server-managed-settings>), or a self-hosted [Claude apps gateway](</docs/en/claude-apps-gateway>). See [settings files](</docs/en/settings#settings-files>) for delivery mechanisms and file locations. - -### - -​ - -Managed-only settings - -The following settings are only read from managed settings. Placing them in user or project settings files has no effect. - -Setting| Description ----|--- -`allowAllClaudeAiMcps`| When `true`, claude.ai connectors load alongside a deployed `managed-mcp.json` instead of being suppressed by its exclusive control. See [Managed MCP configuration](</docs/en/managed-mcp>) -`allowedChannelPlugins`| Allowlist of channel plugins that may push messages. Replaces the default Anthropic allowlist when set. Requires `channelsEnabled: true`. See [Restrict which channel plugins can run](</docs/en/channels#restrict-which-channel-plugins-can-run>) -`allowManagedHooksOnly`| When `true`, only managed hooks, SDK hooks, and hooks from plugins force-enabled in managed settings `enabledPlugins` are loaded. User, project, and all other plugin hooks are blocked -`allowManagedMcpServersOnly`| When `true`, only `allowedMcpServers` from managed settings are respected. `deniedMcpServers` still merges from all sources. See [Managed MCP configuration](</docs/en/managed-mcp>) -`allowManagedPermissionRulesOnly`| When `true`, prevents user and project settings from defining `allow`, `ask`, or `deny` permission rules. Only rules in managed settings apply. Doesn’t affect the MCP server allowlist; for that, set `allowManagedMcpServersOnly` -`blockedMarketplaces`| Blocklist of marketplace sources. Blocked sources are checked before downloading, so they never touch the filesystem. See [managed marketplace restrictions](</docs/en/plugin-marketplaces#managed-marketplace-restrictions>) -`channelsEnabled`| Allow [channels](</docs/en/channels>) for the organization. See [enterprise controls](</docs/en/channels#enterprise-controls>) for the default on each plan -`disableSideloadFlags`| Reject the `--plugin-dir`, `--plugin-url`, `--agents`, and `--mcp-config` CLI flags at startup. Without this, users can bypass `strictKnownMarketplaces` for a single run by passing these flags. See [`disableSideloadFlags`](</docs/en/settings#available-settings>). Requires Claude Code v2.1.193 or later -`forceRemoteSettingsRefresh`| When `true`, blocks CLI startup until remote managed settings are freshly fetched and exits if the fetch fails. See [fail-closed enforcement](</docs/en/server-managed-settings#enforce-fail-closed-startup>) -`pluginTrustMessage`| Custom message appended to the plugin trust warning shown before installation -`sandbox.filesystem.allowManagedReadPathsOnly`| When `true`, only `filesystem.allowRead` paths from managed settings are respected. `denyRead` still merges from all sources -`sandbox.network.allowManagedDomainsOnly`| When `true`, only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are respected. Non-allowed domains are blocked automatically without prompting the user. Denied domains still merge from all sources -`strictKnownMarketplaces`| Controls which plugin marketplace sources users can add and install plugins from. See [managed marketplace restrictions](</docs/en/plugin-marketplaces#managed-marketplace-restrictions>) -`strictPluginOnlyCustomization`| Block skills, agents, hooks, and MCP servers from user and project sources, so they can only come from plugins or managed settings. `true` locks all four surfaces; an array such as `["skills", "hooks"]` locks only the named ones. See [`strictPluginOnlyCustomization`](</docs/en/settings#strictpluginonlycustomization>) -`wslInheritsWindowsSettings`| When `true` in the Windows HKLM registry key or `C:\Program Files\ClaudeCode\managed-settings.json`, WSL reads managed settings from the Windows policy chain in addition to `/etc/claude-code`. See [Settings files](</docs/en/settings#settings-files>) - -`disableBypassPermissionsMode` is typically placed in managed settings to enforce organizational policy, but it works from any scope. A user can set it in their own settings to lock themselves out of bypass mode. - -On Team and Enterprise plans, an Owner enables or disables [Remote Control](</docs/en/remote-control>) and [web sessions](</docs/en/claude-code-on-the-web>) organization-wide in [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>). Remote Control can additionally be disabled per device with the [`disableRemoteControl`](</docs/en/settings#available-settings>) setting. Web sessions have no per-device managed settings key. - -## - -​ - -Settings precedence - -Permission rules follow the same [settings precedence](</docs/en/settings#settings-precedence>) as all other Claude Code settings, with managed settings highest: no other level, including command line arguments, can override a managed permission rule. If a tool is denied at any level, no other level can allow it. For example, a managed settings deny can’t be overridden by `--allowedTools`, and `--disallowedTools` can add restrictions beyond what managed settings define. The same holds across settings scopes: if user settings allow a permission and project settings deny it, the deny rule blocks it. The reverse is also true: a user-level deny blocks a project-level allow, because deny rules from any scope are evaluated before allow rules. Embedding hosts can supply additional managed policy via the SDK `managedSettings` option, including permission allow rules unless the admin sets the `allowManaged*Only` locks; [Deliver policy to Claude Desktop sessions](</docs/en/claude-apps-gateway#deliver-policy-to-claude-desktop-sessions>) covers when embedder policy applies at all. - -## - -​ - -Project allow rules and workspace trust - -`permissions.allow` rules and `permissions.additionalDirectories` entries in a project’s `.claude/settings.json` grant capability, so Claude Code applies them only after you accept the [workspace trust dialog](</docs/en/security#additional-safeguards>) for that workspace. Until then, Claude Code reads the rules but doesn’t apply them. The trust dialog lists the allow rules and additional directories the folder would grant so you can review them before accepting. `deny` and `ask` rules aren’t affected, since they only restrict. Claude Code saves trust per workspace, keyed on the git repository root or, outside a repository, the directory you started Claude Code from. When you start in your home directory, trust is held for the current session only and isn’t written to disk; see the [additional safeguards](</docs/en/security#additional-safeguards>) note. Trusting a parent directory doesn’t apply a nested project’s allow rules. `.claude/settings.local.json` is your own file, so the workspace trust check usually doesn’t apply to it. When a repository could have supplied the file, such as when it is committed to git or `.claude` is a symlink, its allow rules and additional directories go through the trust check like project settings. Claude Code runs git to check whether the repository supplied the file, and it runs that check only in a folder covered by an accepted trust dialog, for that folder or for one of its parent directories. In an interactive session in a folder you haven’t trusted yet, allow rules and additional directories in `.claude/settings.local.json` go through the trust check like project settings until you accept the dialog, unless the session runs in your own configuration home as described below. Of the two exceptions below, only the configuration-home exception applies before the dialog, because it doesn’t need to run git. Determining that a directory isn’t inside a git repository uses the same git check, so the not-inside-a-repository exception takes effect once a trust dialog covering the folder is accepted. Before v2.1.207, an untracked `.claude/settings.local.json` applied its allow rules in that folder before you accepted the dialog. Allow rules and additional directories in `.claude/settings.local.json` also apply without workspace trust in two cases: - - * The directory you started Claude Code from isn’t inside a git repository. - * The session runs in your own configuration home: your home directory or any directory whose `.claude` subdirectory you’ve set as [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>). - -In both cases the file is one you created rather than one a repository could have supplied, and a repository-committed `.claude/settings.local.json` still requires workspace trust. Versions 2.1.196 through 2.1.199 treated the file as repository-supplied in those workspaces, ignored its allow rules, and printed a [`this workspace has not been trusted`](</docs/en/errors#workspace-has-not-been-trusted>) warning to stderr. The two exceptions above match v2.1.195 and earlier and were restored in v2.1.200. Also as of v2.1.200, a workspace whose allow rules or additional directories still aren’t applied, but that never showed the trust dialog because a parent directory was already trusted, shows the dialog the next time you start Claude Code there interactively. The dialog offers two choices: - - * **Yes, I trust this folder** : saves trust for that workspace and applies the rules in the same session. - * **No, continue without these permissions** : keeps working with those rules ignored. The dialog appears again in the next session. - -In [non-interactive mode](</docs/en/headless>) with `-p`, no dialog appears and the rules stay ignored. - -## - -​ - -Example configurations - -This [repository](<https://github.com/anthropics/claude-code/tree/main/examples/settings>) includes starter settings configurations for common deployment scenarios. Use these as starting points and adjust them to fit your needs. - -## - -​ - -See also - - * [Settings](</docs/en/settings>): complete configuration reference including the permission settings table - * [Configure auto mode](</docs/en/auto-mode-config>): tell the auto mode classifier which infrastructure your organization trusts - * [Sandboxing](</docs/en/sandboxing>): OS-level filesystem and network isolation for Bash commands - * [Authentication](</docs/en/authentication>): set up user access to Claude Code - * [Security](</docs/en/security>): security safeguards and best practices - * [Hooks](</docs/en/hooks-guide>): automate workflows and extend permission evaluation +Mode details + +#### + +​ + +Accept edits mode (`acceptEdits`) + +Auto-approves file operations so Claude can edit code without prompting. Other tools (like Bash commands that aren’t filesystem operations) still require normal permissions. **Auto-approved operations:** + + * File edits (Edit, Write tools) + * Filesystem commands: `mkdir`, `touch`, `rm`, `rmdir`, `mv`, `cp`, `sed` + +Both apply only to paths inside the working directory or `additionalDirectories`. Paths outside that scope and writes to protected paths still prompt. **Use when:** you trust Claude’s edits and want faster iteration, such as during prototyping or when working in an isolated directory. + +#### + +​ + +Don’t ask mode (`dontAsk`) + +Converts any permission prompt into a denial. Tools pre-approved by `allowed_tools`, `settings.json` allow rules, or a hook run as normal. Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) and tools that require user interaction are denied even when an allow rule matches. Everything else is denied without calling `canUseTool`. **Use when:** you want a fixed, explicit tool surface for a headless agent and prefer a hard deny over silent reliance on `canUseTool` being absent. + +#### + +​ + +Bypass permissions mode (`bypassPermissions`) + +Auto-approves tool uses without prompting, except the cases listed in the warning below. Hooks still execute and can block operations if needed. + +Use with extreme caution. Claude has full system access in this mode. Only use in controlled environments where you trust all possible operations.`allowed_tools` does not constrain this mode. Every tool is approved, not just the ones you listed. These controls still apply: + + * Deny rules, explicit `ask` rules, and hooks are evaluated before the mode check and can still block a tool. + * Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) and tools that require user interaction still fall through to your `canUseTool` callback. + * The [cross-session messaging safeguards](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) still apply. + +#### + +​ + +Plan mode (`plan`) + +Claude explores the codebase and produces a plan without editing your source files. Read-only tools run as in default mode. File edits are never auto-approved in plan mode, even when an allow rule matches. They prompt through your `canUseTool` callback instead. On Claude Code v2.1.212 or later, shell commands that modify files, such as `touch` and `rm`, reach your `canUseTool` callback the same way. Claude may use `AskUserQuestion` to clarify requirements before finalizing the plan. See [Handle approvals and user input](</docs/en/agent-sdk/user-input#handle-clarifying-questions>) for handling these prompts. **Use when:** you want Claude to propose changes without executing them, such as during code review or when you need to approve changes before they’re made. + +## + +​ + +Related resources + +For the other steps in the permission evaluation flow: + + * [Handle approvals and user input](</docs/en/agent-sdk/user-input>): interactive approval prompts and clarifying questions + * [Hooks guide](</docs/en/agent-sdk/hooks>): run custom code at key points in the agent lifecycle + * [Permission rules](</docs/en/settings#permission-settings>): declarative allow/deny rules in `settings.json`
modified
--- a/permissions.md +++ b/permissions.md @@ -47,9 +47,9 @@ `plan`| Claude reads files and runs read-only shell commands to explore but doesn’t edit your source files; with [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) available, classifier-approved commands also run. Labeled Plan in the CLI and the VS Code extension `auto`| Auto-approves tool calls with background safety checks that verify actions align with your request `dontAsk`| Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules. `AskUserQuestion`, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>) are denied even if you’ve allowed them -`bypassPermissions`| Skips permission prompts, except those forced by explicit `ask` rules, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>). Root and home directory removals such as `rm -rf /` also still prompt as a circuit breaker - -`bypassPermissions` mode skips permission prompts, including for writes to [protected paths](</docs/en/permission-modes#protected-paths>) such as `.git` and `.claude`. Only use this mode in isolated environments like containers or VMs where Claude Code can’t cause damage.A few prompts still fire in this mode. Explicit `ask` rules, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>) still prompt. Removals targeting the filesystem root or home directory, such as `rm -rf /` and `rm -rf ~`, also prompt as a circuit breaker against model error, including when the command contains command substitution with `$(...)` or backticks, or process substitution with `<(...)`. +`bypassPermissions`| Skips permission prompts, except those forced by explicit `ask` rules, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>). Root and home directory removals such as `rm -rf /` also still prompt as a circuit breaker, and the [cross-session messaging safeguards](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) still apply + +`bypassPermissions` mode skips permission prompts, including for writes to [protected paths](</docs/en/permission-modes#protected-paths>) such as `.git` and `.claude`. The [cross-session messaging safeguards](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) still apply. Only use this mode in isolated environments like containers or VMs where Claude Code can’t cause damage.A few prompts still fire in this mode. Explicit `ask` rules, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>) still prompt. Removals targeting the filesystem root or home directory, such as `rm -rf /` and `rm -rf ~`, also prompt as a circuit breaker against model error, including when the command contains command substitution with `$(...)` or backticks, or process substitution with `<(...)`. To prevent `bypassPermissions` or `auto` mode from being used, set `permissions.disableBypassPermissionsMode` or `permissions.disableAutoMode` to `"disable"` in any [settings file](</docs/en/settings#settings-files>). These are most useful in managed settings where they can’t be overridden.
modified
--- a/permissions.md +++ b/permissions.md @@ -49,7 +49,7 @@ `dontAsk`| Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules. `AskUserQuestion`, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>) are denied even if you’ve allowed them `bypassPermissions`| Skips permission prompts, except those forced by explicit `ask` rules, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>). Root and home directory removals such as `rm -rf /` also still prompt as a circuit breaker -`bypassPermissions` mode skips permission prompts, including for writes to `.git`, `.config/git`, `.claude`, `.vscode`, `.idea`, `.husky`, `.cargo`, `.devcontainer`, `.yarn`, and `.mvn`. Only use this mode in isolated environments like containers or VMs where Claude Code can’t cause damage.A few prompts still fire in this mode. Explicit `ask` rules, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>) still prompt. Removals targeting the filesystem root or home directory, such as `rm -rf /` and `rm -rf ~`, also prompt as a circuit breaker against model error, including when the command contains command substitution with `$(...)` or backticks, or process substitution with `<(...)`. Before v2.1.208, only the plain form, such as `rm -rf ~` typed as its own command, prompted; commands that reached the removal through a substitution didn’t. +`bypassPermissions` mode skips permission prompts, including for writes to [protected paths](</docs/en/permission-modes#protected-paths>) such as `.git` and `.claude`. Only use this mode in isolated environments like containers or VMs where Claude Code can’t cause damage.A few prompts still fire in this mode. Explicit `ask` rules, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>) still prompt. Removals targeting the filesystem root or home directory, such as `rm -rf /` and `rm -rf ~`, also prompt as a circuit breaker against model error, including when the command contains command substitution with `$(...)` or backticks, or process substitution with `<(...)`. To prevent `bypassPermissions` or `auto` mode from being used, set `permissions.disableBypassPermissionsMode` or `permissions.disableAutoMode` to `"disable"` in any [settings file](</docs/en/settings#settings-files>). These are most useful in managed settings where they can’t be overridden. @@ -122,7 +122,7 @@ Wildcard patterns -Bash rules support glob patterns with `*`. Wildcards can appear at any position in the command. This configuration allows npm and git commit commands while blocking git push: +Bash rules support glob patterns with `*`. This configuration allows npm and git commit commands while blocking git push: { "permissions": { @@ -139,7 +139,7 @@ } } -The space before `*` matters: `Bash(ls *)` matches `ls -la` but not `lsof`, while `Bash(ls*)` matches both. The `:*` suffix is an equivalent way to write a trailing wildcard, so `Bash(ls:*)` matches the same commands as `Bash(ls *)`. The permission dialog writes the space-separated form when you select “Yes, don’t ask again” for a command prefix. The `:*` form is only recognized at the end of a pattern. In a pattern like `Bash(git:* push)`, the colon is treated as a literal character and won’t match git commands. +The `:*` suffix is an equivalent way to write a trailing wildcard, so `Bash(ls:*)` matches the same commands as `Bash(ls *)`. The permission dialog writes the space-separated form when you select “Yes, don’t ask again” for a command prefix. The `:*` form is only recognized at the end of a pattern. In a pattern like `Bash(git:* push)`, the colon is treated as a literal character and won’t match git commands. ### @@ -509,15 +509,7 @@ Settings precedence -Permission rules follow the same [settings precedence](</docs/en/settings#settings-precedence>) as all other Claude Code settings: - - 1. **Managed settings** : no other level, including command line arguments, can override a managed permission rule - 2. **Command line arguments** : temporary session overrides - 3. **Local project settings** (`.claude/settings.local.json`) - 4. **Shared project settings** (`.claude/settings.json`) - 5. **User settings** (`~/.claude/settings.json`) - -If a tool is denied at any level, no other level can allow it. For example, a managed settings deny can’t be overridden by `--allowedTools`, and `--disallowedTools` can add restrictions beyond what managed settings define. The same holds across settings scopes: if user settings allow a permission and project settings deny it, the deny rule blocks it. The reverse is also true: a user-level deny blocks a project-level allow, because deny rules from any scope are evaluated before allow rules. Embedding hosts can supply additional managed policy via the SDK `managedSettings` option, including permission allow rules unless the admin sets the `allowManaged*Only` locks; [Deliver policy to Claude Desktop sessions](</docs/en/claude-apps-gateway#deliver-policy-to-claude-desktop-sessions>) covers when embedder policy applies at all. +Permission rules follow the same [settings precedence](</docs/en/settings#settings-precedence>) as all other Claude Code settings, with managed settings highest: no other level, including command line arguments, can override a managed permission rule. If a tool is denied at any level, no other level can allow it. For example, a managed settings deny can’t be overridden by `--allowedTools`, and `--disallowedTools` can add restrictions beyond what managed settings define. The same holds across settings scopes: if user settings allow a permission and project settings deny it, the deny rule blocks it. The reverse is also true: a user-level deny blocks a project-level allow, because deny rules from any scope are evaluated before allow rules. Embedding hosts can supply additional managed policy via the SDK `managedSettings` option, including permission allow rules unless the admin sets the `allowManaged*Only` locks; [Deliver policy to Claude Desktop sessions](</docs/en/claude-apps-gateway#deliver-policy-to-claude-desktop-sessions>) covers when embedder policy applies at all. ##
modified
--- a/permissions.md +++ b/permissions.md @@ -471,7 +471,7 @@ Managed settings -For organizations that need centralized control over Claude Code configuration, administrators can deploy managed settings that can’t be overridden by user or project settings. These policy settings follow the same format as regular settings files and can be delivered through MDM/OS-level policies, managed settings files, [server-managed settings](</docs/en/server-managed-settings>), or a self-hosted [Claude apps gateway](</docs/en/claude-apps-gateway>). See [settings files](</docs/en/settings#settings-files>) for delivery mechanisms and file locations. +For organizations that need centralized control over Claude Code configuration, administrators can deploy managed settings that can’t be overridden by user or project settings, apart from the exceptions listed in the [settings reference’s precedence section](</docs/en/settings#settings-precedence>). These policy settings follow the same format as regular settings files and can be delivered through MDM/OS-level policies, managed settings files, [server-managed settings](</docs/en/server-managed-settings>), or a self-hosted [Claude apps gateway](</docs/en/claude-apps-gateway>). See [settings files](</docs/en/settings#settings-files>) for delivery mechanisms and file locations. ### @@ -511,7 +511,7 @@ Permission rules follow the same [settings precedence](</docs/en/settings#settings-precedence>) as all other Claude Code settings: - 1. **Managed settings** : can’t be overridden by any other level, including command line arguments + 1. **Managed settings** : no other level, including command line arguments, can override a managed permission rule 2. **Command line arguments** : temporary session overrides 3. **Local project settings** (`.claude/settings.local.json`) 4. **Shared project settings** (`.claude/settings.json`)
modified
--- a/permissions.md +++ b/permissions.md @@ -1,4 +1,4 @@ -Claude Code supports fine-grained permissions so that you can specify exactly what the agent is allowed to do and what it can’t. Permission settings can be checked into version control and distributed to all developers in your organization, as well as customized by individual developers. +Claude Code supports fine-grained permissions so that you can specify exactly what the agent is allowed to do and what it can’t. You can check permission settings into version control to share them with every developer in your organization, and each developer can customize their own. ## @@ -114,7 +114,7 @@ * The value is compared against the literal input Claude sends, before any normalization. `Agent(model:opus)` matches the alias `opus` but not a full model ID. Run with [`--verbose`](</docs/en/cli-reference>) to see the exact parameter names and values in each tool call * Whitespace around the colon is ignored -Fields that a tool already matches with its own canonicalizing rules are not matchable this way: `command` for Bash and PowerShell, `file_path` for Read, Edit, and Write, `path` for Grep and Glob, `notebook_path` for NotebookEdit, and `url` for WebFetch. A rule like `Bash(command:rm *)` would be bypassable by a compound command, so Claude Code ignores it and emits a startup warning. Use `Bash(rm *)`, `Read(./path)`, or `WebFetch(domain:host)` instead. +You can’t match a tool’s primary content field this way: `command` for Bash and PowerShell, `file_path` for Read, Edit, and Write, `path` for Grep and Glob, `notebook_path` for NotebookEdit, and `url` for WebFetch. A rule like `Bash(command:rm *)` would be bypassable by a compound command, so Claude Code ignores it and emits a startup warning. Use `Bash(rm *)`, `Read(./path)`, or `WebFetch(domain:host)` instead. ### @@ -262,7 +262,7 @@ Read and Edit -`Edit` rules apply to all built-in tools that edit files. Claude makes a best-effort attempt to apply `Read` rules to all built-in tools that read files like Grep and Glob, to `@file` mentions in your prompts, and to the selection and open-file context that a connected [IDE](</docs/en/vs-code#the-built-in-ide-mcp-server>) shares with Claude. A `Read` deny rule also blocks the [Edit tool](</docs/en/errors#file-is-covered-by-a-read-deny-rule>) on the same path, including creating a new file there. Write and NotebookEdit aren’t covered, so add an `Edit` deny rule for paths no tool may change. Requires Claude Code v2.1.208 or later. The file permission checks match only `Edit(path)` and `Read(path)` rules. A `Write(path)`, `NotebookEdit(path)`, or `Glob(path)` rule is accepted but never matched by those checks, so Claude Code warns at startup for each allow, deny, or ask rule in one of these unmatched forms. Use `Edit(docs/**)` in place of `Write(docs/**)` or `NotebookEdit(docs/**)`, and `Read(docs/**)` in place of `Glob(docs/**)`. A tool-name rule with no path, such as a deny rule for `Write`, isn’t affected: it matches the tool everywhere and produces no warning. Requires Claude Code v2.1.210 or later. A deny rule `Write(docs/**)` in project settings produces this startup warning: +`Edit` rules apply to all built-in tools that edit files. Claude makes a best-effort attempt to apply `Read` rules to all built-in tools that read files like Grep and Glob, to `@file` mentions in your prompts, and to the selection and open-file context that a connected [IDE](</docs/en/vs-code#the-built-in-ide-mcp-server>) shares with Claude. A `Read` deny rule also blocks the [Edit tool](</docs/en/errors#file-is-covered-by-a-read-deny-rule>) on the same path, including creating a new file there. Write and NotebookEdit aren’t covered, so add an `Edit` deny rule for paths no tool may change. Requires Claude Code v2.1.208 or later. Claude Code checks file permissions against `Edit(path)` and `Read(path)` rules only. If you write a path rule for `Write`, `NotebookEdit`, `Glob`, or the legacy `MultiEdit` tool instead, Claude Code accepts the rule but never consults it, and [warns at startup](</docs/en/errors#is-not-matched-by-file-permission-checks>), except for a `Glob` rule passed in `--allowedTools`. Use `Edit(docs/**)` in place of `Write(docs/**)`, `NotebookEdit(docs/**)`, or `MultiEdit(docs/**)`, and `Read(docs/**)` in place of `Glob(docs/**)`. Claude Code doesn’t warn about a tool-name rule with no path, such as a deny rule for `Write`; it matches that rule at the tool level everywhere. Requires Claude Code v2.1.210 or later. If you put a deny rule `Write(docs/**)` in project settings, Claude Code prints this startup warning: Permission deny rule (.claude/settings.json): Write(docs/**) is not matched by file permission checks — only Edit(path) rules are. Use Edit(docs/**) instead (Edit rules cover all file-editing tools).
modified
--- a/permissions.md +++ b/permissions.md @@ -44,7 +44,7 @@ ---|--- `default`| Standard behavior: prompts for permission on first use of each tool. Labeled Manual in the CLI, the VS Code and JetBrains extensions, and the desktop app, and Claude Code accepts `manual` as an alias. The label and alias require Claude Code v2.1.200 or later. The desktop app’s label doesn’t depend on your CLI version `acceptEdits`| Automatically accepts file edits and common filesystem commands such as `mkdir`, `touch`, `mv`, and `cp` for paths in the working directory or `additionalDirectories` -`plan`| Claude reads files and runs read-only shell commands to explore but doesn’t edit your source files. Labeled Plan in the CLI and the VS Code extension +`plan`| Claude reads files and runs read-only shell commands to explore but doesn’t edit your source files; with [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) available, classifier-approved commands also run. Labeled Plan in the CLI and the VS Code extension `auto`| Auto-approves tool calls with background safety checks that verify actions align with your request `dontAsk`| Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules. `AskUserQuestion`, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>) are denied even if you’ve allowed them `bypassPermissions`| Skips permission prompts, except those forced by explicit `ask` rules, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>). Root and home directory removals such as `rm -rf /` also still prompt as a circuit breaker @@ -457,11 +457,11 @@ * Filesystem restrictions in the sandbox combine the [`sandbox.filesystem`](</docs/en/sandboxing>) settings with Read and Edit deny rules; both are merged into the final sandbox boundary * Network restrictions combine WebFetch permission rules with the sandbox’s `allowedDomains` and `deniedDomains` lists -When you enable sandboxing and leave `autoAllowBashIfSandboxed` at its default of `true`, sandboxed Bash commands run without prompting even if your permissions include a bare `Bash` ask rule, or the equivalent `Bash(*)` form: the sandbox boundary substitutes for that whole-tool prompt. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), Claude Code skips this substitution. Without an ask rule, the built-in read-only commands still run without prompting, and any other shell command prompts for approval while you are still planning. With a bare `Bash` ask rule, every Bash command prompts, including sandboxed read-only commands, the same as outside sandboxing. Before v2.1.212, the substitution applied in plan mode as well. These checks still apply: +When you enable sandboxing and leave `autoAllowBashIfSandboxed` at its default of `true`, sandboxed Bash commands run without prompting even if your permissions include a bare `Bash` ask rule, or the equivalent `Bash(*)` form: the sandbox boundary substitutes for that whole-tool prompt. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), Claude Code skips this substitution. Without an ask rule, the built-in read-only commands still run without prompting, and any other shell command prompts for approval while you are still planning, or goes to the classifier when [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) is available and `useAutoModeDuringPlan` is on. With a bare `Bash` ask rule, every Bash command prompts, including sandboxed read-only commands, the same as outside sandboxing. Before v2.1.212, the substitution applied in plan mode as well. In v2.1.212 through v2.1.217, those commands prompted even when auto mode was available. These checks still apply: * Content-scoped ask rules like `Bash(git push *)` still force a prompt * Explicit deny rules still apply - * `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a prompt + * `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a prompt, or a classifier check in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>); the classifier routing requires Claude Code v2.1.218 or later Commands that won’t run sandboxed, such as excluded commands, respect the bare `Bash` ask rule as usual. See [sandbox modes](</docs/en/sandboxing#sandbox-modes>) to change this behavior.
modified
--- a/permissions.md +++ b/permissions.md @@ -205,7 +205,18 @@ Read-only commands -Claude Code recognizes a built-in set of Bash commands as read-only and runs them without a permission prompt in every mode. These include `ls`, `cat`, `echo`, `pwd`, `head`, `tail`, `grep`, `find`, `wc`, `which`, `diff`, `stat`, `du`, `cd`, and read-only forms of `git`. The set is not configurable; to require a prompt for one of these commands, add an `ask` or `deny` rule for it. Unquoted glob patterns are permitted for commands whose every flag is read-only, so `ls *.ts` and `wc -l src/*.py` run without a prompt. Commands with write-capable or exec-capable flags, such as `find`, `sort`, `sed`, and `git`, still prompt when an unquoted glob is present because the glob could expand to a flag like `-delete`. A `cd` into a path inside your working directory or an additional directory is also read-only. A compound command like `cd packages/api && ls` runs without a prompt when each part qualifies on its own. Combining `cd` with `git` in one compound command prompts when the `cd` changes into a different directory, since running `git` in a new directory can execute that directory’s hooks. A `cd` whose target resolves to the current working directory is a no-op and doesn’t trigger this prompt. Combining `cd` with an output redirect in one compound command also prompts when Claude Code can’t determine which directory the redirect target resolves against after the `cd` runs. A command whose only redirect target is `/dev/null`, such as `cd app; grep -r pattern . 2>/dev/null`, doesn’t trigger this prompt, because `/dev/null` doesn’t depend on the working directory. Before v2.1.207, a compound command containing `cd` prompted for any output redirect, including one whose only target was `/dev/null`. +Claude Code recognizes a built-in set of Bash commands as read-only and runs them without a permission prompt in every mode. These include `ls`, `cat`, `echo`, `pwd`, `head`, `tail`, `grep`, `find`, `wc`, `which`, `diff`, `stat`, `du`, `cd`, and read-only forms of `git`. The set is not configurable; to require a prompt for one of these commands, add an `ask` or `deny` rule for it. Unquoted glob patterns are permitted for commands whose every flag is read-only, so `ls *.ts` and `wc -l src/*.py` run without a prompt. Commands from this set still prompt in these cases: + + * **Unquoted globs for commands with write-capable flags** : commands with write-capable or exec-capable flags, such as `find`, `sort`, `sed`, and `git`, prompt when an unquoted glob is present, because the glob could expand to a flag like `-delete`. + * **`docker` pointed at another daemon**: read-only forms of `docker` prompt when the command carries a flag that selects a different daemon, such as `-H`, `--context`, or Podman’s `--url` and `--connection`. + * **`file` with path-opening flags**: `file` prompts when it passes `-m`/`--magic-file` or `-f`/`--files-from`, because those flags make `file` open the paths named in the flag’s value. + * **Network paths on Windows** : a command whose arguments include a network (UNC) path, such as `\\server\share\file`, prompts because accessing a network path can send your Windows credentials to the host it names. The same check applies to [PowerShell tool](</docs/en/tools-reference#powershell-tool>) commands. + * **Commands the analysis can’t parse** : when Claude Code can’t fully parse a command, it asks for approval instead of treating the command as read-only. Commands longer than 10,000 characters always prompt because they exceed what the analysis parses. + +A `cd` into a path inside your working directory or an additional directory is also read-only, and a compound command like `cd packages/api && ls` runs without a prompt when each part qualifies on its own. Two combinations prompt even when each part is read-only: + + * **`cd` with `git`**: prompts when the `cd` changes into a different directory, since running `git` in a new directory can execute that directory’s hooks. A `cd` whose target resolves to the current working directory is a no-op and doesn’t trigger the prompt. + * **`cd` with an output redirect**: prompts when Claude Code can’t determine which directory the redirect target resolves against after the `cd` runs. A command whose only redirect target is `/dev/null`, such as `cd app; grep -r pattern . 2>/dev/null`, doesn’t prompt, because `/dev/null` doesn’t depend on the working directory. Bash permission patterns that try to constrain command arguments are fragile. For example, `Bash(curl http://github.com/ *)` intends to restrict curl to GitHub URLs, but won’t match variations like: @@ -257,7 +268,7 @@ Read and Edit deny rules apply to Claude’s built-in file tools and to file commands Claude Code recognizes in Bash, such as `cat`, `head`, `tail`, and `sed`. They don’t apply to arbitrary subprocesses that read or write files indirectly, like a Python or Node script that opens files itself. For OS-level enforcement that blocks all processes from accessing a path, [enable the sandbox](</docs/en/sandboxing>). -Read and Edit rules both follow the [gitignore](<https://git-scm.com/docs/gitignore>) specification with four distinct pattern types: +Read and Edit rules both use [gitignore](<https://git-scm.com/docs/gitignore>) pattern syntax with four distinct pattern types; for single-segment directory patterns, the matching depth also depends on the rule type, described later in this section: Pattern| Meaning| Example| Matches ---|---|---|--- @@ -283,14 +294,36 @@ * `Edit(/docs/**)`: edits in `<project>/docs/`, not `/docs/` or `<project>/.claude/docs/` * `Read(~/.zshrc)`: reads your home directory’s `.zshrc` * `Edit(//tmp/scratch.txt)`: edits the absolute path `/tmp/scratch.txt` - * `Read(src/**)`: reads from `<current-directory>/src/` - -A rule only matches files under its anchor, so the anchor determines how far a deny rule reaches. Bare filenames follow gitignore semantics and match at any depth, so `Read(.env)` and `Read(**/.env)` are equivalent: + * `Read(src/**)`: as an allow rule, reads from `<current-directory>/src/` only; as a deny or ask rule, matches a `src` directory at any depth under the current directory + +A rule only matches files under its anchor; within that bound, matching depth depends on the pattern shape and, for single-segment directory patterns, the rule type, described below. Bare filenames follow gitignore semantics and match at any depth, so `Read(.env)` and `Read(**/.env)` are equivalent: Deny rule| Blocks| Does not block ---|---|--- `Read(.env)` or `Read(**/.env)`| any `.env` at or under the current directory| `.env` in a parent directory or another project `Read(//**/.env)`| any `.env` anywhere on the filesystem| nothing; the rule is anchored at the filesystem root + +A relative pattern with a single directory segment, such as `src/**`, matches at different depths depending on the rule type: + + * **Allow rules** : `Edit(src/**)` matches only `<cwd>/src` and the files under it. To allow a directory name at any depth, write `Edit(**/src/**)`. + * **Deny and ask rules** : `Read(secrets/**)` matches a directory named `secrets` at any depth under the current directory, so the rule also applies to nested copies. + +Every other pattern shape matches at the same depth in every rule type: `Edit(/src/**)` and `Edit(src/components/**)` match only at their anchored location, while `Edit(**/src/**)` matches at any depth. The following example shows each pattern shape against a project with a top-level `src/` directory and a nested copy under `vendor/`: + + <current-directory>/ + ├── src/ + │ └── app.ts + └── vendor/ + └── pkg/ + └── src/ + └── lib.js + +Rule| Matches `src/app.ts`| Matches `vendor/pkg/src/lib.js` +---|---|--- +`Edit(src/**)` as an allow rule| Yes| No +`Edit(src/**)` as a deny or ask rule| Yes| Yes +`Edit(/src/**)` in any rule type| Yes| No +`Edit(**/src/**)` in any rule type| Yes| Yes In gitignore patterns, `*` matches within a single path segment and can appear at any position in the pattern, while `**` matches across directories. To allow all file access, use only the tool name without parentheses: `Read`, `Edit`, or `Write`.
modified
--- a/permissions.md +++ b/permissions.md @@ -28,7 +28,7 @@ * **Ask** rules prompt for confirmation whenever Claude Code tries to use the specified tool. * **Deny** rules prevent Claude Code from using the specified tool. -Rules are evaluated in order: deny, then ask, then allow. The first match in that order determines the outcome, and rule specificity doesn’t change the order. A broad deny rule like `Bash(aws *)` blocks every matching call, including calls that also match a narrower allow rule like `Bash(aws s3 ls)`, so a deny rule can’t carry allowlist exceptions. The same precedence applies between ask and allow: a matching ask rule prompts even when a more specific allow rule also matches the same call. Deny rules behave differently depending on whether they name a tool or scope a pattern within one. A bare tool name like `Bash` removes the tool from Claude’s context entirely, so Claude never sees it. A scoped rule like `Bash(rm *)` leaves the tool available and blocks matching calls when Claude attempts them. +Rules are evaluated in order: deny, then ask, then allow. The first match in that order determines the outcome, and rule specificity doesn’t change the order. A broad deny rule like `Bash(aws *)` blocks every matching call, including calls that also match a narrower allow rule like `Bash(aws s3 ls)`, so a deny rule can’t carry allowlist exceptions. The same precedence applies between ask and allow: a matching ask rule prompts even when a more specific allow rule also matches the same call. Deny rules behave differently depending on whether they name a tool or scope a pattern within one. A bare tool name like `Bash` removes the tool from Claude’s context entirely, so Claude never sees it. Bare-name removal applies to every tool except [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>): a deny rule can’t remove it while any other tool remains, and an ask rule never prompts for it. A scoped rule like `Bash(rm *)` leaves the tool available and blocks matching calls when Claude attempts them. Permission rules are enforced by Claude Code, not by the model. Instructions in your prompt or `CLAUDE.md` shape what Claude tries to do, but they don’t change what Claude Code allows. To grant or revoke access, use `/permissions`, the rules described here, a [permission mode](</docs/en/permission-modes>), or a PreToolUse hook. @@ -147,7 +147,7 @@ Tool name wildcards -Deny and ask rules also accept glob patterns in the tool-name position. The pattern must match the full tool name: `"*"` matches every tool, and `"mcp__*"` matches every MCP tool across all servers. A tool matched by a bare-name glob deny rule is removed from Claude’s context, the same as a bare tool name. This configuration denies every MCP tool: +Deny and ask rules also accept glob patterns in the tool-name position. The pattern must match the full tool name: `"*"` matches every tool, and `"mcp__*"` matches every MCP tool across all servers. A tool matched by a bare-name glob deny rule is removed from Claude’s context, the same as a bare tool name, including the [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>) exception: a glob deny can’t remove it while any other tool remains, and a glob ask never prompts for it. This configuration denies every MCP tool: { "permissions": { @@ -195,9 +195,9 @@ ​ -Process wrappers - -Before matching Bash rules, Claude Code strips a fixed set of process wrappers so a rule like `Bash(npm test *)` also matches `timeout 30 npm test`. The recognized wrappers are `timeout`, `time`, `nice`, `nohup`, and `stdbuf`. Bare `xargs` is also stripped, so `Bash(grep *)` matches `xargs grep pattern`. Stripping applies only when `xargs` has no flags: an invocation like `xargs -n1 grep pattern` is matched as an `xargs` command, so rules written for the inner command do not cover it. This wrapper list is built in and is not configurable. Development environment runners such as `direnv exec`, `devbox run`, `mise exec`, `npx`, and `docker exec` are not in the list. Because these tools execute their arguments as a command, a rule like `Bash(devbox run *)` matches whatever comes after `run`, including `devbox run rm -rf .`. To approve work inside an environment runner, write a specific rule that includes both the runner and the inner command, such as `Bash(devbox run npm test)`. Add one rule per inner command you want to allow. Exec wrappers such as `watch`, `setsid`, `ionice`, and `flock` always prompt and can’t be auto-approved by a prefix rule like `Bash(watch *)`. The same applies to `find` with `-exec` or `-delete`: a `Bash(find *)` rule doesn’t cover these forms. To approve a specific invocation, write an exact-match rule for the full command string. +Wrappers + +Before matching Bash rules, Claude Code strips a fixed set of wrappers, so a rule like `Bash(npm test *)` also matches `timeout 30 npm test`. The stripped wrappers are `timeout`, `time`, `nice`, `nohup`, and `stdbuf`, plus the shell builtins `command` and `builtin`, and zsh’s `noglob`. Each runs its argument as the actual command. Two related forms aren’t stripped: the query form `command -v`, which looks up a command rather than running one, and zsh’s `nocorrect`. Claude Code also strips a leading assignment of certain known-safe environment variables, so `Bash(npm test *)` matches `NODE_ENV=test npm test`. An allow rule won’t match past an assignment of any other variable. A deny or ask rule matches past any leading assignment, so `Bash(rm *)` in deny still matches `FOO=bar rm -rf tmp/`. Bare `xargs` is also stripped, so `Bash(grep *)` matches `xargs grep pattern`. Stripping applies only when `xargs` has no flags: an invocation like `xargs -n1 grep pattern` is matched as an `xargs` command, so rules written for the inner command do not cover it. This wrapper list is built in and is not configurable. Development environment runners such as `direnv exec`, `devbox run`, `mise exec`, `npx`, and `docker exec` are not in the list. Because these tools execute their arguments as a command, a rule like `Bash(devbox run *)` matches whatever comes after `run`, including `devbox run rm -rf .`. To approve work inside an environment runner, write a specific rule that includes both the runner and the inner command, such as `Bash(devbox run npm test)`. Add one rule per inner command you want to allow. Exec wrappers such as `watch`, `setsid`, `ionice`, and `flock` always prompt and can’t be auto-approved by a prefix rule like `Bash(watch *)`. The same applies to `find` with `-exec` or `-delete`: a `Bash(find *)` rule doesn’t cover these forms. To approve a specific invocation, write an exact-match rule for the full command string. #### @@ -369,7 +369,7 @@ Extend permissions with hooks -[Claude Code hooks](</docs/en/hooks-guide>) provide a way to register custom shell commands to perform permission evaluation at runtime. When Claude Code makes a tool call, PreToolUse hooks run before the permission prompt. The hook output can deny the tool call, force a prompt, or skip the prompt to let the call proceed. Hook decisions don’t bypass permission rules. Claude Code evaluates deny and ask rules regardless of what a PreToolUse hook returns: a matching deny rule blocks the call, and a matching ask rule still prompts even when the hook returned `"allow"` or `"ask"`. This preserves the deny-first precedence described in Manage permissions, including deny rules set in managed settings. Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>) also still prompt when a hook returns `"allow"`. A blocking hook also takes precedence over allow rules. A hook that exits with code 2 stops the tool call before permission rules are evaluated, so the block applies even when an allow rule would otherwise let the call proceed. To run all Bash commands without prompts except for a few you want blocked, add `"Bash"` to your allow list and register a PreToolUse hook that rejects those specific commands. See [Block edits to protected files](</docs/en/hooks-guide#block-edits-to-protected-files>) for a hook script you can adapt. +[Claude Code hooks](</docs/en/hooks-guide>) let you register custom shell commands that evaluate permissions at runtime. When Claude Code makes a tool call, PreToolUse hooks run before the permission prompt, for every tool except [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>). The hook output can deny the tool call, force a prompt, or skip the prompt to let the call proceed. Hook decisions don’t bypass permission rules. Claude Code evaluates deny and ask rules regardless of what a PreToolUse hook returns: a matching deny rule blocks the call, and a matching ask rule still prompts even when the hook returned `"allow"` or `"ask"`. This preserves the deny-first precedence described in Manage permissions, including deny rules set in managed settings. Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>) also still prompt when a hook returns `"allow"`. A blocking hook also takes precedence over allow rules. A hook that exits with code 2 stops the tool call before permission rules are evaluated, so the block applies even when an allow rule would otherwise let the call proceed. To run all Bash commands without prompts except for a few you want blocked, add `"Bash"` to your allow list and register a PreToolUse hook that rejects those specific commands. See [Block edits to protected files](</docs/en/hooks-guide#block-edits-to-protected-files>) for a hook script you can adapt. ## @@ -414,7 +414,7 @@ Permissions and [sandboxing](</docs/en/sandboxing>) are complementary security layers: - * **Permissions** control which tools Claude Code can use and which files or domains it can access. They apply to all tools, including Bash, Read, Edit, WebFetch, and MCP. + * **Permissions** control which tools Claude Code can use and which files or domains it can access. They apply to Bash, Read, Edit, WebFetch, MCP, and every other tool, except that a deny or ask rule can’t block [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>) while any other tool remains. * **Sandboxing** provides OS-level enforcement that restricts the Bash tool’s filesystem and network access. It applies only to Bash commands and their child processes. Use both for defense-in-depth:
modified
--- a/permissions.md +++ b/permissions.md @@ -424,7 +424,7 @@ * Filesystem restrictions in the sandbox combine the [`sandbox.filesystem`](</docs/en/sandboxing>) settings with Read and Edit deny rules; both are merged into the final sandbox boundary * Network restrictions combine WebFetch permission rules with the sandbox’s `allowedDomains` and `deniedDomains` lists -When sandboxing is enabled with `autoAllowBashIfSandboxed: true`, which is the default, sandboxed Bash commands run without prompting even if your permissions include a bare `Bash` ask rule, or the equivalent `Bash(*)` form: the sandbox boundary substitutes for that whole-tool prompt. These checks still apply: +When you enable sandboxing and leave `autoAllowBashIfSandboxed` at its default of `true`, sandboxed Bash commands run without prompting even if your permissions include a bare `Bash` ask rule, or the equivalent `Bash(*)` form: the sandbox boundary substitutes for that whole-tool prompt. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), Claude Code skips this substitution. Without an ask rule, the built-in read-only commands still run without prompting, and any other shell command prompts for approval while you are still planning. With a bare `Bash` ask rule, every Bash command prompts, including sandboxed read-only commands, the same as outside sandboxing. Before v2.1.212, the substitution applied in plan mode as well. These checks still apply: * Content-scoped ask rules like `Bash(git push *)` still force a prompt * Explicit deny rules still apply @@ -484,7 +484,7 @@ 4. **Shared project settings** (`.claude/settings.json`) 5. **User settings** (`~/.claude/settings.json`) -If a tool is denied at any level, no other level can allow it. For example, a managed settings deny can’t be overridden by `--allowedTools`, and `--disallowedTools` can add restrictions beyond what managed settings define. The same holds across settings scopes: if user settings allow a permission and project settings deny it, the deny rule blocks it. The reverse is also true: a user-level deny blocks a project-level allow, because deny rules from any scope are evaluated before allow rules. Embedding hosts can supply additional managed policy via the SDK `managedSettings` option when [`parentSettingsBehavior`](</docs/en/settings#settings-precedence>) is set to `"merge"`; embedder values can tighten policy but not loosen it. +If a tool is denied at any level, no other level can allow it. For example, a managed settings deny can’t be overridden by `--allowedTools`, and `--disallowedTools` can add restrictions beyond what managed settings define. The same holds across settings scopes: if user settings allow a permission and project settings deny it, the deny rule blocks it. The reverse is also true: a user-level deny blocks a project-level allow, because deny rules from any scope are evaluated before allow rules. Embedding hosts can supply additional managed policy via the SDK `managedSettings` option, including permission allow rules unless the admin sets the `allowManaged*Only` locks; [Deliver policy to Claude Desktop sessions](</docs/en/claude-apps-gateway#deliver-policy-to-claude-desktop-sessions>) covers when embedder policy applies at all. ##
modified
--- a/permissions.md +++ b/permissions.md @@ -11,10 +11,10 @@ Tool type| Example| Approval required| ”Yes, don’t ask again” behavior ---|---|---|--- Read-only| File reads, Grep| No, within the working directory and additional directories| N/A -Bash commands| Shell execution| Yes, except a built-in set of read-only commands| Permanently per project directory and command +Bash commands| Shell execution| Yes, except a built-in set of read-only commands| Permanently per repository and command File modification| Edit/write files| Yes| Until session end -On a Bash or PowerShell permission prompt, press `Ctrl+E` to show an explanation of the command: what it does, why Claude is running it, and what could go wrong, labeled **Low risk** , **Med risk** , or **High risk**. Claude Code sends the command and Claude’s own description of the call to the model to generate the explanation only when you press `Ctrl+E`, not on every prompt. Showing the explanation doesn’t run the command; press `Ctrl+E` again to hide it. To turn the shortcut off, set [`permissionExplainerEnabled`](</docs/en/settings#global-config-settings>) to `false` in `~/.claude.json`. +When you choose “Yes, don’t ask again” and the approval saves permanently, such as for a Bash command, Claude Code saves the rule to `.claude/settings.local.json` at the root of the git repository, resolved through [worktrees](</docs/en/worktrees>) to the main checkout. The rule applies to future sessions anywhere in that repository, including sessions started in subdirectories and in worktrees. A file-modification approval isn’t saved to the file: as the table shows, it lasts until the session ends. Outside a git repository, and when the repository root is your home directory, Claude Code saves the rule in the directory you started it from. Before v2.1.211, Claude Code always saved the rule in the starting directory, so an approval granted in a worktree or subdirectory didn’t apply to the rest of the repository. Rules that earlier versions saved in a subdirectory or worktree still apply to sessions started there. On a Bash or PowerShell permission prompt, press `Ctrl+E` to show an explanation of the command: what it does, why Claude is running it, and what could go wrong, labeled **Low risk** , **Med risk** , or **High risk**. Claude Code sends the command and Claude’s own description of the call to the model to generate the explanation only when you press `Ctrl+E`, not on every prompt. Showing the explanation doesn’t run the command; press `Ctrl+E` again to hide it. To turn the shortcut off, set [`permissionExplainerEnabled`](</docs/en/settings#global-config-settings>) to `false` in `~/.claude.json`. ## @@ -211,7 +211,7 @@ * Options before URL: `curl -X GET http://github.com/...` * Different protocol: `curl https://github.com/...` - * Redirects: `curl -L http://bit.ly/xyz`, which redirects to GitHub + * Redirects: `curl -L http://short.example.com/xyz`, which redirects to GitHub * Variables: `URL=http://github.com && curl $URL` * Extra spaces: `curl http://github.com` @@ -251,7 +251,9 @@ Read and Edit -`Edit` rules apply to all built-in tools that edit files. Claude makes a best-effort attempt to apply `Read` rules to all built-in tools that read files like Grep and Glob, to `@file` mentions in your prompts, and to the selection and open-file context that a connected [IDE](</docs/en/vs-code#the-built-in-ide-mcp-server>) shares with Claude. A `Read` deny rule also blocks the [Edit tool](</docs/en/errors#file-is-covered-by-a-read-deny-rule>) on the same path, including creating a new file there. Write and NotebookEdit aren’t covered, so add an `Edit` deny rule for paths no tool may change. Requires Claude Code v2.1.208 or later. +`Edit` rules apply to all built-in tools that edit files. Claude makes a best-effort attempt to apply `Read` rules to all built-in tools that read files like Grep and Glob, to `@file` mentions in your prompts, and to the selection and open-file context that a connected [IDE](</docs/en/vs-code#the-built-in-ide-mcp-server>) shares with Claude. A `Read` deny rule also blocks the [Edit tool](</docs/en/errors#file-is-covered-by-a-read-deny-rule>) on the same path, including creating a new file there. Write and NotebookEdit aren’t covered, so add an `Edit` deny rule for paths no tool may change. Requires Claude Code v2.1.208 or later. The file permission checks match only `Edit(path)` and `Read(path)` rules. A `Write(path)`, `NotebookEdit(path)`, or `Glob(path)` rule is accepted but never matched by those checks, so Claude Code warns at startup for each allow, deny, or ask rule in one of these unmatched forms. Use `Edit(docs/**)` in place of `Write(docs/**)` or `NotebookEdit(docs/**)`, and `Read(docs/**)` in place of `Glob(docs/**)`. A tool-name rule with no path, such as a deny rule for `Write`, isn’t affected: it matches the tool everywhere and produces no warning. Requires Claude Code v2.1.210 or later. A deny rule `Write(docs/**)` in project settings produces this startup warning: + + Permission deny rule (.claude/settings.json): Write(docs/**) is not matched by file permission checks — only Edit(path) rules are. Use Edit(docs/**) instead (Edit rules cover all file-editing tools). Read and Edit deny rules apply to Claude’s built-in file tools and to file commands Claude Code recognizes in Bash, such as `cat`, `head`, `tail`, and `sed`. They don’t apply to arbitrary subprocesses that read or write files indirectly, like a Python or Node script that opens files itself. For OS-level enforcement that blocks all processes from accessing a path, [enable the sandbox](</docs/en/sandboxing>). @@ -266,16 +268,17 @@ A pattern like `/Users/alice/file` isn’t an absolute path. The single leading slash anchors at the settings source, not the filesystem root. Use `//Users/alice/file` for absolute paths. -A `/path` pattern anchors at the directory associated with the settings file that defines it, so the same rule matches different locations depending on where you put it: +A `/path` pattern anchors at a directory associated with the settings source that defines it, so the same rule matches different locations depending on where you put it: Rule defined in| `/path` resolves to ---|--- -Project or local settings, such as `.claude/settings.json`| `<project root>/path` +Project settings at `.claude/settings.json`| `<project root>/path` +Local settings at `.claude/settings.local.json`| `<original cwd>/path` User settings at `~/.claude/settings.json`| `~/.claude/path` A file passed with `--settings <file>`| `<directory of file>/path` CLI flags, `/permissions`, or session rules| `<original cwd>/path` -A deny rule such as `Read(/secrets/**)` in user settings blocks `~/.claude/secrets/**`, not a `secrets` directory in your project. To write a rule in user settings that applies inside every project, use a `//` absolute path or a `~/` home-relative path instead. On Windows, paths are normalized to POSIX form before matching. `C:\Users\alice` becomes `/c/Users/alice`, so use `//c/**/.env` to match `.env` files anywhere on that drive. To match across all drives, use `//**/.env`. Examples: +Local settings rules anchor at the directory you started Claude Code from, not at the repository root where Claude Code stores the file in v2.1.211 and later. In a session started at the repository root, the two directories are the same; in a [worktree](</docs/en/worktrees>) session, a shared rule such as `Edit(/src/**)` matches that worktree’s own `src/` directory. A deny rule such as `Read(/secrets/**)` in user settings blocks `~/.claude/secrets/**`, not a `secrets` directory in your project. To write a rule in user settings that applies inside every project, use a `//` absolute path or a `~/` home-relative path instead. On Windows, paths are normalized to POSIX form before matching. `C:\Users\alice` becomes `/c/Users/alice`, so use `//c/**/.env` to match `.env` files anywhere on that drive. To match across all drives, use `//**/.env`. Examples: * `Edit(/docs/**)`: edits in `<project>/docs/`, not `/docs/` or `<project>/.claude/docs/` * `Read(~/.zshrc)`: reads your home directory’s `.zshrc` @@ -397,7 +400,7 @@ [Settings](</docs/en/settings>) in `.claude/settings.json` and `.claude/settings.local.json`| `enabledPlugins` and `extraKnownMarketplaces` keys only [CLAUDE.md](</docs/en/memory>) files, `.claude/rules/`, and `CLAUDE.local.md`| Only when `CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1` is set. `CLAUDE.local.md` additionally requires the `local` setting source, which is enabled by default -Commands and output styles are discovered from the current working directory and its parents, your user directory at `~/.claude/`, and managed settings. Hooks and other `settings.json` keys load from the current working directory’s `.claude/` folder with no parent-directory fallback, alongside your user `~/.claude/settings.json` and managed settings. To share that configuration across projects, use one of these approaches: +Claude Code discovers commands and output styles from the current working directory and its parents, your user directory at `~/.claude/`, and managed settings. Hooks and other `.claude/settings.json` keys load from the current working directory’s `.claude/` folder with no parent-directory fallback, alongside your user `~/.claude/settings.json` and managed settings. `.claude/settings.local.json` loads from the git repository root instead, even when you start Claude Code in a subdirectory; before v2.1.211, it too loaded only from the current working directory. [Agent SDK](</docs/en/agent-sdk/claude-code-features#control-filesystem-settings-with-settingsources>) sessions load it from the working directory in all versions. To share that configuration across projects, use one of these approaches: * **User-level configuration** : place files in `~/.claude/agents/`, `~/.claude/output-styles/`, or `~/.claude/settings.json` to make them available in every project * **Plugins** : package and distribute configuration as a [plugin](</docs/en/plugins>) that teams can install
modified
--- a/permissions.md +++ b/permissions.md @@ -46,10 +46,10 @@ `acceptEdits`| Automatically accepts file edits and common filesystem commands such as `mkdir`, `touch`, `mv`, and `cp` for paths in the working directory or `additionalDirectories` `plan`| Claude reads files and runs read-only shell commands to explore but doesn’t edit your source files. Labeled Plan in the CLI and the VS Code extension `auto`| Auto-approves tool calls with background safety checks that verify actions align with your request -`dontAsk`| Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules -`bypassPermissions`| Skips permission prompts, except those forced by explicit `ask` rules. Root and home directory removals such as `rm -rf /` also still prompt as a circuit breaker - -`bypassPermissions` mode skips permission prompts, including for writes to `.git`, `.config/git`, `.claude`, `.vscode`, `.idea`, `.husky`, `.cargo`, `.devcontainer`, `.yarn`, and `.mvn`. Explicit `ask` rules still force a prompt, and removals targeting the filesystem root or home directory, such as `rm -rf /` and `rm -rf ~`, still prompt as a circuit breaker against model error, including in commands that contain command substitution with `$(...)` or backticks, or process substitution with `<(...)`. The plain form, such as `rm -rf ~` typed as its own command, has prompted in this mode since the circuit breaker was introduced; v2.1.208 extends the same check to commands that reach the removal through a substitution. Before v2.1.208, commands containing those forms didn’t prompt in this mode. Only use this mode in isolated environments like containers or VMs where Claude Code can’t cause damage. +`dontAsk`| Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules. `AskUserQuestion`, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>) are denied even if you’ve allowed them +`bypassPermissions`| Skips permission prompts, except those forced by explicit `ask` rules, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>). Root and home directory removals such as `rm -rf /` also still prompt as a circuit breaker + +`bypassPermissions` mode skips permission prompts, including for writes to `.git`, `.config/git`, `.claude`, `.vscode`, `.idea`, `.husky`, `.cargo`, `.devcontainer`, `.yarn`, and `.mvn`. Only use this mode in isolated environments like containers or VMs where Claude Code can’t cause damage.A few prompts still fire in this mode. Explicit `ask` rules, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>) still prompt. Removals targeting the filesystem root or home directory, such as `rm -rf /` and `rm -rf ~`, also prompt as a circuit breaker against model error, including when the command contains command substitution with `$(...)` or backticks, or process substitution with `<(...)`. Before v2.1.208, only the plain form, such as `rm -rf ~` typed as its own command, prompted; commands that reached the removal through a substitution didn’t. To prevent `bypassPermissions` or `auto` mode from being used, set `permissions.disableBypassPermissionsMode` or `permissions.disableAutoMode` to `"disable"` in any [settings file](</docs/en/settings#settings-files>). These are most useful in managed settings where they can’t be overridden. @@ -324,6 +324,8 @@ * `mcp__puppeteer__*` uses wildcard syntax and also matches all tools from the `puppeteer` server * `mcp__puppeteer__puppeteer_navigate` matches the `puppeteer_navigate` tool provided by the `puppeteer` server +If your organization has set a [claude.ai connector](</docs/en/mcp#organization-controls-on-connector-tools>) tool to `ask`, allow rules for that tool don’t take effect: Claude Code prompts on every call, even in `auto` and `bypassPermissions` modes. In `dontAsk` mode, which never prompts, Claude Code denies the call instead. Connector tools appear as `mcp__claude_ai_<server>__<tool>`. + ### ​ @@ -364,7 +366,7 @@ Extend permissions with hooks -[Claude Code hooks](</docs/en/hooks-guide>) provide a way to register custom shell commands to perform permission evaluation at runtime. When Claude Code makes a tool call, PreToolUse hooks run before the permission prompt. The hook output can deny the tool call, force a prompt, or skip the prompt to let the call proceed. Hook decisions don’t bypass permission rules. Deny and ask rules are evaluated regardless of what a PreToolUse hook returns, so a matching deny rule blocks the call and a matching ask rule still prompts even when the hook returned `"allow"` or `"ask"`. This preserves the deny-first precedence described in Manage permissions, including deny rules set in managed settings. A blocking hook also takes precedence over allow rules. A hook that exits with code 2 stops the tool call before permission rules are evaluated, so the block applies even when an allow rule would otherwise let the call proceed. To run all Bash commands without prompts except for a few you want blocked, add `"Bash"` to your allow list and register a PreToolUse hook that rejects those specific commands. See [Block edits to protected files](</docs/en/hooks-guide#block-edits-to-protected-files>) for a hook script you can adapt. +[Claude Code hooks](</docs/en/hooks-guide>) provide a way to register custom shell commands to perform permission evaluation at runtime. When Claude Code makes a tool call, PreToolUse hooks run before the permission prompt. The hook output can deny the tool call, force a prompt, or skip the prompt to let the call proceed. Hook decisions don’t bypass permission rules. Claude Code evaluates deny and ask rules regardless of what a PreToolUse hook returns: a matching deny rule blocks the call, and a matching ask rule still prompts even when the hook returned `"allow"` or `"ask"`. This preserves the deny-first precedence described in Manage permissions, including deny rules set in managed settings. Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>) also still prompt when a hook returns `"allow"`. A blocking hook also takes precedence over allow rules. A hook that exits with code 2 stops the tool call before permission rules are evaluated, so the block applies even when an allow rule would otherwise let the call proceed. To run all Bash commands without prompts except for a few you want blocked, add `"Bash"` to your allow list and register a PreToolUse hook that rejects those specific commands. See [Block edits to protected files](</docs/en/hooks-guide#block-edits-to-protected-files>) for a hook script you can adapt. ## @@ -378,7 +380,7 @@ * **During session** : use `/add-dir` command * **Persistent configuration** : add to `additionalDirectories` in [settings files](</docs/en/settings#settings-files>) -Files in additional directories follow the same permission rules as the original working directory: they become readable without prompts, and file editing permissions follow the current permission mode. To change the session’s primary working directory instead of adding another, use [`/cd`](</docs/en/commands>). The `/cd` command requires Claude Code v2.1.169 or later. Unlike `/add-dir`, it relocates the session: the new directory’s `CLAUDE.md` is loaded and `--resume` finds the session from there. +Files in additional directories follow the same permission rules as the original working directory: they become readable without prompts, and file editing permissions follow the current permission mode. In background sessions on macOS, the session host requests access to protected folders such as `~/Desktop`, `~/Documents`, and `~/Downloads` separately from your terminal when Claude needs to read or write files there; if reads there fail with `Operation not permitted`, see [how to grant folder access to background sessions](</docs/en/agent-view#background-sessions-can%E2%80%99t-read-desktop-documents-or-downloads-on-macos>). To change the session’s primary working directory instead of adding another, use [`/cd`](</docs/en/commands>). The `/cd` command requires Claude Code v2.1.169 or later. Unlike `/add-dir`, it relocates the session: the new directory’s `CLAUDE.md` is loaded and `--resume` finds the session from there. ###
modified
--- a/permissions.md +++ b/permissions.md @@ -49,7 +49,7 @@ `dontAsk`| Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules `bypassPermissions`| Skips permission prompts, except those forced by explicit `ask` rules. Root and home directory removals such as `rm -rf /` also still prompt as a circuit breaker -`bypassPermissions` mode skips permission prompts, including for writes to `.git`, `.config/git`, `.claude`, `.vscode`, `.idea`, `.husky`, `.cargo`, `.devcontainer`, `.yarn`, and `.mvn`. Explicit `ask` rules still force a prompt, and removals targeting the filesystem root or home directory, such as `rm -rf /` and `rm -rf ~`, still prompt as a circuit breaker against model error. Only use this mode in isolated environments like containers or VMs where Claude Code can’t cause damage. +`bypassPermissions` mode skips permission prompts, including for writes to `.git`, `.config/git`, `.claude`, `.vscode`, `.idea`, `.husky`, `.cargo`, `.devcontainer`, `.yarn`, and `.mvn`. Explicit `ask` rules still force a prompt, and removals targeting the filesystem root or home directory, such as `rm -rf /` and `rm -rf ~`, still prompt as a circuit breaker against model error, including in commands that contain command substitution with `$(...)` or backticks, or process substitution with `<(...)`. The plain form, such as `rm -rf ~` typed as its own command, has prompted in this mode since the circuit breaker was introduced; v2.1.208 extends the same check to commands that reach the removal through a substitution. Before v2.1.208, commands containing those forms didn’t prompt in this mode. Only use this mode in isolated environments like containers or VMs where Claude Code can’t cause damage. To prevent `bypassPermissions` or `auto` mode from being used, set `permissions.disableBypassPermissionsMode` or `permissions.disableAutoMode` to `"disable"` in any [settings file](</docs/en/settings#settings-files>). These are most useful in managed settings where they can’t be overridden. @@ -251,7 +251,7 @@ Read and Edit -`Edit` rules apply to all built-in tools that edit files. Claude makes a best-effort attempt to apply `Read` rules to all built-in tools that read files like Grep and Glob, to `@file` mentions in your prompts, and to the selection and open-file context that a connected [IDE](</docs/en/vs-code#the-built-in-ide-mcp-server>) shares with Claude. +`Edit` rules apply to all built-in tools that edit files. Claude makes a best-effort attempt to apply `Read` rules to all built-in tools that read files like Grep and Glob, to `@file` mentions in your prompts, and to the selection and open-file context that a connected [IDE](</docs/en/vs-code#the-built-in-ide-mcp-server>) shares with Claude. A `Read` deny rule also blocks the [Edit tool](</docs/en/errors#file-is-covered-by-a-read-deny-rule>) on the same path, including creating a new file there. Write and NotebookEdit aren’t covered, so add an `Edit` deny rule for paths no tool may change. Requires Claude Code v2.1.208 or later. Read and Edit deny rules apply to Claude’s built-in file tools and to file commands Claude Code recognizes in Bash, such as `cat`, `head`, `tail`, and `sed`. They don’t apply to arbitrary subprocesses that read or write files indirectly, like a Python or Node script that opens files itself. For OS-level enforcement that blocks all processes from accessing a path, [enable the sandbox](</docs/en/sandboxing>).
modified
--- a/permissions.md +++ b/permissions.md @@ -14,6 +14,8 @@ Bash commands| Shell execution| Yes, except a built-in set of read-only commands| Permanently per project directory and command File modification| Edit/write files| Yes| Until session end +On a Bash or PowerShell permission prompt, press `Ctrl+E` to show an explanation of the command: what it does, why Claude is running it, and what could go wrong, labeled **Low risk** , **Med risk** , or **High risk**. Claude Code sends the command and Claude’s own description of the call to the model to generate the explanation only when you press `Ctrl+E`, not on every prompt. Showing the explanation doesn’t run the command; press `Ctrl+E` again to hide it. To turn the shortcut off, set [`permissionExplainerEnabled`](</docs/en/settings#global-config-settings>) to `false` in `~/.claude.json`. + ## ​ @@ -40,7 +42,7 @@ Mode| Description ---|--- -`default`| Standard behavior: prompts for permission on first use of each tool. Labeled Manual in the CLI and the VS Code and JetBrains extensions, and Claude Code accepts `manual` as an alias. The label and alias require Claude Code v2.1.200 or later +`default`| Standard behavior: prompts for permission on first use of each tool. Labeled Manual in the CLI, the VS Code and JetBrains extensions, and the desktop app, and Claude Code accepts `manual` as an alias. The label and alias require Claude Code v2.1.200 or later. The desktop app’s label doesn’t depend on your CLI version `acceptEdits`| Automatically accepts file edits and common filesystem commands such as `mkdir`, `touch`, `mv`, and `cp` for paths in the working directory or `additionalDirectories` `plan`| Claude reads files and runs read-only shell commands to explore but doesn’t edit your source files. Labeled Plan in the CLI and the VS Code extension `auto`| Auto-approves tool calls with background safety checks that verify actions align with your request @@ -203,7 +205,7 @@ Read-only commands -Claude Code recognizes a built-in set of Bash commands as read-only and runs them without a permission prompt in every mode. These include `ls`, `cat`, `echo`, `pwd`, `head`, `tail`, `grep`, `find`, `wc`, `which`, `diff`, `stat`, `du`, `cd`, and read-only forms of `git`. The set is not configurable; to require a prompt for one of these commands, add an `ask` or `deny` rule for it. Unquoted glob patterns are permitted for commands whose every flag is read-only, so `ls *.ts` and `wc -l src/*.py` run without a prompt. Commands with write-capable or exec-capable flags, such as `find`, `sort`, `sed`, and `git`, still prompt when an unquoted glob is present because the glob could expand to a flag like `-delete`. A `cd` into a path inside your working directory or an additional directory is also read-only. A compound command like `cd packages/api && ls` runs without a prompt when each part qualifies on its own. Combining `cd` with `git` in one compound command prompts when the `cd` changes into a different directory, since running `git` in a new directory can execute that directory’s hooks. A `cd` whose target resolves to the current working directory is a no-op and doesn’t trigger this prompt. +Claude Code recognizes a built-in set of Bash commands as read-only and runs them without a permission prompt in every mode. These include `ls`, `cat`, `echo`, `pwd`, `head`, `tail`, `grep`, `find`, `wc`, `which`, `diff`, `stat`, `du`, `cd`, and read-only forms of `git`. The set is not configurable; to require a prompt for one of these commands, add an `ask` or `deny` rule for it. Unquoted glob patterns are permitted for commands whose every flag is read-only, so `ls *.ts` and `wc -l src/*.py` run without a prompt. Commands with write-capable or exec-capable flags, such as `find`, `sort`, `sed`, and `git`, still prompt when an unquoted glob is present because the glob could expand to a flag like `-delete`. A `cd` into a path inside your working directory or an additional directory is also read-only. A compound command like `cd packages/api && ls` runs without a prompt when each part qualifies on its own. Combining `cd` with `git` in one compound command prompts when the `cd` changes into a different directory, since running `git` in a new directory can execute that directory’s hooks. A `cd` whose target resolves to the current working directory is a no-op and doesn’t trigger this prompt. Combining `cd` with an output redirect in one compound command also prompts when Claude Code can’t determine which directory the redirect target resolves against after the `cd` runs. A command whose only redirect target is `/dev/null`, such as `cd app; grep -r pattern . 2>/dev/null`, doesn’t trigger this prompt, because `/dev/null` doesn’t depend on the working directory. Before v2.1.207, a compound command containing `cd` prompted for any output redirect, including one whose only target was `/dev/null`. Bash permission patterns that try to constrain command arguments are fragile. For example, `Bash(curl http://github.com/ *)` intends to restrict curl to GitHub URLs, but won’t match variations like: @@ -485,7 +487,7 @@ Project allow rules and workspace trust -`permissions.allow` rules and `permissions.additionalDirectories` entries in a project’s `.claude/settings.json` grant capability, so Claude Code applies them only after you accept the [workspace trust dialog](</docs/en/security#additional-safeguards>) for that workspace. Until then, Claude Code reads the rules but doesn’t apply them. The trust dialog lists the allow rules and additional directories the folder would grant so you can review them before accepting. `deny` and `ask` rules aren’t affected, since they only restrict. Claude Code saves trust per workspace, keyed on the git repository root or, outside a repository, the directory you started Claude Code from. When you start in your home directory, trust is held for the current session only and isn’t written to disk; see the [additional safeguards](</docs/en/security#additional-safeguards>) note. Trusting a parent directory doesn’t apply a nested project’s allow rules. `.claude/settings.local.json` is your own file, so the workspace trust check usually doesn’t apply to it. When a repository could have supplied the file, such as when it is committed to git or `.claude` is a symlink, its allow rules and additional directories go through the trust check like project settings. Allow rules and additional directories in `.claude/settings.local.json` also apply without workspace trust in two cases: +`permissions.allow` rules and `permissions.additionalDirectories` entries in a project’s `.claude/settings.json` grant capability, so Claude Code applies them only after you accept the [workspace trust dialog](</docs/en/security#additional-safeguards>) for that workspace. Until then, Claude Code reads the rules but doesn’t apply them. The trust dialog lists the allow rules and additional directories the folder would grant so you can review them before accepting. `deny` and `ask` rules aren’t affected, since they only restrict. Claude Code saves trust per workspace, keyed on the git repository root or, outside a repository, the directory you started Claude Code from. When you start in your home directory, trust is held for the current session only and isn’t written to disk; see the [additional safeguards](</docs/en/security#additional-safeguards>) note. Trusting a parent directory doesn’t apply a nested project’s allow rules. `.claude/settings.local.json` is your own file, so the workspace trust check usually doesn’t apply to it. When a repository could have supplied the file, such as when it is committed to git or `.claude` is a symlink, its allow rules and additional directories go through the trust check like project settings. Claude Code runs git to check whether the repository supplied the file, and it runs that check only in a folder covered by an accepted trust dialog, for that folder or for one of its parent directories. In an interactive session in a folder you haven’t trusted yet, allow rules and additional directories in `.claude/settings.local.json` go through the trust check like project settings until you accept the dialog, unless the session runs in your own configuration home as described below. Of the two exceptions below, only the configuration-home exception applies before the dialog, because it doesn’t need to run git. Determining that a directory isn’t inside a git repository uses the same git check, so the not-inside-a-repository exception takes effect once a trust dialog covering the folder is accepted. Before v2.1.207, an untracked `.claude/settings.local.json` applied its allow rules in that folder before you accepted the dialog. Allow rules and additional directories in `.claude/settings.local.json` also apply without workspace trust in two cases: * The directory you started Claude Code from isn’t inside a git repository. * The session runs in your own configuration home: your home directory or any directory whose `.claude` subdirectory you’ve set as [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>).
modified
--- a/permissions.md +++ b/permissions.md @@ -10,8 +10,8 @@ Tool type| Example| Approval required| ”Yes, don’t ask again” behavior ---|---|---|--- -Read-only| File reads, Grep| No| N/A -Bash commands| Shell execution| Yes| Permanently per project directory and command +Read-only| File reads, Grep| No, within the working directory and additional directories| N/A +Bash commands| Shell execution| Yes, except a built-in set of read-only commands| Permanently per project directory and command File modification| Edit/write files| Yes| Until session end ## @@ -43,7 +43,7 @@ `default`| Standard behavior: prompts for permission on first use of each tool. Labeled Manual in the CLI and the VS Code and JetBrains extensions, and Claude Code accepts `manual` as an alias. The label and alias require Claude Code v2.1.200 or later `acceptEdits`| Automatically accepts file edits and common filesystem commands such as `mkdir`, `touch`, `mv`, and `cp` for paths in the working directory or `additionalDirectories` `plan`| Claude reads files and runs read-only shell commands to explore but doesn’t edit your source files. Labeled Plan in the CLI and the VS Code extension -`auto`| Auto-approves tool calls with background safety checks that verify actions align with your request. Currently a research preview +`auto`| Auto-approves tool calls with background safety checks that verify actions align with your request `dontAsk`| Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules `bypassPermissions`| Skips permission prompts, except those forced by explicit `ask` rules. Root and home directory removals such as `rm -rf /` also still prompt as a circuit breaker
modified
--- a/permissions.md +++ b/permissions.md @@ -42,7 +42,7 @@ ---|--- `default`| Standard behavior: prompts for permission on first use of each tool. Labeled Manual in the CLI and the VS Code and JetBrains extensions, and Claude Code accepts `manual` as an alias. The label and alias require Claude Code v2.1.200 or later `acceptEdits`| Automatically accepts file edits and common filesystem commands such as `mkdir`, `touch`, `mv`, and `cp` for paths in the working directory or `additionalDirectories` -`plan`| Plan Mode: Claude reads files and runs read-only shell commands to explore but doesn’t edit your source files +`plan`| Claude reads files and runs read-only shell commands to explore but doesn’t edit your source files. Labeled Plan in the CLI and the VS Code extension `auto`| Auto-approves tool calls with background safety checks that verify actions align with your request. Currently a research preview `dontAsk`| Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules `bypassPermissions`| Skips permission prompts, except those forced by explicit `ask` rules. Root and home directory removals such as `rm -rf /` also still prompt as a circuit breaker
modified
--- a/permissions.md +++ b/permissions.md @@ -203,7 +203,7 @@ Read-only commands -Claude Code recognizes a built-in set of Bash commands as read-only and runs them without a permission prompt in every mode. These include `ls`, `cat`, `echo`, `pwd`, `head`, `tail`, `grep`, `find`, `wc`, `which`, `diff`, `stat`, `du`, `cd`, and read-only forms of `git`. The set is not configurable; to require a prompt for one of these commands, add an `ask` or `deny` rule for it. Unquoted glob patterns are permitted for commands whose every flag is read-only, so `ls *.ts` and `wc -l src/*.py` run without a prompt. Commands with write-capable or exec-capable flags, such as `find`, `sort`, `sed`, and `git`, still prompt when an unquoted glob is present because the glob could expand to a flag like `-delete`. A `cd` into a path inside your working directory or an additional directory is also read-only. A compound command like `cd packages/api && ls` runs without a prompt when each part qualifies on its own. Combining `cd` with `git` in one compound command always prompts, regardless of the target directory. +Claude Code recognizes a built-in set of Bash commands as read-only and runs them without a permission prompt in every mode. These include `ls`, `cat`, `echo`, `pwd`, `head`, `tail`, `grep`, `find`, `wc`, `which`, `diff`, `stat`, `du`, `cd`, and read-only forms of `git`. The set is not configurable; to require a prompt for one of these commands, add an `ask` or `deny` rule for it. Unquoted glob patterns are permitted for commands whose every flag is read-only, so `ls *.ts` and `wc -l src/*.py` run without a prompt. Commands with write-capable or exec-capable flags, such as `find`, `sort`, `sed`, and `git`, still prompt when an unquoted glob is present because the glob could expand to a flag like `-delete`. A `cd` into a path inside your working directory or an additional directory is also read-only. A compound command like `cd packages/api && ls` runs without a prompt when each part qualifies on its own. Combining `cd` with `git` in one compound command prompts when the `cd` changes into a different directory, since running `git` in a new directory can execute that directory’s hooks. A `cd` whose target resolves to the current working directory is a no-op and doesn’t trigger this prompt. Bash permission patterns that try to constrain command arguments are fragile. For example, `Bash(curl http://github.com/ *)` intends to restrict curl to GitHub URLs, but won’t match variations like: @@ -289,7 +289,7 @@ In gitignore patterns, `*` matches within a single path segment and can appear at any position in the pattern, while `**` matches across directories. To allow all file access, use only the tool name without parentheses: `Read`, `Edit`, or `Write`. -When Claude accesses a symlink, permission rules check two paths: the symlink itself and the file it resolves to. Allow and deny rules treat that pair differently: allow rules fall back to prompting you, while deny rules block outright. +When you approve a file path with “Yes, don’t ask again”, Claude Code escapes gitignore pattern characters in that path, such as `[`, `]`, and `*`, so the generated rule matches only the literal path you approved. Rules you write yourself aren’t escaped. Before v2.1.202, Claude Code saved the path unescaped, so a generated rule for a directory named `[2024-06] Reports` could fail to match its own path or match unintended sibling directories. When Claude accesses a symlink, permission rules check two paths: the symlink itself and the file it resolves to. Allow and deny rules treat that pair differently: allow rules fall back to prompting you, while deny rules block outright. * **Allow rules** : apply only when both the symlink path and its target match. A symlink inside an allowed directory that points outside it still prompts you. * **Deny rules** : apply when either the symlink path or its target matches. A symlink that points to a denied file is itself denied.
modified
--- a/permissions.md +++ b/permissions.md @@ -40,7 +40,7 @@ Mode| Description ---|--- -`default`| Standard behavior: prompts for permission on first use of each tool +`default`| Standard behavior: prompts for permission on first use of each tool. Labeled Manual in the CLI and the VS Code and JetBrains extensions, and Claude Code accepts `manual` as an alias. The label and alias require Claude Code v2.1.200 or later `acceptEdits`| Automatically accepts file edits and common filesystem commands such as `mkdir`, `touch`, `mv`, and `cp` for paths in the working directory or `additionalDirectories` `plan`| Plan Mode: Claude reads files and runs read-only shell commands to explore but doesn’t edit your source files `auto`| Auto-approves tool calls with background safety checks that verify actions align with your request. Currently a research preview @@ -259,12 +259,21 @@ ---|---|---|--- `//path`| Absolute path from filesystem root| `Read(//Users/alice/secrets/**)`| `/Users/alice/secrets/**` `~/path`| Path from home directory| `Read(~/Documents/*.pdf)`| `/Users/alice/Documents/*.pdf` -`/path`| Path relative to project root| `Edit(/src/**/*.ts)`| `<project root>/src/**/*.ts` +`/path`| Path relative to the settings source| `Edit(/src/**/*.ts)`| `<project root>/src/**/*.ts` in project settings `path` or `./path`| Path relative to current directory| `Read(*.env)`| `<cwd>/*.env` -A pattern like `/Users/alice/file` isn’t an absolute path. It’s relative to the project root. Use `//Users/alice/file` for absolute paths. - -On Windows, paths are normalized to POSIX form before matching. `C:\Users\alice` becomes `/c/Users/alice`, so use `//c/**/.env` to match `.env` files anywhere on that drive. To match across all drives, use `//**/.env`. Examples: +A pattern like `/Users/alice/file` isn’t an absolute path. The single leading slash anchors at the settings source, not the filesystem root. Use `//Users/alice/file` for absolute paths. + +A `/path` pattern anchors at the directory associated with the settings file that defines it, so the same rule matches different locations depending on where you put it: + +Rule defined in| `/path` resolves to +---|--- +Project or local settings, such as `.claude/settings.json`| `<project root>/path` +User settings at `~/.claude/settings.json`| `~/.claude/path` +A file passed with `--settings <file>`| `<directory of file>/path` +CLI flags, `/permissions`, or session rules| `<original cwd>/path` + +A deny rule such as `Read(/secrets/**)` in user settings blocks `~/.claude/secrets/**`, not a `secrets` directory in your project. To write a rule in user settings that applies inside every project, use a `//` absolute path or a `~/` home-relative path instead. On Windows, paths are normalized to POSIX form before matching. `C:\Users\alice` becomes `/c/Users/alice`, so use `//c/**/.env` to match `.env` files anywhere on that drive. To match across all drives, use `//**/.env`. Examples: * `Edit(/docs/**)`: edits in `<project>/docs/`, not `/docs/` or `<project>/.claude/docs/` * `Read(~/.zshrc)`: reads your home directory’s `.zshrc` @@ -474,6 +483,24 @@ ​ +Project allow rules and workspace trust + +`permissions.allow` rules and `permissions.additionalDirectories` entries in a project’s `.claude/settings.json` grant capability, so Claude Code applies them only after you accept the [workspace trust dialog](</docs/en/security#additional-safeguards>) for that workspace. Until then, Claude Code reads the rules but doesn’t apply them. The trust dialog lists the allow rules and additional directories the folder would grant so you can review them before accepting. `deny` and `ask` rules aren’t affected, since they only restrict. Claude Code saves trust per workspace, keyed on the git repository root or, outside a repository, the directory you started Claude Code from. When you start in your home directory, trust is held for the current session only and isn’t written to disk; see the [additional safeguards](</docs/en/security#additional-safeguards>) note. Trusting a parent directory doesn’t apply a nested project’s allow rules. `.claude/settings.local.json` is your own file, so the workspace trust check usually doesn’t apply to it. When a repository could have supplied the file, such as when it is committed to git or `.claude` is a symlink, its allow rules and additional directories go through the trust check like project settings. Allow rules and additional directories in `.claude/settings.local.json` also apply without workspace trust in two cases: + + * The directory you started Claude Code from isn’t inside a git repository. + * The session runs in your own configuration home: your home directory or any directory whose `.claude` subdirectory you’ve set as [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>). + +In both cases the file is one you created rather than one a repository could have supplied, and a repository-committed `.claude/settings.local.json` still requires workspace trust. Versions 2.1.196 through 2.1.199 treated the file as repository-supplied in those workspaces, ignored its allow rules, and printed a [`this workspace has not been trusted`](</docs/en/errors#workspace-has-not-been-trusted>) warning to stderr. The two exceptions above match v2.1.195 and earlier and were restored in v2.1.200. Also as of v2.1.200, a workspace whose allow rules or additional directories still aren’t applied, but that never showed the trust dialog because a parent directory was already trusted, shows the dialog the next time you start Claude Code there interactively. The dialog offers two choices: + + * **Yes, I trust this folder** : saves trust for that workspace and applies the rules in the same session. + * **No, continue without these permissions** : keeps working with those rules ignored. The dialog appears again in the next session. + +In [non-interactive mode](</docs/en/headless>) with `-p`, no dialog appears and the rules stay ignored. + +## + +​ + Example configurations This [repository](<https://github.com/anthropics/claude-code/tree/main/examples/settings>) includes starter settings configurations for common deployment scenarios. Use these as starting points and adjust them to fit your needs.
modified
--- a/permissions.md +++ b/permissions.md @@ -422,7 +422,7 @@ Managed settings -For organizations that need centralized control over Claude Code configuration, administrators can deploy managed settings that can’t be overridden by user or project settings. These policy settings follow the same format as regular settings files and can be delivered through MDM/OS-level policies, managed settings files, or [server-managed settings](</docs/en/server-managed-settings>). See [settings files](</docs/en/settings#settings-files>) for delivery mechanisms and file locations. +For organizations that need centralized control over Claude Code configuration, administrators can deploy managed settings that can’t be overridden by user or project settings. These policy settings follow the same format as regular settings files and can be delivered through MDM/OS-level policies, managed settings files, [server-managed settings](</docs/en/server-managed-settings>), or a self-hosted [Claude apps gateway](</docs/en/claude-apps-gateway>). See [settings files](</docs/en/settings#settings-files>) for delivery mechanisms and file locations. ### @@ -441,6 +441,7 @@ `allowManagedPermissionRulesOnly`| When `true`, prevents user and project settings from defining `allow`, `ask`, or `deny` permission rules. Only rules in managed settings apply. Doesn’t affect the MCP server allowlist; for that, set `allowManagedMcpServersOnly` `blockedMarketplaces`| Blocklist of marketplace sources. Blocked sources are checked before downloading, so they never touch the filesystem. See [managed marketplace restrictions](</docs/en/plugin-marketplaces#managed-marketplace-restrictions>) `channelsEnabled`| Allow [channels](</docs/en/channels>) for the organization. See [enterprise controls](</docs/en/channels#enterprise-controls>) for the default on each plan +`disableSideloadFlags`| Reject the `--plugin-dir`, `--plugin-url`, `--agents`, and `--mcp-config` CLI flags at startup. Without this, users can bypass `strictKnownMarketplaces` for a single run by passing these flags. See [`disableSideloadFlags`](</docs/en/settings#available-settings>). Requires Claude Code v2.1.193 or later `forceRemoteSettingsRefresh`| When `true`, blocks CLI startup until remote managed settings are freshly fetched and exits if the fetch fails. See [fail-closed enforcement](</docs/en/server-managed-settings#enforce-fail-closed-startup>) `pluginTrustMessage`| Custom message appended to the plugin trust warning shown before installation `sandbox.filesystem.allowManagedReadPathsOnly`| When `true`, only `filesystem.allowRead` paths from managed settings are respected. `denyRead` still merges from all sources
modified
Show diff (270 lines)
--- a/permissions.md +++ b/permissions.md @@ -1,4 +1,4 @@ -Claude Code supports fine-grained permissions so that you can specify exactly what the agent is allowed to do and what it cannot. Permission settings can be checked into version control and distributed to all developers in your organization, as well as customized by individual developers. +Claude Code supports fine-grained permissions so that you can specify exactly what the agent is allowed to do and what it can’t. Permission settings can be checked into version control and distributed to all developers in your organization, as well as customized by individual developers. ## @@ -20,13 +20,13 @@ Manage permissions -You can view and manage Claude Code’s tool permissions with `/permissions`. This UI lists all permission rules and the settings.json file they are sourced from. +You can view and manage Claude Code’s tool permissions with `/permissions`. This UI lists all permission rules and the `settings.json` file each rule comes from. * **Allow** rules let Claude Code use the specified tool without manual approval. * **Ask** rules prompt for confirmation whenever Claude Code tries to use the specified tool. * **Deny** rules prevent Claude Code from using the specified tool. -Rules are evaluated in order: deny, then ask, then allow. The first match in that order determines the outcome, and rule specificity does not change the order. A broad deny rule like `Bash(aws *)` blocks every matching call, including calls that also match a narrower allow rule like `Bash(aws s3 ls)`, so a deny rule cannot carry allowlist exceptions. The same precedence applies between ask and allow: a matching ask rule prompts even when a more specific allow rule also matches the same call. Deny rules behave differently depending on whether they name a tool or scope a pattern within one. A bare tool name like `Bash` removes the tool from Claude’s context entirely, so Claude never sees it. A scoped rule like `Bash(rm *)` leaves the tool available and blocks matching calls when Claude attempts them. +Rules are evaluated in order: deny, then ask, then allow. The first match in that order determines the outcome, and rule specificity doesn’t change the order. A broad deny rule like `Bash(aws *)` blocks every matching call, including calls that also match a narrower allow rule like `Bash(aws s3 ls)`, so a deny rule can’t carry allowlist exceptions. The same precedence applies between ask and allow: a matching ask rule prompts even when a more specific allow rule also matches the same call. Deny rules behave differently depending on whether they name a tool or scope a pattern within one. A bare tool name like `Bash` removes the tool from Claude’s context entirely, so Claude never sees it. A scoped rule like `Bash(rm *)` leaves the tool available and blocks matching calls when Claude attempts them. Permission rules are enforced by Claude Code, not by the model. Instructions in your prompt or `CLAUDE.md` shape what Claude tries to do, but they don’t change what Claude Code allows. To grant or revoke access, use `/permissions`, the rules described here, a [permission mode](</docs/en/permission-modes>), or a PreToolUse hook. @@ -36,20 +36,20 @@ Permission modes -Claude Code supports several permission modes that control how tools are approved. See [Permission modes](</docs/en/permission-modes>) for when to use each one. Set the `defaultMode` in your [settings files](</docs/en/settings#settings-files>): +Claude Code supports several permission modes that control how it approves tool calls. See [Permission modes](</docs/en/permission-modes>) for when to use each one. Set the `defaultMode` in your [settings files](</docs/en/settings#settings-files>): Mode| Description ---|--- `default`| Standard behavior: prompts for permission on first use of each tool -`acceptEdits`| Automatically accepts file edits and common filesystem commands (`mkdir`, `touch`, `mv`, `cp`, etc.) for paths in the working directory or `additionalDirectories` -`plan`| Plan Mode: Claude reads files and runs read-only shell commands to explore but does not edit your source files +`acceptEdits`| Automatically accepts file edits and common filesystem commands such as `mkdir`, `touch`, `mv`, and `cp` for paths in the working directory or `additionalDirectories` +`plan`| Plan Mode: Claude reads files and runs read-only shell commands to explore but doesn’t edit your source files `auto`| Auto-approves tool calls with background safety checks that verify actions align with your request. Currently a research preview `dontAsk`| Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules `bypassPermissions`| Skips permission prompts, except those forced by explicit `ask` rules. Root and home directory removals such as `rm -rf /` also still prompt as a circuit breaker -`bypassPermissions` mode skips permission prompts, including for writes to `.git`, `.config/git`, `.claude`, `.vscode`, `.idea`, `.husky`, `.cargo`, `.devcontainer`, `.yarn`, and `.mvn`. Explicit `ask` rules still force a prompt, and removals targeting the filesystem root or home directory, such as `rm -rf /` and `rm -rf ~`, still prompt as a circuit breaker against model error. Only use this mode in isolated environments like containers or VMs where Claude Code cannot cause damage. Administrators can prevent this mode by setting `permissions.disableBypassPermissionsMode` to `"disable"` in managed settings. - -To prevent `bypassPermissions` or `auto` mode from being used, set `permissions.disableBypassPermissionsMode` or `permissions.disableAutoMode` to `"disable"` in any [settings file](</docs/en/settings#settings-files>). These are most useful in managed settings where they cannot be overridden. +`bypassPermissions` mode skips permission prompts, including for writes to `.git`, `.config/git`, `.claude`, `.vscode`, `.idea`, `.husky`, `.cargo`, `.devcontainer`, `.yarn`, and `.mvn`. Explicit `ask` rules still force a prompt, and removals targeting the filesystem root or home directory, such as `rm -rf /` and `rm -rf ~`, still prompt as a circuit breaker against model error. Only use this mode in isolated environments like containers or VMs where Claude Code can’t cause damage. + +To prevent `bypassPermissions` or `auto` mode from being used, set `permissions.disableBypassPermissionsMode` or `permissions.disableAutoMode` to `"disable"` in any [settings file](</docs/en/settings#settings-files>). These are most useful in managed settings where they can’t be overridden. ## @@ -65,7 +65,7 @@ Match all uses of a tool -To match all uses of a tool, use just the tool name without parentheses: +To match all uses of a tool, use only the tool name without parentheses: Rule| Effect ---|--- @@ -95,7 +95,7 @@ Match by input parameter -Deny and ask rules can match a top-level input parameter on any tool with `Tool(param:value)`. The rule matches when Claude calls the tool with that parameter set to that exact value. This syntax is for deny and ask rules; an allow rule for one parameter value would not establish that the call is safe overall, so allow rules continue to use each tool’s own specifier syntax. This works for any scalar parameter the tool accepts: +Deny and ask rules can match a top-level input parameter on any tool with `Tool(param:value)`. The rule matches when Claude calls the tool with that parameter set to that exact value. An allow rule for one parameter value wouldn’t establish that the call is safe overall, so allow rules continue to use each tool’s own specifier syntax. This works for any scalar parameter the tool accepts: Rule| Matches ---|--- @@ -108,7 +108,7 @@ * The parameter name must be a direct field of the tool’s input, such as `model` on the Agent tool. Fields nested inside an object or array are not matchable * Each rule names one parameter. To gate on both `model` and `isolation`, write two rules, `Agent(model:opus)` and `Agent(isolation:worktree)`, rather than combining them in one rule * The value supports `*` as a wildcard that matches any sequence of characters, so `Agent(isolation:*)` matches any explicit isolation value. Without `*` the match is exact - * A parameter the model omits is never matched, so `Agent(model:*)` does not match a call that leaves `model` unset + * A parameter the model omits is never matched, so `Agent(model:*)` doesn’t match a call that leaves `model` unset * The value is compared against the literal input Claude sends, before any normalization. `Agent(model:opus)` matches the alias `opus` but not a full model ID. Run with [`--verbose`](</docs/en/cli-reference>) to see the exact parameter names and values in each tool call * Whitespace around the colon is ignored @@ -155,7 +155,7 @@ } } -Allow rules accept tool-name globs only after a literal `mcp__<server>__` prefix. The server segment must be glob-free so the rule names a specific server you configured. `mcp__puppeteer__*` matches every tool from the `puppeteer` server, and `mcp__github__get_*` matches its `get_` tools. An unanchored allow glob such as `"*"`, `"B*"`, or `"mcp__*"` is skipped with a warning and does not auto-approve anything. A deny or ask rule whose tool name matches no known tool produces a startup warning to catch typos. Tool names containing `_` or `*` are exempt from the check. The label shown for a tool in the transcript and permission dialog can differ from its canonical name. For example, the tool labeled `Stop Task` in the transcript has the canonical name `TaskStop`. Permission rules and [hook matchers](</docs/en/hooks>) match the canonical name only, so a rule written as `Stop Task` does not match. For deny and ask rules, the startup warning above catches the mismatch. Use the canonical names listed in the [tools reference](</docs/en/tools-reference>). +Allow rules accept tool-name globs only after a literal `mcp__<server>__` prefix. The server segment must be glob-free so the rule names a specific server you configured. `mcp__puppeteer__*` matches every tool from the `puppeteer` server, and `mcp__github__get_*` matches its `get_` tools. An unanchored allow glob such as `"*"`, `"B*"`, or `"mcp__*"` is skipped with a warning and doesn’t auto-approve anything. A deny or ask rule whose tool name matches no known tool produces a startup warning to catch typos. Tool names containing `_` or `*` are exempt from the check. The label shown for a tool in the transcript and permission dialog can differ from its canonical name. For example, the tool labeled `Stop Task` in the transcript has the canonical name `TaskStop`. Permission rules and [hook matchers](</docs/en/hooks>) match the canonical name only, so a rule written as `Stop Task` doesn’t match. For deny and ask rules, the startup warning above catches the mismatch. Use the canonical names listed in the [tools reference](</docs/en/tools-reference>). ## @@ -195,7 +195,7 @@ Process wrappers -Before matching Bash rules, Claude Code strips a fixed set of process wrappers so a rule like `Bash(npm test *)` also matches `timeout 30 npm test`. The recognized wrappers are `timeout`, `time`, `nice`, `nohup`, and `stdbuf`. Bare `xargs` is also stripped, so `Bash(grep *)` matches `xargs grep pattern`. Stripping applies only when `xargs` has no flags: an invocation like `xargs -n1 grep pattern` is matched as an `xargs` command, so rules written for the inner command do not cover it. This wrapper list is built in and is not configurable. Development environment runners such as `direnv exec`, `devbox run`, `mise exec`, `npx`, and `docker exec` are not in the list. Because these tools execute their arguments as a command, a rule like `Bash(devbox run *)` matches whatever comes after `run`, including `devbox run rm -rf .`. To approve work inside an environment runner, write a specific rule that includes both the runner and the inner command, such as `Bash(devbox run npm test)`. Add one rule per inner command you want to allow. Exec wrappers such as `watch`, `setsid`, `ionice`, and `flock` always prompt and cannot be auto-approved by a prefix rule like `Bash(watch *)`. The same applies to `find` with `-exec` or `-delete`: a `Bash(find *)` rule does not cover these forms. To approve a specific invocation, write an exact-match rule for the full command string. +Before matching Bash rules, Claude Code strips a fixed set of process wrappers so a rule like `Bash(npm test *)` also matches `timeout 30 npm test`. The recognized wrappers are `timeout`, `time`, `nice`, `nohup`, and `stdbuf`. Bare `xargs` is also stripped, so `Bash(grep *)` matches `xargs grep pattern`. Stripping applies only when `xargs` has no flags: an invocation like `xargs -n1 grep pattern` is matched as an `xargs` command, so rules written for the inner command do not cover it. This wrapper list is built in and is not configurable. Development environment runners such as `direnv exec`, `devbox run`, `mise exec`, `npx`, and `docker exec` are not in the list. Because these tools execute their arguments as a command, a rule like `Bash(devbox run *)` matches whatever comes after `run`, including `devbox run rm -rf .`. To approve work inside an environment runner, write a specific rule that includes both the runner and the inner command, such as `Bash(devbox run npm test)`. Add one rule per inner command you want to allow. Exec wrappers such as `watch`, `setsid`, `ionice`, and `flock` always prompt and can’t be auto-approved by a prefix rule like `Bash(watch *)`. The same applies to `find` with `-exec` or `-delete`: a `Bash(find *)` rule doesn’t cover these forms. To approve a specific invocation, write an exact-match rule for the full command string. #### @@ -209,7 +209,7 @@ * Options before URL: `curl -X GET http://github.com/...` * Different protocol: `curl https://github.com/...` - * Redirects: `curl -L http://bit.ly/xyz` (redirects to github) + * Redirects: `curl -L http://bit.ly/xyz`, which redirects to GitHub * Variables: `URL=http://github.com && curl $URL` * Extra spaces: `curl http://github.com` @@ -219,7 +219,7 @@ * **Use PreToolUse hooks** : implement a hook that validates URLs in Bash commands and blocks disallowed domains * **Add CLAUDE.md guidance** : describe your allowed curl patterns in `CLAUDE.md`. This shapes what Claude tries but doesn’t enforce a boundary, so pair it with one of the options above -Note that using WebFetch alone does not prevent network access. If Bash is allowed, Claude can still use `curl`, `wget`, or other tools to reach any URL. +Note that using WebFetch alone doesn’t prevent network access. If Bash is allowed, Claude can still use `curl`, `wget`, or other tools to reach any URL. ### @@ -251,22 +251,22 @@ `Edit` rules apply to all built-in tools that edit files. Claude makes a best-effort attempt to apply `Read` rules to all built-in tools that read files like Grep and Glob, to `@file` mentions in your prompts, and to the selection and open-file context that a connected [IDE](</docs/en/vs-code#the-built-in-ide-mcp-server>) shares with Claude. -Read and Edit deny rules apply to Claude’s built-in file tools and to file commands Claude Code recognizes in Bash, such as `cat`, `head`, `tail`, and `sed`. They do not apply to arbitrary subprocesses that read or write files indirectly, like a Python or Node script that opens files itself. For OS-level enforcement that blocks all processes from accessing a path, [enable the sandbox](</docs/en/sandboxing>). +Read and Edit deny rules apply to Claude’s built-in file tools and to file commands Claude Code recognizes in Bash, such as `cat`, `head`, `tail`, and `sed`. They don’t apply to arbitrary subprocesses that read or write files indirectly, like a Python or Node script that opens files itself. For OS-level enforcement that blocks all processes from accessing a path, [enable the sandbox](</docs/en/sandboxing>). Read and Edit rules both follow the [gitignore](<https://git-scm.com/docs/gitignore>) specification with four distinct pattern types: Pattern| Meaning| Example| Matches ---|---|---|--- -`//path`| **Absolute** path from filesystem root| `Read(//Users/alice/secrets/**)`| `/Users/alice/secrets/**` -`~/path`| Path from **home** directory| `Read(~/Documents/*.pdf)`| `/Users/alice/Documents/*.pdf` -`/path`| Path **relative to project root**| `Edit(/src/**/*.ts)`| `<project root>/src/**/*.ts` -`path` or `./path`| Path **relative to current directory**| `Read(*.env)`| `<cwd>/*.env` - -A pattern like `/Users/alice/file` is NOT an absolute path. It’s relative to the project root. Use `//Users/alice/file` for absolute paths. +`//path`| Absolute path from filesystem root| `Read(//Users/alice/secrets/**)`| `/Users/alice/secrets/**` +`~/path`| Path from home directory| `Read(~/Documents/*.pdf)`| `/Users/alice/Documents/*.pdf` +`/path`| Path relative to project root| `Edit(/src/**/*.ts)`| `<project root>/src/**/*.ts` +`path` or `./path`| Path relative to current directory| `Read(*.env)`| `<cwd>/*.env` + +A pattern like `/Users/alice/file` isn’t an absolute path. It’s relative to the project root. Use `//Users/alice/file` for absolute paths. On Windows, paths are normalized to POSIX form before matching. `C:\Users\alice` becomes `/c/Users/alice`, so use `//c/**/.env` to match `.env` files anywhere on that drive. To match across all drives, use `//**/.env`. Examples: - * `Edit(/docs/**)`: edits in `<project>/docs/` (NOT `/docs/` and NOT `<project>/.claude/docs/`) + * `Edit(/docs/**)`: edits in `<project>/docs/`, not `/docs/` or `<project>/.claude/docs/` * `Read(~/.zshrc)`: reads your home directory’s `.zshrc` * `Edit(//tmp/scratch.txt)`: edits the absolute path `/tmp/scratch.txt` * `Read(src/**)`: reads from `<current-directory>/src/` @@ -278,7 +278,7 @@ `Read(.env)` or `Read(**/.env)`| any `.env` at or under the current directory| `.env` in a parent directory or another project `Read(//**/.env)`| any `.env` anywhere on the filesystem| nothing; the rule is anchored at the filesystem root -In gitignore patterns, `*` matches within a single path segment and can appear at any position in the pattern, while `**` matches across directories. To allow all file access, use just the tool name without parentheses: `Read`, `Edit`, or `Write`. +In gitignore patterns, `*` matches within a single path segment and can appear at any position in the pattern, while `**` matches across directories. To allow all file access, use only the tool name without parentheses: `Read`, `Edit`, or `Write`. When Claude accesses a symlink, permission rules check two paths: the symlink itself and the file it resolves to. Allow and deny rules treat that pair differently: allow rules fall back to prompting you, while deny rules block outright. @@ -307,8 +307,10 @@ MCP - * `mcp__puppeteer` matches any tool provided by the `puppeteer` server (name configured in Claude Code) - * `mcp__puppeteer__*` wildcard syntax that also matches all tools from the `puppeteer` server +MCP rules use the server name as configured in Claude Code, optionally followed by the name of a tool from that server. + + * `mcp__puppeteer` matches any tool provided by the `puppeteer` server + * `mcp__puppeteer__*` uses wildcard syntax and also matches all tools from the `puppeteer` server * `mcp__puppeteer__puppeteer_navigate` matches the `puppeteer_navigate` tool provided by the `puppeteer` server ### @@ -337,7 +339,7 @@ Cd -`Cd` rules control which directories the [`/cd` command](</docs/en/commands>) can move the session to. `Cd` is not a model-invocable tool: Claude cannot call it, and the rules apply only when you run `/cd` yourself. A bare `Cd` deny rule disables `/cd` entirely. A `Cd(<path-pattern>)` deny rule blocks matching targets. Deny rules check every spelling of the target, including each symlink hop it resolves through, so a rule written for one path also blocks targets that resolve to it. Adding any `Cd` allow rule switches `/cd` to allowlist mode: the resolved target directory must match one of your allow rules, or `/cd` refuses. With no `Cd` rules configured, `/cd` keeps its default behavior and prompts you to trust an unfamiliar directory. Path patterns share the `//`, `~/`, and `/` anchors from Read and Edit rules, but matching is anchored to the whole directory path rather than gitignore-style. `*` matches exactly one path segment and `**` matches across segments. A trailing `/**` also matches its named root. +`Cd` rules control which directories the [`/cd` command](</docs/en/commands>) can move the session to. `Cd` is not a model-invocable tool: Claude can’t call it, and the rules apply only when you run `/cd` yourself. A bare `Cd` deny rule disables `/cd` entirely. A `Cd(<path-pattern>)` deny rule blocks matching targets. Deny rules check every spelling of the target, including each symlink hop it resolves through, so a rule written for one path also blocks targets that resolve to it. Adding any `Cd` allow rule switches `/cd` to allowlist mode: the resolved target directory must match one of your allow rules, or `/cd` refuses. With no `Cd` rules configured, `/cd` keeps its default behavior and prompts you to trust an unfamiliar directory. Path patterns share the `//`, `~/`, and `/` anchors from Read and Edit rules, but matching is anchored to the whole directory path rather than gitignore-style. `*` matches exactly one path segment and `**` matches across segments. A trailing `/**` also matches its named root. Rule| Matches| Does not match ---|---|--- @@ -351,7 +353,7 @@ Extend permissions with hooks -[Claude Code hooks](</docs/en/hooks-guide>) provide a way to register custom shell commands to perform permission evaluation at runtime. When Claude Code makes a tool call, PreToolUse hooks run before the permission prompt. The hook output can deny the tool call, force a prompt, or skip the prompt to let the call proceed. Hook decisions do not bypass permission rules. Deny and ask rules are evaluated regardless of what a PreToolUse hook returns, so a matching deny rule blocks the call and a matching ask rule still prompts even when the hook returned `"allow"` or `"ask"`. This preserves the deny-first precedence described in Manage permissions, including deny rules set in managed settings. A blocking hook also takes precedence over allow rules. A hook that exits with code 2 stops the tool call before permission rules are evaluated, so the block applies even when an allow rule would otherwise let the call proceed. To run all Bash commands without prompts except for a few you want blocked, add `"Bash"` to your allow list and register a PreToolUse hook that rejects those specific commands. See [Block edits to protected files](</docs/en/hooks-guide#block-edits-to-protected-files>) for a hook script you can adapt. +[Claude Code hooks](</docs/en/hooks-guide>) provide a way to register custom shell commands to perform permission evaluation at runtime. When Claude Code makes a tool call, PreToolUse hooks run before the permission prompt. The hook output can deny the tool call, force a prompt, or skip the prompt to let the call proceed. Hook decisions don’t bypass permission rules. Deny and ask rules are evaluated regardless of what a PreToolUse hook returns, so a matching deny rule blocks the call and a matching ask rule still prompts even when the hook returned `"allow"` or `"ask"`. This preserves the deny-first precedence described in Manage permissions, including deny rules set in managed settings. A blocking hook also takes precedence over allow rules. A hook that exits with code 2 stops the tool call before permission rules are evaluated, so the block applies even when an allow rule would otherwise let the call proceed. To run all Bash commands without prompts except for a few you want blocked, add `"Bash"` to your allow list and register a PreToolUse hook that rejects those specific commands. See [Block edits to protected files](</docs/en/hooks-guide#block-edits-to-protected-files>) for a hook script you can adapt. ## @@ -359,7 +361,7 @@ Working directories -By default, Claude has access to files in the directory where it was launched. You can extend this access: +By default, Claude has access to files in the directory where you launched it. You can extend this access: * **During startup** : use `--add-dir <path>` CLI argument * **During session** : use `/add-dir` command @@ -373,7 +375,7 @@ Additional directories grant file access, not configuration -Adding a directory extends where Claude can read and edit files. It does not make that directory a full configuration root: most `.claude/` configuration is not discovered from additional directories, though a few types are loaded as exceptions. These exceptions apply only to directories added with the `--add-dir` flag or the `/add-dir` command. Directories listed in `permissions.additionalDirectories` in a settings file grant file access only and do not load any of the configuration below. The following configuration types are loaded from `--add-dir` directories: +Adding a directory extends where Claude can read and edit files. It doesn’t make that directory a full configuration root: most `.claude/` configuration is not discovered from additional directories, though a few types are loaded as exceptions. These exceptions apply only to directories added with the `--add-dir` flag or the `/add-dir` command. Directories listed in `permissions.additionalDirectories` in a settings file grant file access only and don’t load any of the configuration below. The following configuration types are loaded from `--add-dir` directories: Configuration| Loaded from `--add-dir` ---|--- @@ -396,7 +398,7 @@ Permissions and [sandboxing](</docs/en/sandboxing>) are complementary security layers: - * **Permissions** control which tools Claude Code can use and which files or domains it can access. They apply to all tools (Bash, Read, Edit, WebFetch, MCP, and others). + * **Permissions** control which tools Claude Code can use and which files or domains it can access. They apply to all tools, including Bash, Read, Edit, WebFetch, and MCP. * **Sandboxing** provides OS-level enforcement that restricts the Bash tool’s filesystem and network access. It applies only to Bash commands and their child processes. Use both for defense-in-depth: @@ -406,7 +408,13 @@ * Filesystem restrictions in the sandbox combine the [`sandbox.filesystem`](</docs/en/sandboxing>) settings with Read and Edit deny rules; both are merged into the final sandbox boundary * Network restrictions combine WebFetch permission rules with the sandbox’s `allowedDomains` and `deniedDomains` lists -When sandboxing is enabled with `autoAllowBashIfSandboxed: true`, which is the default, sandboxed Bash commands run without prompting even if your permissions include a bare `Bash` ask rule, or the equivalent `Bash(*)` form: the sandbox boundary substitutes for that whole-tool prompt. Content-scoped ask rules like `Bash(git push *)` still force a prompt, explicit deny rules still apply, and `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a prompt. Commands that won’t run sandboxed, such as excluded commands, respect the bare `Bash` ask rule as usual. See [sandbox modes](</docs/en/sandboxing#sandbox-modes>) to change this behavior. +When sandboxing is enabled with `autoAllowBashIfSandboxed: true`, which is the default, sandboxed Bash commands run without prompting even if your permissions include a bare `Bash` ask rule, or the equivalent `Bash(*)` form: the sandbox boundary substitutes for that whole-tool prompt. These checks still apply: + + * Content-scoped ask rules like `Bash(git push *)` still force a prompt + * Explicit deny rules still apply + * `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a prompt + +Commands that won’t run sandboxed, such as excluded commands, respect the bare `Bash` ask rule as usual. See [sandbox modes](</docs/en/sandboxing#sandbox-modes>) to change this behavior. ## @@ -414,7 +422,7 @@ Managed settings -For organizations that need centralized control over Claude Code configuration, administrators can deploy managed settings that cannot be overridden by user or project settings. These policy settings follow the same format as regular settings files and can be delivered through MDM/OS-level policies, managed settings files, or [server-managed settings](</docs/en/server-managed-settings>). See [settings files](</docs/en/settings#settings-files>) for delivery mechanisms and file locations. +For organizations that need centralized control over Claude Code configuration, administrators can deploy managed settings that can’t be overridden by user or project settings. These policy settings follow the same format as regular settings files and can be delivered through MDM/OS-level policies, managed settings files, or [server-managed settings](</docs/en/server-managed-settings>). See [settings files](</docs/en/settings#settings-files>) for delivery mechanisms and file locations. ### @@ -430,7 +438,7 @@ `allowedChannelPlugins`| Allowlist of channel plugins that may push messages. Replaces the default Anthropic allowlist when set. Requires `channelsEnabled: true`. See [Restrict which channel plugins can run](</docs/en/channels#restrict-which-channel-plugins-can-run>) `allowManagedHooksOnly`| When `true`, only managed hooks, SDK hooks, and hooks from plugins force-enabled in managed settings `enabledPlugins` are loaded. User, project, and all other plugin hooks are blocked `allowManagedMcpServersOnly`| When `true`, only `allowedMcpServers` from managed settings are respected. `deniedMcpServers` still merges from all sources. See [Managed MCP configuration](</docs/en/managed-mcp>) -`allowManagedPermissionRulesOnly`| When `true`, prevents user and project settings from defining `allow`, `ask`, or `deny` permission rules. Only rules in managed settings apply. Does not affect the MCP server allowlist; for that, set `allowManagedMcpServersOnly` +`allowManagedPermissionRulesOnly`| When `true`, prevents user and project settings from defining `allow`, `ask`, or `deny` permission rules. Only rules in managed settings apply. Doesn’t affect the MCP server allowlist; for that, set `allowManagedMcpServersOnly` `blockedMarketplaces`| Blocklist of marketplace sources. Blocked sources are checked before downloading, so they never touch the filesystem. See [managed marketplace restrictions](</docs/en/plugin-marketplaces#managed-marketplace-restrictions>) `channelsEnabled`| Allow [channels](</docs/en/channels>) for the organization. See [enterprise controls](</docs/en/channels#enterprise-controls>) for the default on each plan `forceRemoteSettingsRefresh`| When `true`, blocks CLI startup until remote managed settings are freshly fetched and exits if the fetch fails. See [fail-closed enforcement](</docs/en/server-managed-settings#enforce-fail-closed-startup>) @@ -443,7 +451,7 @@ `disableBypassPermissionsMode` is typically placed in managed settings to enforce organizational policy, but it works from any scope. A user can set it in their own settings to lock themselves out of bypass mode. -On Team and Enterprise plans, an Owner enables or disables [Remote Control](</docs/en/remote-control>) and [web sessions](</docs/en/claude-code-on-the-web>) organization-wide in [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>). Remote Control can additionally be disabled per device with the [`disableRemoteControl`](</docs/en/settings#available-settings>) managed setting. Web sessions have no per-device managed settings key. +On Team and Enterprise plans, an Owner enables or disables [Remote Control](</docs/en/remote-control>) and [web sessions](</docs/en/claude-code-on-the-web>) organization-wide in [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>). Remote Control can additionally be disabled per device with the [`disableRemoteControl`](</docs/en/settings#available-settings>) setting. Web sessions have no per-device managed settings key. ## @@ -453,13 +461,13 @@ Permission rules follow the same [settings precedence](</docs/en/settings#settings-precedence>) as all other Claude Code settings: - 1. **Managed settings** : cannot be overridden by any other level, including command line arguments + 1. **Managed settings** : can’t be overridden by any other level, including command line arguments 2. **Command line arguments** : temporary session overrides 3. **Local project settings** (`.claude/settings.local.json`) 4. **Shared project settings** (`.claude/settings.json`) 5. **User settings** (`~/.claude/settings.json`) -If a tool is denied at any level, no other level can allow it. For example, a managed settings deny cannot be overridden by `--allowedTools`, and `--disallowedTools` can add restrictions beyond what managed settings define. Embedding hosts can supply additional managed policy via the SDK `managedSettings` option when [`parentSettingsBehavior`](</docs/en/settings#settings-precedence>) is set to `"merge"`; embedder values can tighten policy but not loosen it. For example, if user settings allow a permission and project settings deny it, the deny rule blocks it. The reverse is also true: a user-level deny blocks a project-level allow, because deny rules from any scope are evaluated before allow rules. +If a tool is denied at any level, no other level can allow it. For example, a managed settings deny can’t be overridden by `--allowedTools`, and `--disallowedTools` can add restrictions beyond what managed settings define. The same holds across settings scopes: if user settings allow a permission and project settings deny it, the deny rule blocks it. The reverse is also true: a user-level deny blocks a project-level allow, because deny rules from any scope are evaluated before allow rules. Embedding hosts can supply additional managed policy via the SDK `managedSettings` option when [`parentSettingsBehavior`](</docs/en/settings#settings-precedence>) is set to `"merge"`; embedder values can tighten policy but not loosen it. ##
modified
--- a/permissions.md +++ b/permissions.md @@ -443,7 +443,7 @@ `disableBypassPermissionsMode` is typically placed in managed settings to enforce organizational policy, but it works from any scope. A user can set it in their own settings to lock themselves out of bypass mode. -On Team and Enterprise plans, an admin enables or disables [Remote Control](</docs/en/remote-control>) and [web sessions](</docs/en/claude-code-on-the-web>) organization-wide in [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>). Remote Control can additionally be disabled per device with the [`disableRemoteControl`](</docs/en/settings#available-settings>) managed setting. Web sessions have no per-device managed settings key. +On Team and Enterprise plans, an Owner enables or disables [Remote Control](</docs/en/remote-control>) and [web sessions](</docs/en/claude-code-on-the-web>) organization-wide in [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>). Remote Control can additionally be disabled per device with the [`disableRemoteControl`](</docs/en/settings#available-settings>) managed setting. Web sessions have no per-device managed settings key. ##
modified
--- a/permissions.md +++ b/permissions.md @@ -379,7 +379,7 @@ ---|--- [Skills](</docs/en/skills>) in `.claude/skills/`| Yes, with live reload [Subagents](</docs/en/sub-agents>) in `.claude/agents/`| Yes -Plugin settings in `.claude/settings.json`| `enabledPlugins` and `extraKnownMarketplaces` only +[Settings](</docs/en/settings>) in `.claude/settings.json` and `.claude/settings.local.json`| `enabledPlugins` and `extraKnownMarketplaces` keys only [CLAUDE.md](</docs/en/memory>) files, `.claude/rules/`, and `CLAUDE.local.md`| Only when `CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1` is set. `CLAUDE.local.md` additionally requires the `local` setting source, which is enabled by default Commands and output styles are discovered from the current working directory and its parents, your user directory at `~/.claude/`, and managed settings. Hooks and other `settings.json` keys load from the current working directory’s `.claude/` folder with no parent-directory fallback, alongside your user `~/.claude/settings.json` and managed settings. To share that configuration across projects, use one of these approaches:
modified
--- a/permissions.md +++ b/permissions.md @@ -26,7 +26,7 @@ * **Ask** rules prompt for confirmation whenever Claude Code tries to use the specified tool. * **Deny** rules prevent Claude Code from using the specified tool. -Rules are evaluated in order: deny, then ask, then allow. The first match in that order determines the outcome, and rule specificity does not change the order. A matching ask rule prompts even when a more specific allow rule also matches the same call. Deny rules behave differently depending on whether they name a tool or scope a pattern within one. A bare tool name like `Bash` removes the tool from Claude’s context entirely, so Claude never sees it. A scoped rule like `Bash(rm *)` leaves the tool available and blocks matching calls when Claude attempts them. +Rules are evaluated in order: deny, then ask, then allow. The first match in that order determines the outcome, and rule specificity does not change the order. A broad deny rule like `Bash(aws *)` blocks every matching call, including calls that also match a narrower allow rule like `Bash(aws s3 ls)`, so a deny rule cannot carry allowlist exceptions. The same precedence applies between ask and allow: a matching ask rule prompts even when a more specific allow rule also matches the same call. Deny rules behave differently depending on whether they name a tool or scope a pattern within one. A bare tool name like `Bash` removes the tool from Claude’s context entirely, so Claude never sees it. A scoped rule like `Bash(rm *)` leaves the tool available and blocks matching calls when Claude attempts them. Permission rules are enforced by Claude Code, not by the model. Instructions in your prompt or `CLAUDE.md` shape what Claude tries to do, but they don’t change what Claude Code allows. To grant or revoke access, use `/permissions`, the rules described here, a [permission mode](</docs/en/permission-modes>), or a PreToolUse hook. @@ -88,6 +88,31 @@ `Bash(npm run build)`| Matches the exact command `npm run build` `Read(./.env)`| Matches reading the `.env` file in the current directory `WebFetch(domain:example.com)`| Matches fetch requests to example.com + +### + +​ + +Match by input parameter + +Deny and ask rules can match a top-level input parameter on any tool with `Tool(param:value)`. The rule matches when Claude calls the tool with that parameter set to that exact value. This syntax is for deny and ask rules; an allow rule for one parameter value would not establish that the call is safe overall, so allow rules continue to use each tool’s own specifier syntax. This works for any scalar parameter the tool accepts: + +Rule| Matches +---|--- +`Agent(model:opus)`| Agent calls that request the Opus model tier +`Agent(isolation:worktree)`| Agent calls that request a git worktree +`Bash(run_in_background:true)`| Bash calls that run in the background + +Parameter matching follows these rules: + + * The parameter name must be a direct field of the tool’s input, such as `model` on the Agent tool. Fields nested inside an object or array are not matchable + * Each rule names one parameter. To gate on both `model` and `isolation`, write two rules, `Agent(model:opus)` and `Agent(isolation:worktree)`, rather than combining them in one rule + * The value supports `*` as a wildcard that matches any sequence of characters, so `Agent(isolation:*)` matches any explicit isolation value. Without `*` the match is exact + * A parameter the model omits is never matched, so `Agent(model:*)` does not match a call that leaves `model` unset + * The value is compared against the literal input Claude sends, before any normalization. `Agent(model:opus)` matches the alias `opus` but not a full model ID. Run with [`--verbose`](</docs/en/cli-reference>) to see the exact parameter names and values in each tool call + * Whitespace around the colon is ignored + +Fields that a tool already matches with its own canonicalizing rules are not matchable this way: `command` for Bash and PowerShell, `file_path` for Read, Edit, and Write, `path` for Grep and Glob, `notebook_path` for NotebookEdit, and `url` for WebFetch. A rule like `Bash(command:rm *)` would be bypassable by a compound command, so Claude Code ignores it and emits a startup warning. Use `Bash(rm *)`, `Read(./path)`, or `WebFetch(domain:host)` instead. ### @@ -274,7 +299,7 @@ * `WebFetch(domain:*.example.com)` matches any subdomain at any depth, such as `api.example.com` or `a.b.example.com`, but not `example.com` itself * `WebFetch(domain:*)` matches every domain and is equivalent to a bare `WebFetch` rule -A `*` matches across a `.` only as a leading `*.` or as the entire pattern. Elsewhere it stays within one label, so `WebFetch(domain:github.*)` matches `github.io` but not `github.evil.com`, a domain an attacker could register. When an exact rule and a wildcard rule in the same allow, ask, or deny list both match a hostname, the exact rule is the one matched. Evaluation order is unchanged: deny rules still run before ask and allow rules regardless of specificity. +In any position other than a leading `*.` or a bare `*`, the wildcard matches only the text between two dots. `WebFetch(domain:example.*)` matches `example.org`, where `*` becomes `org`, but not `example.evil.com`, where `*` would have to become `evil.com` and cross a dot. This keeps a trailing wildcard from matching domains an attacker could register. ### @@ -353,10 +378,11 @@ Configuration| Loaded from `--add-dir` ---|--- [Skills](</docs/en/skills>) in `.claude/skills/`| Yes, with live reload +[Subagents](</docs/en/sub-agents>) in `.claude/agents/`| Yes Plugin settings in `.claude/settings.json`| `enabledPlugins` and `extraKnownMarketplaces` only [CLAUDE.md](</docs/en/memory>) files, `.claude/rules/`, and `CLAUDE.local.md`| Only when `CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1` is set. `CLAUDE.local.md` additionally requires the `local` setting source, which is enabled by default -Subagents, commands, and output styles are discovered from the current working directory and its parents, your user directory at `~/.claude/`, and managed settings. Hooks and other `settings.json` keys load from the current working directory’s `.claude/` folder with no parent-directory fallback, alongside your user `~/.claude/settings.json` and managed settings. To share that configuration across projects, use one of these approaches: +Commands and output styles are discovered from the current working directory and its parents, your user directory at `~/.claude/`, and managed settings. Hooks and other `settings.json` keys load from the current working directory’s `.claude/` folder with no parent-directory fallback, alongside your user `~/.claude/settings.json` and managed settings. To share that configuration across projects, use one of these approaches: * **User-level configuration** : place files in `~/.claude/agents/`, `~/.claude/output-styles/`, or `~/.claude/settings.json` to make them available in every project * **Plugins** : package and distribute configuration as a [plugin](</docs/en/plugins>) that teams can install
modified
--- a/permissions.md +++ b/permissions.md @@ -130,7 +130,7 @@ } } -Allow rules accept tool-name globs only after a literal `mcp__<server>__` prefix. The server segment must be glob-free so the rule names a specific server you configured. `mcp__puppeteer__*` matches every tool from the `puppeteer` server, and `mcp__github__get_*` matches its `get_` tools. An unanchored allow glob such as `"*"`, `"B*"`, or `"mcp__*"` is skipped with a warning and does not auto-approve anything. A deny or ask rule whose tool name matches no known tool produces a startup warning to catch typos. Tool names containing `_` or `*` are exempt from the check. +Allow rules accept tool-name globs only after a literal `mcp__<server>__` prefix. The server segment must be glob-free so the rule names a specific server you configured. `mcp__puppeteer__*` matches every tool from the `puppeteer` server, and `mcp__github__get_*` matches its `get_` tools. An unanchored allow glob such as `"*"`, `"B*"`, or `"mcp__*"` is skipped with a warning and does not auto-approve anything. A deny or ask rule whose tool name matches no known tool produces a startup warning to catch typos. Tool names containing `_` or `*` are exempt from the check. The label shown for a tool in the transcript and permission dialog can differ from its canonical name. For example, the tool labeled `Stop Task` in the transcript has the canonical name `TaskStop`. Permission rules and [hook matchers](</docs/en/hooks>) match the canonical name only, so a rule written as `Stop Task` does not match. For deny and ask rules, the startup warning above catches the mismatch. Use the canonical names listed in the [tools reference](</docs/en/tools-reference>). ##
modified
--- a/permissions.md +++ b/permissions.md @@ -253,7 +253,7 @@ `Read(.env)` or `Read(**/.env)`| any `.env` at or under the current directory| `.env` in a parent directory or another project `Read(//**/.env)`| any `.env` anywhere on the filesystem| nothing; the rule is anchored at the filesystem root -In gitignore patterns, `*` matches files in a single directory while `**` matches recursively across directories. To allow all file access, use just the tool name without parentheses: `Read`, `Edit`, or `Write`. +In gitignore patterns, `*` matches within a single path segment and can appear at any position in the pattern, while `**` matches across directories. To allow all file access, use just the tool name without parentheses: `Read`, `Edit`, or `Write`. When Claude accesses a symlink, permission rules check two paths: the symlink itself and the file it resolves to. Allow and deny rules treat that pair differently: allow rules fall back to prompting you, while deny rules block outright. @@ -268,7 +268,13 @@ WebFetch - * `WebFetch(domain:example.com)` matches fetch requests to example.com +WebFetch rules use a `domain:` prefix and match against the hostname of the requested URL. Matching is case-insensitive, supports `*` wildcards, and strips a trailing `.` from both the rule and the hostname so `example.com.` and `example.com` are treated the same. + + * `WebFetch(domain:example.com)` matches requests to `example.com` + * `WebFetch(domain:*.example.com)` matches any subdomain at any depth, such as `api.example.com` or `a.b.example.com`, but not `example.com` itself + * `WebFetch(domain:*)` matches every domain and is equivalent to a bare `WebFetch` rule + +A `*` matches across a `.` only as a leading `*.` or as the entire pattern. Elsewhere it stays within one label, so `WebFetch(domain:github.*)` matches `github.io` but not `github.evil.com`, a domain an attacker could register. When an exact rule and a wildcard rule in the same allow, ask, or deny list both match a hostname, the exact rule is the one matched. Evaluation order is unchanged: deny rules still run before ask and allow rules regardless of specificity. ###
modified
--- a/permissions.md +++ b/permissions.md @@ -26,7 +26,7 @@ * **Ask** rules prompt for confirmation whenever Claude Code tries to use the specified tool. * **Deny** rules prevent Claude Code from using the specified tool. -Rules are evaluated in order: **deny - > ask -> allow**. The first matching rule wins, so deny rules always take precedence. Deny rules behave differently depending on whether they name a tool or scope a pattern within one. A bare tool name like `Bash` removes the tool from Claude’s context entirely, so Claude never sees it. A scoped rule like `Bash(rm *)` leaves the tool available and blocks matching calls when Claude attempts them. +Rules are evaluated in order: deny, then ask, then allow. The first match in that order determines the outcome, and rule specificity does not change the order. A matching ask rule prompts even when a more specific allow rule also matches the same call. Deny rules behave differently depending on whether they name a tool or scope a pattern within one. A bare tool name like `Bash` removes the tool from Claude’s context entirely, so Claude never sees it. A scoped rule like `Bash(rm *)` leaves the tool available and blocks matching calls when Claude attempts them. Permission rules are enforced by Claude Code, not by the model. Instructions in your prompt or `CLAUDE.md` shape what Claude tries to do, but they don’t change what Claude Code allows. To grant or revoke access, use `/permissions`, the rules described here, a [permission mode](</docs/en/permission-modes>), or a PreToolUse hook. @@ -45,9 +45,9 @@ `plan`| Plan Mode: Claude reads files and runs read-only shell commands to explore but does not edit your source files `auto`| Auto-approves tool calls with background safety checks that verify actions align with your request. Currently a research preview `dontAsk`| Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules -`bypassPermissions`| Skips all permission prompts. Root and home directory removals such as `rm -rf /` still prompt as a circuit breaker - -`bypassPermissions` mode skips all permission prompts, including writes to `.git`, `.config/git`, `.claude`, `.vscode`, `.idea`, `.husky`, `.cargo`, `.devcontainer`, `.yarn`, and `.mvn`. Removals targeting the filesystem root or home directory, such as `rm -rf /` and `rm -rf ~`, still prompt as a circuit breaker against model error. Only use this mode in isolated environments like containers or VMs where Claude Code cannot cause damage. Administrators can prevent this mode by setting `permissions.disableBypassPermissionsMode` to `"disable"` in managed settings. +`bypassPermissions`| Skips permission prompts, except those forced by explicit `ask` rules. Root and home directory removals such as `rm -rf /` also still prompt as a circuit breaker + +`bypassPermissions` mode skips permission prompts, including for writes to `.git`, `.config/git`, `.claude`, `.vscode`, `.idea`, `.husky`, `.cargo`, `.devcontainer`, `.yarn`, and `.mvn`. Explicit `ask` rules still force a prompt, and removals targeting the filesystem root or home directory, such as `rm -rf /` and `rm -rf ~`, still prompt as a circuit breaker against model error. Only use this mode in isolated environments like containers or VMs where Claude Code cannot cause damage. Administrators can prevent this mode by setting `permissions.disableBypassPermissionsMode` to `"disable"` in managed settings. To prevent `bypassPermissions` or `auto` mode from being used, set `permissions.disableBypassPermissionsMode` or `permissions.disableAutoMode` to `"disable"` in any [settings file](</docs/en/settings#settings-files>). These are most useful in managed settings where they cannot be overridden. @@ -114,6 +114,24 @@ The space before `*` matters: `Bash(ls *)` matches `ls -la` but not `lsof`, while `Bash(ls*)` matches both. The `:*` suffix is an equivalent way to write a trailing wildcard, so `Bash(ls:*)` matches the same commands as `Bash(ls *)`. The permission dialog writes the space-separated form when you select “Yes, don’t ask again” for a command prefix. The `:*` form is only recognized at the end of a pattern. In a pattern like `Bash(git:* push)`, the colon is treated as a literal character and won’t match git commands. +### + +​ + +Tool name wildcards + +Deny and ask rules also accept glob patterns in the tool-name position. The pattern must match the full tool name: `"*"` matches every tool, and `"mcp__*"` matches every MCP tool across all servers. A tool matched by a bare-name glob deny rule is removed from Claude’s context, the same as a bare tool name. This configuration denies every MCP tool: + + { + "permissions": { + "deny": [ + "mcp__*" + ] + } + } + +Allow rules accept tool-name globs only after a literal `mcp__<server>__` prefix. The server segment must be glob-free so the rule names a specific server you configured. `mcp__puppeteer__*` matches every tool from the `puppeteer` server, and `mcp__github__get_*` matches its `get_` tools. An unanchored allow glob such as `"*"`, `"B*"`, or `"mcp__*"` is skipped with a warning and does not auto-approve anything. A deny or ask rule whose tool name matches no known tool produces a startup warning to catch typos. Tool names containing `_` or `*` are exempt from the check. + ## ​ @@ -282,6 +300,20 @@ } } +### + +​ + +Cd + +`Cd` rules control which directories the [`/cd` command](</docs/en/commands>) can move the session to. `Cd` is not a model-invocable tool: Claude cannot call it, and the rules apply only when you run `/cd` yourself. A bare `Cd` deny rule disables `/cd` entirely. A `Cd(<path-pattern>)` deny rule blocks matching targets. Deny rules check every spelling of the target, including each symlink hop it resolves through, so a rule written for one path also blocks targets that resolve to it. Adding any `Cd` allow rule switches `/cd` to allowlist mode: the resolved target directory must match one of your allow rules, or `/cd` refuses. With no `Cd` rules configured, `/cd` keeps its default behavior and prompts you to trust an unfamiliar directory. Path patterns share the `//`, `~/`, and `/` anchors from Read and Edit rules, but matching is anchored to the whole directory path rather than gitignore-style. `*` matches exactly one path segment and `**` matches across segments. A trailing `/**` also matches its named root. + +Rule| Matches| Does not match +---|---|--- +`Cd(~/code/*)`| `~/code/app`| `~/code/app/src`, `~/code` +`Cd(~/code/**)`| `~/code` and any directory under it| directories outside `~/code` +`Cd(**/node_modules)`| any `node_modules` directory at any depth| `node_modules/pkg` + ## ​ @@ -302,7 +334,7 @@ * **During session** : use `/add-dir` command * **Persistent configuration** : add to `additionalDirectories` in [settings files](</docs/en/settings#settings-files>) -Files in additional directories follow the same permission rules as the original working directory: they become readable without prompts, and file editing permissions follow the current permission mode. +Files in additional directories follow the same permission rules as the original working directory: they become readable without prompts, and file editing permissions follow the current permission mode. To change the session’s primary working directory instead of adding another, use [`/cd`](</docs/en/commands>). The `/cd` command requires Claude Code v2.1.169 or later. Unlike `/add-dir`, it relocates the session: the new directory’s `CLAUDE.md` is loaded and `--resume` finds the session from there. ### @@ -342,7 +374,7 @@ * Filesystem restrictions in the sandbox combine the [`sandbox.filesystem`](</docs/en/sandboxing>) settings with Read and Edit deny rules; both are merged into the final sandbox boundary * Network restrictions combine WebFetch permission rules with the sandbox’s `allowedDomains` and `deniedDomains` lists -When sandboxing is enabled with `autoAllowBashIfSandboxed: true`, which is the default, sandboxed Bash commands run without prompting even if your permissions include `ask: Bash(*)`. The sandbox boundary substitutes for the per-command prompt. Explicit deny rules still apply, and `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a prompt. See [sandbox modes](</docs/en/sandboxing#sandbox-modes>) to change this behavior. +When sandboxing is enabled with `autoAllowBashIfSandboxed: true`, which is the default, sandboxed Bash commands run without prompting even if your permissions include a bare `Bash` ask rule, or the equivalent `Bash(*)` form: the sandbox boundary substitutes for that whole-tool prompt. Content-scoped ask rules like `Bash(git push *)` still force a prompt, explicit deny rules still apply, and `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a prompt. Commands that won’t run sandboxed, such as excluded commands, respect the bare `Bash` ask rule as usual. See [sandbox modes](</docs/en/sandboxing#sandbox-modes>) to change this behavior. ##
modified
--- a/permissions.md +++ b/permissions.md @@ -1,9 +1,3 @@ -> ## Documentation Index -> -> Fetch the complete documentation index at: <https://code.claude.com/docs/llms.txt> -> -> Use this file to discover all available pages before exploring further. - Claude Code supports fine-grained permissions so that you can specify exactly what the agent is allowed to do and what it cannot. Permission settings can be checked into version control and distributed to all developers in your organization, as well as customized by individual developers. ##
modified
--- a/permissions.md +++ b/permissions.md @@ -53,7 +53,7 @@ `dontAsk`| Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules `bypassPermissions`| Skips all permission prompts. Root and home directory removals such as `rm -rf /` still prompt as a circuit breaker -`bypassPermissions` mode skips all permission prompts, including writes to `.git`, `.claude`, `.vscode`, `.idea`, `.husky`, and `.cargo`. Removals targeting the filesystem root or home directory, such as `rm -rf /` and `rm -rf ~`, still prompt as a circuit breaker against model error. Only use this mode in isolated environments like containers or VMs where Claude Code cannot cause damage. Administrators can prevent this mode by setting `permissions.disableBypassPermissionsMode` to `"disable"` in managed settings. +`bypassPermissions` mode skips all permission prompts, including writes to `.git`, `.config/git`, `.claude`, `.vscode`, `.idea`, `.husky`, `.cargo`, `.devcontainer`, `.yarn`, and `.mvn`. Removals targeting the filesystem root or home directory, such as `rm -rf /` and `rm -rf ~`, still prompt as a circuit breaker against model error. Only use this mode in isolated environments like containers or VMs where Claude Code cannot cause damage. Administrators can prevent this mode by setting `permissions.disableBypassPermissionsMode` to `"disable"` in managed settings. To prevent `bypassPermissions` or `auto` mode from being used, set `permissions.disableBypassPermissionsMode` or `permissions.disableAutoMode` to `"disable"` in any [settings file](</docs/en/settings#settings-files>). These are most useful in managed settings where they cannot be overridden.
modified
--- a/permissions.md +++ b/permissions.md @@ -53,7 +53,7 @@ `dontAsk`| Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules `bypassPermissions`| Skips all permission prompts. Root and home directory removals such as `rm -rf /` still prompt as a circuit breaker -`bypassPermissions` mode skips all permission prompts, including writes to `.git`, `.claude`, `.vscode`, `.idea`, and `.husky`. Removals targeting the filesystem root or home directory, such as `rm -rf /` and `rm -rf ~`, still prompt as a circuit breaker against model error. Only use this mode in isolated environments like containers or VMs where Claude Code cannot cause damage. Administrators can prevent this mode by setting `permissions.disableBypassPermissionsMode` to `"disable"` in managed settings. +`bypassPermissions` mode skips all permission prompts, including writes to `.git`, `.claude`, `.vscode`, `.idea`, `.husky`, and `.cargo`. Removals targeting the filesystem root or home directory, such as `rm -rf /` and `rm -rf ~`, still prompt as a circuit breaker against model error. Only use this mode in isolated environments like containers or VMs where Claude Code cannot cause damage. Administrators can prevent this mode by setting `permissions.disableBypassPermissionsMode` to `"disable"` in managed settings. To prevent `bypassPermissions` or `auto` mode from being used, set `permissions.disableBypassPermissionsMode` or `permissions.disableAutoMode` to `"disable"` in any [settings file](</docs/en/settings#settings-files>). These are most useful in managed settings where they cannot be overridden.
modified
--- a/permissions.md +++ b/permissions.md @@ -316,7 +316,7 @@ Additional directories grant file access, not configuration -Adding a directory extends where Claude can read and edit files. It does not make that directory a full configuration root: most `.claude/` configuration is not discovered from additional directories, though a few types are loaded as exceptions. The following configuration types are loaded from `--add-dir` directories: +Adding a directory extends where Claude can read and edit files. It does not make that directory a full configuration root: most `.claude/` configuration is not discovered from additional directories, though a few types are loaded as exceptions. These exceptions apply only to directories added with the `--add-dir` flag or the `/add-dir` command. Directories listed in `permissions.additionalDirectories` in a settings file grant file access only and do not load any of the configuration below. The following configuration types are loaded from `--add-dir` directories: Configuration| Loaded from `--add-dir` ---|--- @@ -368,6 +368,7 @@ Setting| Description ---|--- +`allowAllClaudeAiMcps`| When `true`, claude.ai connectors load alongside a deployed `managed-mcp.json` instead of being suppressed by its exclusive control. See [Managed MCP configuration](</docs/en/managed-mcp>) `allowedChannelPlugins`| Allowlist of channel plugins that may push messages. Replaces the default Anthropic allowlist when set. Requires `channelsEnabled: true`. See [Restrict which channel plugins can run](</docs/en/channels#restrict-which-channel-plugins-can-run>) `allowManagedHooksOnly`| When `true`, only managed hooks, SDK hooks, and hooks from plugins force-enabled in managed settings `enabledPlugins` are loaded. User, project, and all other plugin hooks are blocked `allowManagedMcpServersOnly`| When `true`, only `allowedMcpServers` from managed settings are respected. `deniedMcpServers` still merges from all sources. See [Managed MCP configuration](</docs/en/managed-mcp>)
modified
--- a/permissions.md +++ b/permissions.md @@ -370,8 +370,8 @@ ---|--- `allowedChannelPlugins`| Allowlist of channel plugins that may push messages. Replaces the default Anthropic allowlist when set. Requires `channelsEnabled: true`. See [Restrict which channel plugins can run](</docs/en/channels#restrict-which-channel-plugins-can-run>) `allowManagedHooksOnly`| When `true`, only managed hooks, SDK hooks, and hooks from plugins force-enabled in managed settings `enabledPlugins` are loaded. User, project, and all other plugin hooks are blocked -`allowManagedMcpServersOnly`| When `true`, only `allowedMcpServers` from managed settings are respected. `deniedMcpServers` still merges from all sources. See [Managed MCP configuration](</docs/en/mcp#managed-mcp-configuration>) -`allowManagedPermissionRulesOnly`| When `true`, prevents user and project settings from defining `allow`, `ask`, or `deny` permission rules. Only rules in managed settings apply +`allowManagedMcpServersOnly`| When `true`, only `allowedMcpServers` from managed settings are respected. `deniedMcpServers` still merges from all sources. See [Managed MCP configuration](</docs/en/managed-mcp>) +`allowManagedPermissionRulesOnly`| When `true`, prevents user and project settings from defining `allow`, `ask`, or `deny` permission rules. Only rules in managed settings apply. Does not affect the MCP server allowlist; for that, set `allowManagedMcpServersOnly` `blockedMarketplaces`| Blocklist of marketplace sources. Blocked sources are checked before downloading, so they never touch the filesystem. See [managed marketplace restrictions](</docs/en/plugin-marketplaces#managed-marketplace-restrictions>) `channelsEnabled`| Allow [channels](</docs/en/channels>) for the organization. See [enterprise controls](</docs/en/channels#enterprise-controls>) for the default on each plan `forceRemoteSettingsRefresh`| When `true`, blocks CLI startup until remote managed settings are freshly fetched and exits if the fetch fails. See [fail-closed enforcement](</docs/en/server-managed-settings#enforce-fail-closed-startup>)
modified
--- a/permissions.md +++ b/permissions.md @@ -379,6 +379,7 @@ `sandbox.filesystem.allowManagedReadPathsOnly`| When `true`, only `filesystem.allowRead` paths from managed settings are respected. `denyRead` still merges from all sources `sandbox.network.allowManagedDomainsOnly`| When `true`, only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are respected. Non-allowed domains are blocked automatically without prompting the user. Denied domains still merge from all sources `strictKnownMarketplaces`| Controls which plugin marketplace sources users can add and install plugins from. See [managed marketplace restrictions](</docs/en/plugin-marketplaces#managed-marketplace-restrictions>) +`strictPluginOnlyCustomization`| Block skills, agents, hooks, and MCP servers from user and project sources, so they can only come from plugins or managed settings. `true` locks all four surfaces; an array such as `["skills", "hooks"]` locks only the named ones. See [`strictPluginOnlyCustomization`](</docs/en/settings#strictpluginonlycustomization>) `wslInheritsWindowsSettings`| When `true` in the Windows HKLM registry key or `C:\Program Files\ClaudeCode\managed-settings.json`, WSL reads managed settings from the Windows policy chain in addition to `/etc/claude-code`. See [Settings files](</docs/en/settings#settings-files>) `disableBypassPermissionsMode` is typically placed in managed settings to enforce organizational policy, but it works from any scope. A user can set it in their own settings to lock themselves out of bypass mode.
modified
--- a/permissions.md +++ b/permissions.md @@ -32,7 +32,7 @@ * **Ask** rules prompt for confirmation whenever Claude Code tries to use the specified tool. * **Deny** rules prevent Claude Code from using the specified tool. -Rules are evaluated in order: **deny - > ask -> allow**. The first matching rule wins, so deny rules always take precedence. +Rules are evaluated in order: **deny - > ask -> allow**. The first matching rule wins, so deny rules always take precedence. Deny rules behave differently depending on whether they name a tool or scope a pattern within one. A bare tool name like `Bash` removes the tool from Claude’s context entirely, so Claude never sees it. A scoped rule like `Bash(rm *)` leaves the tool available and blocks matching calls when Claude attempts them. Permission rules are enforced by Claude Code, not by the model. Instructions in your prompt or `CLAUDE.md` shape what Claude tries to do, but they don’t change what Claude Code allows. To grant or revoke access, use `/permissions`, the rules described here, a [permission mode](</docs/en/permission-modes>), or a PreToolUse hook. @@ -79,7 +79,7 @@ `WebFetch`| Matches all web fetch requests `Read`| Matches all file reads -`Bash(*)` is equivalent to `Bash` and matches all Bash commands. +`Bash(*)` is equivalent to `Bash` and matches all Bash commands. As a deny rule, both forms remove the tool from Claude’s context. ###
modified
--- a/permissions.md +++ b/permissions.md @@ -212,7 +212,7 @@ Read and Edit -`Edit` rules apply to all built-in tools that edit files. Claude makes a best-effort attempt to apply `Read` rules to all built-in tools that read files like Grep and Glob. +`Edit` rules apply to all built-in tools that edit files. Claude makes a best-effort attempt to apply `Read` rules to all built-in tools that read files like Grep and Glob, to `@file` mentions in your prompts, and to the selection and open-file context that a connected [IDE](</docs/en/vs-code#the-built-in-ide-mcp-server>) shares with Claude. Read and Edit deny rules apply to Claude’s built-in file tools and to file commands Claude Code recognizes in Bash, such as `cat`, `head`, `tail`, and `sed`. They do not apply to arbitrary subprocesses that read or write files indirectly, like a Python or Node script that opens files itself. For OS-level enforcement that blocks all processes from accessing a path, [enable the sandbox](</docs/en/sandboxing>).
modified
--- a/permissions.md +++ b/permissions.md @@ -399,7 +399,7 @@ 4. **Shared project settings** (`.claude/settings.json`) 5. **User settings** (`~/.claude/settings.json`) -If a tool is denied at any level, no other level can allow it. For example, a managed settings deny cannot be overridden by `--allowedTools`, and `--disallowedTools` can add restrictions beyond what managed settings define. Embedding hosts can supply additional managed policy via the SDK `managedSettings` option when [`parentSettingsBehavior`](</docs/en/settings#settings-precedence>) is set to `"merge"`; embedder values can tighten policy but not loosen it. If a permission is allowed in user settings but denied in project settings, the project setting takes precedence and the permission is blocked. +If a tool is denied at any level, no other level can allow it. For example, a managed settings deny cannot be overridden by `--allowedTools`, and `--disallowedTools` can add restrictions beyond what managed settings define. Embedding hosts can supply additional managed policy via the SDK `managedSettings` option when [`parentSettingsBehavior`](</docs/en/settings#settings-precedence>) is set to `"merge"`; embedder values can tighten policy but not loosen it. For example, if user settings allow a permission and project settings deny it, the deny rule blocks it. The reverse is also true: a user-level deny blocks a project-level allow, because deny rules from any scope are evaluated before allow rules. ##
modified
--- a/permissions.md +++ b/permissions.md @@ -166,7 +166,7 @@ Read-only commands -Claude Code recognizes a built-in set of Bash commands as read-only and runs them without a permission prompt in every mode. These include `ls`, `cat`, `head`, `tail`, `grep`, `find`, `wc`, `diff`, `stat`, `du`, `cd`, and read-only forms of `git`. The set is not configurable; to require a prompt for one of these commands, add an `ask` or `deny` rule for it. Unquoted glob patterns are permitted for commands whose every flag is read-only, so `ls *.ts` and `wc -l src/*.py` run without a prompt. Commands with write-capable or exec-capable flags, such as `find`, `sort`, `sed`, and `git`, still prompt when an unquoted glob is present because the glob could expand to a flag like `-delete`. A `cd` into a path inside your working directory or an additional directory is also read-only. A compound command like `cd packages/api && ls` runs without a prompt when each part qualifies on its own. Combining `cd` with `git` in one compound command always prompts, regardless of the target directory. +Claude Code recognizes a built-in set of Bash commands as read-only and runs them without a permission prompt in every mode. These include `ls`, `cat`, `echo`, `pwd`, `head`, `tail`, `grep`, `find`, `wc`, `which`, `diff`, `stat`, `du`, `cd`, and read-only forms of `git`. The set is not configurable; to require a prompt for one of these commands, add an `ask` or `deny` rule for it. Unquoted glob patterns are permitted for commands whose every flag is read-only, so `ls *.ts` and `wc -l src/*.py` run without a prompt. Commands with write-capable or exec-capable flags, such as `find`, `sort`, `sed`, and `git`, still prompt when an unquoted glob is present because the glob could expand to a flag like `-delete`. A `cd` into a path inside your working directory or an additional directory is also read-only. A compound command like `cd packages/api && ls` runs without a prompt when each part qualifies on its own. Combining `cd` with `git` in one compound command always prompts, regardless of the target directory. Bash permission patterns that try to constrain command arguments are fragile. For example, `Bash(curl http://github.com/ *)` intends to restrict curl to GitHub URLs, but won’t match variations like: @@ -324,7 +324,7 @@ Plugin settings in `.claude/settings.json`| `enabledPlugins` and `extraKnownMarketplaces` only [CLAUDE.md](</docs/en/memory>) files, `.claude/rules/`, and `CLAUDE.local.md`| Only when `CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1` is set. `CLAUDE.local.md` additionally requires the `local` setting source, which is enabled by default -Everything else, including subagents, commands, output styles, hooks, and other settings, is discovered only from the current working directory and its parents, your user directory at `~/.claude/`, and managed settings. To share that configuration across projects, use one of these approaches: +Subagents, commands, and output styles are discovered from the current working directory and its parents, your user directory at `~/.claude/`, and managed settings. Hooks and other `settings.json` keys load from the current working directory’s `.claude/` folder with no parent-directory fallback, alongside your user `~/.claude/settings.json` and managed settings. To share that configuration across projects, use one of these approaches: * **User-level configuration** : place files in `~/.claude/agents/`, `~/.claude/output-styles/`, or `~/.claude/settings.json` to make them available in every project * **Plugins** : package and distribute configuration as a [plugin](</docs/en/plugins>) that teams can install @@ -399,7 +399,7 @@ 4. **Shared project settings** (`.claude/settings.json`) 5. **User settings** (`~/.claude/settings.json`) -If a tool is denied at any level, no other level can allow it. For example, a managed settings deny cannot be overridden by `--allowedTools`, and `--disallowedTools` can add restrictions beyond what managed settings define. If a permission is allowed in user settings but denied in project settings, the project setting takes precedence and the permission is blocked. +If a tool is denied at any level, no other level can allow it. For example, a managed settings deny cannot be overridden by `--allowedTools`, and `--disallowedTools` can add restrictions beyond what managed settings define. Embedding hosts can supply additional managed policy via the SDK `managedSettings` option when [`parentSettingsBehavior`](</docs/en/settings#settings-precedence>) is set to `"merge"`; embedder values can tighten policy but not loosen it. If a permission is allowed in user settings but denied in project settings, the project setting takes precedence and the permission is blocked. ##
modified
--- a/permissions.md +++ b/permissions.md @@ -33,6 +33,8 @@ * **Deny** rules prevent Claude Code from using the specified tool. Rules are evaluated in order: **deny - > ask -> allow**. The first matching rule wins, so deny rules always take precedence. + +Permission rules are enforced by Claude Code, not by the model. Instructions in your prompt or `CLAUDE.md` shape what Claude tries to do, but they don’t change what Claude Code allows. To grant or revoke access, use `/permissions`, the rules described here, a [permission mode](</docs/en/permission-modes>), or a PreToolUse hook. ## @@ -178,7 +180,7 @@ * **Restrict Bash network tools** : use deny rules to block `curl`, `wget`, and similar commands, then use the WebFetch tool with `WebFetch(domain:github.com)` permission for allowed domains * **Use PreToolUse hooks** : implement a hook that validates URLs in Bash commands and blocks disallowed domains - * Instructing Claude Code about your allowed curl patterns via CLAUDE.md + * **Add CLAUDE.md guidance** : describe your allowed curl patterns in `CLAUDE.md`. This shapes what Claude tries but doesn’t enforce a boundary, so pair it with one of the options above Note that using WebFetch alone does not prevent network access. If Bash is allowed, Claude can still use `curl`, `wget`, or other tools to reach any URL. @@ -212,7 +214,7 @@ `Edit` rules apply to all built-in tools that edit files. Claude makes a best-effort attempt to apply `Read` rules to all built-in tools that read files like Grep and Glob. -Read and Edit deny rules apply to Claude’s built-in file tools, not to Bash subprocesses. A `Read(./.env)` deny rule blocks the Read tool but does not prevent `cat .env` in Bash. For OS-level enforcement that blocks all processes from accessing a path, [enable the sandbox](</docs/en/sandboxing>). +Read and Edit deny rules apply to Claude’s built-in file tools and to file commands Claude Code recognizes in Bash, such as `cat`, `head`, `tail`, and `sed`. They do not apply to arbitrary subprocesses that read or write files indirectly, like a Python or Node script that opens files itself. For OS-level enforcement that blocks all processes from accessing a path, [enable the sandbox](</docs/en/sandboxing>). Read and Edit rules both follow the [gitignore](<https://git-scm.com/docs/gitignore>) specification with four distinct pattern types:
modified
--- a/permissions.md +++ b/permissions.md @@ -232,6 +232,13 @@ * `Edit(//tmp/scratch.txt)`: edits the absolute path `/tmp/scratch.txt` * `Read(src/**)`: reads from `<current-directory>/src/` +A rule only matches files under its anchor, so the anchor determines how far a deny rule reaches. Bare filenames follow gitignore semantics and match at any depth, so `Read(.env)` and `Read(**/.env)` are equivalent: + +Deny rule| Blocks| Does not block +---|---|--- +`Read(.env)` or `Read(**/.env)`| any `.env` at or under the current directory| `.env` in a parent directory or another project +`Read(//**/.env)`| any `.env` anywhere on the filesystem| nothing; the rule is anchored at the filesystem root + In gitignore patterns, `*` matches files in a single directory while `**` matches recursively across directories. To allow all file access, use just the tool name without parentheses: `Read`, `Edit`, or `Write`. When Claude accesses a symlink, permission rules check two paths: the symlink itself and the file it resolves to. Allow and deny rules treat that pair differently: allow rules fall back to prompting you, while deny rules block outright.
modified
--- a/permissions.md +++ b/permissions.md @@ -46,7 +46,7 @@ ---|--- `default`| Standard behavior: prompts for permission on first use of each tool `acceptEdits`| Automatically accepts file edits and common filesystem commands (`mkdir`, `touch`, `mv`, `cp`, etc.) for paths in the working directory or `additionalDirectories` -`plan`| Plan Mode: Claude can analyze but not modify files or execute commands +`plan`| Plan Mode: Claude reads files and runs read-only shell commands to explore but does not edit your source files `auto`| Auto-approves tool calls with background safety checks that verify actions align with your request. Currently a research preview `dontAsk`| Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules `bypassPermissions`| Skips all permission prompts. Root and home directory removals such as `rm -rf /` still prompt as a circuit breaker @@ -336,7 +336,7 @@ * Permission deny rules block Claude from even attempting to access restricted resources * Sandbox restrictions prevent Bash commands from reaching resources outside defined boundaries, even if a prompt injection bypasses Claude’s decision-making - * Filesystem restrictions in the sandbox use Read and Edit deny rules, not separate sandbox configuration + * Filesystem restrictions in the sandbox combine the [`sandbox.filesystem`](</docs/en/sandboxing>) settings with Read and Edit deny rules; both are merged into the final sandbox boundary * Network restrictions combine WebFetch permission rules with the sandbox’s `allowedDomains` and `deniedDomains` lists When sandboxing is enabled with `autoAllowBashIfSandboxed: true`, which is the default, sandboxed Bash commands run without prompting even if your permissions include `ask: Bash(*)`. The sandbox boundary substitutes for the per-command prompt. Explicit deny rules still apply, and `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a prompt. See [sandbox modes](</docs/en/sandboxing#sandbox-modes>) to change this behavior. @@ -364,7 +364,7 @@ `allowManagedMcpServersOnly`| When `true`, only `allowedMcpServers` from managed settings are respected. `deniedMcpServers` still merges from all sources. See [Managed MCP configuration](</docs/en/mcp#managed-mcp-configuration>) `allowManagedPermissionRulesOnly`| When `true`, prevents user and project settings from defining `allow`, `ask`, or `deny` permission rules. Only rules in managed settings apply `blockedMarketplaces`| Blocklist of marketplace sources. Blocked sources are checked before downloading, so they never touch the filesystem. See [managed marketplace restrictions](</docs/en/plugin-marketplaces#managed-marketplace-restrictions>) -`channelsEnabled`| Allow [channels](</docs/en/channels>) for Team and Enterprise users. Unset or `false` blocks channel message delivery regardless of what users pass to `--channels` +`channelsEnabled`| Allow [channels](</docs/en/channels>) for the organization. See [enterprise controls](</docs/en/channels#enterprise-controls>) for the default on each plan `forceRemoteSettingsRefresh`| When `true`, blocks CLI startup until remote managed settings are freshly fetched and exits if the fetch fails. See [fail-closed enforcement](</docs/en/server-managed-settings#enforce-fail-closed-startup>) `pluginTrustMessage`| Custom message appended to the plugin trust warning shown before installation `sandbox.filesystem.allowManagedReadPathsOnly`| When `true`, only `filesystem.allowRead` paths from managed settings are respected. `denyRead` still merges from all sources @@ -374,7 +374,7 @@ `disableBypassPermissionsMode` is typically placed in managed settings to enforce organizational policy, but it works from any scope. A user can set it in their own settings to lock themselves out of bypass mode. -Access to [Remote Control](</docs/en/remote-control>) and [web sessions](</docs/en/claude-code-on-the-web>) is not controlled by a managed settings key. On Team and Enterprise plans, an admin enables or disables these features in [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>). +On Team and Enterprise plans, an admin enables or disables [Remote Control](</docs/en/remote-control>) and [web sessions](</docs/en/claude-code-on-the-web>) organization-wide in [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>). Remote Control can additionally be disabled per device with the [`disableRemoteControl`](</docs/en/settings#available-settings>) managed setting. Web sessions have no per-device managed settings key. ##
modified
--- a/permissions.md +++ b/permissions.md @@ -49,9 +49,9 @@ `plan`| Plan Mode: Claude can analyze but not modify files or execute commands `auto`| Auto-approves tool calls with background safety checks that verify actions align with your request. Currently a research preview `dontAsk`| Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules -`bypassPermissions`| Skips permission prompts except for writes to protected directories (see warning below) - -`bypassPermissions` mode skips permission prompts. Writes to `.git`, `.claude`, `.vscode`, `.idea`, and `.husky` directories still prompt for confirmation to prevent accidental corruption of repository state, editor configuration, and git hooks. Writes to `.claude/commands`, `.claude/agents`, and `.claude/skills` are exempt and do not prompt, because Claude routinely writes there when creating skills, subagents, and commands. Only use this mode in isolated environments like containers or VMs where Claude Code cannot cause damage. Administrators can prevent this mode by setting `permissions.disableBypassPermissionsMode` to `"disable"` in managed settings. +`bypassPermissions`| Skips all permission prompts. Root and home directory removals such as `rm -rf /` still prompt as a circuit breaker + +`bypassPermissions` mode skips all permission prompts, including writes to `.git`, `.claude`, `.vscode`, `.idea`, and `.husky`. Removals targeting the filesystem root or home directory, such as `rm -rf /` and `rm -rf ~`, still prompt as a circuit breaker against model error. Only use this mode in isolated environments like containers or VMs where Claude Code cannot cause damage. Administrators can prevent this mode by setting `permissions.disableBypassPermissionsMode` to `"disable"` in managed settings. To prevent `bypassPermissions` or `auto` mode from being used, set `permissions.disableBypassPermissionsMode` or `permissions.disableAutoMode` to `"disable"` in any [settings file](</docs/en/settings#settings-files>). These are most useful in managed settings where they cannot be overridden. @@ -186,6 +186,28 @@ ​ +PowerShell + +PowerShell permission rules use the same shape as Bash rules. Wildcards with `*` match at any position, the `:*` suffix is equivalent to a trailing ` *`, and a bare `PowerShell` or `PowerShell(*)` matches every command. This configuration allows `Get-ChildItem` and `git commit` commands while blocking `Remove-Item`: + + { + "permissions": { + "allow": [ + "PowerShell(Get-ChildItem *)", + "PowerShell(git commit *)" + ], + "deny": [ + "PowerShell(Remove-Item *)" + ] + } + } + +Common aliases are canonicalized before matching. A rule written for the cmdlet name also matches its aliases, so `PowerShell(Get-ChildItem *)` matches `gci`, `ls`, and `dir` as well. Matching is case-insensitive. Claude Code parses the PowerShell AST and checks each command in a compound command independently. Pipeline operators `|`, statement separators `;`, and on PowerShell 7+ the chain operators `&&` and `||` split a compound command into subcommands. A rule must match every subcommand for the compound command to be allowed. + +### + +​ + Read and Edit `Edit` rules apply to all built-in tools that edit files. Claude makes a best-effort attempt to apply `Read` rules to all built-in tools that read files like Grep and Glob.
modified
--- a/permissions.md +++ b/permissions.md @@ -1,3 +1,9 @@ +> ## Documentation Index +> +> Fetch the complete documentation index at: <https://code.claude.com/docs/llms.txt> +> +> Use this file to discover all available pages before exploring further. + Claude Code supports fine-grained permissions so that you can specify exactly what the agent is allowed to do and what it cannot. Permission settings can be checked into version control and distributed to all developers in your organization, as well as customized by individual developers. ##
modified
--- a/permissions.md +++ b/permissions.md @@ -342,6 +342,7 @@ `sandbox.filesystem.allowManagedReadPathsOnly`| When `true`, only `filesystem.allowRead` paths from managed settings are respected. `denyRead` still merges from all sources `sandbox.network.allowManagedDomainsOnly`| When `true`, only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are respected. Non-allowed domains are blocked automatically without prompting the user. Denied domains still merge from all sources `strictKnownMarketplaces`| Controls which plugin marketplace sources users can add and install plugins from. See [managed marketplace restrictions](</docs/en/plugin-marketplaces#managed-marketplace-restrictions>) +`wslInheritsWindowsSettings`| When `true` in the Windows HKLM registry key or `C:\Program Files\ClaudeCode\managed-settings.json`, WSL reads managed settings from the Windows policy chain in addition to `/etc/claude-code`. See [Settings files](</docs/en/settings#settings-files>) `disableBypassPermissionsMode` is typically placed in managed settings to enforce organizational policy, but it works from any scope. A user can set it in their own settings to lock themselves out of bypass mode.
modified
Show diff (136 lines)
--- a/permissions.md +++ b/permissions.md @@ -341,124 +341,11 @@ `pluginTrustMessage`| Custom message appended to the plugin trust warning shown before installation `sandbox.filesystem.allowManagedReadPathsOnly`| When `true`, only `filesystem.allowRead` paths from managed settings are respected. `denyRead` still merges from all sources `sandbox.network.allowManagedDomainsOnly`| When `true`, only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are respected. Non-allowed domains are blocked automatically without prompting the user. Denied domains still merge from all sources -`strictKnownMarketplaces`| Controls which plugin marketplaces users can add. See [managed marketplace restrictions](</docs/en/plugin-marketplaces#managed-marketplace-restrictions>) +`strictKnownMarketplaces`| Controls which plugin marketplace sources users can add and install plugins from. See [managed marketplace restrictions](</docs/en/plugin-marketplaces#managed-marketplace-restrictions>) `disableBypassPermissionsMode` is typically placed in managed settings to enforce organizational policy, but it works from any scope. A user can set it in their own settings to lock themselves out of bypass mode. Access to [Remote Control](</docs/en/remote-control>) and [web sessions](</docs/en/claude-code-on-the-web>) is not controlled by a managed settings key. On Team and Enterprise plans, an admin enables or disables these features in [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>). - -## - -​ - -Review auto mode denials - -When [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) denies a tool call, a notification appears and the denied action is recorded in `/permissions` under the Recently denied tab. Press `r` on a denied action to mark it for retry: when you exit the dialog, Claude Code sends a message telling the model it may retry that tool call and resumes the conversation. To react to denials programmatically, use the [`PermissionDenied` hook](</docs/en/hooks#permissiondenied>). - -## - -​ - -Configure the auto mode classifier - -[Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) uses a classifier model to decide whether each action is safe to run without prompting. Out of the box it trusts only the working directory and, if present, the current repo’s remotes. Actions like pushing to your company’s source control org or writing to a team cloud bucket will be blocked as potential data exfiltration. To adjust what the classifier allows or blocks, add instructions to your [CLAUDE.md](</docs/en/memory>) file. The classifier reads CLAUDE.md from trusted directories alongside the conversation, so an instruction like “never force push” steers both Claude and the classifier at the same time. Start here for project conventions and behavioral rules. For rules that apply across projects, such as trusted infrastructure or organization-wide deny rules, use the `autoMode` settings block. The classifier reads `autoMode` from user settings, `.claude/settings.local.json`, and managed settings. It does not read from shared project settings in `.claude/settings.json`, because a checked-in repo could otherwise inject its own allow rules. - -Scope| File| Use for ----|---|--- -One developer| `~/.claude/settings.json`| Personal trusted infrastructure -One project, one developer| `.claude/settings.local.json`| Per-project trusted buckets or services, gitignored -Organization-wide| Managed settings| Trusted infrastructure enforced for all developers - -Entries from each scope are combined. A developer can extend `environment`, `allow`, and `soft_deny` with personal entries but cannot remove entries that managed settings provide. Because allow rules act as exceptions to block rules inside the classifier, a developer-added `allow` entry can override an organization `soft_deny` entry: the combination is additive, not a hard policy boundary. If you need a rule that developers cannot work around, use `permissions.deny` in managed settings instead, which blocks actions before the classifier is consulted. - -### - -​ - -Define trusted infrastructure - -For most organizations, `autoMode.environment` is the only field you need to set. It tells the classifier which repos, buckets, and domains are trusted, without touching the built-in block and allow rules. The classifier uses `environment` to decide what “external” means: any destination not listed is a potential exfiltration target. - - { - "autoMode": { - "environment": [ - "Source control: github.example.com/acme-corp and all repos under it", - "Trusted cloud buckets: s3://acme-build-artifacts, gs://acme-ml-datasets", - "Trusted internal domains: *.corp.example.com, api.internal.example.com", - "Key internal services: Jenkins at ci.example.com, Artifactory at artifacts.example.com" - ] - } - } - -Entries are prose, not regex or tool patterns. The classifier reads them as natural-language rules. Write them the way you would describe your infrastructure to a new engineer. A thorough environment section covers: - - * **Organization** : your company name and what Claude Code is primarily used for, like software development, infrastructure automation, or data engineering - * **Source control** : every GitHub, GitLab, or Bitbucket org your developers push to - * **Cloud providers and trusted buckets** : bucket names or prefixes that Claude should be able to read from and write to - * **Trusted internal domains** : hostnames for APIs, dashboards, and services inside your network, like `*.internal.example.com` - * **Key internal services** : CI, artifact registries, internal package indexes, incident tooling - * **Additional context** : regulated-industry constraints, multi-tenant infrastructure, or compliance requirements that affect what the classifier should treat as risky - -A useful starting template: fill in the bracketed fields and remove any lines that don’t apply: - - { - "autoMode": { - "environment": [ - "Organization: {COMPANY_NAME}. Primary use: {PRIMARY_USE_CASE, e.g. software development, infrastructure automation}", - "Source control: {SOURCE_CONTROL, e.g. GitHub org github.example.com/acme-corp}", - "Cloud provider(s): {CLOUD_PROVIDERS, e.g. AWS, GCP, Azure}", - "Trusted cloud buckets: {TRUSTED_BUCKETS, e.g. s3://acme-builds, gs://acme-datasets}", - "Trusted internal domains: {TRUSTED_DOMAINS, e.g. *.internal.example.com, api.example.com}", - "Key internal services: {SERVICES, e.g. Jenkins at ci.example.com, Artifactory at artifacts.example.com}", - "Additional context: {EXTRA, e.g. regulated industry, multi-tenant infrastructure, compliance requirements}" - ] - } - } - -The more specific context you give, the better the classifier can distinguish routine internal operations from exfiltration attempts. You don’t need to fill everything in at once. A reasonable rollout: start with the defaults and add your source control org and key internal services, which resolves the most common false positives like pushing to your own repos. Add trusted domains and cloud buckets next. Fill the rest as blocks come up. - -### - -​ - -Override the block and allow rules - -Two additional fields let you replace the classifier’s built-in rule lists: `autoMode.soft_deny` controls what gets blocked, and `autoMode.allow` controls which exceptions apply. Each is an array of prose descriptions, read as natural-language rules. Inside the classifier, the precedence is: `soft_deny` rules block first, then `allow` rules override as exceptions, then explicit user intent overrides both. If the user’s message directly and specifically describes the exact action Claude is about to take, the classifier allows it even if a `soft_deny` rule matches. General requests don’t count: asking Claude to “clean up the repo” does not authorize force-pushing, but asking Claude to “force-push this branch” does. To loosen: remove rules from `soft_deny` when the defaults block something your pipeline already guards against with PR review, CI, or staging environments, or add to `allow` when the classifier repeatedly flags a routine pattern the default exceptions don’t cover. To tighten: add to `soft_deny` for risks specific to your environment that the defaults miss, or remove from `allow` to hold a default exception to the block rules. In all cases, run `claude auto-mode defaults` to get the full default lists, then copy and edit: never start from an empty list. - - { - "autoMode": { - "environment": [ - "Source control: github.example.com/acme-corp and all repos under it" - ], - "allow": [ - "Deploying to the staging namespace is allowed: staging is isolated from production and resets nightly", - "Writing to s3://acme-scratch/ is allowed: ephemeral bucket with a 7-day lifecycle policy" - ], - "soft_deny": [ - "Never run database migrations outside the migrations CLI, even against dev databases", - "Never modify files under infra/terraform/prod/: production infrastructure changes go through the review workflow", - "...copy full default soft_deny list here first, then add your rules..." - ] - } - } - -Setting `allow` or `soft_deny` replaces the entire default list for that section. If you set `soft_deny` with a single entry, every built-in block rule is discarded: force push, data exfiltration, `curl | bash`, production deploys, and all other default block rules become allowed. To customize safely, run `claude auto-mode defaults` to print the built-in rules, copy them into your settings file, then review each rule against your own pipeline and risk tolerance. Only remove rules for risks your infrastructure already mitigates. - -The three sections are evaluated independently, so setting `environment` alone leaves the default `allow` and `soft_deny` lists intact. - -### - -​ - -Inspect the defaults and your effective config - -Because setting `allow` or `soft_deny` replaces the defaults, start any customization by copying the full default lists. Three CLI subcommands help you inspect and validate: - - claude auto-mode defaults # the built-in environment, allow, and soft_deny rules - claude auto-mode config # what the classifier actually uses: your settings where set, defaults otherwise - claude auto-mode critique # get AI feedback on your custom allow and soft_deny rules - -Save the output of `claude auto-mode defaults` to a file, edit the lists to match your policy, and paste the result into your settings file. After saving, run `claude auto-mode config` to confirm the effective rules are what you expect. If you’ve written custom rules, `claude auto-mode critique` reviews them and flags entries that are ambiguous, redundant, or likely to cause false positives. ## @@ -491,6 +378,7 @@ See also * [Settings](</docs/en/settings>): complete configuration reference including the permission settings table + * [Configure auto mode](</docs/en/auto-mode-config>): tell the auto mode classifier which infrastructure your organization trusts * [Sandboxing](</docs/en/sandboxing>): OS-level filesystem and network isolation for Bash commands * [Authentication](</docs/en/authentication>): set up user access to Claude Code * [Security](</docs/en/security>): security safeguards and best practices
modified
--- a/permissions.md +++ b/permissions.md @@ -311,7 +311,7 @@ * Filesystem restrictions in the sandbox use Read and Edit deny rules, not separate sandbox configuration * Network restrictions combine WebFetch permission rules with the sandbox’s `allowedDomains` and `deniedDomains` lists -When sandboxing is enabled with `autoAllowBashIfSandboxed: true`, which is the default, sandboxed Bash commands run without prompting even if your permissions include `ask: Bash(*)`. The sandbox boundary substitutes for the per-command prompt. See [sandbox modes](</docs/en/sandboxing#sandbox-modes>) to change this behavior. +When sandboxing is enabled with `autoAllowBashIfSandboxed: true`, which is the default, sandboxed Bash commands run without prompting even if your permissions include `ask: Bash(*)`. The sandbox boundary substitutes for the per-command prompt. Explicit deny rules still apply, and `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a prompt. See [sandbox modes](</docs/en/sandboxing#sandbox-modes>) to change this behavior. ## @@ -361,7 +361,7 @@ Configure the auto mode classifier -[Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) uses a classifier model to decide whether each action is safe to run without prompting. Out of the box it trusts only the working directory and, if present, the current repo’s remotes. Actions like pushing to your company’s source control org or writing to a team cloud bucket will be blocked as potential data exfiltration. The `autoMode` settings block lets you tell the classifier which infrastructure your organization trusts. The classifier reads `autoMode` from user settings, `.claude/settings.local.json`, and managed settings. It does not read from shared project settings in `.claude/settings.json`, because a checked-in repo could otherwise inject its own allow rules. +[Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) uses a classifier model to decide whether each action is safe to run without prompting. Out of the box it trusts only the working directory and, if present, the current repo’s remotes. Actions like pushing to your company’s source control org or writing to a team cloud bucket will be blocked as potential data exfiltration. To adjust what the classifier allows or blocks, add instructions to your [CLAUDE.md](</docs/en/memory>) file. The classifier reads CLAUDE.md from trusted directories alongside the conversation, so an instruction like “never force push” steers both Claude and the classifier at the same time. Start here for project conventions and behavioral rules. For rules that apply across projects, such as trusted infrastructure or organization-wide deny rules, use the `autoMode` settings block. The classifier reads `autoMode` from user settings, `.claude/settings.local.json`, and managed settings. It does not read from shared project settings in `.claude/settings.json`, because a checked-in repo could otherwise inject its own allow rules. Scope| File| Use for ---|---|---
modified
--- a/permissions.md +++ b/permissions.md @@ -132,7 +132,7 @@ * `Bash(* install)` matches any command ending with ` install` * `Bash(git * main)` matches commands like `git checkout main` and `git log --oneline main` -A single `*` matches any sequence of characters including spaces, so one wildcard can span multiple arguments. `Bash(git:*)` matches `git log --oneline --all`, and `Bash(git * main)` matches `git push origin main` as well as `git merge main`. When `*` appears at the end with a space before it (like `Bash(ls *)`), it enforces a word boundary, requiring the prefix to be followed by a space or end-of-string. For example, `Bash(ls *)` matches `ls -la` but not `lsof`. In contrast, `Bash(ls*)` without a space matches both `ls -la` and `lsof` because there’s no word boundary constraint. +A single `*` matches any sequence of characters including spaces, so one wildcard can span multiple arguments. `Bash(git *)` matches `git log --oneline --all`, and `Bash(git * main)` matches `git push origin main` as well as `git merge main`. When `*` appears at the end with a space before it (like `Bash(ls *)`), it enforces a word boundary, requiring the prefix to be followed by a space or end-of-string. For example, `Bash(ls *)` matches `ls -la` but not `lsof`. In contrast, `Bash(ls*)` without a space matches both `ls -la` and `lsof` because there’s no word boundary constraint. #### @@ -150,7 +150,7 @@ Process wrappers -Before matching Bash rules, Claude Code strips a fixed set of process wrappers so a rule like `Bash(npm test *)` also matches `timeout 30 npm test`. The recognized wrappers are `timeout`, `time`, `nice`, `nohup`, and `stdbuf`. Bare `xargs` is also stripped, so `Bash(grep *)` matches `xargs grep pattern`. Stripping applies only when `xargs` has no flags: an invocation like `xargs -n1 grep pattern` is matched as an `xargs` command, so rules written for the inner command do not cover it. This wrapper list is built in and is not configurable. Development environment runners such as `direnv exec`, `devbox run`, `mise exec`, `npx`, and `docker exec` are not in the list. Because these tools execute their arguments as a command, a rule like `Bash(devbox run *)` matches whatever comes after `run`, including `devbox run rm -rf .`. To approve work inside an environment runner, write a specific rule that includes both the runner and the inner command, such as `Bash(devbox run npm test)`. Add one rule per inner command you want to allow. +Before matching Bash rules, Claude Code strips a fixed set of process wrappers so a rule like `Bash(npm test *)` also matches `timeout 30 npm test`. The recognized wrappers are `timeout`, `time`, `nice`, `nohup`, and `stdbuf`. Bare `xargs` is also stripped, so `Bash(grep *)` matches `xargs grep pattern`. Stripping applies only when `xargs` has no flags: an invocation like `xargs -n1 grep pattern` is matched as an `xargs` command, so rules written for the inner command do not cover it. This wrapper list is built in and is not configurable. Development environment runners such as `direnv exec`, `devbox run`, `mise exec`, `npx`, and `docker exec` are not in the list. Because these tools execute their arguments as a command, a rule like `Bash(devbox run *)` matches whatever comes after `run`, including `devbox run rm -rf .`. To approve work inside an environment runner, write a specific rule that includes both the runner and the inner command, such as `Bash(devbox run npm test)`. Add one rule per inner command you want to allow. Exec wrappers such as `watch`, `setsid`, `ionice`, and `flock` always prompt and cannot be auto-approved by a prefix rule like `Bash(watch *)`. The same applies to `find` with `-exec` or `-delete`: a `Bash(find *)` rule does not cover these forms. To approve a specific invocation, write an exact-match rule for the full command string. #### @@ -309,7 +309,7 @@ * Permission deny rules block Claude from even attempting to access restricted resources * Sandbox restrictions prevent Bash commands from reaching resources outside defined boundaries, even if a prompt injection bypasses Claude’s decision-making * Filesystem restrictions in the sandbox use Read and Edit deny rules, not separate sandbox configuration - * Network restrictions combine WebFetch permission rules with the sandbox’s `allowedDomains` list + * Network restrictions combine WebFetch permission rules with the sandbox’s `allowedDomains` and `deniedDomains` lists When sandboxing is enabled with `autoAllowBashIfSandboxed: true`, which is the default, sandboxed Bash commands run without prompting even if your permissions include `ask: Bash(*)`. The sandbox boundary substitutes for the per-command prompt. See [sandbox modes](</docs/en/sandboxing#sandbox-modes>) to change this behavior.
modified
--- a/permissions.md +++ b/permissions.md @@ -110,7 +110,7 @@ } } -The space before `*` matters: `Bash(ls *)` matches `ls -la` but not `lsof`, while `Bash(ls*)` matches both. The `:*` suffix is an equivalent way to write a trailing wildcard, so `Bash(ls:*)` matches the same commands as `Bash(ls *)`. The permission dialog writes the `:*` form when you select “Yes, don’t ask again” for a command prefix. This form is only recognized at the end of a pattern. In a pattern like `Bash(git:* push)`, the colon is treated as a literal character and won’t match git commands. +The space before `*` matters: `Bash(ls *)` matches `ls -la` but not `lsof`, while `Bash(ls*)` matches both. The `:*` suffix is an equivalent way to write a trailing wildcard, so `Bash(ls:*)` matches the same commands as `Bash(ls *)`. The permission dialog writes the space-separated form when you select “Yes, don’t ask again” for a command prefix. The `:*` form is only recognized at the end of a pattern. In a pattern like `Bash(git:* push)`, the colon is treated as a literal character and won’t match git commands. ## @@ -151,6 +151,14 @@ Process wrappers Before matching Bash rules, Claude Code strips a fixed set of process wrappers so a rule like `Bash(npm test *)` also matches `timeout 30 npm test`. The recognized wrappers are `timeout`, `time`, `nice`, `nohup`, and `stdbuf`. Bare `xargs` is also stripped, so `Bash(grep *)` matches `xargs grep pattern`. Stripping applies only when `xargs` has no flags: an invocation like `xargs -n1 grep pattern` is matched as an `xargs` command, so rules written for the inner command do not cover it. This wrapper list is built in and is not configurable. Development environment runners such as `direnv exec`, `devbox run`, `mise exec`, `npx`, and `docker exec` are not in the list. Because these tools execute their arguments as a command, a rule like `Bash(devbox run *)` matches whatever comes after `run`, including `devbox run rm -rf .`. To approve work inside an environment runner, write a specific rule that includes both the runner and the inner command, such as `Bash(devbox run npm test)`. Add one rule per inner command you want to allow. + +#### + +​ + +Read-only commands + +Claude Code recognizes a built-in set of Bash commands as read-only and runs them without a permission prompt in every mode. These include `ls`, `cat`, `head`, `tail`, `grep`, `find`, `wc`, `diff`, `stat`, `du`, `cd`, and read-only forms of `git`. The set is not configurable; to require a prompt for one of these commands, add an `ask` or `deny` rule for it. Unquoted glob patterns are permitted for commands whose every flag is read-only, so `ls *.ts` and `wc -l src/*.py` run without a prompt. Commands with write-capable or exec-capable flags, such as `find`, `sort`, `sed`, and `git`, still prompt when an unquoted glob is present because the glob could expand to a flag like `-delete`. A `cd` into a path inside your working directory or an additional directory is also read-only. A compound command like `cd packages/api && ls` runs without a prompt when each part qualifies on its own. Combining `cd` with `git` in one compound command always prompts, regardless of the target directory. Bash permission patterns that try to constrain command arguments are fragile. For example, `Bash(curl http://github.com/ *)` intends to restrict curl to GitHub URLs, but won’t match variations like: @@ -197,6 +205,13 @@ * `Read(src/**)`: reads from `<current-directory>/src/` In gitignore patterns, `*` matches files in a single directory while `**` matches recursively across directories. To allow all file access, use just the tool name without parentheses: `Read`, `Edit`, or `Write`. + +When Claude accesses a symlink, permission rules check two paths: the symlink itself and the file it resolves to. Allow and deny rules treat that pair differently: allow rules fall back to prompting you, while deny rules block outright. + + * **Allow rules** : apply only when both the symlink path and its target match. A symlink inside an allowed directory that points outside it still prompts you. + * **Deny rules** : apply when either the symlink path or its target matches. A symlink that points to a denied file is itself denied. + +For example, with `Read(./project/**)` allowed and `Read(~/.ssh/**)` denied, a symlink at `./project/key` pointing to `~/.ssh/id_rsa` is blocked: the target fails the allow rule and matches the deny rule. ###
modified
--- a/permissions.md +++ b/permissions.md @@ -110,7 +110,7 @@ } } -The space before `*` matters: `Bash(ls *)` matches `ls -la` but not `lsof`, while `Bash(ls*)` matches both. The `:*` suffix is an equivalent way to write a trailing wildcard. `Bash(ls:*)` matches the same commands as `Bash(ls *)`. +The space before `*` matters: `Bash(ls *)` matches `ls -la` but not `lsof`, while `Bash(ls*)` matches both. The `:*` suffix is an equivalent way to write a trailing wildcard, so `Bash(ls:*)` matches the same commands as `Bash(ls *)`. The permission dialog writes the `:*` form when you select “Yes, don’t ask again” for a command prefix. This form is only recognized at the end of a pattern. In a pattern like `Bash(git:* push)`, the colon is treated as a literal character and won’t match git commands. ## @@ -130,13 +130,27 @@ * `Bash(npm run test *)` matches Bash commands starting with `npm run test` * `Bash(npm *)` matches any command starting with `npm ` * `Bash(* install)` matches any command ending with ` install` - * `Bash(git * main)` matches commands like `git checkout main`, `git merge main` - -When `*` appears at the end with a space before it (like `Bash(ls *)`), it enforces a word boundary, requiring the prefix to be followed by a space or end-of-string. For example, `Bash(ls *)` matches `ls -la` but not `lsof`. In contrast, `Bash(ls*)` without a space matches both `ls -la` and `lsof` because there’s no word boundary constraint. - -Claude Code is aware of shell operators (like `&&`) so a prefix match rule like `Bash(safe-cmd *)` won’t give it permission to run the command `safe-cmd && other-cmd`. + * `Bash(git * main)` matches commands like `git checkout main` and `git log --oneline main` + +A single `*` matches any sequence of characters including spaces, so one wildcard can span multiple arguments. `Bash(git:*)` matches `git log --oneline --all`, and `Bash(git * main)` matches `git push origin main` as well as `git merge main`. When `*` appears at the end with a space before it (like `Bash(ls *)`), it enforces a word boundary, requiring the prefix to be followed by a space or end-of-string. For example, `Bash(ls *)` matches `ls -la` but not `lsof`. In contrast, `Bash(ls*)` without a space matches both `ls -la` and `lsof` because there’s no word boundary constraint. + +#### + +​ + +Compound commands + +Claude Code is aware of shell operators, so a rule like `Bash(safe-cmd *)` won’t give it permission to run the command `safe-cmd && other-cmd`. The recognized command separators are `&&`, `||`, `;`, `|`, `|&`, `&`, and newlines. A rule must match each subcommand independently. When you approve a compound command with “Yes, don’t ask again”, Claude Code saves a separate rule for each subcommand that requires approval, rather than a single rule for the full compound string. For example, approving `git status && npm test` saves a rule for `npm test`, so future `npm test` invocations are recognized regardless of what precedes the `&&`. Subcommands like `cd` into a subdirectory generate their own Read rule for that path. Up to 5 rules may be saved for a single compound command. + +#### + +​ + +Process wrappers + +Before matching Bash rules, Claude Code strips a fixed set of process wrappers so a rule like `Bash(npm test *)` also matches `timeout 30 npm test`. The recognized wrappers are `timeout`, `time`, `nice`, `nohup`, and `stdbuf`. Bare `xargs` is also stripped, so `Bash(grep *)` matches `xargs grep pattern`. Stripping applies only when `xargs` has no flags: an invocation like `xargs -n1 grep pattern` is matched as an `xargs` command, so rules written for the inner command do not cover it. This wrapper list is built in and is not configurable. Development environment runners such as `direnv exec`, `devbox run`, `mise exec`, `npx`, and `docker exec` are not in the list. Because these tools execute their arguments as a command, a rule like `Bash(devbox run *)` matches whatever comes after `run`, including `devbox run rm -rf .`. To approve work inside an environment runner, write a specific rule that includes both the runner and the inner command, such as `Bash(devbox run npm test)`. Add one rule per inner command you want to allow. Bash permission patterns that try to constrain command arguments are fragile. For example, `Bash(curl http://github.com/ *)` intends to restrict curl to GitHub URLs, but won’t match variations like: @@ -228,7 +242,7 @@ Extend permissions with hooks -[Claude Code hooks](</docs/en/hooks-guide>) provide a way to register custom shell commands to perform permission evaluation at runtime. When Claude Code makes a tool call, PreToolUse hooks run before the permission prompt. The hook output can deny the tool call, force a prompt, or skip the prompt to let the call proceed. Skipping the prompt does not bypass permission rules. Deny and ask rules are still evaluated after a hook returns `"allow"`, so a matching deny rule still blocks the call. This preserves the deny-first precedence described in Manage permissions, including deny rules set in managed settings. A blocking hook also takes precedence over allow rules. A hook that exits with code 2 stops the tool call before permission rules are evaluated, so the block applies even when an allow rule would otherwise let the call proceed. To run all Bash commands without prompts except for a few you want blocked, add `"Bash"` to your allow list and register a PreToolUse hook that rejects those specific commands. See [Block edits to protected files](</docs/en/hooks-guide#block-edits-to-protected-files>) for a hook script you can adapt. +[Claude Code hooks](</docs/en/hooks-guide>) provide a way to register custom shell commands to perform permission evaluation at runtime. When Claude Code makes a tool call, PreToolUse hooks run before the permission prompt. The hook output can deny the tool call, force a prompt, or skip the prompt to let the call proceed. Hook decisions do not bypass permission rules. Deny and ask rules are evaluated regardless of what a PreToolUse hook returns, so a matching deny rule blocks the call and a matching ask rule still prompts even when the hook returned `"allow"` or `"ask"`. This preserves the deny-first precedence described in Manage permissions, including deny rules set in managed settings. A blocking hook also takes precedence over allow rules. A hook that exits with code 2 stops the tool call before permission rules are evaluated, so the block applies even when an allow rule would otherwise let the call proceed. To run all Bash commands without prompts except for a few you want blocked, add `"Bash"` to your allow list and register a PreToolUse hook that rejects those specific commands. See [Block edits to protected files](</docs/en/hooks-guide#block-edits-to-protected-files>) for a hook script you can adapt. ## @@ -256,7 +270,7 @@ ---|--- [Skills](</docs/en/skills>) in `.claude/skills/`| Yes, with live reload Plugin settings in `.claude/settings.json`| `enabledPlugins` and `extraKnownMarketplaces` only -[CLAUDE.md](</docs/en/memory>) files and `.claude/rules/`| Only when `CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1` is set +[CLAUDE.md](</docs/en/memory>) files, `.claude/rules/`, and `CLAUDE.local.md`| Only when `CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1` is set. `CLAUDE.local.md` additionally requires the `local` setting source, which is enabled by default Everything else, including subagents, commands, output styles, hooks, and other settings, is discovered only from the current working directory and its parents, your user directory at `~/.claude/`, and managed settings. To share that configuration across projects, use one of these approaches:
modified
--- a/permissions.md +++ b/permissions.md @@ -110,7 +110,7 @@ } } -The space before `*` matters: `Bash(ls *)` matches `ls -la` but not `lsof`, while `Bash(ls*)` matches both. The legacy `:*` suffix syntax is equivalent to ` *` but is deprecated. +The space before `*` matters: `Bash(ls *)` matches `ls -la` but not `lsof`, while `Bash(ls*)` matches both. The `:*` suffix is an equivalent way to write a trailing wildcard. `Bash(ls:*)` matches the same commands as `Bash(ls *)`. ## @@ -303,7 +303,7 @@ Setting| Description ---|--- `allowedChannelPlugins`| Allowlist of channel plugins that may push messages. Replaces the default Anthropic allowlist when set. Requires `channelsEnabled: true`. See [Restrict which channel plugins can run](</docs/en/channels#restrict-which-channel-plugins-can-run>) -`allowManagedHooksOnly`| When `true`, prevents loading of user, project, and plugin hooks. Only managed hooks and SDK hooks are allowed +`allowManagedHooksOnly`| When `true`, only managed hooks, SDK hooks, and hooks from plugins force-enabled in managed settings `enabledPlugins` are loaded. User, project, and all other plugin hooks are blocked `allowManagedMcpServersOnly`| When `true`, only `allowedMcpServers` from managed settings are respected. `deniedMcpServers` still merges from all sources. See [Managed MCP configuration](</docs/en/mcp#managed-mcp-configuration>) `allowManagedPermissionRulesOnly`| When `true`, prevents user and project settings from defining `allow`, `ask`, or `deny` permission rules. Only rules in managed settings apply `blockedMarketplaces`| Blocklist of marketplace sources. Blocked sources are checked before downloading, so they never touch the filesystem. See [managed marketplace restrictions](</docs/en/plugin-marketplaces#managed-marketplace-restrictions>)
modified
--- a/permissions.md +++ b/permissions.md @@ -39,7 +39,7 @@ Mode| Description ---|--- `default`| Standard behavior: prompts for permission on first use of each tool -`acceptEdits`| Automatically accepts file edit permissions for the session, except writes to protected directories +`acceptEdits`| Automatically accepts file edits and common filesystem commands (`mkdir`, `touch`, `mv`, `cp`, etc.) for paths in the working directory or `additionalDirectories` `plan`| Plan Mode: Claude can analyze but not modify files or execute commands `auto`| Auto-approves tool calls with background safety checks that verify actions align with your request. Currently a research preview `dontAsk`| Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules
modified
--- a/permissions.md +++ b/permissions.md @@ -308,6 +308,7 @@ `allowManagedPermissionRulesOnly`| When `true`, prevents user and project settings from defining `allow`, `ask`, or `deny` permission rules. Only rules in managed settings apply `blockedMarketplaces`| Blocklist of marketplace sources. Blocked sources are checked before downloading, so they never touch the filesystem. See [managed marketplace restrictions](</docs/en/plugin-marketplaces#managed-marketplace-restrictions>) `channelsEnabled`| Allow [channels](</docs/en/channels>) for Team and Enterprise users. Unset or `false` blocks channel message delivery regardless of what users pass to `--channels` +`forceRemoteSettingsRefresh`| When `true`, blocks CLI startup until remote managed settings are freshly fetched and exits if the fetch fails. See [fail-closed enforcement](</docs/en/server-managed-settings#enforce-fail-closed-startup>) `pluginTrustMessage`| Custom message appended to the plugin trust warning shown before installation `sandbox.filesystem.allowManagedReadPathsOnly`| When `true`, only `filesystem.allowRead` paths from managed settings are respected. `denyRead` still merges from all sources `sandbox.network.allowManagedDomainsOnly`| When `true`, only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are respected. Non-allowed domains are blocked automatically without prompting the user. Denied domains still merge from all sources
modified
--- a/permissions.md +++ b/permissions.md @@ -39,13 +39,13 @@ Mode| Description ---|--- `default`| Standard behavior: prompts for permission on first use of each tool -`acceptEdits`| Automatically accepts file edit permissions for the session +`acceptEdits`| Automatically accepts file edit permissions for the session, except writes to protected directories `plan`| Plan Mode: Claude can analyze but not modify files or execute commands `auto`| Auto-approves tool calls with background safety checks that verify actions align with your request. Currently a research preview `dontAsk`| Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules `bypassPermissions`| Skips permission prompts except for writes to protected directories (see warning below) -`bypassPermissions` mode skips permission prompts. Writes to `.git`, `.claude`, `.vscode`, and `.idea` directories still prompt for confirmation to prevent accidental corruption of repository state and local configuration. Writes to `.claude/commands`, `.claude/agents`, and `.claude/skills` are exempt and do not prompt, because Claude routinely writes there when creating skills, subagents, and commands. Only use this mode in isolated environments like containers or VMs where Claude Code cannot cause damage. Administrators can prevent this mode by setting `permissions.disableBypassPermissionsMode` to `"disable"` in managed settings. +`bypassPermissions` mode skips permission prompts. Writes to `.git`, `.claude`, `.vscode`, `.idea`, and `.husky` directories still prompt for confirmation to prevent accidental corruption of repository state, editor configuration, and git hooks. Writes to `.claude/commands`, `.claude/agents`, and `.claude/skills` are exempt and do not prompt, because Claude routinely writes there when creating skills, subagents, and commands. Only use this mode in isolated environments like containers or VMs where Claude Code cannot cause damage. Administrators can prevent this mode by setting `permissions.disableBypassPermissionsMode` to `"disable"` in managed settings. To prevent `bypassPermissions` or `auto` mode from being used, set `permissions.disableBypassPermissionsMode` or `permissions.disableAutoMode` to `"disable"` in any [settings file](</docs/en/settings#settings-files>). These are most useful in managed settings where they cannot be overridden. @@ -281,6 +281,8 @@ * Sandbox restrictions prevent Bash commands from reaching resources outside defined boundaries, even if a prompt injection bypasses Claude’s decision-making * Filesystem restrictions in the sandbox use Read and Edit deny rules, not separate sandbox configuration * Network restrictions combine WebFetch permission rules with the sandbox’s `allowedDomains` list + +When sandboxing is enabled with `autoAllowBashIfSandboxed: true`, which is the default, sandboxed Bash commands run without prompting even if your permissions include `ask: Bash(*)`. The sandbox boundary substitutes for the per-command prompt. See [sandbox modes](</docs/en/sandboxing#sandbox-modes>) to change this behavior. ##
modified
--- a/permissions.md +++ b/permissions.md @@ -45,9 +45,9 @@ `dontAsk`| Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules `bypassPermissions`| Skips permission prompts except for writes to protected directories (see warning below) -`bypassPermissions` mode skips permission prompts. Writes to `.git`, `.claude`, `.vscode`, and `.idea` directories still prompt for confirmation to prevent accidental corruption of repository state and local configuration. Writes to `.claude/commands`, `.claude/agents`, and `.claude/skills` are exempt and do not prompt, because Claude routinely writes there when creating skills, subagents, and commands. Only use this mode in isolated environments like containers or VMs where Claude Code cannot cause damage. Administrators can prevent this mode by setting `disableBypassPermissionsMode` to `"disable"` in managed settings. - -To prevent `bypassPermissions` or `auto` mode from being used, set `permissions.disableBypassPermissionsMode` or `disableAutoMode` to `"disable"` in any [settings file](</docs/en/settings#settings-files>). These are most useful in managed settings where they cannot be overridden. +`bypassPermissions` mode skips permission prompts. Writes to `.git`, `.claude`, `.vscode`, and `.idea` directories still prompt for confirmation to prevent accidental corruption of repository state and local configuration. Writes to `.claude/commands`, `.claude/agents`, and `.claude/skills` are exempt and do not prompt, because Claude routinely writes there when creating skills, subagents, and commands. Only use this mode in isolated environments like containers or VMs where Claude Code cannot cause damage. Administrators can prevent this mode by setting `permissions.disableBypassPermissionsMode` to `"disable"` in managed settings. + +To prevent `bypassPermissions` or `auto` mode from being used, set `permissions.disableBypassPermissionsMode` or `permissions.disableAutoMode` to `"disable"` in any [settings file](</docs/en/settings#settings-files>). These are most useful in managed settings where they cannot be overridden. ## @@ -314,6 +314,14 @@ `disableBypassPermissionsMode` is typically placed in managed settings to enforce organizational policy, but it works from any scope. A user can set it in their own settings to lock themselves out of bypass mode. Access to [Remote Control](</docs/en/remote-control>) and [web sessions](</docs/en/claude-code-on-the-web>) is not controlled by a managed settings key. On Team and Enterprise plans, an admin enables or disables these features in [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>). + +## + +​ + +Review auto mode denials + +When [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) denies a tool call, a notification appears and the denied action is recorded in `/permissions` under the Recently denied tab. Press `r` on a denied action to mark it for retry: when you exit the dialog, Claude Code sends a message telling the model it may retry that tool call and resumes the conversation. To react to denials programmatically, use the [`PermissionDenied` hook](</docs/en/hooks#permissiondenied>). ##
modified
--- a/permissions.md +++ b/permissions.md @@ -244,6 +244,26 @@ Files in additional directories follow the same permission rules as the original working directory: they become readable without prompts, and file editing permissions follow the current permission mode. +### + +​ + +Additional directories grant file access, not configuration + +Adding a directory extends where Claude can read and edit files. It does not make that directory a full configuration root: most `.claude/` configuration is not discovered from additional directories, though a few types are loaded as exceptions. The following configuration types are loaded from `--add-dir` directories: + +Configuration| Loaded from `--add-dir` +---|--- +[Skills](</docs/en/skills>) in `.claude/skills/`| Yes, with live reload +Plugin settings in `.claude/settings.json`| `enabledPlugins` and `extraKnownMarketplaces` only +[CLAUDE.md](</docs/en/memory>) files and `.claude/rules/`| Only when `CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1` is set + +Everything else, including subagents, commands, output styles, hooks, and other settings, is discovered only from the current working directory and its parents, your user directory at `~/.claude/`, and managed settings. To share that configuration across projects, use one of these approaches: + + * **User-level configuration** : place files in `~/.claude/agents/`, `~/.claude/output-styles/`, or `~/.claude/settings.json` to make them available in every project + * **Plugins** : package and distribute configuration as a [plugin](</docs/en/plugins>) that teams can install + * **Launch from the config directory** : run Claude Code from the directory containing the `.claude/` configuration you want + ## ​ @@ -276,18 +296,22 @@ Managed-only settings -Some settings are only effective in managed settings: +The following settings are only read from managed settings. Placing them in user or project settings files has no effect. Setting| Description ---|--- -`allowManagedPermissionRulesOnly`| When `true`, prevents user and project settings from defining `allow`, `ask`, or `deny` permission rules. Only rules in managed settings apply +`allowedChannelPlugins`| Allowlist of channel plugins that may push messages. Replaces the default Anthropic allowlist when set. Requires `channelsEnabled: true`. See [Restrict which channel plugins can run](</docs/en/channels#restrict-which-channel-plugins-can-run>) `allowManagedHooksOnly`| When `true`, prevents loading of user, project, and plugin hooks. Only managed hooks and SDK hooks are allowed `allowManagedMcpServersOnly`| When `true`, only `allowedMcpServers` from managed settings are respected. `deniedMcpServers` still merges from all sources. See [Managed MCP configuration](</docs/en/mcp#managed-mcp-configuration>) -`allowedChannelPlugins`| Allowlist of channel plugins that may push messages. Replaces the default Anthropic allowlist when set. Requires `channelsEnabled: true`. See [Restrict which channel plugins can run](</docs/en/channels#restrict-which-channel-plugins-can-run>) +`allowManagedPermissionRulesOnly`| When `true`, prevents user and project settings from defining `allow`, `ask`, or `deny` permission rules. Only rules in managed settings apply `blockedMarketplaces`| Blocklist of marketplace sources. Blocked sources are checked before downloading, so they never touch the filesystem. See [managed marketplace restrictions](</docs/en/plugin-marketplaces#managed-marketplace-restrictions>) +`channelsEnabled`| Allow [channels](</docs/en/channels>) for Team and Enterprise users. Unset or `false` blocks channel message delivery regardless of what users pass to `--channels` +`pluginTrustMessage`| Custom message appended to the plugin trust warning shown before installation +`sandbox.filesystem.allowManagedReadPathsOnly`| When `true`, only `filesystem.allowRead` paths from managed settings are respected. `denyRead` still merges from all sources `sandbox.network.allowManagedDomainsOnly`| When `true`, only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are respected. Non-allowed domains are blocked automatically without prompting the user. Denied domains still merge from all sources -`sandbox.filesystem.allowManagedReadPathsOnly`| When `true`, only `allowRead` paths from managed settings are respected. `allowRead` entries from user, project, and local settings are ignored `strictKnownMarketplaces`| Controls which plugin marketplaces users can add. See [managed marketplace restrictions](</docs/en/plugin-marketplaces#managed-marketplace-restrictions>) + +`disableBypassPermissionsMode` is typically placed in managed settings to enforce organizational policy, but it works from any scope. A user can set it in their own settings to lock themselves out of bypass mode. Access to [Remote Control](</docs/en/remote-control>) and [web sessions](</docs/en/claude-code-on-the-web>) is not controlled by a managed settings key. On Team and Enterprise plans, an admin enables or disables these features in [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>).
modified
--- a/permissions.md +++ b/permissions.md @@ -94,12 +94,6 @@ Wildcard patterns Bash rules support glob patterns with `*`. Wildcards can appear at any position in the command. This configuration allows npm and git commit commands while blocking git push: - -Report incorrect code - -Copy - -Ask AI { "permissions": { @@ -222,12 +216,6 @@ Add these rules to the `deny` array in your settings or use the `--disallowedTools` CLI flag to disable specific agents. To disable the Explore agent: -Report incorrect code - -Copy - -Ask AI - { "permissions": { "deny": ["Agent(Explore)"] @@ -295,6 +283,7 @@ `allowManagedPermissionRulesOnly`| When `true`, prevents user and project settings from defining `allow`, `ask`, or `deny` permission rules. Only rules in managed settings apply `allowManagedHooksOnly`| When `true`, prevents loading of user, project, and plugin hooks. Only managed hooks and SDK hooks are allowed `allowManagedMcpServersOnly`| When `true`, only `allowedMcpServers` from managed settings are respected. `deniedMcpServers` still merges from all sources. See [Managed MCP configuration](</docs/en/mcp#managed-mcp-configuration>) +`allowedChannelPlugins`| Allowlist of channel plugins that may push messages. Replaces the default Anthropic allowlist when set. Requires `channelsEnabled: true`. See [Restrict which channel plugins can run](</docs/en/channels#restrict-which-channel-plugins-can-run>) `blockedMarketplaces`| Blocklist of marketplace sources. Blocked sources are checked before downloading, so they never touch the filesystem. See [managed marketplace restrictions](</docs/en/plugin-marketplaces#managed-marketplace-restrictions>) `sandbox.network.allowManagedDomainsOnly`| When `true`, only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are respected. Non-allowed domains are blocked automatically without prompting the user. Denied domains still merge from all sources `sandbox.filesystem.allowManagedReadPathsOnly`| When `true`, only `allowRead` paths from managed settings are respected. `allowRead` entries from user, project, and local settings are ignored @@ -325,12 +314,6 @@ Define trusted infrastructure For most organizations, `autoMode.environment` is the only field you need to set. It tells the classifier which repos, buckets, and domains are trusted, without touching the built-in block and allow rules. The classifier uses `environment` to decide what “external” means: any destination not listed is a potential exfiltration target. - -Report incorrect code - -Copy - -Ask AI { "autoMode": { @@ -353,12 +336,6 @@ * **Additional context** : regulated-industry constraints, multi-tenant infrastructure, or compliance requirements that affect what the classifier should treat as risky A useful starting template: fill in the bracketed fields and remove any lines that don’t apply: - -Report incorrect code - -Copy - -Ask AI { "autoMode": { @@ -383,12 +360,6 @@ Override the block and allow rules Two additional fields let you replace the classifier’s built-in rule lists: `autoMode.soft_deny` controls what gets blocked, and `autoMode.allow` controls which exceptions apply. Each is an array of prose descriptions, read as natural-language rules. Inside the classifier, the precedence is: `soft_deny` rules block first, then `allow` rules override as exceptions, then explicit user intent overrides both. If the user’s message directly and specifically describes the exact action Claude is about to take, the classifier allows it even if a `soft_deny` rule matches. General requests don’t count: asking Claude to “clean up the repo” does not authorize force-pushing, but asking Claude to “force-push this branch” does. To loosen: remove rules from `soft_deny` when the defaults block something your pipeline already guards against with PR review, CI, or staging environments, or add to `allow` when the classifier repeatedly flags a routine pattern the default exceptions don’t cover. To tighten: add to `soft_deny` for risks specific to your environment that the defaults miss, or remove from `allow` to hold a default exception to the block rules. In all cases, run `claude auto-mode defaults` to get the full default lists, then copy and edit: never start from an empty list. - -Report incorrect code - -Copy - -Ask AI { "autoMode": { @@ -419,12 +390,6 @@ Because setting `allow` or `soft_deny` replaces the defaults, start any customization by copying the full default lists. Three CLI subcommands help you inspect and validate: -Report incorrect code - -Copy - -Ask AI - claude auto-mode defaults # the built-in environment, allow, and soft_deny rules claude auto-mode config # what the classifier actually uses: your settings where set, defaults otherwise claude auto-mode critique # get AI feedback on your custom allow and soft_deny rules
modified
Show diff (168 lines)
--- a/permissions.md +++ b/permissions.md @@ -34,17 +34,20 @@ Permission modes -Claude Code supports several permission modes that control how tools are approved. Set the `defaultMode` in your [settings files](</docs/en/settings#settings-files>): +Claude Code supports several permission modes that control how tools are approved. See [Permission modes](</docs/en/permission-modes>) for when to use each one. Set the `defaultMode` in your [settings files](</docs/en/settings#settings-files>): Mode| Description ---|--- `default`| Standard behavior: prompts for permission on first use of each tool `acceptEdits`| Automatically accepts file edit permissions for the session `plan`| Plan Mode: Claude can analyze but not modify files or execute commands +`auto`| Auto-approves tool calls with background safety checks that verify actions align with your request. Currently a research preview `dontAsk`| Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules `bypassPermissions`| Skips permission prompts except for writes to protected directories (see warning below) `bypassPermissions` mode skips permission prompts. Writes to `.git`, `.claude`, `.vscode`, and `.idea` directories still prompt for confirmation to prevent accidental corruption of repository state and local configuration. Writes to `.claude/commands`, `.claude/agents`, and `.claude/skills` are exempt and do not prompt, because Claude routinely writes there when creating skills, subagents, and commands. Only use this mode in isolated environments like containers or VMs where Claude Code cannot cause damage. Administrators can prevent this mode by setting `disableBypassPermissionsMode` to `"disable"` in managed settings. + +To prevent `bypassPermissions` or `auto` mode from being used, set `permissions.disableBypassPermissionsMode` or `disableAutoMode` to `"disable"` in any [settings file](</docs/en/settings#settings-files>). These are most useful in managed settings where they cannot be overridden. ## @@ -289,7 +292,6 @@ Setting| Description ---|--- -`disableBypassPermissionsMode`| Set to `"disable"` to prevent `bypassPermissions` mode and the `--dangerously-skip-permissions` flag `allowManagedPermissionRulesOnly`| When `true`, prevents user and project settings from defining `allow`, `ask`, or `deny` permission rules. Only rules in managed settings apply `allowManagedHooksOnly`| When `true`, prevents loading of user, project, and plugin hooks. Only managed hooks and SDK hooks are allowed `allowManagedMcpServersOnly`| When `true`, only `allowedMcpServers` from managed settings are respected. `deniedMcpServers` still merges from all sources. See [Managed MCP configuration](</docs/en/mcp#managed-mcp-configuration>) @@ -304,6 +306,135 @@ ​ +Configure the auto mode classifier + +[Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) uses a classifier model to decide whether each action is safe to run without prompting. Out of the box it trusts only the working directory and, if present, the current repo’s remotes. Actions like pushing to your company’s source control org or writing to a team cloud bucket will be blocked as potential data exfiltration. The `autoMode` settings block lets you tell the classifier which infrastructure your organization trusts. The classifier reads `autoMode` from user settings, `.claude/settings.local.json`, and managed settings. It does not read from shared project settings in `.claude/settings.json`, because a checked-in repo could otherwise inject its own allow rules. + +Scope| File| Use for +---|---|--- +One developer| `~/.claude/settings.json`| Personal trusted infrastructure +One project, one developer| `.claude/settings.local.json`| Per-project trusted buckets or services, gitignored +Organization-wide| Managed settings| Trusted infrastructure enforced for all developers + +Entries from each scope are combined. A developer can extend `environment`, `allow`, and `soft_deny` with personal entries but cannot remove entries that managed settings provide. Because allow rules act as exceptions to block rules inside the classifier, a developer-added `allow` entry can override an organization `soft_deny` entry: the combination is additive, not a hard policy boundary. If you need a rule that developers cannot work around, use `permissions.deny` in managed settings instead, which blocks actions before the classifier is consulted. + +### + +​ + +Define trusted infrastructure + +For most organizations, `autoMode.environment` is the only field you need to set. It tells the classifier which repos, buckets, and domains are trusted, without touching the built-in block and allow rules. The classifier uses `environment` to decide what “external” means: any destination not listed is a potential exfiltration target. + +Report incorrect code + +Copy + +Ask AI + + { + "autoMode": { + "environment": [ + "Source control: github.example.com/acme-corp and all repos under it", + "Trusted cloud buckets: s3://acme-build-artifacts, gs://acme-ml-datasets", + "Trusted internal domains: *.corp.example.com, api.internal.example.com", + "Key internal services: Jenkins at ci.example.com, Artifactory at artifacts.example.com" + ] + } + } + +Entries are prose, not regex or tool patterns. The classifier reads them as natural-language rules. Write them the way you would describe your infrastructure to a new engineer. A thorough environment section covers: + + * **Organization** : your company name and what Claude Code is primarily used for, like software development, infrastructure automation, or data engineering + * **Source control** : every GitHub, GitLab, or Bitbucket org your developers push to + * **Cloud providers and trusted buckets** : bucket names or prefixes that Claude should be able to read from and write to + * **Trusted internal domains** : hostnames for APIs, dashboards, and services inside your network, like `*.internal.example.com` + * **Key internal services** : CI, artifact registries, internal package indexes, incident tooling + * **Additional context** : regulated-industry constraints, multi-tenant infrastructure, or compliance requirements that affect what the classifier should treat as risky + +A useful starting template: fill in the bracketed fields and remove any lines that don’t apply: + +Report incorrect code + +Copy + +Ask AI + + { + "autoMode": { + "environment": [ + "Organization: {COMPANY_NAME}. Primary use: {PRIMARY_USE_CASE, e.g. software development, infrastructure automation}", + "Source control: {SOURCE_CONTROL, e.g. GitHub org github.example.com/acme-corp}", + "Cloud provider(s): {CLOUD_PROVIDERS, e.g. AWS, GCP, Azure}", + "Trusted cloud buckets: {TRUSTED_BUCKETS, e.g. s3://acme-builds, gs://acme-datasets}", + "Trusted internal domains: {TRUSTED_DOMAINS, e.g. *.internal.example.com, api.example.com}", + "Key internal services: {SERVICES, e.g. Jenkins at ci.example.com, Artifactory at artifacts.example.com}", + "Additional context: {EXTRA, e.g. regulated industry, multi-tenant infrastructure, compliance requirements}" + ] + } + } + +The more specific context you give, the better the classifier can distinguish routine internal operations from exfiltration attempts. You don’t need to fill everything in at once. A reasonable rollout: start with the defaults and add your source control org and key internal services, which resolves the most common false positives like pushing to your own repos. Add trusted domains and cloud buckets next. Fill the rest as blocks come up. + +### + +​ + +Override the block and allow rules + +Two additional fields let you replace the classifier’s built-in rule lists: `autoMode.soft_deny` controls what gets blocked, and `autoMode.allow` controls which exceptions apply. Each is an array of prose descriptions, read as natural-language rules. Inside the classifier, the precedence is: `soft_deny` rules block first, then `allow` rules override as exceptions, then explicit user intent overrides both. If the user’s message directly and specifically describes the exact action Claude is about to take, the classifier allows it even if a `soft_deny` rule matches. General requests don’t count: asking Claude to “clean up the repo” does not authorize force-pushing, but asking Claude to “force-push this branch” does. To loosen: remove rules from `soft_deny` when the defaults block something your pipeline already guards against with PR review, CI, or staging environments, or add to `allow` when the classifier repeatedly flags a routine pattern the default exceptions don’t cover. To tighten: add to `soft_deny` for risks specific to your environment that the defaults miss, or remove from `allow` to hold a default exception to the block rules. In all cases, run `claude auto-mode defaults` to get the full default lists, then copy and edit: never start from an empty list. + +Report incorrect code + +Copy + +Ask AI + + { + "autoMode": { + "environment": [ + "Source control: github.example.com/acme-corp and all repos under it" + ], + "allow": [ + "Deploying to the staging namespace is allowed: staging is isolated from production and resets nightly", + "Writing to s3://acme-scratch/ is allowed: ephemeral bucket with a 7-day lifecycle policy" + ], + "soft_deny": [ + "Never run database migrations outside the migrations CLI, even against dev databases", + "Never modify files under infra/terraform/prod/: production infrastructure changes go through the review workflow", + "...copy full default soft_deny list here first, then add your rules..." + ] + } + } + +Setting `allow` or `soft_deny` replaces the entire default list for that section. If you set `soft_deny` with a single entry, every built-in block rule is discarded: force push, data exfiltration, `curl | bash`, production deploys, and all other default block rules become allowed. To customize safely, run `claude auto-mode defaults` to print the built-in rules, copy them into your settings file, then review each rule against your own pipeline and risk tolerance. Only remove rules for risks your infrastructure already mitigates. + +The three sections are evaluated independently, so setting `environment` alone leaves the default `allow` and `soft_deny` lists intact. + +### + +​ + +Inspect the defaults and your effective config + +Because setting `allow` or `soft_deny` replaces the defaults, start any customization by copying the full default lists. Three CLI subcommands help you inspect and validate: + +Report incorrect code + +Copy + +Ask AI + + claude auto-mode defaults # the built-in environment, allow, and soft_deny rules + claude auto-mode config # what the classifier actually uses: your settings where set, defaults otherwise + claude auto-mode critique # get AI feedback on your custom allow and soft_deny rules + +Save the output of `claude auto-mode defaults` to a file, edit the lists to match your policy, and paste the result into your settings file. After saving, run `claude auto-mode config` to confirm the effective rules are what you expect. If you’ve written custom rules, `claude auto-mode critique` reviews them and flags entries that are ambiguous, redundant, or likely to cause false positives. + +## + +​ + Settings precedence Permission rules follow the same [settings precedence](</docs/en/settings#settings-precedence>) as all other Claude Code settings:
added
Show diff (340 lines)
--- a/permissions.md +++ b/permissions.md @@ -0,0 +1,337 @@ +Claude Code supports fine-grained permissions so that you can specify exactly what the agent is allowed to do and what it cannot. Permission settings can be checked into version control and distributed to all developers in your organization, as well as customized by individual developers. + +## + +​ + +Permission system + +Claude Code uses a tiered permission system to balance power and safety: + +Tool type| Example| Approval required| ”Yes, don’t ask again” behavior +---|---|---|--- +Read-only| File reads, Grep| No| N/A +Bash commands| Shell execution| Yes| Permanently per project directory and command +File modification| Edit/write files| Yes| Until session end + +## + +​ + +Manage permissions + +You can view and manage Claude Code’s tool permissions with `/permissions`. This UI lists all permission rules and the settings.json file they are sourced from. + + * **Allow** rules let Claude Code use the specified tool without manual approval. + * **Ask** rules prompt for confirmation whenever Claude Code tries to use the specified tool. + * **Deny** rules prevent Claude Code from using the specified tool. + +Rules are evaluated in order: **deny - > ask -> allow**. The first matching rule wins, so deny rules always take precedence. + +## + +​ + +Permission modes + +Claude Code supports several permission modes that control how tools are approved. Set the `defaultMode` in your [settings files](</docs/en/settings#settings-files>): + +Mode| Description +---|--- +`default`| Standard behavior: prompts for permission on first use of each tool +`acceptEdits`| Automatically accepts file edit permissions for the session +`plan`| Plan Mode: Claude can analyze but not modify files or execute commands +`dontAsk`| Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules +`bypassPermissions`| Skips permission prompts except for writes to protected directories (see warning below) + +`bypassPermissions` mode skips permission prompts. Writes to `.git`, `.claude`, `.vscode`, and `.idea` directories still prompt for confirmation to prevent accidental corruption of repository state and local configuration. Writes to `.claude/commands`, `.claude/agents`, and `.claude/skills` are exempt and do not prompt, because Claude routinely writes there when creating skills, subagents, and commands. Only use this mode in isolated environments like containers or VMs where Claude Code cannot cause damage. Administrators can prevent this mode by setting `disableBypassPermissionsMode` to `"disable"` in managed settings. + +## + +​ + +Permission rule syntax + +Permission rules follow the format `Tool` or `Tool(specifier)`. + +### + +​ + +Match all uses of a tool + +To match all uses of a tool, use just the tool name without parentheses: + +Rule| Effect +---|--- +`Bash`| Matches all Bash commands +`WebFetch`| Matches all web fetch requests +`Read`| Matches all file reads + +`Bash(*)` is equivalent to `Bash` and matches all Bash commands. + +### + +​ + +Use specifiers for fine-grained control + +Add a specifier in parentheses to match specific tool uses: + +Rule| Effect +---|--- +`Bash(npm run build)`| Matches the exact command `npm run build` +`Read(./.env)`| Matches reading the `.env` file in the current directory +`WebFetch(domain:example.com)`| Matches fetch requests to example.com + +### + +​ + +Wildcard patterns + +Bash rules support glob patterns with `*`. Wildcards can appear at any position in the command. This configuration allows npm and git commit commands while blocking git push: + +Report incorrect code + +Copy + +Ask AI + + { + "permissions": { + "allow": [ + "Bash(npm run *)", + "Bash(git commit *)", + "Bash(git * main)", + "Bash(* --version)", + "Bash(* --help *)" + ], + "deny": [ + "Bash(git push *)" + ] + } + } + +The space before `*` matters: `Bash(ls *)` matches `ls -la` but not `lsof`, while `Bash(ls*)` matches both. The legacy `:*` suffix syntax is equivalent to ` *` but is deprecated. + +## + +​ + +Tool-specific permission rules + +### + +​ + +Bash + +Bash permission rules support wildcard matching with `*`. Wildcards can appear at any position in the command, including at the beginning, middle, or end: + + * `Bash(npm run build)` matches the exact Bash command `npm run build` + * `Bash(npm run test *)` matches Bash commands starting with `npm run test` + * `Bash(npm *)` matches any command starting with `npm ` + * `Bash(* install)` matches any command ending with ` install` + * `Bash(git * main)` matches commands like `git checkout main`, `git merge main` + +When `*` appears at the end with a space before it (like `Bash(ls *)`), it enforces a word boundary, requiring the prefix to be followed by a space or end-of-string. For example, `Bash(ls *)` matches `ls -la` but not `lsof`. In contrast, `Bash(ls*)` without a space matches both `ls -la` and `lsof` because there’s no word boundary constraint. + +Claude Code is aware of shell operators (like `&&`) so a prefix match rule like `Bash(safe-cmd *)` won’t give it permission to run the command `safe-cmd && other-cmd`. + +When you approve a compound command with “Yes, don’t ask again”, Claude Code saves a separate rule for each subcommand that requires approval, rather than a single rule for the full compound string. For example, approving `git status && npm test` saves a rule for `npm test`, so future `npm test` invocations are recognized regardless of what precedes the `&&`. Subcommands like `cd` into a subdirectory generate their own Read rule for that path. Up to 5 rules may be saved for a single compound command. + +Bash permission patterns that try to constrain command arguments are fragile. For example, `Bash(curl http://github.com/ *)` intends to restrict curl to GitHub URLs, but won’t match variations like: + + * Options before URL: `curl -X GET http://github.com/...` + * Different protocol: `curl https://github.com/...` + * Redirects: `curl -L http://bit.ly/xyz` (redirects to github) + * Variables: `URL=http://github.com && curl $URL` + * Extra spaces: `curl http://github.com` + +For more reliable URL filtering, consider: + + * **Restrict Bash network tools** : use deny rules to block `curl`, `wget`, and similar commands, then use the WebFetch tool with `WebFetch(domain:github.com)` permission for allowed domains + * **Use PreToolUse hooks** : implement a hook that validates URLs in Bash commands and blocks disallowed domains + * Instructing Claude Code about your allowed curl patterns via CLAUDE.md + +Note that using WebFetch alone does not prevent network access. If Bash is allowed, Claude can still use `curl`, `wget`, or other tools to reach any URL. + +### + +​ + +Read and Edit + +`Edit` rules apply to all built-in tools that edit files. Claude makes a best-effort attempt to apply `Read` rules to all built-in tools that read files like Grep and Glob. + +Read and Edit deny rules apply to Claude’s built-in file tools, not to Bash subprocesses. A `Read(./.env)` deny rule blocks the Read tool but does not prevent `cat .env` in Bash. For OS-level enforcement that blocks all processes from accessing a path, [enable the sandbox](</docs/en/sandboxing>). + +Read and Edit rules both follow the [gitignore](<https://git-scm.com/docs/gitignore>) specification with four distinct pattern types: + +Pattern| Meaning| Example| Matches +---|---|---|--- +`//path`| **Absolute** path from filesystem root| `Read(//Users/alice/secrets/**)`| `/Users/alice/secrets/**` +`~/path`| Path from **home** directory| `Read(~/Documents/*.pdf)`| `/Users/alice/Documents/*.pdf` +`/path`| Path **relative to project root**| `Edit(/src/**/*.ts)`| `<project root>/src/**/*.ts` +`path` or `./path`| Path **relative to current directory**| `Read(*.env)`| `<cwd>/*.env` + +A pattern like `/Users/alice/file` is NOT an absolute path. It’s relative to the project root. Use `//Users/alice/file` for absolute paths. + +On Windows, paths are normalized to POSIX form before matching. `C:\Users\alice` becomes `/c/Users/alice`, so use `//c/**/.env` to match `.env` files anywhere on that drive. To match across all drives, use `//**/.env`. Examples: + + * `Edit(/docs/**)`: edits in `<project>/docs/` (NOT `/docs/` and NOT `<project>/.claude/docs/`) + * `Read(~/.zshrc)`: reads your home directory’s `.zshrc` + * `Edit(//tmp/scratch.txt)`: edits the absolute path `/tmp/scratch.txt` + * `Read(src/**)`: reads from `<current-directory>/src/` + +In gitignore patterns, `*` matches files in a single directory while `**` matches recursively across directories. To allow all file access, use just the tool name without parentheses: `Read`, `Edit`, or `Write`. + +### + +​ + +WebFetch + + * `WebFetch(domain:example.com)` matches fetch requests to example.com + +### + +​ + +MCP + + * `mcp__puppeteer` matches any tool provided by the `puppeteer` server (name configured in Claude Code) + * `mcp__puppeteer__*` wildcard syntax that also matches all tools from the `puppeteer` server + * `mcp__puppeteer__puppeteer_navigate` matches the `puppeteer_navigate` tool provided by the `puppeteer` server + +### + +​ + +Agent (subagents) + +Use `Agent(AgentName)` rules to control which [subagents](</docs/en/sub-agents>) Claude can use: + + * `Agent(Explore)` matches the Explore subagent + * `Agent(Plan)` matches the Plan subagent + * `Agent(my-custom-agent)` matches a custom subagent named `my-custom-agent` + +Add these rules to the `deny` array in your settings or use the `--disallowedTools` CLI flag to disable specific agents. To disable the Explore agent: + +Report incorrect code + +Copy + +Ask AI + + { + "permissions": { + "deny": ["Agent(Explore)"] + } + } + +## + +​ + +Extend permissions with hooks + +[Claude Code hooks](</docs/en/hooks-guide>) provide a way to register custom shell commands to perform permission evaluation at runtime. When Claude Code makes a tool call, PreToolUse hooks run before the permission prompt. The hook output can deny the tool call, force a prompt, or skip the prompt to let the call proceed. Skipping the prompt does not bypass permission rules. Deny and ask rules are still evaluated after a hook returns `"allow"`, so a matching deny rule still blocks the call. This preserves the deny-first precedence described in Manage permissions, including deny rules set in managed settings. A blocking hook also takes precedence over allow rules. A hook that exits with code 2 stops the tool call before permission rules are evaluated, so the block applies even when an allow rule would otherwise let the call proceed. To run all Bash commands without prompts except for a few you want blocked, add `"Bash"` to your allow list and register a PreToolUse hook that rejects those specific commands. See [Block edits to protected files](</docs/en/hooks-guide#block-edits-to-protected-files>) for a hook script you can adapt. + +## + +​ + +Working directories + +By default, Claude has access to files in the directory where it was launched. You can extend this access: + + * **During startup** : use `--add-dir <path>` CLI argument + * **During session** : use `/add-dir` command + * **Persistent configuration** : add to `additionalDirectories` in [settings files](</docs/en/settings#settings-files>) + +Files in additional directories follow the same permission rules as the original working directory: they become readable without prompts, and file editing permissions follow the current permission mode. + +## + +​ + +How permissions interact with sandboxing + +Permissions and [sandboxing](</docs/en/sandboxing>) are complementary security layers: + + * **Permissions** control which tools Claude Code can use and which files or domains it can access. They apply to all tools (Bash, Read, Edit, WebFetch, MCP, and others). + * **Sandboxing** provides OS-level enforcement that restricts the Bash tool’s filesystem and network access. It applies only to Bash commands and their child processes. + +Use both for defense-in-depth: + + * Permission deny rules block Claude from even attempting to access restricted resources + * Sandbox restrictions prevent Bash commands from reaching resources outside defined boundaries, even if a prompt injection bypasses Claude’s decision-making + * Filesystem restrictions in the sandbox use Read and Edit deny rules, not separate sandbox configuration + * Network restrictions combine WebFetch permission rules with the sandbox’s `allowedDomains` list + +## + +​ + +Managed settings + +For organizations that need centralized control over Claude Code configuration, administrators can deploy managed settings that cannot be overridden by user or project settings. These policy settings follow the same format as regular settings files and can be delivered through MDM/OS-level policies, managed settings files, or [server-managed settings](</docs/en/server-managed-settings>). See [settings files](</docs/en/settings#settings-files>) for delivery mechanisms and file locations. + +### + +​ + +Managed-only settings + +Some settings are only effective in managed settings: + +Setting| Description +---|--- +`disableBypassPermissionsMode`| Set to `"disable"` to prevent `bypassPermissions` mode and the `--dangerously-skip-permissions` flag +`allowManagedPermissionRulesOnly`| When `true`, prevents user and project settings from defining `allow`, `ask`, or `deny` permission rules. Only rules in managed settings apply +`allowManagedHooksOnly`| When `true`, prevents loading of user, project, and plugin hooks. Only managed hooks and SDK hooks are allowed +`allowManagedMcpServersOnly`| When `true`, only `allowedMcpServers` from managed settings are respected. `deniedMcpServers` still merges from all sources. See [Managed MCP configuration](</docs/en/mcp#managed-mcp-configuration>) +`blockedMarketplaces`| Blocklist of marketplace sources. Blocked sources are checked before downloading, so they never touch the filesystem. See [managed marketplace restrictions](</docs/en/plugin-marketplaces#managed-marketplace-restrictions>) +`sandbox.network.allowManagedDomainsOnly`| When `true`, only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are respected. Non-allowed domains are blocked automatically without prompting the user. Denied domains still merge from all sources +`sandbox.filesystem.allowManagedReadPathsOnly`| When `true`, only `allowRead` paths from managed settings are respected. `allowRead` entries from user, project, and local settings are ignored +`strictKnownMarketplaces`| Controls which plugin marketplaces users can add. See [managed marketplace restrictions](</docs/en/plugin-marketplaces#managed-marketplace-restrictions>) + +Access to [Remote Control](</docs/en/remote-control>) and [web sessions](</docs/en/claude-code-on-the-web>) is not controlled by a managed settings key. On Team and Enterprise plans, an admin enables or disables these features in [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>). + +## + +​ + +Settings precedence + +Permission rules follow the same [settings precedence](</docs/en/settings#settings-precedence>) as all other Claude Code settings: + + 1. **Managed settings** : cannot be overridden by any other level, including command line arguments + 2. **Command line arguments** : temporary session overrides + 3. **Local project settings** (`.claude/settings.local.json`) + 4. **Shared project settings** (`.claude/settings.json`) + 5. **User settings** (`~/.claude/settings.json`) + +If a tool is denied at any level, no other level can allow it. For example, a managed settings deny cannot be overridden by `--allowedTools`, and `--disallowedTools` can add restrictions beyond what managed settings define. If a permission is allowed in user settings but denied in project settings, the project setting takes precedence and the permission is blocked. + +## + +​ + +Example configurations + +This [repository](<https://github.com/anthropics/claude-code/tree/main/examples/settings>) includes starter settings configurations for common deployment scenarios. Use these as starting points and adjust them to fit your needs. + +## + +​ + +See also + + * [Settings](</docs/en/settings>): complete configuration reference including the permission settings table + * [Sandboxing](</docs/en/sandboxing>): OS-level filesystem and network isolation for Bash commands + * [Authentication](</docs/en/authentication>): set up user access to Claude Code + * [Security](</docs/en/security>): security safeguards and best practices + * [Hooks](</docs/en/hooks-guide>): automate workflows and extend permission evaluation