.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

  1. Create a .claudeignore file in the project root with these patterns:
.env*
**/.env*
**/.env.local
**/.env.production
**/.env.development
  1. Have a .env.local file in a subdirectory (e.g., web/.env.local)
  1. Start a fresh Claude Code session (not a restart - brand new session)
  1. Ask Claude to read the file using the Read tool
  1. 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 .claudeignore file 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

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗