Denying Access to Files
Not every file should be visible to Claude Code — deny rules make secrets and irrelevant files invisible, not just off-limits.
Some files are huge and would just waste context, some contain secrets (API keys, credentials, .env files), and some are simply irrelevant to the task. A deny list in settings.json tells Claude Code those paths are completely off-limits: it won't discover them in search results, won't read them even if directly asked, and won't include them in context at all. This is a stronger guarantee than just “don't touch this” — it's “this doesn't exist as far as you're concerned.”
Real-life use cases
Protecting API keys by default
A project denies access to .env, any secrets/ folder, and credential files before the first real session starts, so even an unusual or ambiguous prompt can't accidentally surface a key in a response.
Keeping a client's data folder invisible
A consultant working across several client projects in one repo denies access to other clients' data directories, so a broad “search the whole project” instruction can't leak cross-client information.
Source
- Source video: “Claude Code Explained” — 27 concepts in 27 minutes (YouTube)https://www.youtube.com/watch?v=ZlDnsf_DOzg
- Permissionshttps://code.claude.com/docs/en/permissions