Atlas
TechnicalFrom Atlas

Claude Code Permissions: Allow, Ask and Deny Rules

How Claude Code permission rules work: deny, ask and allow order, Bash wildcards, Read and Edit paths, and why a deny rule is not a security wall.

1Deny rulescheckedfirst2Ask rulescheckednext3Allowrulescheckedlast4Firstmatchdecides

The short version

  • Claude Code checks deny rules first, then ask, then allow, and the first match wins, so an allow rule can never carve an exception out of a deny rule.
  • In a Bash rule, the space before a trailing star matters: Bash(ls *) matches ls but not lsof, while Bash(ls*) matches both.
  • Deny rules match the command as Claude wrote it, so Bash(curl *) does not stop /usr/bin/curl or sh -c 'curl ...'; use the sandbox or a hook for a real boundary.
  • Read and Edit rules use gitignore-style paths: a single leading slash is relative to the settings source and a double slash is the filesystem root.
  • Commit deny and ask rules in .claude/settings.json and they apply at once; allow rules in a committed file wait until each teammate trusts the folder.
On this page
  1. The short version
  2. How do Claude Code permission rules work?
  3. How do Bash wildcards work?
  4. Is a deny rule a security boundary?
  5. How do Read and Edit path rules match?
  6. Can a rule match a tool's parameters?
  7. A starter settings file
  8. Where should rules live, and what do teammates get?
  9. A short checklist
  10. What Atlas does here
  11. Conclusion
  12. Questions people ask

Claude Code permission rules come in three kinds: allow, ask and deny. Deny is checked first, then ask, then allow, and the first match decides. Write the rules once in a committed settings file and every teammate gets the same guardrails. A few details catch people out, though: wildcards, wrapper commands and path anchors.

This guide covers the rule syntax, the matching traps, and a starter file you can adapt. It is based on Anthropic's permissions documentation and settings documentation. Check them against your installed version, because some behaviours are tied to specific releases.

How do Claude Code permission rules work?

Each rule is either Tool or Tool(specifier). A bare tool name such as Bash, WebFetch or Read matches every use of that tool. A specifier narrows it:

RuleEffect
Bash(npm run build)The exact command npm run build
Read(./.env)Reading .env in the current directory
WebFetch(domain:example.com)Fetch requests to example.com

The three lists do different jobs:

  • allow: use the tool without asking.
  • ask: always prompt.
  • deny: block the call.

Rules are evaluated deny, then ask, then allow, and the first match wins. A narrower rule does not beat a broader one in a stricter list. So Bash(aws *) in deny blocks aws s3 ls even if you also allow Bash(aws s3 ls). Likewise, a matching ask rule prompts even when a narrower allow rule matches.

How do Bash wildcards work?

A * in a Bash rule matches any text, including spaces. A rule with no * matches one exact command. The details that matter:

You writeMatchesDoes not match
Bash(npm run build)npm run buildnpm run build --watch
Bash(npm run *)npm run build, npm run test --watchnpm install
Bash(ls *)ls -la, lslsof
Bash(ls*)ls -la, lsof

The space before a trailing * is part of the rule. Bash(ls *) requires a space after ls, so lsof does not match, but the bare command ls still does. The older :* suffix is an equivalent way to write a trailing wildcard: Bash(ls:*) matches the same commands as Bash(ls *).

The same trap applies to short prefixes. Without the space, a rule like Bash(git diff*) would also match git diff-index. When you want a command and its arguments but not look-alike commands, keep the space.

Wrappers and special cases

Claude Code splits compound commands and strips a fixed set of wrappers before it matches Bash rules. The set is timeout, time, nice, nohup and stdbuf, plus the shell builtins command and builtin and zsh's noglob. So Bash(npm test *) also matches timeout 30 npm test.

Other wrappers are not stripped, and some commands never match a prefix allow rule. In Manual mode, exec wrappers such as watch, setsid, ionice and flock still prompt. So does find when it is used with -exec, -delete, -rm, -fprint or -files0-from. If you want to approve one specific invocation, write an exact rule with no star.

Wrappers also make broad rules broader than they look. A rule such as Bash(devbox run *) matches whatever comes after run, including devbox run rm -rf .. The docs recommend a specific rule that names both the runner and the inner command.

Is a deny rule a security boundary?

No, and the documentation says so. A Bash rule matches the command text Claude writes. It does not match the same program invoked another way:

RuleStopsDoes not stop
Bash(curl *)curl https://example.com/usr/bin/curl https://example.com, sh -c 'curl https://example.com'

Treat deny and ask rules as protection against the usual form of a command, not a wall around the program. An allow rule has a related side effect: if Bash(curl *) is allowed and the command matches, the rule also approves a retry outside the sandbox with no prompt.

For limits that do not depend on command text, use sandboxing or a PreToolUse hook that checks the command before it runs. The sandbox is an operating-system boundary around shell commands and the processes they start. It uses Seatbelt on macOS and bubblewrap on Linux and WSL2, and it is off by default. For files, writes are allowed only in the working directory, a per-user temp directory and any directories you add, while reads are allowed across most of the machine unless you restrict them. For the network, commands go through a proxy that checks each hostname against an allowed-domains list, which starts empty.

The sandbox covers shell commands only. Built-in file tools, WebFetch, MCP servers and hooks follow permission rules instead. That is why the two mechanisms are best used together.

How do Read and Edit path rules match?

Read and Edit rules use gitignore pattern syntax with four pattern types:

PatternMeaningExample
//pathAbsolute path from the filesystem rootRead(//Users/alice/secrets/**)
~/pathFrom your home directoryRead(~/Documents/*.pdf)
/pathRelative to the settings sourceEdit(/src/**/*.ts)
path or ./pathRelative to the current directoryRead(*.env)

The trap is the single slash. /Users/alice/file is not an absolute path; it anchors at the settings source. In project settings and project local settings that means the primary working directory. In user settings (~/.claude/settings.json) it means ~/.claude, so a deny rule Read(/secrets/**) there blocks ~/.claude/secrets/**, not a secrets folder in your project. A file passed with --settings anchors at that file's directory. Use //Users/alice/file for a true absolute path, or ~/ for something under your home directory.

Gitignore semantics apply to bare names. Read(.env) and Read(**/.env) are equivalent, because a bare filename matches at any depth. Deny and ask rules such as Read(secrets/**) also match nested copies, while an allow rule such as Edit(src/**) matches only the anchored location.

Some more points about which tools a rule covers:

  • Edit rules cover all built-in tools that write files, including Write and NotebookEdit. Use Edit(docs/**), not Write(docs/**).
  • A Read deny rule also blocks the Edit and Write tools on the same path, including creating a new file there, according to the tools reference.
  • Search tools follow Read rules on a best-effort basis. A Grep(docs/**) rule does not stop Grep from searching that folder; write Read(docs/**) instead.

Can a rule match a tool's parameters?

Deny and ask rules can match a tool's top-level input parameter with Tool(param:value). The example in the June 2026 release notes is Agent(model:opus), which matches subagent calls that request the Opus tier. Matching is exact unless you use * as a wildcard in the value, as in Agent(isolation:*).

A starter settings file

This .claude/settings.json is a sketch built from the rule shapes above. Adjust the commands to your stack:

json
{
  "permissions": {
    "allow": [
      "Bash(npm run *)",
      "Bash(git commit *)"
    ],
    "ask": [
      "Bash(git push *)",
      "Agent(model:opus)"
    ],
    "deny": [
      "Bash(rm *)",
      "Read(./.env)",
      "Read(./.env.*)",
      "Read(./secrets/**)",
      "Edit(/migrations/**)"
    ]
  }
}

Here /migrations/** in project settings resolves to the primary working directory, so edits to the migrations folder are blocked. Remember the limits: Bash(rm *) stops the usual form only, so /bin/rm or bash -c 'rm ...' can slip past it.

Settings files are strict JSON. A // comment or a trailing comma is a syntax error. After saving, run /status to confirm the file loaded and claude doctor to list entries Claude Code rejected. A malformed rule on its own is skipped as a warning and the rest of the file stays in effect. In a claude -p run there is no dialog; with the default text output format, stderr lists what did not load or was skipped.

Where should rules live, and what do teammates get?

Lists such as permissions.allow merge across settings files instead of overriding, so each file can add rules without removing another file's. The permission-specific points are:

  • Commit deny and ask rules. They apply as soon as someone clones the repository.
  • Committed allow rules wait for trust. permissions.allow and permissions.additionalDirectories in .claude/settings.json apply only after each teammate trusts the folder. Until then they still see prompts.
  • "Yes, and don't ask again" writes to .claude/settings.local.json. In the CLI that is the only file it writes. An allow rule there does not outrank an ask rule from a project or managed file.
  • Organizations can restrict allow rules. When allowManagedPermissionRulesOnly is set in managed settings, allow rules from other scopes no longer apply.
  • Some modes cannot come from a repository. permissions.defaultMode values auto and bypassPermissions do not take effect from project or local settings. Set them in user or managed settings, or pass --permission-mode for one session.

A short checklist

  1. Start from allow rules for the commands you run all day (tests, lint, build), with the star after the subcommand and the space before it.
  2. Put pushes, deploys and anything with side effects in ask.
  3. Put secrets and migrations in Read and Edit deny rules, with the right anchor (// for absolute).
  4. Do not rely on a deny rule for hard limits. Add the sandbox or a PreToolUse hook.
  5. Commit the file, run /status and claude doctor, and test a few commands, including odd forms like a full path or sh -c.

What Atlas does here

Atlas runs each engineer as its own Claude Code session on your Claude plan. Today it keeps five decisions with you: production go-lives, spending, deleting data, sending anything outside and dropping scope. An optional daily budget warns at 50% and 80% and pauses at 100%. Atlas does not yet let you write or audit Claude Code allow, ask and deny rules per project. That is coming to Atlas, built in, so it needs no setup on your side. Until then, commit a settings file like the one above in your project.

Conclusion

Permission rules are cheap to write and worth committing. Remember the order (deny, ask, allow), the space before the star, the single-slash anchor, and that a Bash deny rule covers the usual form of a command rather than every way of running the program. For real limits, add the sandbox or a hook.

Questions people ask

What order does Claude Code check allow, ask and deny rules?

It checks deny first, then ask, then allow, and the first match wins. A narrower allow rule cannot override a broader deny rule, so Bash(aws *) in deny blocks aws s3 ls even if that exact command is allowed.

Why does Bash(ls*) match lsof but Bash(ls *) does not?

The space before a trailing star is part of the rule. Bash(ls *) needs a space after ls (or the bare command), while Bash(ls*) has no space and so also matches lsof.

Does a deny rule like Bash(curl *) block all curl use?

No. It stops the usual form, but not /usr/bin/curl or sh -c 'curl ...'. For a real boundary use the sandbox or a PreToolUse hook.

Should I commit Claude Code permission rules to git?

Yes, in .claude/settings.json. Deny and ask rules apply immediately for teammates; allow rules apply only after each teammate trusts the folder. Personal approvals go to .claude/settings.local.json.

How do I write an absolute path in a Read or Edit rule?

Start it with a double slash, as in Read(//Users/alice/secrets/**). A single leading slash is relative to the settings source, not the filesystem root.

Sources

  1. Configure permissions - Claude Code Docs
  2. Settings files and precedence - Claude Code Docs
  3. Claude Code sandboxing

Researched and drafted with Claude, then checked against the sources above. Atlas is an independent product, not affiliated with Anthropic or OpenAI. Claude and Claude Code are trademarks of Anthropic; Codex is a product of OpenAI.