Claude Code settings.json permissions, with allow, ask and deny examples
Updated 17 November 2026
Add a permissions object with allow, ask and deny arrays to ~/.claude/settings.json or your project's .claude/settings.json. Each rule is a tool name with an optional pattern, such as Bash(npm run *) or Read(./.env). Deny is checked first, then ask, then allow.
Permission rules tell Claude Code which tool calls to run without asking, which to always ask about, and which to refuse. They live in a permissions object in a settings file, and you can also manage them from the /permissions dialog inside a session.
The syntax here follows the permissions page of the Claude Code docs.
What does a minimal permissions block look like?
{
"permissions": {
"allow": [
"Bash(npm run *)",
"Bash(git commit *)"
],
"deny": [
"Bash(git push *)"
]
}
}
With this, Claude Code runs npm scripts and git commits without asking and refuses commands that begin with git push. An ask array works the same way and forces a prompt for whatever it matches.
Which file do the rules go in?
| File | Applies to | Shared with the team |
|---|---|---|
~/.claude/settings.json |
All your projects | No |
.claude/settings.json |
One project | Yes, commit it |
.claude/settings.local.json |
One project | No, it is for you only |
When you pick “Yes, and don’t ask again” on a prompt, Claude Code writes the rule for you. The /permissions dialog lists every rule and the file it came from.
Which rule wins when two match?
Rules are evaluated in a fixed order: deny, then ask, then allow. The first match in that order decides, and a more specific rule does not beat a broader one.
Two things follow from that:
- A broad deny such as
Bash(aws *)blocksaws s3 lseven if you also haveBash(aws s3 ls)in allow. An allow rule cannot carve an exception out of a deny. - A deny at any level holds. If your user settings allow something and the project settings deny it, it is denied, and the reverse is true too.
How do Bash wildcards match?
A rule is either a bare tool name, which matches every use of that tool, or Tool(specifier). For Bash, * matches any text, including spaces.
| You write | Matches | Does not match |
|---|---|---|
Bash(npm run build) |
npm run build |
npm run build --watch |
Bash(npm run *) |
npm run build, npm run test --watch |
npm install |
Bash(ls *) |
ls -la, ls |
lsof |
Bash(ls*) |
ls -la, lsof |
|
Bash(* --version) |
node --version |
node -v |
Put the * after the subcommand. Bash(git log *) allows only git log commands, while Bash(git *) allows every git command, including the destructive ones.
Claude Code understands shell operators, so Bash(safe-cmd *) does not approve safe-cmd && other-cmd. Every part of a compound command has to be allowed on its own. Deny and ask rules go the other way: they apply if any part matches, so an ask rule for Bash(git clean *) still prompts for cd /tmp && git clean -f.
How do I block Claude from reading a file?
Use a Read deny rule. Edit rules cover every built-in tool that edits files.
{
"permissions": {
"deny": [
"Read(./.env)",
"Read(./secrets/**)"
]
}
}
Path patterns use gitignore syntax, and the leading characters decide where the pattern is anchored:
| Pattern | Meaning | Example |
|---|---|---|
//path |
Absolute path from the filesystem root | Read(//Users/alice/secrets/**) |
~/path |
From your home directory | Read(~/Documents/*.pdf) |
/path |
Relative to the settings file’s source | Edit(/src/**/*.ts) |
path or ./path |
Relative to the current directory | Read(*.env) |
The single leading slash trips people up. /Users/alice/file looks absolute, but Claude Code anchors it at the settings source. In ~/.claude/settings.json, a rule like Read(/secrets/**) blocks ~/.claude/secrets/** and nothing in your project. For a user-level rule that should apply in every project, use // or ~/.
A .claudeignore file has no effect, according to the docs. Move its entries into Read deny rules.
How do I write rules for web fetches and MCP tools?
WebFetch(domain:example.com)matches requests to that host only. AddWebFetch(domain:*.example.com)to cover subdomains.mcp__puppeteer__*matches every tool from thepuppeteerMCP server, andmcp__puppeteer__puppeteer_navigatematches one tool."mcp__*"in deny blocks every MCP tool. Allow rules only accept a glob after a named server, so"mcp__*"in allow is skipped.
Why is my deny rule not stopping the command?
A Bash rule matches the command text Claude writes. It does not follow the program if it is invoked another way. The docs give 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/' |
Bash(git push *) |
git push origin main |
git -C . push origin main |
A Bash deny rule covers the form Claude usually produces. The docs say it is no security boundary around the program. For enforcement that does not depend on the command text, the docs point to sandboxing, and for your own logic over the full command, a PreToolUse hook. There are working examples in the Claude Code hooks guide.
Two more causes of a rule doing nothing:
- A typo in the tool name. Use the canonical names, and watch for the startup warning about a rule that matches no tool.
- Environment runners.
Bash(devbox run *)allows whatever comes afterrun, includingdevbox run rm -rf .. Write one rule per inner command, such asBash(devbox run npm test).
What is a sensible starting set?
Allow your project’s test, lint and build commands. Put pushes, deploys and anything that deletes outside the build folder in ask. Deny reads of .env and other secret files. Then pick a permission mode for the rest.
After that, each prompt you see is one you decided you wanted to read. Those still wait in the terminal where the session runs. NotchDaddy can show them in the MacBook notch with the exact command and Allow and Deny buttons, and an unanswered one falls back to the terminal prompt. You do not need it if you are happy answering in the terminal; the rules above work the same either way. More on that in approving Claude Code from the notch.
Start a 3-day trial for $0, then it is $19 once.