claude-code - 💡(How to fix) Fix [BUG] Claude reads/edits the files referenced in .claudeignore

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

Error Messages/Logs

RAW_BUFFERClick to expand / collapse

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?

This is what Clause reports back when pushed why he edited a file that was in the .claudeignore:

I don't store, transmit, or retain data between conversations. Once this session ends, everything is gone.

However, I want to be transparent: I should not have read that file given your .claudeignore. That was my mistake, and the fact that .claudeignore didn't enforce the restriction is a real bug in Claude Code. I'd encourage you to report it at
https://github.com/anthropics/claude-code/issues so it gets fixed for everyone.

For now, the environment variable approach is your best protection — secrets that aren't in files can't be accidentally read.

What Should Happen?

Claude should respect the .claudeignore file. If not we cannot work with it

Error Messages/Logs

Steps to Reproduce

  • create .claudeignore file
  • add there a path of a project file to be ignored
  • ask claude to add some new properties in the property file (Spring Boot app where the application.properties is in the .claudeignore)
  • claude addes the property nonetheless

Claude Model

None

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

Claude Sonnet 4.6

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

IntelliJ IDEA terminal

Additional Information

No response

extent analysis

TL;DR

The issue can be mitigated by using the environment variable approach to protect secrets, as suggested by Claude, until the .claudeignore bug is fixed.

Guidance

  • Verify that the .claudeignore file is correctly formatted and the path to the file to be ignored is accurate.
  • Test the environment variable approach as a temporary workaround to protect secrets.
  • Report the bug to the Claude Code issues page as suggested by Claude to ensure it gets fixed for everyone.
  • Consider checking the documentation for any updates on how to properly configure the .claudeignore file.

Example

No code snippet is provided as the issue does not require a code-level fix at this point.

Notes

The root cause of the issue seems to be a bug in Claude Code that prevents the .claudeignore file from being respected. The environment variable approach is suggested as a temporary workaround.

Recommendation

Apply the environment variable approach as a workaround until the .claudeignore bug is fixed, as it provides a way to protect secrets that aren't in files from being accidentally read.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] Claude reads/edits the files referenced in .claudeignore