[BUG] .claudeignore is silently ignored

Resolved 💬 3 comments Opened May 7, 2026 by adrianszablowski Closed May 11, 2026

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)
  • [x] I am using the latest version of Claude Code

What's Wrong?

I added a .claudeignore file to my project hoping it would stop Claude from reading my .env files. It didn't work. Claude read the env file with all my secrets and pulled them into the conversation.

There is no warning. No error. No mention in the docs. The file just sits there doing nothing, while I think my secrets are safe.

What Should Happen?

Make .claudeignore work. Use the same syntax as .gitignore. Apply it to all file reading tools (Read, Glob, Grep, and shell commands like cat) or if you don't plan to support it, show a warning when one exists in the project. Something like: Found .claudeignore but Claude Code doesn't use this file. Use permissions.deny in .claude/settings.json instead.

Error Messages/Logs

Steps to Reproduce

  1. In any project, create .claudeignore at the root with:

.env
secrets/
*.pem

  1. Ask Claude "can you see my env file?"
  2. Claude reads it. The secrets are now in context.

Claude Model

Not sure / Multiple models

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.132

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

After finding out .claudeignore does nothing, I had to block env files manually using permissions.deny in .claude/settings.json.

{
  "permissions": {
    "deny": [
      "Read(**/.env)",
      "Read(**/.env.local)",
      "Read(**/.env.*.local)",
      "Read(**/.env.development)",
      "Read(**/.env.production)",
      "Read(**/.env.staging)",
      "Read(**/.env.test)",
      "Read(**/secrets/**)",
      "Read(**/*.pem)",
      "Read(**/*.key)",
      "Read(**/*.p12)",
      "Read(**/*.pfx)",
      "Read(**/credentials.json)",
      "Read(**/service-account*.json)",
      "Read(**/id_rsa)",
      "Read(**/id_ed25519)",
      "Bash(cat **/.env)",
      "Bash(cat **/.env.local)",
      "Bash(cat **/.env.*.local)",
      "Bash(cat **/secrets/**)"
    ]
  }
}

View original on GitHub ↗

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