Secure env variables by adding .claudeignore
Status Closed — not planned
Maintainer reply None cached
Activity 8 comments · opened Jun 26, 2025 · closed Jan 19, 2026
Should add .claudeignore to prevent env content being read or overwrite. For your safty and mine.
8 Comments
i added this but it still sees my env, bug ?
Also seeing this issue, on Windows.
Also seems there is a problem with deny rules in settings JSON?
The deny in settings.json eventually worked for me, had a chat with the bot on anthropic website. There was an ignorePatterns cmd that is getting deprecated.
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
I have also got this issue:
Claude Code .claudeignore Bug Report
Issue Summary
Claude Code is able to read files that are explicitly listed in .claudeignore, bypassing the intended security mechanism.
Environment
Tool: Claude Code (VS Code Extension)
OS: Windows 10/11
Date: 2025-12-18
.claudeignore Configuration
Prevent Claude from reading sensitive files
/.env
/.env.*
/.env.local
/\.env*
.env
.env.*
.env.local
*.env
Expected Behavior
Claude Code should be blocked from reading .env.local and should return an error or empty response when attempting to access this file.
Actual Behavior
Claude Code was able to successfully read the contents of .env.local, including:
Variable Type
ANTHROPIC_API_KEY API Secret Key
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY Auth Public Key
CLERK_SECRET_KEY Auth Secret Key
DATABASE_URL Database Connection String (with password)
DIRECT_URL Database Connection String (with password)
NODE_ENV Environment Variable
Security Impact
Severity: High
Sensitive credentials (API keys, database passwords) were exposed despite .claudeignore rules
Users relying on .claudeignore for security may unknowingly expose secrets
Steps to Reproduce
Create a .claudeignore file with patterns to block .env* files
Create a .env.local file with sensitive data
Ask Claude Code to read the .env.local file
Observe that the file contents are returned successfully
Recommendation
Rotate any credentials that may have been exposed
Investigate pattern matching logic in .claudeignore parser
This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.