Claude Code decides whether to run a tool by checking permission rules in your settings files. Rules go in a permissions object with allow, ask and deny lists, for example "allow": ["Bash(npm run *)"]. Deny rules are checked first, then ask, then allow, and the first match wins. Run /permissions inside Claude Code to see every rule and the file it comes from. Anything no rule covers falls back to your permission mode, which in the default mode means Claude asks you.
01A first example
Put this in .claude/settings.json in your project:
{
"permissions": {
"allow": ["Bash(npm run *)", "Bash(git commit *)"],
"deny": ["Bash(git push *)", "Read(./.env)"]
}
}
Claude can now run any npm run script and make commits without asking, can never push, and can never read .env.
02Where the rules live
~/.claude/settings.jsonYou, in every project.claude/settings.jsonThe project, shared with your team through git.claude/settings.local.jsonThe project, just for youWhen you answer a prompt with "Yes, and don't ask again", Claude Code saves the rule to .claude/settings.local.json at the root of the git repository. Organizations can also set managed rules, which no other file and no command line option can override.
03How rules are checked
- The order is deny, then ask, then allow. The first match decides, and a more specific rule does not change the order.
- An allow rule cannot make an exception to a deny rule.
- Anything no rule matches is handled by your permission mode.
04Bash rules
Bash(npm run build)matches that exact command.*matches any text, including spaces.Bash(git log *)allows onlygit log;Bash(git *)allows every git command.- A space before a trailing
*matters:Bash(ls *)matcheslsandls -labut notlsof, whileBash(ls*)also matcheslsof. - Commands joined with
&&,||,;or|are split, and every part must be allowed. - Simple wrappers such as
timeout,timeandnohupare stripped before matching. Runners such asnpxanddocker execare not.
Bash rules match the command text, so they are a convenience, not a sandbox. Anthropic's documentation notes, for example, that Bash(curl *) does not stop /usr/bin/curl.
05File, web and MCP rules
- Files:
Read(./.env)orRead(./secrets/**)use gitignore-style patterns. AReaddeny also blocks editing and writing that path. Start a path with//for an absolute path and~/for your home folder; a single leading/means relative to the settings file's location. - Web:
WebFetch(domain:example.com)covers one domain,WebFetch(domain:*.example.com)its subdomains. - MCP:
mcp__puppeteer__*covers every tool from a server,mcp__puppeteer__puppeteer_navigateone tool.
06The /permissions command
Type /permissions in a session to list every rule and the settings file it comes from, and to add or remove rules. You can open it while Claude is working; changes apply from Claude's next tool call.
08Rules and walking away
Good allow rules are what let a long task run without stopping at every command, while deny rules keep the risky ones off the table. Whatever is left still waits for you. If you are away from the keyboard, a notification tool can bring those prompts to your phone. Claude Code Notifier is one: an independent tool (not made by Anthropic) with a free command line tool, ccn, for Mac, Windows and Linux, and apps for iPhone and Android, which lets you allow once, allow for the session or deny with a tap. See Approve Claude Code permission requests from your phone.
09FAQ
Where do I put Claude Code permission rules?
In a permissions object in ~/.claude/settings.json (all your projects), .claude/settings.json (shared with the project) or .claude/settings.local.json (the project, just for you).
Which wins, allow or deny?
Deny. Claude Code checks deny rules first, then ask, then allow, and an allow rule cannot override a deny rule.
How do I allow all git commands?
Add "Bash(git *)" to the allow list. To allow only some, list them, for example "Bash(git status)" and "Bash(git log *)".
How do I stop Claude Code reading my .env file?
Add "Read(./.env)" to the deny list. A Read deny also stops Claude editing or writing that file.
Use OpenAI's Codex CLI? Notifier for Codex does the same for Codex.