# Claude Code Permission Rules: Allow, Ask and Deny Patterns

> How Claude Code permission rules work: deny, ask and allow order, Bash wildcards, Read and Edit paths, and what a rule will not stop. Includes a starter config.

Canonical: https://bridge-terminal.com/atlas/blog/claude-code-permission-rules-allow-ask-deny/
Last updated: 2026-12-06

Published 6 December 2026 · Technical · How-to · 7 min read

## 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, a space before the trailing star matters: Bash(ls *) matches ls but not lsof, while Bash(ls*) matches both.
- A Bash deny rule stops the usual form of a command only; /usr/bin/curl or sh -c 'curl ...' can slip past it, so treat rules as guardrails, not a security boundary.
- Read and Edit rules use gitignore-style paths, and a single leading slash anchors at the settings source, not the filesystem root; use // for absolute paths.
- For hard limits, pair permission rules with the sandbox, which restricts what a running command can reach, or with a PreToolUse hook that inspects the full command.

How do Claude Code permission rules work? You write `allow`, `ask` and `deny` lists in a settings file, each entry shaped like `Tool` or `Tool(specifier)`. Claude Code checks deny first, then ask, then allow, and the first match decides. That order, plus a few matching quirks, is what most "why did it prompt?" and "why did it run that?" questions come down to.

This guide covers the rule syntax from the [official permissions documentation](https://code.claude.com/docs/en/permissions), a starter config you can paste, and the cases where a rule does not stop what you expected.

## How does Claude Code decide: deny, ask or allow?

There are three kinds of rule:

- **Allow** rules let Claude Code use the tool without manual approval.
- **Ask** rules prompt for confirmation.
- **Deny** rules prevent the use.

Rules are evaluated in the order deny, then ask, then allow. The first match in that order determines the outcome, and specificity does not change the order. The docs give the consequence directly: a broad deny such as `Bash(aws *)` blocks every matching call, including ones that also match a narrower allow like `Bash(aws s3 ls)`. An allow rule cannot carve an exception out of a deny rule. The same holds between ask and allow: a matching ask rule prompts even when a more specific allow also matches.

So design your lists from the top down. Put hard stops in `deny`, "check with me" actions in `ask`, and routine safe commands in `allow`. Do not expect a narrow allow to rescue a command that a broad deny already catches.

One more distinction: a bare tool name in `deny` (for example `Bash`) removes the tool from Claude's context entirely. A scoped rule like `Bash(rm *)` leaves the tool available and blocks matching calls when Claude tries them.

## What is the rule syntax?

A rule is `Tool` or `Tool(specifier)`. A bare name matches all uses of the tool. `Bash(*)` is equivalent to `Bash`. Examples from the docs:

| Rule | Effect |
| :- | :- |
| `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 |

Deny and ask rules can also match a single input parameter with `Tool(param:value)`, for example `Agent(model:opus)`. You cannot do this for a tool's main content field: a rule like `Bash(command:rm *)` is ignored with a startup warning because a compound command would bypass it. Use `Bash(rm *)` instead.

## How do Bash wildcards work?

A `*` in a Bash rule matches any text, including spaces. A rule with no `*` matches one exact command. A `*` can sit at the start, middle or end.

This is the starter config the docs use as their example:

```json
{
  "permissions": {
    "allow": [
      "Bash(npm run *)",
      "Bash(git commit *)"
    ],
    "deny": [
      "Bash(git push *)"
    ]
  }
}
```

The details that trip people up:

- **The space before a trailing star is part of the rule.** `Bash(ls *)` matches `ls` and `ls -la` but not `lsof`. `Bash(ls*)` has no space, so it matches `lsof` too.
- **A trailing ` *` also matches the bare command.** `Bash(git log *)` matches `git log`. This holds only when the trailing star is the rule's only wildcard.
- **`:*` is an older equivalent** of a trailing wildcard, recognised only at the end of a pattern. In `Bash(git:* push)` the colon is literal.
- **Put the star after the subcommand.** `Bash(git log *)` allows only `git log` commands; `Bash(git *)` allows every git command. Claude Code warns at startup about an allow rule with a star before the subcommand, such as `Bash(git * main)`, which would also match `git -c core.fsmonitor=<script> diff main`.

### What about compound commands and wrappers?

Claude Code understands shell operators. The recognised separators are `&&`, `||`, `;`, `|`, `|&`, `&` and newlines. A rule like `Bash(safe-cmd *)` will not approve `safe-cmd && other-cmd`: every subcommand must be allowed. Deny and ask rules apply if any subcommand matches, including one nested in a subshell, a command substitution or a `for` loop. So `Bash(git clean *)` as an ask rule still prompts for `cd /tmp && git clean -f`.

Before matching, a fixed set of wrappers is stripped: `timeout`, `time`, `nice`, `nohup`, `stdbuf`, plus the builtins `command` and `builtin` and zsh's `noglob`. So `Bash(npm test *)` also matches `timeout 30 npm test`. Certain known-safe environment variable assignments are stripped too, so it matches `NODE_ENV=test npm test`. An allow rule does not match past other variable assignments, but a deny or ask rule does: `Bash(rm *)` in deny still matches `FOO=bar rm -rf tmp/`.

Environment runners are a trap. `Bash(devbox run *)` would match `devbox run rm -rf .`. Write the inner command into the rule instead, such as `Bash(devbox run npm test)`, one rule per command you want.

## How do Read and Edit rules match paths?

Read and Edit rules use gitignore pattern syntax. There are four pattern types:

| Pattern | Meaning | Example |
| - | - | - |
| `//path` | Absolute path from filesystem root | `Read(//Users/alice/secrets/**)` |
| `~/path` | Path from home directory | `Read(~/Documents/*.pdf)` |
| `/path` | Relative to the settings source | `Edit(/src/**/*.ts)` |
| `path` or `./path` | Relative to current directory | `Read(*.env)` |

The warning to remember: `/Users/alice/file` is not an absolute path. A single leading slash anchors at the settings source, so in project settings it resolves under the primary working directory, and in user settings under `~/.claude`. Use `//Users/alice/file` for a real absolute path. For where each settings file lives and which wins, see [settings.json scopes and precedence](https://bridge-terminal.com/atlas/blog/claude-code-settings-json-scopes-precedence/).

Two more points from the docs:

- Claude Code checks file permissions against `Edit(path)` and `Read(path)` rules only. A `Grep(docs/**)` or `Write(docs/**)` rule with a path is accepted but does not match anything. Write `Read(docs/**)` and `Edit(docs/**)` instead.
- A `.claudeignore` file has no effect. Move its entries into `Read` deny rules, such as `Read(./.env)` or `Read(./secrets/**)`.

A safe deny block for secrets therefore looks like this:

```json
{
  "permissions": {
    "deny": [
      "Read(./.env)",
      "Read(./secrets/**)",
      "Edit(./secrets/**)"
    ]
  }
}
```

## What will a rule not stop?

This is the part to read before you trust a deny list. A Bash rule matches the command text Claude writes, after splitting compound commands and stripping wrappers. It does not match the same program invoked another way. The docs list these examples:

| Rule | Stops | Does not stop |
| :- | :- | :- |
| `Bash(curl *)` | `curl https://example.com` | `/usr/bin/curl https://example.com`, `sh -c 'curl https://example.com'` |
| `Bash(rm *)` | `rm -rf build/` | `/bin/rm -rf build/`, `bash -c 'rm -rf build/'` |

The same reasoning applies to the push rule in the config above: `git -C . push` is not matched by `Bash(git push *)`. The docs say plainly that a deny or ask rule covers the invocation Claude usually produces and is not a security boundary around the program.

Read and Edit deny rules have gaps too. They apply to built-in file tools and to Bash commands Claude Code can analyse, such as `cat`, `head`, `tail`, `sed`, `tee` and redirection targets. But `grep -r pattern .` run from the directory holding a denied file, or a Python or Node script that opens files itself, can still reach it.

### What do you use for hard limits?

Two things, both documented:

1. **The sandbox.** It is an OS-enforced boundary around Bash commands and the processes they start. Sandboxed commands can write only to the working directory, a temp directory and directories you add, and network access goes through a proxy that allows only hosts on your `allowedDomains` list, which starts empty. The [sandboxing documentation](https://code.claude.com/docs/en/sandboxing) describes permission rules and the sandbox as complementary: rules are checked against the command text before it runs, while the sandbox restricts what a running command can reach. Note that the built-in file tools (Read, Edit, Write) run outside the sandbox and follow only permission rules. Our [sandbox guide](https://bridge-terminal.com/atlas/blog/claude-code-sandbox-bash-files-network/) covers setup.
2. **A PreToolUse hook.** It can inspect the full command text with your own logic before it runs. See [hooks that format, block and enforce rules](https://bridge-terminal.com/atlas/blog/claude-code-hooks-format-block-enforce-rules/).

## How should a team set this up?

A practical order of work:

1. Start with `deny` for secrets and destructive or outward-facing actions, written for the usual form of each command.
2. Add `allow` for the exact commands the agent runs all day: test, lint, build, `git commit`.
3. Put anything you want a human to see, such as a deploy, in `ask`. Remember ask beats allow.
4. Review the rules in `/permissions`, which shows where each rule comes from.
5. Commit the project settings so everyone shares them, and put the non-negotiables in managed settings so individual users cannot override them.
6. Test the rules. Run a few forms of the commands you denied, including the absolute-path and `sh -c` forms, and see which still run. Cover those gaps with the sandbox or a hook.

## Conclusion

Permission rules are simple once the order is clear: deny, ask, allow, first match wins. Write allow rules narrowly, with the star after the subcommand and the space in the right place, and treat deny rules as guardrails for the usual form of a command, not a wall. For anything that must hold, add the sandbox or a hook.

## Where Atlas fits

[Atlas](https://bridge-terminal.com/atlas/) runs each of its engineers as its own Claude Code session, and it keeps production go-lives, spending, deleting data and sending anything outside as decisions that wait for you. It does not test or edit your project's own allow and deny patterns today. Checking them for gaps is coming to Atlas, built in, so it will need no setup. Until then, run the bypass forms from the step above against your own deny list by hand.

## Questions people ask

### What order does Claude Code check permission rules in?

Deny first, then ask, then allow. The first match decides, and specificity does not change the order, so a narrow allow cannot override a broader deny.

### Why does my Bash allow rule not match a command?

Common causes are a compound command where one part is not allowed, a star placed before the subcommand, a missing space before the trailing star, or a different form of the command. Every part of a compound command must be allowed.

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

No. It stops the usual form, but the docs say /usr/bin/curl or sh -c 'curl ...' are not matched. Use the sandbox or a PreToolUse hook for a hard limit.

### How do I stop Claude Code reading my .env file?

Add a Read deny rule such as Read(./.env). A .claudeignore file has no effect. A script Claude runs can still open files itself, so add the sandbox for stronger protection.

### Do Write(path) or Grep(path) rules work?

They are accepted but never match. Claude Code checks file permissions against Edit(path) and Read(path), so write those instead.

## About Atlas: Shared permission rules across several engineers

Atlas runs each engineer as its own Claude Code session and keeps production go-lives, spending, deleting data and sending outside as decisions that wait for you. It does not test your allow and deny patterns for gaps today; that is coming to Atlas, built in, with no setup. Until then, try the bypass forms by hand. — https://bridge-terminal.com/atlas/

## Sources

- [Configure permissions - Claude Code Docs](https://code.claude.com/docs/en/permissions)
- [Sandboxing - Claude Code Docs](https://code.claude.com/docs/en/sandboxing)

_Researched and drafted with Claude, then checked against the sources above. Atlas is an independent product, not affiliated with Anthropic or OpenAI._

## Related

- [Claude Code Permissions: Allow, Deny Rules and Modes](https://bridge-terminal.com/atlas/blog/claude-code-permissions-allow-deny-rules/)
- [Claude Code can now deny prompts instead of waiting](https://bridge-terminal.com/atlas/blog/claude-code-deny-instead-of-prompting-setting/)
- [Claude Code Hooks: Format, Block and Enforce Rules](https://bridge-terminal.com/atlas/blog/claude-code-hooks-format-block-enforce-rules/)
