If you let Claude Code run with broad permissions, your deny list is the last line of defence. Three ways it quietly fails:
1. Write(path) rules
The 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)".
2. The file never parsed
A 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.
3. The shell is a different tool
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/
Check your file
I built a free, browser-only checker for these (and ~30 other issues): https://github.com/curpowsto/claude-settings-doctor — source on GitHub, MIT. Unofficial; verify against the official docs.
