Claude Code reads files to help you. That is great, until the file is .env, a private key, or a cloud credentials folder. Permission deny rules let you block those reads outright.
Minimal deny list
In .claude/settings.json (shared with the team) or settings.local.json (personal), add these entries under permissions.deny:
- Read(./.env)
- Read(./.env.*)
- Read(./secrets/**)
- Read(~/.aws/**)
- Read(~/.ssh/**)
Deny rules win over allow rules, so even if you later allow broad Read access, these paths stay blocked.
Tips
- Commit the deny list in .claude/settings.json so every teammate gets it.
- Add patterns for your own stack: .pem, terraform.tfstate, service-account.json.
- Deny Bash(curl:*) too if you do not want the agent sending data out.
- Test it: ask Claude Code to read .env and confirm it is refused.
Pair with ask rules
Use deny for things that must never happen, ask for things like git push that need a human, and allow for safe everyday commands like npm test.
Want the rest of the setup?
I keep copy-ready Claude Code configs (CLAUDE.md templates, slash commands, hooks, permission rules) in Vildanden Agent Config. There is a free sample: https://justly-mia-429.rehost.page/
Top comments (0)