Claude Code permission rules that look right and do nothing
You wrote a deny rule to keep your coding agent away from the environment-variables file. It parses. Claude Code starts without a warning. The rule never fires.
That is the trap. Claude Code's permission system is small enough to fit in one settings file and subtle enough that most people ship at least one rule that does nothing. The rule looks correct. The JSON is valid. The session boots. And the rule is quietly never consulted.
This post is the audit I run before an unattended agent run: five shapes that look plausible but silently fail, what to write instead, and how to verify a rule actually fires.
How Claude Code evaluates permission rules
Claude Code reads permissions from several settings files: user settings, project .claude/settings.json, project-local .claude/settings.local.json, and managed organization settings. Rules are evaluated in a fixed order: deny first, then ask, then allow. The first match decides, and deny wins in every mode — including bypassPermissions. That means a deny rule cannot be carved around by an allow rule elsewhere, and an allow rule cannot resurrect something a deny blocks.
This ordering is useful to know, but it only matters if the rule is actually consulted. The silent-fail shapes below are rules that parse, start clean, and are never matched against a real tool call.
1. Write(path), NotebookEdit(path), Glob(path) path rules
As of Claude Code 2.1.210, file-permission checks only match Edit(path) and Read(path) rules. A path rule on Write, NotebookEdit, or Glob is accepted and never consulted. Claude Code warns at startup, but only on recent versions, and only if you read the startup output.
This means a rule like Write(docs/**) does not block writes to docs. A Glob(secrets/**) deny does not stop Grep or Glob from searching secrets.
What to write instead:
- Use
Edit(...)in place ofWrite(...)orNotebookEdit(...). Edit rules cover every built-in file-editing tool. - Use
Read(...)in place ofGlob(...).
A bare Write deny with no path is unaffected — it removes the tool everywhere. But a path-specific Write rule is silent.
2. Bash(command:) parameter rules
Bash(command:rm *) looks like it should block rm -rf .. It does not. Because command is a field Bash already matches with its own rules, Bash(command:...) is ignored and warned about.
Write Bash(rm *) instead — match the command name and its arguments, not the command: parameter field.
The same applies to other canonicalized fields: file_path for Read/Edit/Write, path for Grep/Glob, notebook_path for NotebookEdit, and url for WebFetch. Parameter matching with Tool(param:value) works for top-level inputs like Agent(model:opus) or Bash(run_in_background:true), but not for fields the tool already canonicalizes.
3. Unanchored allow globs
"*", "B*", or mcp__* in the allow list are skipped with a warning and approve nothing. An unanchored MCP allow glob is the most dangerous silence, because it looks like a blanket approval and approves exactly zero calls.
A tool-name glob is only honored after a literal mcp__<server>__ prefix, and the server segment itself must be glob-free. mcp__github__get_* is fine. mcp__* as an allow rule is not. (mcp__* works fine as a deny rule.)
4. Mid-pattern wildcards and prefix wrappers
Bash(git * main) draws a startup warning since 2.1.246, because the * also matches options placed before the subcommand — such as git -c, which runs a program you choose. Keep that shape out of allow rules.
Prefix wrappers always prompt, so an allow rule on them can't auto-approve: watch, setsid, ionice, flock, and find with -exec or -delete. Bash deny and ask rules also missed commands written with quoted words (fixed in 2.1.319) and names set through declare or export prefixes (fixed in 2.1.290), so test the actual command string your agent writes.
5. The one settings file to audit
Before your next headless or overnight run, open .claude/settings.json and check for these:
- Any
Write(...),NotebookEdit(...), orGlob(...)rule with a path. Replace withEdit(...)orRead(...). - Any
Bash(command:...)rule. Replace withBash(<name> <args>). - Any
"*","B*", ormcp__*allow rule. Remove it or narrow it to a named server. - Any mid-pattern wildcard like
Bash(git * main). Use a space before the trailing*instead:Bash(git push *). - Any
Read(plus the environment-variables filename without a matchingEdit(deny. The pair keeps secrets out of reads and writes.
Claude Code evaluates rules in order: deny, then ask, then allow. The first match decides. Deny wins in every mode, including bypassPermissions. So a deny rule cannot be carved around by an allow elsewhere, and an allow rule cannot resurrect something a deny blocks.
A starter settings.json you can audit against
Here is a conservative baseline for a TypeScript repo, using only specifier forms that are actually consulted:
{
"permissions": {
"defaultMode": "default",
"allow": [
"Bash(npm run build)",
"Bash(npm run test:*)",
"Bash(npm run lint:*)",
"Bash(npx tsc:*)",
"Bash(git commit *)",
"Bash(git status)",
"Bash(git diff:*)"
],
"ask": [
"Bash(git push *)"
],
"deny": [
"Read(secrets/**)",
"Edit(secrets/**)",
"Bash(curl *)",
"Bash(wget *)"
]
}
}
Notice what changed from common drafts: Read(secrets/**) and Edit(secrets/**) cover both reading and writing. The Bash(curl *) and Bash(wget *) denies close the network side-channel that a Read deny alone leaves open — a script can exfiltrate data through curl without ever reading a file through the file-permission path.
Keep this in .claude/settings.json for team-wide rules, and put anything personal in .claude/settings.local.json. Both lists merge, and deny always wins.
How to verify a rule actually fires
A rule that parses but never matches is worse than no rule, because it creates false confidence. Before you ship an unattended run, do these checks:
- Read startup warnings. Claude Code emits startup warnings for silently-ignored rules (Write/Glob path rules, unanchored allow globs, mid-pattern wildcards). Do not dismiss them without reading.
- Run
/permissionsin a session. It lists every active rule and which settings file each one came from — the fastest way to find a rule that is not taking effect because a higher scope shadows it. - Start with
--verbose. It shows the exact parameter names and values Claude Code sees for each tool call, which is what you need when a parameter-match rule is not firing. - Test the actual command string. Bash deny and ask rules missed commands written with quoted words and names set through
declareorexportprefixes. Run the exact command your agent would run and confirm the rule fires.
What this does not fix
Auditing your settings file closes the silent-path problem: rules that parse and never fire. It does not make your policy right. A run that denies everything because the allow rules are too tight will pass every check and deliver nothing. The audit tells you the rule matches. Only you can tell you it matches for the right reason.
Pair the settings audit with a sandbox for OS-level enforcement, scoped credentials so the agent does not inherit your full identity, and human merge authority for anything it pushes. The settings file is the gate you control directly. Make sure it is actually closed.
Sources
- rulestack, "Claude Code permission rules: how allow, deny, and ask actually match," dev.to, posted Jul 17, edited Nov 10 2026. Primary source for rule specifier shapes, silent-fail rules, and the 2.1.210 / 2.1.322 changelog points.
- suraj_khaitan, "Claude Code Auto Mode Is the Beginning of Overnight Software Engineering," dev.to, posted Aug 23 2026. Source for unattended-run recommendations: sandbox, scoped credentials, hooks, and human merge authority.
- Claude Code permissions page and CHANGELOG, cited via the dev.to update notes above (2.1.210 through 2.1.322).
This post was written with AI assistance. The author is responsible for its content.