Claude Code

Claude Code permissions: allow, ask and deny rules, rule syntax and allowed tools

How do Claude Code permissions work, and how do I allow or block specific tools?

Claude Code checks every tool call against permission rules in your settings files. Rules go in permissions.allow, permissions.ask and permissions.deny, use the format Tool or Tool(specifier), and are evaluated deny first, then ask, then allow. Use /permissions to see every rule and the file it comes from, or pass --allowedTools and --disallowedTools for one session.

Allow, ask and deny

  • Allow rules let Claude Code use the matching tool without asking you.
  • Ask rules prompt for confirmation every time the matching tool is used.
  • Deny rules block the matching tool.
  • Order is deny, then ask, then allow. The first match wins and specificity does not change the order, so a broad deny like Bash(aws *) beats a narrower allow like Bash(aws s3 ls).
  • A deny rule with a bare tool name, such as Bash, removes the tool from Claude's context. A scoped deny such as Bash(rm *) keeps the tool and blocks only matching calls.

Rules are enforced by Claude Code, not by the model. Instructions in CLAUDE.md shape what Claude tries to do but do not change what it is allowed to do.

Rule syntax by tool

  • Whole tool: Bash, Read or WebFetch with no parentheses. Bash(*) is the same as Bash.
  • Bash: Bash(npm run build) matches that exact command. Bash(npm run *) matches every npm script. Put the * after the subcommand: Bash(git log *) allows only git log, while Bash(git *) allows every git command.
  • Bash(ls *) needs a space after ls, so it does not match lsof. Bash(ls:*) is an equivalent way to write the trailing wildcard.
  • Read and Edit use gitignore patterns. Read(./.env) blocks the .env file in the current directory, Read(./secrets/**) blocks a folder. Use Edit rules, not Write rules, for paths no tool may change.
  • Paths: //path is absolute from the filesystem root, ~/path is from your home folder, /path is relative to the settings file's project, and path or ./path is relative to the current directory.
  • WebFetch: WebFetch(domain:example.com) matches example.com only. Add WebFetch(domain:*.example.com) for subdomains.
  • MCP: mcp__github matches every tool from the github server, mcp__github__get_* matches its get_ tools, and mcp__github__create_issue matches one tool.
  • Subagents: Agent(Explore) or Agent(my-custom-agent). Put one in deny to stop Claude from using that subagent.

Example settings

.claude/settings.json

{
  "permissions": {
    "allow": [
      "Bash(npm run *)",
      "Bash(git commit *)",
      "WebFetch(domain:docs.example.com)",
      "mcp__github__get_*"
    ],
    "ask": ["Bash(git push *)"],
    "deny": [
      "Read(./.env)",
      "Read(./secrets/**)",
      "Bash(rm *)"
    ]
  }
}

Allow rules and additionalDirectories in a project's .claude/settings.json only take effect after you accept the workspace trust dialog for that folder. Deny and ask rules apply right away.

Allowed tools on the command line

  • --allowedTools (or --allowed-tools): tools that run without prompting, using the same rule syntax.
  • --disallowedTools (or --disallowed-tools): deny rules for this session. "mcp__*" removes every MCP tool.
  • --tools: limits which built-in tools exist at all, for example "Bash,Edit,Read".
  • --add-dir: adds working directories Claude can read and edit. Save them in permissions.additionalDirectories to keep them.

Terminal

claude -p "summarize recent changes" \
  --allowedTools "Bash(git log *)" "Bash(git diff *)" "Read" \
  --disallowedTools "Edit"

Which settings win

  • A deny at any level cannot be allowed by another level. If user settings allow something and project settings deny it, it is denied, and the reverse is also true.
  • Managed settings are highest. Even --allowedTools cannot override a managed deny, while --disallowedTools can add more restrictions.
  • allowManagedPermissionRulesOnly makes managed settings the only source of permission rules.
  • Set permissions.disableBypassPermissionsMode or permissions.disableAutoMode to "disable" to block those modes. They are most useful in managed settings.

Permission modes

Rules sit on top of the session's permission mode: default (Manual), acceptEdits, plan, auto, dontAsk or bypassPermissions. Set one with claude --permission-mode <mode> or permissions.defaultMode in settings. dontAsk denies anything that would prompt except tools your allow rules already approve. To run with no prompts at all, see the guide on allowing all commands in Claude Code.

Get Claude Code settings changes by email

When a setting, flag or permission rule in this guide changes, it goes in the weekly AgentAtlas update, checked against the vendor docs. One email a week.

Sources

More on Claude Code

More Claude Code guides

Other guides

Cursor: allow all terminal commandsCodex CLI: approval and sandbox modesGemini CLI: YOLO mode, auto_edit and allowing specific shell commandsCursor Privacy Mode: telemetry, training and data retentionGemini CLI: turn off usage statistics and telemetryAdd MCP servers to Cursor with mcp.json: Keep files out of Cursor with .cursorignore: Configure Codex with config.toml: Configure Gemini CLI with settings.json: GitHub Copilot custom instructions: Adding MCP servers to GitHub Copilot: Gemini CLI extensions and custom commands: Configuring OpenCode with opencode.json: Cline Rules: workspace, global, and conditional rulesKiro steering files: .kiro/steering, inclusion modes, and AGENTS.mdZed agent: instruction files, MCP servers, tool permissions, and ACP agentsCursor CLI: install, headless mode, permissions and CIAider: CONVENTIONS.md, .aider.conf.yml and API keysJunie guidelines, MCP and the Action Allowlist: Amp AGENTS.md, settings.json and MCP: Configure Goose extensions, hints, recipes and permissions: Customize OpenHands with skills, AGENTS.md, setup.sh and MCP: Configure Factory Droid CLI: AGENTS.md, settings.json, autonomy, custom droids and MCPConfigure Qwen Code: settings.json, providers, QWEN.md, MCP and approval modesCursor hooks: hooks.json, beforeShellExecution, afterFileEdit and exit codesCursor sandbox: sandbox.json, network allowlist and run modesCursor settings: settings.json, Cursor Settings and the ~/.cursor config filesCursor browser agent: @browser, browser automation and approval modesCursor subagents: .cursor/agents, frontmatter, built-in Explore, Bash and BrowserCursor telemetry and OpenTelemetry export (Privacy Mode, OTLP, Analytics API): Cursor rules setup: project, user and Team Rules, .mdc frontmatter, globs and AGENTS.mdCodex AGENTS.md: global, project and override instruction files explainedCodex MCP servers: codex mcp add and [mcp_servers] in config.tomlCodex sandbox modes: read-only, workspace-write, danger-full-access and network accesscodex exec: run Codex non-interactively in scripts and CI with JSON outputCodex skills: create SKILL.md, skill folder locations and $skill invocationGEMINI.md in Gemini CLI: context file locations, imports and /memoryGemini CLI MCP servers: gemini mcp add and mcpServers in settings.jsonGemini CLI custom slash commands: TOML files, {{args}}, !{shell} and @{file}Gemini CLI headless mode: gemini -p, JSON output and exit codes for scripts and CIGemini CLI sandbox: enable Docker, Podman, macOS Seatbelt or gVisorcopilot-setup-steps.yml: set up the GitHub Copilot cloudGitHub Copilot CLI permissions: --allow-tool, --deny-tool, --allow-all-tools and trusted directoriesGitHub Copilot custom agents: .github/agents/*.agent.md profiles, tools and frontmatterGitHub Copilot code review settings: automatic PR reviews, rulesets, effort level and approvalsOpenCode MCP Server Setup: Local and Remote Servers in opencode.jsonOpenCode Permissions: Allow, Ask or Deny Bash, Edit and WebfetchOpenCode Custom Agents and Subagents: Markdown Files, Modes and @ MentionsCline MCP Setup: cline_mcp_settings.json for Local and Remote ServersCline Auto Approve and YOLO Mode: Run Commands and Edits Without PromptsCline Skills: SKILL.md Location, Format and Slash Command UseAmp MCP Setup: amp mcp add, amp.mcpServers and Workspace ApprovalAmp AGENTS.md: File Locations, @ Mentions and Glob-Scoped GuidanceAmp Skills: SKILL.md Folders, amp skill add and Search OrderKiro MCP Setup: .kiro/settings/mcp.json, autoApprove and OAuthKiro Hooks: .kiro/hooks JSON, PreToolUse, PostFileSave and StopKiro Permissions: permissions.yaml Allow, Ask and Deny RulesFactory Droid MCP Setup: droid mcp add, mcp.json Locations and /mcpFactory Droid Hooks: hooks.json, PreToolUse Matchers and Exit CodesFactory Droid Custom Droids (Subagents): .factory/droids Markdown FilesJunie MCP Setup: .junie/mcp/mcp.json for CLI and /mcp CommandJunie Brave Mode and Action Allowlist: Auto-Approve Commands in Junie CLIJunie Custom Slash Commands: .junie/commands Markdown Files and Argumentsgoose .goosehints and AGENTS.md: Global and Project Instructionsgoose Permission Modes: GOOSE_MODE auto, approve, smart_approve and chatgoose Recipes: recipe.yaml Format, Parameters and goose run --recipeZed Agent Tool Permissions: Auto-Approve Terminal Commands with tool_permissionsUse Claude, Codex and Gemini CLI in Zed: External Agents and agent_serversZed with Ollama, LM Studio and llama.cpp: Local Model Setup and Context Length

Reviewed Oct 13, 2026. Settings change often; the linked vendor docs are the source of truth.