[FEATURE] Persistent config option to disable IDE context sharing (opened files, selections)

Status Open
Reported on v2.1.159
Maintainer reply ✓ Yes — bcherny
Activity 10 comments · opened Jun 16, 2026
💡 Likely answer: A maintainer (bcherny, collaborator) responded on this thread — see the highlighted reply below.

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

The Claude Code VS Code extension automatically sends the currently opened file name and any highlighted text selection to the API as part of the system prompt context (ide_opened_file and ide_selection tags). There is no setting to disable this behavior.

There is a toggle in the input field UI (crossed eye icon) to disable this per session, but it does not persist between sessions or reboots. Every time the editor restarts, context sharing is re-enabled silently.

Additionally, the eye icon toggle is only visible when there are open editors. If no files are open when the session starts, there is no indication that this behavior is active. As soon as a file is opened, it gets shared silently before the user has a chance to toggle it off.

This is a privacy concern. When using Claude Code as a sidebar panel, any file open in the editor (including personal, medical, legal, or financial documents) has its filename and selection content sent to the API without persistent, explicit consent.

Proposed Solution

Add a persistent configuration option in settings.json to disable IDE context sharing entirely:

{
  "claudeCode.sendEditorContext": false
}

Or more granular options:

{
  "claudeCode.sendOpenedFileName": false,
  "claudeCode.sendEditorSelection": false
}

The setting should persist across sessions and reboots, unlike the current per-session toggle.

Alternative Solutions

  • The in-UI toggle (crossed eye icon) exists but resets every session. Making that toggle persist would be a minimal fix.
  • Closing sensitive files before using Claude Code works but is not practical when using the sidebar panel alongside normal editor work.

Priority

High - Significant impact on productivity

Feature Category

Configuration and settings

Use Case Example

  1. User opens a personal document in VS Code (medical notes, personal writing, financial records)
  2. User switches to the Claude Code sidebar panel to work on a coding task
  3. The extension silently sends the personal document's filename (and any selected text) as context in the API request
  4. User has no persistent way to prevent this. The per-session toggle resets on every restart
  5. With this feature, the user could set sendEditorContext: false once and never worry about accidental context leakage

Additional Context

  • The DISABLE_TELEMETRY and DO_NOT_TRACK environment variables do not affect this behavior, as it is part of the core API request, not telemetry
  • This is especially important for users in regulated industries or with strict personal privacy requirements
  • Related issues: #24726 (open since Feb 2026, no dev response), #40869 (open since May 2026, reports of credential leaks), #53518 (closed as stale)
  • See comment below for a proof-of-concept patch with code analysis

Environment

  • Claude Code VSIX version: 2.1.159 (Anthropic.claude-code-2.1.159@linux-x64)
  • IDE: VSCodium 1.100.3 (also affects VS Code)
  • OS: Linux (Nobara 43 / Fedora)

View original on GitHub ↗

9 Comments

github-actions[bot] · 2 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/68837
  2. https://github.com/anthropics/claude-code/issues/24726
  3. https://github.com/anthropics/claude-code/issues/20944

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

ScrewTSW · 2 months ago

Related issues requesting similar functionality:

  • #24726 (open since Feb 2026, 15+ comments, no dev response)
  • #40869 (open since May 2026, reports of accidental credential leaks)
  • #53518 (closed as stale without resolution)

This request differs in a specific way: the per-session eye icon toggle in the input field UI already exists, but it resets on every session restart or reboot. I'm asking for a persistent config option so I don't have to remember to disable it every time I open the editor.

Additionally, the eye icon toggle is only visible when there are open editors. If no files are open when I start the session, there is no indication that this behavior is active. As soon as I open a file, it gets shared silently before I even have a chance to toggle it off.

I use Claude Code as a sidebar panel alongside normal editor work. Every file I open or select text in gets silently sent as API context. When I have personal or sensitive documents open, there is no persistent way to prevent this from being shared. The toggle resetting on restart means the default is always "share everything" regardless of my preference.

ScrewTSW · 2 months ago

Proof-of-concept patch (updated)

I traced the relevant code in the extension webview (version 2.1.159, webview/index.js).

What controls the behavior:

The includeSelection React state determines whether the currently opened file name and text selection are injected into the API request as <ide_opened_file> and <ide_selection> tags. This state is initialized via useState(!0) (i.e. true), meaning context sharing is always on when the extension loads.

The eye icon toggle in the input field calls a state setter to flip this value, but since it is component state (useState), it resets to true on every session start, window reload, or reboot.

Where it lives in the minified code (2.1.159):

In webview/index.js, the oe1 component (which receives {session:$, context:Z, ...}) initializes the state at byte offset ~4748401:

useRef(!0),[P,_]=n1.useState(!0),[M,w]=n1.useState(!1)
//                            ^^-- includeSelection default (true)

P is passed as includeSelection to the input component, which gates whether the selection/file data reaches the EB1 function (byte offset ~3154893) that builds the user message content array:

async function EB1($,Z,J,Y,X,Q,G){
  let q=[];
  if(J)  // J = includeSelection, when true:
    if(J.selectedText)
      q.push({type:"text",text:`<ide_selection>...`});
    else
      q.push({type:"text",text:`<ide_opened_file>...`});

What the patch does:

The oe1 component already has access to the session config via $.config.value?.claudeSettings?.effective, which mirrors all keys from ~/.claude/settings.json. The settings schema has "additionalProperties": {} at the root, so custom keys are accepted without schema changes.

The patch replaces the hardcoded useState(!0) with a check against a disableEditorContext key in settings.json:

// Before:
[P,_]=n1.useState(!0)

// After:
[P,_]=n1.useState(!($.config.value?.claudeSettings?.effective?.disableEditorContext===true))

When "disableEditorContext": true is in ~/.claude/settings.json, the toggle defaults to off. The eye icon toggle still works for per-message override. The setting persists across sessions and reboots.

To use:

  1. Apply the patch: https://gist.github.com/ScrewTSW/3b9fc6f053fae26ef60f3e73e6f7d7e2
  2. Add to ~/.claude/settings.json:

``json
"disableEditorContext": true
``

  1. Reload VS Code/VSCodium

This is a workaround patch against minified code (written for 2.1.159, variable names will differ across versions). The proper fix from Anthropic would be adding disableEditorContext to the official settings schema and reading it natively in the source.

ScrewTSW · 2 months ago

Update: image paste remount fix

The original patch had a bug where pasting an image or adding an attachment would reset the toggle back to ON.

The oe1 component has key={$.activeSession.value.internalId} as a React key. Pasting an image can cause React to remount the component, which re-evaluates the useState initial value. If $.config.value hasn't loaded yet at that point, the optional chaining falls through and the toggle defaults back to ON, silently re-enabling context sharing.

Fixed with a three-way check:

// Before (broken on remount):
$.config.value?.claudeSettings?.effective?.disableEditorContext===true?!1:!0

// After (safe default when config not loaded):
$.config.value?.claudeSettings?.effective?.disableEditorContext===true?!1:$.config.value?.claudeSettings?!0:!1

Logic:

  1. disableEditorContext === true -> OFF
  2. claudeSettings exists but key is absent -> ON (original behavior)
  3. claudeSettings is undefined (config not loaded) -> OFF (safe default)

Gist updated with the fix.

padixa · 1 month ago

Automatically injecting the active editor's full file content into every API request poses a serious security risk (e.g., when developers inadvertently have .env or credentials open in a tab).

Asking users to remember toggling off the context button for every message is error-prone. To improve workspace safety, could we consider:

Adding a global setting to disable automatic active-file context injection (e.g., claude.autoIncludeActiveFile: false)?

This would make the extension much safer for enterprise and security-conscious environments.

ScrewTSW · 1 month ago
Automatically injecting the active editor's full file content into every API request poses a serious security risk (e.g., when developers inadvertently have .env or credentials open in a tab). Asking users to remember toggling off the context button for every message is error-prone. To improve workspace safety, could we consider: Adding a global setting to disable automatic active-file context injection (e.g., claude.autoIncludeActiveFile: false)? This would make the extension much safer for enterprise and security-conscious environments.

my patch does it via a config entry, that could easily be added into VSCode/VSCodium settings interface and defaults it to off, with an easy per-case toggle at the usual Claude Code interface location. It behaves exactly like if you hide the file manually, only does it by default

ScrewTSW · 1 month ago

I've updated the patcher gist to run against 2.1.220 (latest at time of making) and added version pinning option https://gist.github.com/ScrewTSW/3b9fc6f053fae26ef60f3e73e6f7d7e2

ScrewTSW · 1 month ago

Unrelated to the issue, but I've also added --add-bars optional flag that enables usage statistics in the bottom bar
https://gist.github.com/ScrewTSW/3b9fc6f053fae26ef60f3e73e6f7d7e2

Third Party provider shows total conversation tokens used:
<img width="750" height="102" alt="Image" src="https://github.com/user-attachments/assets/86567cf4-ced8-4cf4-864a-7e0f29ce9fb4" />
Anthropic subscription shows the standard Account and Subscriptions bars:
<img width="700" height="108" alt="Image" src="https://github.com/user-attachments/assets/67f3d3cb-78b3-47f5-93b6-a668d5f6f27b" />

bcherny collaborator · 13 days ago

Thanks for raising this. There is one persistent option today, though it is per-path rather than global: adding a Read deny permission rule for a file or pattern prevents both the selected text and the open-file notice for that path from being sent to Claude, and permission rules persist in your settings across sessions.

See: https://code.claude.com/docs/en/vs-code#how-the-extension-and-cli-connect (the "Selection and open-file context" note) and https://code.claude.com/docs/en/permissions#read-and-edit

A global, persistent "never share editor context" setting is not available yet, so we'll leave this open to track that.

🤖 Generated with Claude Code

Showing cached comments. Read the full discussion on GitHub ↗