claude-code - 💡(How to fix) Fix VS Code extension: new chat sessions auto-attach the currently focused editor file with no way to disable [1 comments, 2 participants]

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…
GitHub stats
anthropics/claude-code#58810Fetched 2026-05-14 03:38:56
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
labeled ×4commented ×1

Fix Action

Fix / Workaround

  • 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 under claude-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.
RAW_BUFFERClick to expand / collapse

Preflight

  • I have searched existing issues and this hasn't been reported
  • 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

  1. 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).
  2. Open a new "Untitled" Claude Code session in a new panel.
  3. 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>.
  4. 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 under claude-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:

  1. 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
  2. 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

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 VS Code extension: new chat sessions auto-attach the currently focused editor file with no way to disable [1 comments, 2 participants]