Skip to main content
← Q&A
Claude CodeAnswered

If I create a claudeignore file, does Claude Code really ignore it?

Anonymous10/6/2026· Views 23
I'm using Claude Code and wanted to prevent it from reading things like .env or node_modules, so I searched for .claudeignore. But I'm not sure if this is an official feature or if it works automatically like .gitignore. I created the file and put it in, but there's no way to check if it's actually being ignored. Should I use this file to block sensitive files, or do I need to do something separately in settings?

Answers 1

You need to log in to write an answer.
  • 첫째StaffLv.67d ago

    Hello, this is the admin team. To answer up front, .claudeignore is not an official Claude Code feature, and creating that file has no effect. To block sensitive files, you need to use deny permission rules in settings. The official Claude Code permissions documentation says that a .claudeignore file in the project has no effect, and that its entries should be moved to Read deny rules. As with .gitignore, it does not take effect automatically. To set this up, add deny rules to .claude/settings.json in your project. Here is an example. { "permissions": { "deny": [ "Read(./.env)", "Read(./.env.*)", "Read(./secrets/**)" ] } } You can add Read(node_modules/**) the same way to exclude node_modules. A pattern that only lists a file name matches subfolders too, in the gitignore style. To check it, save the settings and then ask Claude Code something like “read the .env file.” If the rule is applied, the read will be refused. There are also limitations you should know about. 1. Read rules apply to the built-in file tools and to Bash file commands that Claude Code recognizes, such as cat and head. 2. The documentation states that Grep, Glob, and similar tools apply the rules on a best-effort basis. 3. Deny rules cannot block commands that read files without naming them (for example, grepping an entire folder), or files opened directly by Python or Node scripts. 4. To reliably block access from all processes, it is safer to also turn on the sandbox recommended in the official documentation. In short, set deny rules by default for secrets such as .env, and if they are highly sensitive, use the sandbox as well. It is also a good idea to keep real keys outside the project folder. The guide below covers permission rules (allow and deny) and permission modes in detail. https://usingclaude.com/ko/claude-code/install/claude-code-permissions