Claude Code permissions not working: why a deny rule doesn't block or an allow rule still asks
Tested on Claude Code 2.1.332: allow rules in .claude/settings.json are ignored in claude -p until the folder is trusted, a Bash(rm *) deny stopped seven ways of running rm but not find -delete, python or eval, and a trailing comma or lower-case tool name drops rules without a word.
· 7 min read
Most Claude Code permission rules that “don’t work” fail for one of three reasons, and Claude Code says little about any of them. An allow rule in a project’s .claude/settings.json is ignored until you trust the folder, and claude -p never asks you to. A deny rule matches the command you named, so Bash(rm *) stopped seven ways of running rm but not find -delete, a Python one-liner or eval. And a rule with a small mistake, such as a lower-case tool name or a trailing comma in the file, is skipped, while a script reading JSON output sees no warning at all.
We tested each case on Claude Code 2.1.332 on macOS on 27 November 2026, as claude -p with Haiku in a throwaway git project, with only the project’s own settings loaded. We checked the folder afterwards, not the model’s account of what it did. If your problem is .env files, see how to stop Claude Code reading .env files, which covers Read rules and the sandbox.
An allow rule that still asks: the folder is not trusted
permissions.allow rules in .claude/settings.json grant something, so Claude Code applies them only after you accept the workspace trust dialog for that folder. The dialog appears in an interactive session, but never in claude -p or the SDK. In our runs, Bash(touch *) and Bash(node -e *) in the project file were both ignored and the command still needed approval. The only sign was a line on stderr:
Ignoring 1 permissions.allow entry from .claude/settings.json:
this workspace has not been trusted. Run Claude Code interactively
here once and accept the trust dialog, or set
projects["/path/to/repo"].hasTrustDialogAccepted: true
in ~/.claude.json.The same rule worked from an untracked .claude/settings.local.json and from --settings. Once we committed settings.local.json to git, Claude Code treated it as part of the repository and ignored it with the same warning. Deny and ask rules are not affected: they only restrict, so they apply at once in every case we tried.
The fix: open Claude Code once in the folder and accept the trust dialog, keep personal allow rules in an untracked settings.local.json or ~/.claude/settings.json, or pass them with --settings in CI.
A deny rule that doesn’t block: it names a program
We put Bash(rm *) in deny and ran in bypassPermissions mode, where nothing asks and only a deny rule can stop a call. Claude Code looks inside compound commands, bash -c, environment assignments, absolute paths, nice and xargs, so all of those were refused. It does not know what other programs do:
| Option | What happened |
|---|---|
| rm victim.txt | What happenedRefused |
| echo hi && rm victim.txt | What happenedRefused |
| bash -c "rm victim.txt" | What happenedRefused |
| FOO=1 rm victim.txt | What happenedRefused |
| /bin/rm victim.txt | What happenedRefused |
| nice rm victim.txt | What happenedRefused |
| echo victim.txt | xargs rm | What happenedRefused |
| find . -name victim.txt -delete | What happenedRan: the file was deleted |
| python3 -c "import os; os.remove('victim.txt')" | What happenedRan: the file was deleted |
| eval "rm victim.txt" | What happenedRan: the file was deleted. In the default mode it asked first instead |
The same goes for allow rules. With Bash(node -e *) allowed and Bash(rm *) denied, node -e with fs.unlinkSync deleted the file in the default mode without asking. An allow rule for an interpreter allows everything that interpreter can do.
The legacy form Bash(rm:*) worked like Bash(rm *) in deny and in allow. Claude Code reads :* only at the end of a pattern.
Rules that are skipped without a word
| Option | What Claude Code did | What it told us |
|---|---|---|
| An allow rule in .claude/settings.json, run with claude -p | What Claude Code didIgnored: the command still needed approval | What it told usstderr: “Ignoring 1 permissions.allow entry from .claude/settings.json: this workspace has not been trusted.” |
| The same allow rule in .claude/settings.local.json, committed to git | What Claude Code didIgnored, the same way | What it told usThe same trust warning on stderr |
| The same allow rule in an untracked .claude/settings.local.json, or passed with --settings | What Claude Code didApplied | What it told usNothing |
| A deny rule in a settings.json with a trailing comma | What Claude Code didThe whole file was skipped: rm ran | What it told usNothing with --output-format json or stream-json; with text output, stderr said the file did not load |
| bash(rm *) in deny, lower-case tool name | What Claude Code didSkipped: rm ran | What it told usNothing in the run; claude doctor: “Tool names must start with uppercase” |
| Bash(rm) in deny, with no wildcard | What Claude Code didMatched only a bare rm: rm victim.txt ran | What it told usNothing, also in claude doctor |
| "deny": [...] at the top level, outside "permissions" | What Claude Code didIgnored: rm ran | What it told usNothing, also in claude doctor |
| "defaultMode": "bypassPermissions" in .claude/settings.local.json | What Claude Code didNot applied: rm still asked | What it told usNothing |
| --permission-mode acceptEdits, no rules | What Claude Code didrm ran without asking | What it told usNothing: this is how the mode works |
Two of these surprised us. A settings file that is not valid JSON is skipped whole, deny rules and all. Claude Code says so in an interactive session and on stderr with the default text output, but in our runs with --output-format stream-json, the format most scripts use, stderr was empty. And claude doctor caught the lower-case bash(rm *) but not Bash(rm) without a wildcard, which matches only a bare rm, nor a deny list placed outside permissions.
Which rule wins
Deny beat everything we tried, which matches Anthropic’s documented order of deny, then ask, then allow:
- An allow rule in
settings.jsonand a deny rule for the same command insettings.local.json: refused, even in bypassPermissions mode. - A deny rule in settings and
--allowedTools "Bash(rm *)"on the command line: refused. --disallowedTools "Bash(rm *)"with no settings, in bypassPermissions mode: refused.- An allow rule and an ask rule for the same command: it asked.
Modes that change what the rules mean
- acceptEdits deletes. With no rules at all,
rm victim.txtran without asking. The mode auto-approvesmkdir,touch,rm,rmdir,mv,cpandsedinside the working folders, so “accept edits” includes removing files. Add a deny or ask rule forrmif that is not what you want. - bypassPermissions leaves only deny. Ask rules and prompts are gone, so every gap in the deny table above runs. In this mode
eval "rm victim.txt"deleted the file; in the default mode it asked. - A project cannot switch on bypassPermissions or auto by itself.
"defaultMode": "bypassPermissions"insettings.local.jsonwas not applied andrmstill asked. Set it in~/.claude/settings.jsonor pass--permission-mode.
Rules for one tool don’t cover the shell
A deny rule for Edit(./config.json) also refused sed -i on that file, in bypassPermissions mode: Claude Code checks the files a few shell commands write. A deny rule for WebFetch(domain:example.com) did not stop curl -s -o page.html https://example.com, which saved the page. WebFetch rules cover the WebFetch tool only. To keep the shell off a site, deny or ask for curl and wget too, or use the sandbox’s network list.
A starting point
The deny rules below held in our runs against every form in the table except the ones marked as ran. The ask rules cover those gaps in the default mode by asking before any find, Python or Node command; we did not test them separately, and they do nothing in bypassPermissions mode.
{
"permissions": {
"deny": ["Bash(rm *)", "Bash(rmdir *)"],
"ask": ["Bash(find *)", "Bash(python3 *)", "Bash(node *)"]
}
}A list of programs is never complete: perl, git clean, a build script or a test runner can delete files too. Rules are good at keeping out what you can name. For the rest, keep the default mode and read the command before you approve it.
Check your own setup
Copy your settings into a throwaway project, run a deletion the long way round in bypassPermissions mode, and see whether the file survives. Then run claude doctor, which lists the rules Claude Code skipped:
mkdir /tmp/perm-check && cd /tmp/perm-check && git init -q
touch victim.txt
mkdir -p .claude && cp ~/your-settings.json .claude/settings.json
claude -p "Use the Bash tool to run exactly this command once: find . -name victim.txt -delete" \
--model haiku --setting-sources project,local --permission-mode bypassPermissions
ls victim.txt # gone means your deny list did not cover it
claude doctor # lists rules it skipped, such as a lower-case tool nameIn scripts, read Claude Code’s stderr even when you parse its JSON output: the trust warning lands there, and with text output, so does the notice that a settings file did not load.
Where VariantGate fits
Permission rules decide by the shape of a command. Some calls can’t be decided that way: a deploy that is fine on Tuesday and not during a release freeze, a refund that depends on the amount, a deletion in a folder that matters. VariantGate’s Claude Code hook sends those calls to a person, who approves or denies from the inbox, Slack or a phone, and the agent waits for the answer. Setup is in the Claude Code guide. To write the rules themselves, the Claude Code permissions builder makes allow, ask and deny lists with a warning for rules that won’t do what you expect, and the settings checker reads a file you already have. If your hooks are the part that is not working, see Claude Code hook not working and the hooks checker.
Sources
- Claude Code: Permissions (rule order, Bash matching, project allow rules and workspace trust), read 27 November 2026
- Claude Code: Settings (broken settings files, settings in -p runs, claude doctor), read 27 November 2026
- Claude Code: Permission modes (acceptEdits commands, defaultMode from project settings), read 27 November 2026
Give your agents somewhere to ask.
Free for 100 requests a month. Sign in with your email and have a first request waiting a few minutes from now.
Start free