claude-code - 💡(How to fix) Fix [BUG] .claudeignore is silently ignored

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

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.

Error Messages/Logs

Code Example



---

{
  "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/**)"
    ]
  }
}
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?

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
  2. Ask Claude "can you see my env file?"
  3. 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/**)"
    ]
  }
}

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] .claudeignore is silently ignored