Claude Code permissions. Allow, ask and deny rules in settings.json
Where Claude Code keeps permissions, which file wins, how to write allow, ask and deny rules for commands, files and websites, and a complete settings.json example.
Part of the guideClaude Code, the complete guide. From installation to your own skills and plugins
In this article
In short
Claude Code permissions are allow, ask and deny rules in settings.json files, and the program enforces them, not the model. We cover which file wins, how to write rules for commands, files, websites and MCP servers, where mistakes happen and what a complete example looks like.
Someone adds "never read the .env file" to CLAUDE.md and considers it done. Someone else creates a .claudeignore file because that is how other tools worked. The Anthropic documentation answers both directly. Instructions in CLAUDE.md shape what Claude tries to do, but they do not change what Claude Code allows, and .claudeignore has no effect at all. That is what permissions in the settings files are for. Everything below was checked against the permissions docs and the settings docs as of 10 November 2026.
Permission modes for beginners are explained in What is Claude Code. Here we go deeper, into the rules themselves. The whole series lives in the Claude Code guide.
Where Claude Code keeps permissions
Permissions are part of the settings, so they live in the same files. Installing Claude Code creates none of them.
| File | Who it affects | Use it for |
|---|---|---|
~/.claude/settings.json | You, in every project | Your own rules and preferences |
.claude/settings.json | Everyone in the project, once committed | Shared team rules |
.claude/settings.local.json | You, in one project | Personal exceptions, kept out of git |
| Managed settings | The whole organization | Company security policy |
On Windows, ~/.claude means %USERPROFILE%\.claude. There is also ~/.claude.json, but Claude Code writes that one for itself. It holds trust decisions for folders, among other things, and you do not need to edit it.
The local file appears on its own when you pick Yes, and don't ask again on a command prompt. The rule goes into .claude/settings.local.json at the repository root and applies across the whole repository, subfolders included. Approval for a file edit is not saved and lasts until the session ends. Claude Code also adds this file to your global git excludes so it does not end up in a commit.
Which rule wins
Within the rules the order is fixed. Deny first, then ask, then allow, and the first match decides. Specificity does not matter. A broad deny rule Bash(aws *) also blocks aws s3 ls, even when a separate allow rule names exactly that command. In the same way, a matching ask rule prompts even when a narrower allow rule also matches.
Between files, the settings order applies. Managed settings come first, then --settings from the command line, then the local file, the project file and finally your user file. Rule lists do not replace each other, they merge, so every file can add its own. A deny rule at any level blocks an allow at any other. A deny in your user file stops an allow in the project file and the other way round.
In practice this explains one thing that puzzles people. You picked Yes, and don't ask again, and Claude Code keeps asking. Usually the project file or company settings have an ask rule, and a local allow cannot beat it.
Allow, ask and deny rule syntax
A rule looks like Tool or Tool(specifier). The bare tool name covers every use of it.
| Rule | What it covers |
|---|---|
Bash | Every shell command |
Bash(npm run build) | Exactly that one command |
Bash(npm run *) | npm run build, npm run test and plain npm run |
Bash(git log *) | Only git log commands |
Read(./.env) | Reading .env in the current folder |
Edit(/src/**/*.ts) | Editing TypeScript files in the project's src |
WebFetch(domain:example.com) | Fetching pages from that domain |
mcp__github__* | Every tool from the MCP server named github |
Agent(Explore) | The Explore subagent |
For shell commands, where you put the asterisk matters. Everything before the first asterisk must match exactly. Bash(git log *) allows only git log, while Bash(git *) allows every git command, push included. Bash(git * main) lets git push origin main through, which is why Claude Code warns at startup about an asterisk placed before the subcommand. The space before a trailing asterisk counts as well. Bash(ls *) does not cover lsof, but Bash(ls*) does.
Claude Code understands chained commands. Bash(npm test *) will not let npm test && rm -rf build through, because every part must be allowed on its own. A deny rule applies when any part matches. The documentation is clear, though, that a command rule matches the command text, not the program. Bash(rm *) stops rm -rf build/, but not /bin/rm -rf build/ or bash -c 'rm -rf build/'. It is not a security boundary. For real isolation there is the sandbox, /sandbox on macOS, Linux and WSL 2.
Paths in Read and Edit rules work like .gitignore, and how a path starts matters. // means a path from the filesystem root, ~/ from your home folder, a single / from the folder the settings file belongs to, and ./ or a bare name from the current folder. This one is easy to get wrong. Read(/secrets/**) in your user file protects ~/.claude/secrets, not a secrets folder in your project. On Windows, paths are converted to forward-slash form, so C:\Users\alice becomes /c/Users/alice.
A settings.json permissions example
This is what a shared .claude/settings.json could look like in a Node.js project.
{
"permissions": {
"defaultMode": "acceptEdits",
"allow": [
"Bash(npm run *)",
"Bash(git diff *)",
"Bash(git commit *)",
"WebFetch(domain:code.claude.com)"
],
"ask": [
"Bash(git push *)"
],
"deny": [
"Read(./.env)",
"Read(./secrets/**)",
"Bash(rm *)"
],
"additionalDirectories": ["../docs"]
}
}Claude edits files and runs npm scripts without asking, asks before every push, and does not read .env or the secrets folder. Allow rules and extra directories from a project file only take effect after you accept the folder trust dialog, which lists them. Ask and deny rules apply right away, because they only restrict. Inside a session, /permissions shows and edits every rule, along with the file each one comes from.
Permission modes as a reference
The mode sets the baseline, and rules refine it. The default mode goes in the permissions.defaultMode key.
| Mode | What runs without asking |
|---|---|
default, shown as Manual | Reads only |
acceptEdits | Reads, file edits and simple commands like mkdir, mv, cp |
plan | Reading and exploring, no edits |
auto | Everything, with a separate model checking each step |
dontAsk | Only what allow rules permit, everything else is denied |
bypassPermissions | Everything, for containers and virtual machines only |
Deny rules apply in every mode, bypassPermissions included. Allow rules mean nothing in bypassPermissions, since everything goes through anyway. Setting auto or bypassPermissions as the default in .claude/settings.json or .claude/settings.local.json has no effect. You set them in your user file or with a flag at startup. A company can switch them off entirely with permissions.disableAutoMode and permissions.disableBypassPermissionsMode set to "disable" in managed settings.
How to start Claude Code and get through day one is in first run and login. Hooks that check commands with your own script are covered in Claude Code hooks, and /permissions with the other built-ins in Claude Code slash commands.
Start with a few deny rules for files with secrets and an ask rule for push, and add allow rules only when the same prompt keeps coming back every day. If you want to see where AI could safely take over part of the work in your business, our free AI audit is a good place to start.
What would you like to change in your business?
Leave your number. We will talk about your process and see whether we can help. The first call is free.
The service this text is about
Automation and AI / OCRAutomation of document re-typing, OCR and checking rules, and your data stays with you.