Skip to content
,

Claude Code Permissions: Allow, Deny and Ask Rules Explained (2026)

7–11 minutes
Woman on a rooftop terrace holding a tablet with a PERMISSION RULES card, hook stop the endless prompts

Claude Code asks before it runs shell commands, edits files or fetches web pages. That is safe, but answering the same prompt for npm test fifty times a day gets old fast.

Permission rules fix that: you decide once which commands run freely, which always ask, and which are never allowed, such as reading your .env file or running git push.

This guide explains how the permission system works, the /permissions dialog, allow, ask and deny rules, the exact rule syntax with wildcards, rules for Bash, files, web fetch, MCP and subagents, permission modes, working directories, and ready-to-paste example configs. It follows Anthropic’s official Claude Code documentation as of December 2026.

The key rule to remember: deny beats ask, and ask beats allow, no matter how specific the allow rule is.

TL;DR

  • Manage: run /permissions to see every rule and which settings file it comes from.
  • Order: deny, then ask, then allow. A deny can never be overridden by an allow.
  • Syntax: Tool or Tool(specifier), for example Bash(npm run *), Read(./.env), WebFetch(domain:github.com).
  • Put * after the subcommand: Bash(git log *), not Bash(git *).
  • Modes: press Shift+Tab to cycle; or start with claude --permission-mode plan.
  • Secrets: add Read(./.env) and Read(./secrets/**) to deny.

How Claude Code Permissions Work

In the default Manual mode, Claude Code uses a tiered system:

Tool type Asks first? “Yes, and don’t ask again” lasts
Read-only (file reads, Grep) No, inside your working directories Not needed
Bash commands Yes, except a built-in set of read-only commands Permanently, per repository and command
File edits and writes Yes Until the session ends
WebFetch Yes, except some preapproved documentation domains Permanently, per repository and domain
WebSearch Yes Permanently, per repository

When you choose “Yes, and don’t ask again”, Claude Code saves a rule to .claude/settings.local.json at the repository root. On most prompts you can also press Tab on Yes or No to attach a comment, which Claude reads as context or as the reason for a denial.

Permission rules are enforced by Claude Code, not by the model. Writing “never touch .env” in CLAUDE.md shapes what Claude tries, but only a rule actually blocks it. Our “don’t ask again” secrets leak report shows why broad approvals deserve care.

Manage Rules With /permissions

Run /permissions in a session. The dialog lists every rule and the settings.json file it comes from, and you can add or remove rules even while Claude is working.

  • Allow rules let Claude use the tool without asking.
  • Ask rules always prompt.
  • Deny rules block the tool.

Rules are evaluated deny, then ask, then allow, and the first match wins. A broad deny like Bash(aws *) blocks aws s3 ls even if you also allow Bash(aws s3 ls). A deny that names a whole tool, such as Bash, removes the tool from Claude’s context entirely.

You can also edit rules directly in a settings file under permissions. Our Claude Code settings guide explains which file to use.

Permission Rule Syntax

Every rule is Tool or Tool(specifier).

Rule Matches
Bash or Bash(*) Every Bash command
Bash(npm run build) Exactly npm run build
Read(./.env) Reading .env in the current directory
WebFetch(domain:example.com) Fetches to example.com
mcp__github__* Every tool from the github MCP server
Agent(Explore) The Explore subagent

Deny and ask rules can also match a top-level input parameter with Tool(param:value), such as Agent(model:opus) or Bash(run_in_background:true). They cannot match a tool’s main field, so Bash(command:rm *) is ignored. Deny and ask rules also accept tool-name globs, so "deny": ["mcp__*"] blocks every MCP tool.

Bash Rules and Wildcards

A * in a Bash rule matches any text, including spaces. Write the command you want and replace the parts that vary with *.

Rule Matches Does not match
Bash(npm run *) npm run build, npm run test --watch, npm run npm install
Bash(git log *) git log, git log --oneline git push
Bash(git * main) git merge main, git push origin main git log
Bash(ls *) ls, ls -la lsof
Bash(ls*) ls -la, lsof
  • Put the * after the subcommand. Bash(git *) allows every git command, including git push and git -c tricks.
  • The space matters. Bash(ls *) needs a space after ls; Bash(ls*) also matches lsof.
  • Bash(ls:*) is an older equivalent of Bash(ls *), recognised only at the end.

Compound commands are split

Claude Code understands &&, ||, ;, |, & and newlines. Bash(safe-cmd *) does not approve safe-cmd && other-cmd: every part must be allowed. Deny and ask rules apply if any part matches, even inside subshells or loops.

Approving a compound command with “don’t ask again” saves a separate rule per part.

Read-only commands run freely

A built-in set of read-only commands, such as ls, cat and git status, runs without a prompt in every mode. Some still prompt in edge cases, such as an unquoted glob on find or sed, or a command too complex to parse.

Read and Edit Rules for Files

File rules use gitignore-style patterns with four anchors:

Pattern Meaning Example
//path Absolute path from filesystem root Read(//Users/alice/secrets/**)
~/path From your home folder Read(~/Documents/*.pdf)
/path Relative to the settings source (project root for project settings) Edit(/src/**/*.ts)
path or ./path Relative to the current directory Read(*.env)

Watch out: /Users/alice/file is not absolute. A single slash anchors at the settings source; use // for real absolute paths.

  • A Read deny rule also blocks Edit and Write on the same path, and Claude tries to apply it to Grep, Glob, @file mentions and pasted image paths.
  • .claudeignore files have no effect. Move their entries into Read deny rules.
  • Deny rules cover built-in tools and Bash commands Claude Code can analyse, like cat and sed. A Python script that opens files itself can still read them. For an OS-level guarantee, use the Claude Code sandbox.

WebFetch, MCP and Subagent Rules

WebFetch

  • WebFetch(domain:example.com) matches only example.com. Add WebFetch(domain:*.example.com) for subdomains.
  • A bare WebFetch allow lets Claude fetch anything without prompting. A bare WebFetch deny removes the tool.
  • WebFetch(domain:*) also changes which hosts sandboxed commands can reach, unlike the bare form.

MCP tools

mcp__puppeteer__* matches every tool of the puppeteer server, and mcp__puppeteer__puppeteer_navigate matches one tool. For a server from a plugin, use the plugin-scoped name, such as mcp__plugin_my-plugin_database-tools__*. See our Claude Code MCP setup guide.

Subagents

Deny Agent(Explore) or Agent(my-custom-agent) to stop Claude starting that subagent. More in our subagents guide.

Permission Modes

Modes change how much Claude Code asks. Press Shift+Tab in the CLI to cycle, use the mode selector in VS Code or Desktop, start with --permission-mode, or set defaultMode in settings.

Mode Behavior Good for
default (Manual) Prompts before most edits, commands and network requests Sensitive or unfamiliar code
acceptEdits Auto-accepts file edits and common filesystem commands in your working directories Iterating on code you are watching
plan Reads and explores, no source edits until you approve a plan Planning first; see our plan mode guide
auto A background classifier reviews actions instead of you Hands-off work; see our auto mode guide
dontAsk Auto-denies anything that would prompt CI with an exact allowlist
bypassPermissions Skips prompts, including writes to .git and .claude Only inside a container or VM

A CI example from the docs:

claude -p "run the test suite" --permission-mode dontAsk --allowedTools "Bash(npm test)" "Read"

To stop anyone using bypass or auto mode, set permissions.disableBypassPermissionsMode or permissions.disableAutoMode to "disable". More on scripted runs in our claude -p headless guide.

Working Directories

Claude can read files in the folder you started it from. To add more:

  • At startup: claude --add-dir ../shared-lib
  • During a session: /add-dir ../shared-lib
  • Permanently: additionalDirectories in settings

To make file tools refuse anything outside the working directories in every mode, set permissions.blockReadsOutsideWorkingDirectories and permissions.blockWritesOutsideWorkingDirectories to true.

Example Configurations

Everyday JavaScript project

{
  "permissions": {
    "allow": [
      "Bash(npm run *)",
      "Bash(npm test *)",
      "Bash(git commit *)",
      "Bash(git diff *)",
      "WebFetch(domain:developer.mozilla.org)"
    ],
    "ask": [
      "Bash(git push *)",
      "Bash(npm publish *)"
    ],
    "deny": [
      "Read(./.env)",
      "Read(./.env.*)",
      "Read(./secrets/**)",
      "Bash(curl *)"
    ]
  }
}

Locked-down review session

{
  "permissions": {
    "defaultMode": "plan",
    "deny": ["WebFetch", "mcp__*", "Bash(rm *)"]
  }
}

Python project

{
  "permissions": {
    "allow": ["Bash(pytest *)", "Bash(uv run *)", "Bash(ruff check *)"],
    "deny": ["Read(./.env)", "Edit(/migrations/**)"]
  }
}

Remember: a deny on Bash(git push *) does not catch a push written as git -C . push. For strict control, combine rules with the sandbox or a hook; see our Claude Code hooks guide.

Settings Precedence and Workspace Trust

  • Rules from every settings level and command-line flags are combined, not replaced.
  • A deny at any level wins. A user-level deny blocks a project-level allow, and a managed deny cannot be overridden by --allowedTools.
  • Managed settings from your organization override user and project settings, and allowManagedPermissionRulesOnly can make them the only source of rules.
  • Allow rules and extra directories in a project’s .claude/settings.json only apply after you accept the workspace trust dialog for that folder, so a cloned repo cannot pre-approve commands on its own.

Troubleshooting

My allow rule still prompts

An ask or deny rule also matches, the command is compound and another part is not allowed, or the * is in the wrong place. Check /permissions for the source of each rule.

Startup warns a rule “matches no tool”

There is a typo in the tool name, or you used the display label instead of the canonical name. Tool names are case-sensitive.

My absolute path rule does nothing

Use // for absolute paths. A single / anchors at the settings source.

Project allow rules are ignored

You have not accepted workspace trust for that folder, or you are in claude -p where the trust dialog does not appear.

Claude still read a denied file via a script

Deny rules cover built-in tools and analysable commands only. Enable the sandbox for OS-level limits.

MCP allow rule with parentheses is skipped

Write MCP allow rules without a specifier, and use --disallowedTools for parameter-level MCP denies.

FAQ

Where are Claude Code permissions stored?

In the permissions block of your settings files: ~/.claude/settings.json, .claude/settings.json and .claude/settings.local.json. “Don’t ask again” saves to the local file.

How do I stop Claude Code asking for permission?

Add allow rules for safe commands, use acceptEdits or auto mode, or reserve bypassPermissions for containers.

What does –dangerously-skip-permissions do?

It starts in bypassPermissions mode and skips prompts. The docs recommend it only inside a container, VM or sandbox runtime.

How do I block Claude from reading .env files?

Add Read(./.env) and Read(./.env.*) to permissions.deny.

Can an allow rule override a deny rule?

No. Deny is checked first and always wins.

How do I reset saved approvals?

Remove the rules in /permissions or delete them from .claude/settings.local.json.

Sources

Free weekly email

Get new AI guides every week

One short weekly email with our newest local AI, ComfyUI and AI tool guides. No spam, no pop-ups, just the good stuff.

Free. Unsubscribe anytime in one click. We only use your email to send this newsletter. See our privacy policy.

Woman on a rooftop terrace holding a tablet with a PERMISSION RULES card, hook stop the endless prompts