Add file exclusion for open-file context sent to Claude
Problem
The VS Code extension sends the contents of files currently open in the IDE as <system-reminder> context to Claude. There is no way to exclude specific files (e.g., .env, secrets.json, credentials) from this behavior.
Even with permissions.deny rules preventing Claude from using Read/Edit/Write on .env files, the IDE extension still sends their contents when the user has them open in a tab. This creates a secret leakage vector — especially problematic when hooks or logging (e.g., observability tools) capture conversation context.
Current workarounds
- Don't open
.envfiles in the IDE while Claude is active (fragile, easy to forget) respectGitIgnoreonly affects file searches, not open-file context
Proposed solution
Add a setting like:
{
"claudeCode.excludeFileContext": ["**/.env", "**/.env.*", "**/secrets/**"]
}
Files matching these glob patterns would not have their contents sent as system-reminder context, even if open in the editor.
Alternatively, respect the existing permissions.deny rules for Read() — if a file is denied for Read, its contents should not be sent as open-file context either.
Environment
- Claude Code VS Code extension v2.1.68
- WSL2 / Linux
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗