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.
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.
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:
Edit(...) in place of Write(...) or NotebookEdit(...). Edit rules cover every built-in file-editing tool. Read(...) in place of Glob(...).
A bare Write deny with no path is unaffected — it removes the tool everywhere. But a path-specific Write rule is silent.
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.
"*", "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.)
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.
Before your next headless or overnight run, open .claude/settings.json and check for these:
Bash(command:...) rule. Replace with Bash(<name> <args>)."*", "B*", or mcp__* allow rule. Remove it or narrow it to a named server.Bash(git * main). Use a space before the trailing * instead: Bash(git push *). Read( plus the environment-variables filename without a matching Edit( 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.
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.
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:
/permissions in a session.--verbose. declare or export prefixes. Run the exact command your agent would run and confirm the rule fires.
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.
This post was written with AI assistance. The author is responsible for its content.