VS Code extension: new chat sessions auto-attach the currently focused editor file with no way to disable
Preflight
- [x] I have searched existing issues and this hasn't been reported
- [x] This is a single bug / feature request
Problem
In the Claude Code VS Code extension, every new chat session auto-attaches the file currently focused in the editor as context to my first prompt — visible as a file chip next to the send button. I never asked for it; the model now treats that file as relevant context regardless of whether it has anything to do with the question I'm about to ask.
In a multi-session workflow this feels like sessions "inherit" focused files from each other. The IDE's currently-active editor tab is global state, but the chat session is supposed to be a fresh context. Switching between session tabs, or opening a brand-new "Untitled" session, drags whatever file happens to be focused into the new session's context. There is no setting to turn it off.
Reproduce
- Open a Claude Code session in the VS Code extension and do some work in it; have an arbitrary file open in the editor (e.g.,
docs/some-notes.md). - Open a new "Untitled" Claude Code session in a new panel.
- Before typing anything, observe that the file open in the editor is already attached as a chip in the prompt input. The system prompt also exposes it to the model as
<ide_opened_file>. - Type a question unrelated to that file. The model now has that file in context anyway.
Why this is a problem
- Context pollution. I'm asking about VS Code keybindings; the model gets a 500-line markdown file it has no reason to see.
- Cross-session bleed. The focused file is typically the artifact I was discussing in a prior session. A fresh session shouldn't inherit that context implicitly.
- No off-switch. Documentation at https://code.claude.com/docs/en/vscode covers
@-mentions and editor selection but does not describe this auto-attach behavior, and I can't find a setting for it underclaude-code.*in VS Code settings or in~/.claude/settings.json. - Workarounds fight the tool. I either click the X on the file chip every single prompt, or close the file in the editor before starting a session. Both feel wrong.
Expected
Either:
- A setting like
claudeCode.autoAttachFocusedFile: "off" | "selection-only" | "file"(default"selection-only"would be reasonable — keep the existing behavior for selections, drop the whole-file default), or - New sessions start with no auto-attached context — let me
@-mention what I want explicitly. The selection-attach behavior can stay.
Environment
- Claude Code VS Code extension (native), latest as of 2026-05-13
- VS Code on Linux (Ubuntu 24.04, remote SSH workflow)
- Multiple concurrent Claude Code session tabs is a normal workflow for me
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗