[proxy] code.claude.com← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light

Configure permissions - Claude Code Docs

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 typeExampleApproval required”Yes, don’t ask again” behavior
Read-onlyFile reads, GrepNoN/A
Bash commandsShell executionYesPermanently per project directory and command
File modificationEdit/write filesYesUntil 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.

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:

ModeDescription
defaultStandard behavior: prompts for permission on first use of each tool
acceptEditsAutomatically accepts file edit permissions for the session
planPlan Mode: Claude can analyze but not modify files or execute commands
dontAskAuto-denies tools unless pre-approved via /permissions or permissions.allow rules
bypassPermissionsSkips all permission prompts (requires safe environment, see warning below)

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:

RuleEffect
BashMatches all Bash commands
WebFetchMatches all web fetch requests
ReadMatches 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:

RuleEffect
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:

{
  "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:

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.

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 rules both follow the gitignore specification with four distinct pattern types:

PatternMeaningExampleMatches
//pathAbsolute path from filesystem rootRead(//Users/alice/secrets/**)/Users/alice/secrets/**
~/pathPath from home directoryRead(~/Documents/*.pdf)/Users/alice/Documents/*.pdf
/pathPath relative to project rootEdit(/src/**/*.ts)<project root>/src/**/*.ts
path or ./pathPath relative to current directoryRead(*.env)<cwd>/*.env

Examples:

WebFetch

MCP

Agent (subagents)

Use Agent(AgentName) rules to control which subagents Claude can use:

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)"]
  }
}

Extend permissions with hooks

Claude Code hooks 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 system, and the hook output can determine whether to approve or deny the tool call in place of the permission system.

Working directories

By default, Claude has access to files in the directory where it was launched. You can extend this access:

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 are complementary security layers:

Use both for defense-in-depth:

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. See settings files for delivery mechanisms and file locations.

Managed-only settings

Some settings are only effective in managed settings:

SettingDescription
disableBypassPermissionsModeSet to "disable" to prevent bypassPermissions mode and the --dangerously-skip-permissions flag
allowManagedPermissionRulesOnlyWhen true, prevents user and project settings from defining allow, ask, or deny permission rules. Only rules in managed settings apply
allowManagedHooksOnlyWhen true, prevents loading of user, project, and plugin hooks. Only managed hooks and SDK hooks are allowed
allowManagedMcpServersOnlyWhen true, only allowedMcpServers from managed settings are respected. deniedMcpServers still merges from all sources. See Managed MCP configuration
blockedMarketplacesBlocklist of marketplace sources. Blocked sources are checked before downloading, so they never touch the filesystem. See managed marketplace restrictions
sandbox.network.allowManagedDomainsOnlyWhen true, only allowedDomains and WebFetch(domain:...) allow rules from managed settings are respected. Denied domains still merge from all sources
strictKnownMarketplacesControls which plugin marketplaces users can add. See managed marketplace restrictions
allow_remote_sessionsWhen true, allows users to start Remote Control and web sessions. Defaults to true. Set to false to prevent remote session access

Settings precedence

Permission rules follow the same settings precedence as all other Claude Code settings: managed settings have the highest precedence, followed by command line arguments, local project, shared project, and user settings. 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 includes starter settings configurations for common deployment scenarios. Use these as starting points and adjust them to fit your needs.

See also