Repository navigation
Description
Preflight Checklist
- I have searched existing issues and this hasn't been reported yet
- This is a single bug report (please file separate reports for different bugs)
- I am using the latest version of Claude Code
What's Wrong?
The .claudeignore file is documented as a way to exclude files from Claude's context. However, Claude would appear to still be able to explicitly read files listed in .claudeignore (possibly using a read tool?), effectively bypassing the ignore rules.
What Should Happen?
Claude appears to read ignored files even if those files are listed in .claudeignore.
This makes the feature unreliable for excluding certain files.
Impact:
Users relying on .claudeignore to protect files have no real guarantee that those files are excluded from context.
This behavior has been observed both when using Claude from the terminal and via the VS Code extension.
Error Messages/Logs
Steps to Reproduce
- Add examplefile.json to .claudeignore 2. Ask Claude to show one of files listed in claudeignore 3. Claude reads and displays the content of file
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
No response
Claude Code Version
2.1.79
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
VS Code integrated terminal
Additional Information
This issue was observed while using Claude through the monthly subscription, not the Anthropic API. Specifically, it occurs when using Claude from the terminal and the VS Code extension.
The .claudeignore file was placed in the root of the project and was recognized by Claude.
Activity
github-actions commentedon Mar 19, 2026
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
π€ Generated with Claude Code
Madsim commentedon Mar 20, 2026
This is really annoying. Also it is not clear when claude code will ask for read permission and when it is just reading files out of the blue.
matt-savvy commentedon Mar 24, 2026
Can you link me the official documentation?
vasuchawla commentedon Mar 25, 2026
came here to report the same.
@matt-savvy if you ask claude (on web) example "how do i restrict claude code from reading .env", it would reply with
In Claude Code, add a .claudeignore file in your project root. Claude Code respects this file and will not read, reference, or suggest changes to anything listed in it β same concept as .gitignore.and when i asked
can i add this globally?it even suggested further
matt-savvy commentedon Mar 25, 2026
That's not what I asked about though. I just wanted to see the Claude Code documentation about this.
rjluebbert commentedon Mar 29, 2026
I am having the same issue. Claude subagents will ignore the .claudeignore to pull sensitive data into the thread
swapnildukare commentedon Apr 2, 2026
In official docs , I don't see any mention of .claudeignore file being supported
This is supported via third party hook - https://github.com/li-zhixin/claude-ignore
matt-savvy commentedon Apr 2, 2026
Almost as if this is not a feature of Claude Code
jaerith commentedon Apr 2, 2026
I am experiencing the same issue.
jasonb-occasio commentedon Apr 6, 2026
I first heard about the
.claudeignorefile on LinkedIn. I thought I'd search for the official documentation and found nothing except this closed GitHub issue from more than a year ago, where a contributor explicitly suggests using 'deny permission rules':#579
guys are we all hallucinating config files?
matt-savvy commentedon Apr 6, 2026
Yes
Madsim commentedon Apr 6, 2026
Regardless if this is actually a feature, the file reading is inconsistent as hell. Sometimes the model pops-up dialogs for every single read and sometimes it just uses file-tools to ingest multiple files without asking. File permissions should never be governed by model decisions, but by algorithmic solutions.
ttamg commentedon Apr 12, 2026
I also have the same issue and have seen it a number of times. My
.envis in both.gitignoreand.claudeignorewhen asking Claude Code to tell me what it did earlier in the thread it knows it read the file (I saw it do that too) and it says that the ignore files are not enforced. That seems to be an oversight.whitehatmiddleman commentedon Apr 17, 2026
I'm leveraging the CLAUDE.md rules section to understand what the file is. Until a fix is in place.
Add the following rule:
Example:
iuriguilherme commentedon Apr 18, 2026
@ttamg it is not an oversight, the feature doesn't exist and your agent is hallucinating.
kriss145 commentedon Apr 18, 2026
I can confirm this bug on macOS with the VS Code extension (Claude Code).
My .claudeignore contained .env, yet Claude read the file without any warning or permission prompt.
I tested this across multiple new sessions and the behavior is consistent: .claudeignore does not prevent the Read tool from accessing listed files.
chmod 600 .env also did not help, as Claude Code runs as the same OS user as the file owner.
This is a serious security issue. Users reasonably expect .claudeignore to act as an access boundary, not just an autocomplete hint. The documentation should clearly state this limitation until it is fixed - or the Read tool should actually respect .claudeignore.
Environment: macOS, VS Code extension, Claude Sonnet 4.6
kriss145 commentedon Apr 19, 2026
Move .env outside the project directory (one level up) and start for example dev server with:
npx dotenv-cli -e .env -- yarn --cwd app devThis keeps .env outside Claude Code's working directory entirely, so it won't be accessible regardless of .claudeignore behavior.
For npm users:
npx dotenv-cli -e ../.env -- npm run devIn my opinion it it the only safe solution.
Additional security tips:
ttamg commentedon Apr 19, 2026
OK an update as I did a load more testing and research.
Examples of the sort of preventions you can add to the the .claude/settings.json file to try to stop the tool calls reading your secret files. This is better than what we had but cannot be fully relied upon.
github-actions commentedon May 26, 2026
Closing for now β inactive for too long. Please open a new issue if this is still relevant.
github-actions commentedon Jul 22, 2026
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.