Omniscio

OmniscioGuidesClaude Code permission rules

Claude Code permission rules: copy-paste examples

Most permission problems are not a missing feature. They are one rule written in a shape that matches nothing, in a file that loses to another one.

This page opens with one small block you can paste, then explains the format and the rules of the road. The ten pages under it are complete blocks for the needs people ask about most: npm and tests, read-only exploration, secrets, git without push, MCP tools, web fetches, protected files, docker, the cloud CLIs, and subagents.

Checked against Anthropic’s Claude Code permission documentation. By the Omniscio team. Updated .

The smallest useful block

Three lists, one rule each. Save it as .claude/settings.json in a project, or as ~/.claude/settings.json for every project on the machine.

{
  "permissions": {
    "allow": ["Bash(npm run *)"],
    "ask": ["Bash(git push *)"],
    "deny": ["Read(.env)"]
  }
}

That block runs npm scripts without a prompt, asks before a push, and refuses reads of .env. Each of the ten pages under this one is a fuller version of the same idea, with what every rule matches and the mistake that breaks it.

The rule, in one line

Every permission rule has the same shape: a tool name, and optionally a specifier in parentheses.

RuleWhat it matches
BashEvery Bash command. Bash(*) means the same thing
Bash(npm run build)Exactly that command, and nothing after it
Bash(npm run *)npm run build, npm run test --watch, and bare npm run
Read(./.env)Reading that file; the same rule also blocks writing it through the file tools
WebFetch(domain:example.com)Fetches from that host
mcp__github__get_*The get_ tools of the github MCP server
Agent(Explore)The Explore subagent

The specifier is the part people get wrong, because each tool reads its own specifier differently. Bash rules match the command text. Read and Edit rules match paths with gitignore syntax. WebFetch takes a domain: prefix. MCP rules match tool names. The pages below spell out the wildcards and limits for each case.

The tool name is its canonical name, not the label in the transcript. A rule written for a label such as Stop Task matches nothing; the canonical name is TaskStop. Anthropic’s tools reference lists the canonical names.

Deny, then ask, then allow

Rules are evaluated in one fixed order: deny, then ask, then allow. The first match decides, and specificity does not reorder them. A broad deny such as Bash(aws *) blocks a call that also matches the narrower allow Bash(aws s3 ls). The same holds between ask and allow: an ask rule prompts even when a more specific allow rule also matches.

An allow rule can never carve an exception out of a deny rule. If a tool is denied at any level, no other level can allow it — a project allow does not beat a user deny, because both deny lists are consulted first.

How a deny is written changes what happens to the tool:

  • A bare tool name, such as "deny": ["Bash"], removes the tool from Claude’s context entirely. Claude never sees it, and cannot try.
  • A scoped rule, such as Bash(rm *), leaves the tool available and blocks the calls that match when Claude attempts them.

Ask rules are for the middle case: an action you want to see before it runs, rather than forbid. Anthropic’s own team example uses an ask rule for git push, and a deny rule for reads of .env.

What a wildcard matches

A * stands in for any text, including spaces. A rule with no * matches one exact command.

You writeMatchesDoes not match
Bash(npm run build)npm run buildnpm run build --watch
Bash(npm run *)npm run build, npm run test --watch, npm runnpm install
Bash(git log * main)git log --oneline main, git log -5 maingit log main, git push origin main
Bash(ls *)ls -la, lslsof
Bash(ls*)ls -la, lsofAnything that does not start with ls; the missing space is why it catches lsof too

Three habits follow from that table:

  • Put the * after the subcommand. In git log --oneline main, git is the program and log is the subcommand. Claude Code matches everything before the first * as written, so Bash(git log *) allows only git log, and Bash(git *) allows every git command. An allow rule with a wildcard before the subcommand, such as Bash(git * main), earns a startup warning.
  • A space before a trailing * is part of the rule. Bash(ls *) requires the space, so lsof does not match; Bash(ls*) matches it too. A trailing * with a space before it also matches the bare command, but only when it is the rule’s only wildcard: Bash(ls *) matches ls, while Bash(* --help *) does not match npm --help.
  • :* is the other spelling of a trailing wildcard. Bash(ls:*) matches what Bash(ls *) matches. It is only recognized at the end: in Bash(git:* push) the colon is a literal character.

Two more limits matter before you trust a rule:

  • A Bash rule does not match the same program invoked another way. Bash(curl *) stops curl https://example.com, not /usr/bin/curl https://example.com or sh -c 'curl https://example.com'. In the same way Bash(rm *) does not stop /bin/rm, and Bash(git push *) does not stop git -C . push. Anthropic says plainly that these rules cover the invocation Claude usually produces and are not a security boundary around the program.
  • A compound command runs without a prompt only when every subcommand is allowed. Bash(safe-cmd *) does not approve safe-cmd && other-cmd. Anthropic recognizes &&, ||, ;, |, |&, & and newlines as separators.

Claude Code also strips a fixed set of wrappers before matching, so Bash(npm test *) matches timeout 30 npm test. The stripped wrappers are timeout, time, nice, nohup, stdbuf, the shell builtins command and builtin, and zsh’s noglob. Environment runners such as npx, docker exec and devbox run are not on the list, so a rule like Bash(npx *) approves whatever package name comes after it. Name the package: Bash(npx vitest *).

Where the block goes, and what wins

ScopeFileWho it reaches
User~/.claude/settings.jsonYou, in every project on this machine
Shared project.claude/settings.jsonEveryone in the folder; commit it so teammates get it
Project local.claude/settings.local.jsonYou, in this one project. Claude Code keeps it out of git when it creates the file
Managedmanaged-settings.json and other managed sourcesEveryone your organization deploys it to

Three rules about precedence decide most surprises:

  • Lists merge; they do not override. When two files both set permissions.allow, Claude Code combines them. You cannot remove a teammate’s allow rule by writing a shorter list in your own file; you add to it.
  • Deny beats allow across every scope. If user settings allow something and project settings deny it, the deny wins. Swap the two files and the deny still wins.
  • Managed settings sit on top. Nothing in your own files or in --settings overrides a managed permission rule.

One trust step is easy to miss: allow rules and additionalDirectories in a project’s .claude/settings.json take effect only after you accept the workspace trust dialog for that folder. Deny and ask rules are not affected, because they only restrict. A claude -p or SDK session never shows the dialog, so a project’s allow rules do not apply there unless the folder was trusted before.

Path rules have their own anchor. A pattern starting with one slash, such as Edit(/src/**), is relative to the settings source that defines it — not to the filesystem root. In user settings, /path resolves under ~/.claude; in a file passed with --settings, it resolves beside that file. Use // for an absolute path and ~/ for one from your home directory.

Where a single developer’s files live, and how a managed file fits above them, are covered in the settings.json locations guide and the managed settings guide.

Confirm it took effect

Run /permissions. The dialog lists all permission rules and the settings.json file each rule comes from, which is the one place that tells you both what loaded and where it was written. You can open it while Claude is working; a rule you add or remove applies from Claude’s next tool call in the same turn.

Then cause the action and watch what happens. An allow rule means no prompt, apart from the calls an allow rule never pre-approves, such as writes to protected paths and reads from network paths. An ask rule means a prompt even in a mode that would otherwise approve the action. A deny rule means a refusal.

/status answers a different question. Its Setting sources line lists the settings files Claude Code loaded for the session, but not which file supplied which key. When a rule is dropped rather than applied, claude doctor lists the entries it rejected, and an interactive session can show the same thing as a Settings Warning at startup.

For one session only, the command line can carry the same rules: --allowedTools adds allow rules, and --disallowedTools adds deny rules. A deny rule from any settings file still blocks a tool the flag names as allowed.

The ten blocks

Each page is a complete settings.json block, what every rule matches and does not match, where the file goes, how to confirm it loaded, and the mistake that usually breaks it. If you only want fewer prompts, start with the npm block.

If nobody is at the terminal to answer a prompt at all, a setting refuses the call instead of waiting; the deny instead of prompting guide covers it.

The five mistakes that make a rule misfire

  1. A wildcard in allow before the subcommand. Bash(git * main) approves every git subcommand that ends in main, including git push origin main. Claude Code warns about it at startup.
  2. A missing space before the trailing wildcard. Bash(ls*) also matches lsof, and Bash(npm run*) is a different rule from Bash(npm run *).
  3. A path rule in the wrong list. Write(path), Glob(path) and Grep(path) rules are accepted but match nothing. Write Edit(path) or Read(path) instead, or the bare tool name to match every use.
  4. A user-settings path anchored where you did not expect. Read(/secrets/**) in ~/.claude/settings.json blocks ~/.claude/secrets/**, not your project’s secrets folder. Use // or ~/ for a rule that should follow you into every project.
  5. Expecting a deny to be a wall. Bash(git push *) does not stop git -C . push, and a Read deny does not stop grep -r that names no file. For enforcement that does not depend on the command text, Anthropic points to sandboxing or a PreToolUse hook.

Build the block instead of typing it

If you would rather pick rules than spell them, the Claude Code permissions builder takes a tool, a specifier and a list, warns about the shapes above, and gives you a block to copy. It is the same syntax this page describes, assembled in the browser.

The permission modes — what each one asks by default — are a separate subject, covered on the permission modes page. Rules and modes stack: a rule decides individual tool calls, and the mode decides what is asked when no rule matches.

Where these answers come from

Common questions

Do allow rules in settings.json merge or replace each other?

They merge. When the same list key appears in more than one settings file, Claude Code combines the lists, so each file can add entries without removing another file’s.

Can an allow rule override a deny rule?

No. Deny rules are evaluated first, the first match decides, and specificity does not change the order. An allow rule cannot carve an exception out of a deny rule.

What is the difference between deny and ask?

An ask rule makes Claude Code prompt before the call, even in a mode that would otherwise approve it. A deny rule blocks the call. A bare tool name in deny also removes the tool from Claude’s context entirely.

Is --allowedTools the same as permissions.allow?

For one session, yes: --allowedTools adds allow rules from the command line and writes nothing. permissions.allow in a settings file applies wherever that file is read, and lists merge across files rather than replacing one another.

Where do I see which rule did what?

/permissions lists every permission rule and the settings file each one came from. /status lists the settings files that loaded, and claude doctor lists entries Claude Code rejected.