{"slug": "claude-code-permission-rules-that-look-right-and-do-nothing", "title": "Claude Code permission rules that look right and do nothing", "summary": "A developer documented five Claude Code permission-rule shapes that parse cleanly and start without errors but are never consulted, including path rules on Write, NotebookEdit and Glob (only Edit and Read path rules are matched as of version 2.1.210), Bash(command:...) rules, and bare mcp__* allow globs that approve nothing. The audit recommends replacing Write(path) with Edit(path), Glob(path) with Read(path), and Bash(command:rm *) with Bash(rm *), and verifying each rule actually fires before unattended or overnight agent runs.", "body_md": "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.\n\nThat 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.\n\nThis 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.\n\nClaude 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.\n\nThis 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.\n\nAs 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.\n\nThis 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.\n\nWhat to write instead:\n\n`Edit(...)` in place of `Write(...)` or `NotebookEdit(...)`. Edit rules cover every built-in file-editing tool.` Read(...)` in place of `Glob(...)`.\nA bare `Write` deny with no path is unaffected — it removes the tool everywhere. But a path-specific Write rule is silent.\n\n`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.\n\nWrite `Bash(rm *)` instead — match the command name and its arguments, not the `command:` parameter field.\n\nThe 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.\n\n`\"*\"`, `\"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.\n\nA 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.)\n\n`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.\n\nPrefix 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.\n\nBefore your next headless or overnight run, open `.claude/settings.json` and check for these:\n\n`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.\nClaude 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.\n\nHere is a conservative baseline for a TypeScript repo, using only specifier forms that are actually consulted:\n\n```\n{\n  \"permissions\": {\n    \"defaultMode\": \"default\",\n    \"allow\": [\n      \"Bash(npm run build)\",\n      \"Bash(npm run test:*)\",\n      \"Bash(npm run lint:*)\",\n      \"Bash(npx tsc:*)\",\n      \"Bash(git commit *)\",\n      \"Bash(git status)\",\n      \"Bash(git diff:*)\"\n    ],\n    \"ask\": [\n      \"Bash(git push *)\"\n    ],\n    \"deny\": [\n      \"Read(secrets/**)\",\n      \"Edit(secrets/**)\",\n      \"Bash(curl *)\",\n      \"Bash(wget *)\"\n    ]\n  }\n}\n```\n\nNotice 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.\n\nKeep 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.\n\nA 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:\n\n`/permissions` in a session.`--verbose`.` declare` or `export` prefixes. Run the exact command your agent would run and confirm the rule fires.\nAuditing 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.\n\nPair 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.\n\n*This post was written with AI assistance. The author is responsible for its content.*", "url": "https://wpnews.pro/news/claude-code-permission-rules-that-look-right-and-do-nothing", "canonical_source": "https://dev.to/dekita/claude-code-permission-rules-that-look-right-and-do-nothing-2dbc", "published_at": "2026-11-19 12:08:27+00:00", "updated_at": "2026-11-19 12:13:58.123691+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "ai-safety"], "entities": ["Claude Code", "Anthropic"], "also_reported_by": [], "takeaway": "Path rules on Write, NotebookEdit and Glob are silently ignored in Claude Code 2.1.210 — use Edit(path) and Read(path) instead, and write Bash(rm *) rather than Bash(command:rm *).", "recommendation": {"advice": "Audit .claude/settings.json before unattended runs: replace Write(path) with Edit(path), Glob(path) with Read(path), drop bare mcp__* allow globs, and confirm each deny rule actually fires.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/claude-code-permission-rules-that-look-right-and-do-nothing", "markdown": "https://wpnews.pro/news/claude-code-permission-rules-that-look-right-and-do-nothing.md", "text": "https://wpnews.pro/news/claude-code-permission-rules-that-look-right-and-do-nothing.txt", "jsonld": "https://wpnews.pro/news/claude-code-permission-rules-that-look-right-and-do-nothing.jsonld"}}