Claude Code in VS Code: Extension, Diffs, and Settings
There are two ways to use Claude Code in VS Code. The extension gives you a graphical chat panel with side-by-side diffs, plans you can annotate, and conversations in editor tabs. The CLI, run in VS Code's integrated terminal, gives you the full command set and still opens its diffs in VS Code's diff viewer, through a small local server the extension runs. Both share the same settings, CLAUDE.md files, MCP servers, and conversation history.
This guide follows Anthropic's VS Code documentation: installing and opening the extension, what context it sends with each prompt (and what it withholds), reviewing changes, plan mode, checkpoints, the settings that matter, how the CLI connects, and the shortcuts worth learning. Version numbers are noted where features are recent; the extension's version is the Claude Code version it bundles.
For JetBrains IDEs, see Claude Code for JetBrains. For the permission modes referenced throughout, see Claude Code Auto Mode.
Install, open, and sign in
You need VS Code 1.94.0 or later and an Anthropic account: any paid Claude plan (Pro, Max, Team, or Enterprise) or a Claude Console account. Bedrock, Google Cloud, and Foundry users configure the provider through the extension's environment settings instead.
Install from the Extensions view (Cmd+Shift+X / Ctrl+Shift+X, search "Claude Code"). The same extension installs in Cursor and other VS Code forks, or from the Open VSX registry.
The Spark icon marks Claude Code throughout VS Code. Click it in the editor toolbar (top right, visible when a file is open), in the Activity Bar for the sessions list, or ✻ Claude Code in the status bar. The Command Palette also has Claude Code: Open in New Tab. The first time you open the panel, click Sign in and finish in the browser.
One detail causes a lot of confusion: the extension bundles a private copy of the CLI for its panel, but it does not put claude on your shell PATH. To use claude in a terminal, claude mcp add, or claude --resume, install the standalone CLI as well.
Quick reference
- If the Spark icon does not appear after installing, run Developer: Reload Window from the Command Palette.
- If
ANTHROPIC_API_KEYis set in your shell but you still see the sign-in prompt, VS Code did not inherit your shell environment. Launch it from a terminal withcode .. - Editors that cannot install the extension can run the CLI in their own integrated terminal.
Remember this
Install the extension for the panel, and the standalone CLI too if you want claude in a terminal.
What context each prompt carries
The extension sends more than the text you type:
- The open file: Claude sees which file is open in the editor, even with nothing selected. Turn off Attach Open File (v2.1.271 or later) to send only selections.
- Your selection: highlighted code is included automatically, and the prompt footer shows how many lines. Press
Option+K(Mac) orAlt+K(Windows/Linux) to insert an explicit reference such as@app.ts#5-10. Click the X on the selection indicator to leave it out. - @-mentions: type
@and part of a name; matching is fuzzy, so@authfindsauth.jsorAuthService.ts. Add a trailing slash for a folder:@src/components/. - Attachments: paste an image into the prompt box, or hold
Shiftwhile dragging files in.
The extension also withholds selected text from some files. If a workspace file matches your files.exclude or search.exclude settings, or is ignored by git (with search.useIgnoreFiles and the extension's respectGitIgnore on, the defaults), Claude receives at most its path.
That filter applies to the chat panel only. When the CLI runs in the integrated terminal, it sends your selection whatever the file. To keep a file such as .env away from Claude in both, add a Read deny rule for its path.
Quick reference
- For large PDFs, ask for specific pages ("read pages 1-10"); this needs
poppler-utilson the machine where Claude Code runs. - A
Readdeny rule also stops the open-file notice for that file from reaching Claude in CLI sessions. - Selecting the exact lines you mean is usually better than describing them; Claude gets the file path and line numbers.
Remember this
Selections and the open file go along automatically; excluded files are filtered only in the panel, so use deny rules for secrets.
Permission modes and reviewing edits
The mode indicator at the bottom of the prompt box shows the permission mode; click it to switch. With Claude Code v2.1.283 or later, Auto is the built-in starting mode, so Claude edits most workspace files and runs routine commands without asking while a classifier blocks risky actions. The other modes are Manual (asks before edits and most shell commands), Edit automatically (edits without asking), and Plan.
In Manual mode, each proposed edit opens as a side-by-side comparison with a permission prompt. You can accept, reject, or tell Claude what to do instead. Since v2.1.275 you can review one change at a time with Accept this change and Reject this change buttons under each hunk, or from the editor's context menu. You can also edit the proposed content directly in the diff before accepting; Claude is told you modified it, so it does not assume the file matches its proposal.
Plan mode makes Claude describe what it will do and wait. VS Code opens the plan as a full Markdown document where you can add inline comments before Claude starts. Type /plan to switch, or /plan fix the auth bug to switch and start planning that task (v2.1.280 or later).
Quick reference
- If you want to approve every edit while learning, switch to Manual, or set the extension's
initialPermissionModetodefaultin your user settings. - VS Code reads
initialPermissionModefrom user settings only and ignores workspace values, so a repository cannot change your starting mode. allowDangerouslySkipPermissionsadds Bypass permissions to the selector. The docs say to use it only in sandboxes with no internet access.- Diffs with more than 100 changes open without per-change buttons.
Remember this
Check the mode indicator before you start: recent versions begin in Auto, and Manual is where per-change review happens.
Checkpoints, history, and multiple conversations
The extension tracks Claude's file edits as checkpoints. Hover over any message to show the rewind button, then choose:
- Fork conversation from here: a new conversation branch, keeping all code changes.
- Rewind code to here: revert file changes to that point, keeping the conversation.
- Fork conversation and rewind code: both.
Checkpoints cover edits made through Claude's file tools, not changes made by shell commands, so commit before large tasks.
Conversations are saved and listed in the sessions view (Spark icon in the Activity Bar), where you can filter and group them. Open several at once as editor tabs (Cmd+Shift+Esc / Ctrl+Shift+Esc for a new tab) or in separate windows. The extension and CLI share conversation history: run claude --resume in a terminal to pick up an extension conversation there. You can also resume cloud sessions from claude.ai in the extension.
Quick reference
- Inactive sessions are archived automatically after 14 days by default (
archiveInactiveSessions). Cmd+Shift+T/Ctrl+Shift+Treopens the most recently closed Claude tab.- Two conversations editing the same files in one workspace can overwrite each other; use separate worktrees for parallel work.
Remember this
Rewind covers Claude's file edits; git covers everything else. Tabs and claude --resume let you move between conversations and the CLI.
Settings that matter
The extension reads configuration from two places. Extension settings, in VS Code's settings UI, control the extension's own behaviour. Claude Code settings, in ~/.claude/settings.json and the project's .claude/settings.json, hold permission rules, hooks, MCP servers, and environment variables, and are shared with the CLI and the desktop app.
Put anything you want everywhere (rules, hooks, MCP) in the Claude Code settings files. Use the extension's environmentVariables for things the extension itself must see before it starts, such as ANTHROPIC_BASE_URL and a credential for an LLM gateway, because values only in ~/.claude/settings.json do not reach the extension's own login check.
Add "$schema": "https://json.schemastore.org/claude-code-settings.json" to a settings.json to get autocomplete and validation in VS Code.
| Setting | Default | What it does |
|---|---|---|
| initialPermissionMode | unset | Starting mode for new conversations; read from user settings only |
| preferredLocation | panel | Open Claude in a new tab (panel) or the right sidebar |
| autosave | true | Save files before Claude reads or writes them |
| respectGitIgnore | true | Exclude gitignored files from search and selection context |
| attachOpenFile | true | Send the open file's name with each message |
| environmentVariables | [] | Environment for the Claude process, e.g. gateway or provider variables |
| useTerminal | false | Launch Claude in terminal mode instead of the panel |
| allowDangerouslySkipPermissions | false | Add Bypass permissions to the mode selector |
Quick reference
- The command menu's Customize section (type
/) lets you view and edit hooks, permission rules, memory, and CLAUDE.md files from the panel in recent versions. - With
autosaveon, unsaved edits in your editor are written to disk before Claude reads the file, so Claude never works on stale content. - An
environmentVariablesentry forCLAUDE_CONFIG_DIRmust be an absolute path; the extension does not expand~.
Remember this
Shared behaviour goes in ~/.claude/settings.json; extension-only behaviour and pre-login environment go in VS Code settings.
The CLI in VS Code and the IDE server
Some features exist only in the CLI: the full set of commands and skills, the ! Bash shortcut, and tab completion. To use them without leaving VS Code, open the integrated terminal and run claude (with the standalone CLI installed). The CLI detects VS Code automatically. From an external terminal, run /ide inside Claude Code to connect it.
The connection works through a local MCP server the extension runs, named ide. Through it, the CLI opens diffs in VS Code's native diff viewer, reads your current selection for @-mentions, sends the active file path with each prompt, and can execute cells in a Jupyter notebook. The server binds to 127.0.0.1 on a random port. Each extension activation writes a fresh auth token to ~/.claude/ide/<port>.lock with 0600 permissions, and the CLI must present it to connect.
Only two of its tools are visible to the model: mcp__ide__getDiagnostics, which returns the errors and warnings from the Problems panel, and mcp__ide__executeCode, which runs Python in the active notebook's kernel after confirmation. If your organisation allowlists MCP tools with a PreToolUse hook, include them. In the chat panel, diagnostics come from a separate server, so rules must also name mcp__claude-vscode__getDiagnostics.
Quick reference
- Diagnostics are why the integration helps: Claude can check type errors in the Problems panel after an edit without running the full build.
- The transport is unencrypted
ws://on loopback; the docs note that a process able to capture that traffic could also read the token file, so TLS would add nothing. - If
claudeis not found in the integrated terminal, the standalone CLI is not installed or not onPATH.
Remember this
Run the CLI in the integrated terminal when you need its full command set; it still uses VS Code's diff viewer and diagnostics.
Shortcuts worth learning
Shortcuts depend on focus: when the cursor is in a file the editor is focused, and when it is in the prompt box Claude is. Cmd+Esc (Mac) or Ctrl+Esc (Windows/Linux) toggles between them, and it is the one shortcut to learn first.
Option+K/Alt+K: insert an @-mention for the current file and selection (editor focused).Cmd+Shift+Esc/Ctrl+Shift+Esc: open a new conversation in an editor tab.Cmd+Shift+T/Ctrl+Shift+T: reopen the last closed Claude tab.Ctrl+Option+F/Ctrl+Alt+F: toggle Focus view, which hides tool calls and thinking behind expandable rows.Cmd+N/Ctrl+N: new conversation, only if you enableenableNewConversationShortcut.
Every extension command is in the Command Palette under "Claude Code", including Accept Change at Cursor, Reject Change at Cursor, Show Logs, and Open Walkthrough for a guided tour.
Quick reference
- If
Cmd+Escdoes nothing on macOS Tahoe or later, the system Game Overlay shortcut has it: clear it under Keyboard Shortcuts > Game Controllers, or rebind Claude Code: Focus input. - Type
/btwwith a question for a side answer that does not enter the conversation. - Type
/in the prompt box for the command menu: model, effort, attachments, and the Customize section.
Remember this
Learn Cmd+Esc to jump between code and Claude, and Option+K to reference exactly the lines you mean.
Hands-on: a reviewed change from a selection
Use a small project with a test command.
1. Install the extension, open the panel from the Spark icon, sign in, and switch the mode indicator to Manual.
2. Select a function, press Option+K / Alt+K, and ask: "add input validation to this function and a test for it".
3. In the diff, accept one change, reject another, and edit one line yourself before accepting the file.
4. Hover over your first message and choose Rewind code to here. Confirm with git status that the edits are gone.
5. Install the standalone CLI, open the integrated terminal, run claude --resume, and pick the same conversation.
6. Add "deny": ["Read(./.env)"] to .claude/settings.json, select text in .env, and confirm Claude cannot read it from either the panel or the CLI.
Pass criterion: per-change review works, the rewind restores the files, the conversation resumes in the CLI, and .env stays unreadable in both.
Quick reference
- If no per-change buttons appear, check that the extension is v2.1.275 or later.
- If
claudeis not found in step 5, the standalone CLI is not on yourPATH. - If Claude still sees
.envtext from the terminal, check the deny rule path is relative to the project root with./.
Remember this
Practise per-change review, a rewind, and a deny rule once; they are the controls you rely on later.
Key takeaway
Claude Code in VS Code comes in two forms that share one engine. The extension gives you a chat panel that sends your open file and selection as context, opens Manual-mode edits as side-by-side diffs you can review change by change, turns plans into annotatable Markdown documents, and rewinds Claude's edits from any message. The CLI in the integrated terminal adds the full command set and connects back through a loopback IDE server for diffs, selections, and Problems-panel diagnostics.
Two things are easy to get wrong: recent versions start in Auto mode rather than asking before every edit, and the extension's exclusion of ignored files applies to the panel only, so secrets need a Read deny rule. For those rules, see Claude Code Permissions; for checks that run after every edit, see Claude Code Hooks.
Practice (25 min): run the six steps above, then set initialPermissionMode to the mode you want new conversations to start in.
References
- Claude Code docs: Use Claude Code in VS Code — checked Oct 17, 2026
- Claude Code docs: Choose a permission mode — checked Oct 17, 2026
Shoaib Hossain
Lead Author & Systems ArchitectSoftware engineer and distributed systems architect specializing in backend scalability, cloud-native infrastructure, databases, and AI engineering workflows. Author and maintainer of Core Concept Learning.
Related Articles
Explore this topic