{"slug": "your-claude-code-deny-rule-might-be-protecting-nothing", "title": "Your Claude Code deny rule might be protecting nothing", "summary": "A developer built claude-settings-doctor, a free browser-only tool that checks Claude Code settings files for roughly 30 misconfiguration issues. The tool highlights three silent failures in deny rules: Write(path) rules that should be Edit(path), invalid JSON caused by a UTF-8 BOM, trailing comma or comment that disables all rules and hooks, and Bash commands like echo writing to files that Edit rules cannot block, which the developer says require a PreToolUse hook exiting with code 2.", "body_md": "If you let Claude Code run with broad permissions, your `deny` list is the last line of defence. Three ways it quietly fails:\n\n`Write(path)` rules\nThe permissions docs describe file path rules as `Read(...)` and `Edit(...)`; `Edit` rules apply to all built-in file-editing tools, including Write. A rule like `\"Write(.env)\"` therefore doesn't do what it looks like. Use `\"Edit(.env)\"`.\n\nA UTF-8 BOM (PowerShell 5.1 `Set-Content`/` Out-File`), a trailing comma or a `// comment` makes the settings file invalid JSON. When that happens, none of its rules or hooks apply.\n\n`Edit(.claude/settings.json)` blocks the Edit tool. `echo '{}' > .claude/settings.json` is a Bash call. Bash deny patterns can't enumerate every way to write a file, so add a PreToolUse hook that inspects the command and exits with code 2 to block it. Full example: [https://wangsheng190331-crypto.github.io/claude-settings-doctor/fix/deny-rules-shell-bypass/](https://wangsheng190331-crypto.github.io/claude-settings-doctor/fix/deny-rules-shell-bypass/)\n\nI built a free, browser-only checker for these (and ~30 other issues): [https://github.com/curpowsto/claude-settings-doctor](https://github.com/curpowsto/claude-settings-doctor) — source on GitHub, MIT. Unofficial; verify against the official docs.", "url": "https://wpnews.pro/news/your-claude-code-deny-rule-might-be-protecting-nothing", "canonical_source": "https://dev.to/cruypoto/your-claude-code-deny-rule-might-be-protecting-nothing-311a", "published_at": "2026-12-03 09:11:44+00:00", "updated_at": "2026-12-03 09:17:32.018440+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "ai-safety"], "entities": ["Claude Code", "Anthropic", "claude-settings-doctor", "GitHub", "PowerShell"], "also_reported_by": [], "takeaway": "Claude Code deny rules fail silently in three ways: use Edit(.env) rather than Write(.env) since Edit rules cover all built-in file-editing tools, keep settings JSON free of BOMs, trailing commas and comments or all rules and hooks are dropped, and add a PreToolUse hook that exits with code 2 to blo", "recommendation": {"advice": "Audit Claude Code deny rules: replace Write(path) with Edit(path), validate settings JSON for BOMs and trailing commas, and add a PreToolUse hook exiting with code 2 to block shell-based file writes.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/your-claude-code-deny-rule-might-be-protecting-nothing", "markdown": "https://wpnews.pro/news/your-claude-code-deny-rule-might-be-protecting-nothing.md", "text": "https://wpnews.pro/news/your-claude-code-deny-rule-might-be-protecting-nothing.txt", "jsonld": "https://wpnews.pro/news/your-claude-code-deny-rule-might-be-protecting-nothing.jsonld"}}