.claudeignore not blocking Read tool access to .env files
Resolved 💬 3 comments Opened Jan 9, 2026 by skycope Closed Jan 12, 2026
Bug Description
The .claudeignore file is not preventing the Read tool from accessing files that match the ignore patterns.
Steps to Reproduce
- Create a
.claudeignorefile in the project root with these patterns:
.env*
**/.env*
**/.env.local
**/.env.production
**/.env.development
- Have a
.env.localfile in a subdirectory (e.g.,web/.env.local)
- Start a fresh Claude Code session (not a restart - brand new session)
- Ask Claude to read the file using the Read tool
- The file contents are returned despite matching the ignore patterns
Expected Behavior
The Read tool should respect .claudeignore patterns and deny access to matching files.
Actual Behavior
The Read tool ignores the .claudeignore patterns and returns the full file contents, including sensitive credentials.
Additional Context
- This occurs in a fresh session - not a case of needing to restart for changes to take effect
- The
.claudeignorefile is correctly placed in the project root - Bash tool access to the same file IS blocked (as expected), only the Read tool bypasses the ignore
Environment
- Platform: macOS (Darwin 25.0.0)
- Claude Code version: latest
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗