Claude Code can read .env files, private keys and cloud credential folders while helping you. The post shows how to block those paths outright with `permissions.deny` rules and share the list with your team.
Key points
- The deny list goes under `permissions.deny` in `.claude/settings.json` (team) or `settings.local.json` (personal).
- Sample patterns cover `Read(./.env)`, `Read(./.env.*)`, `Read(./secrets/**)`, `Read(~/.aws/**)` and `Read(~/.ssh/**)`.
- Deny rules beat allow rules, so broad `Read` access later added does not reopen those paths.
- Add patterns for your own stack such as `.pem`, `terraform.tfstate` and `service-account.json`.
- Deny `Bash(curl:*)` as well if you want to stop the agent from sending data out.
- Verify by asking Claude Code to read `.env` and confirming the request is refused.
Real-world use
- A developer joining a team that keeps secrets in `.env` files inherits the deny rules from one committed settings file.
- Stopping an agent running on a CI or cloud box from reaching credentials under `~/.aws` and `~/.ssh`.
- Closing off agent access to Terraform state and service account keys in a repo that stores them locally.
- Moving risky commands like `git push` to `ask` rules and everyday test commands to `allow` to define where human approval is required.
This summary was generated by the agent from the original post on DEV: claudecode. The full text and all rights belong to its author and publisher. Go to original