Claude Code Integration with VS Code: Setup Guide
If you want to run Claude Code directly inside your editor instead of switching to a terminal window, the integration works through a VS Code extension that connects to your existing terminal session. You install the extension, open a project, and Claude Code appears as a panel that reads your open files, understands your project structure, and can edit code with your approval — all without leaving VS Code.
This article walks through the actual setup: what to install, how the extension talks to the CLI, common keybindings, and how to fix the connection issues people run into most. If you're evaluating whether this workflow fits your team, skip to the FAQ at the end for quick answers.
What the VS Code integration actually does
Claude Code is a command-line tool at its core. The VS Code extension doesn't replace that — it wraps it. When you install the extension and run Claude Code from VS Code's integrated terminal, the extension automatically:
- Detects the running Claude Code session and connects to it
- Shows diffs inline in the editor instead of as raw terminal text
- Lets you jump from a suggested change to the exact file and line
- Shares your current selection or open tab as context when you ask a question
So the "integration" is really a bridge between the CLI process and the editor UI. If you close VS Code, the CLI session in the terminal is still running; if you kill the terminal process, the extension loses its connection.
Installing and connecting
- Install VS Code (1.80 or later works reliably).
- Install the Claude Code CLI on your machine following the official installer for your OS.
- Install the Claude Code extension from the VS Code marketplace.
- Open a project folder in VS Code — not just a single file.
- Open the integrated terminal (
Ctrl+\/Cmd+\``) and run:
claude
- The extension should detect the session automatically. If it doesn't, use the command palette (
Cmd+Shift+P/Ctrl+Shift+P) and run Claude Code: Connect.
If the extension shows "no active session," the most common cause is running claude in a terminal that isn't the one VS Code is tracking (for example, a separate system terminal window). Always launch the CLI from VS Code's own integrated terminal for the connection to work reliably.
Working with diffs and file edits
Once connected, asking Claude Code to make a change produces a diff view rather than a terminal dump of code. You can:
- Accept or reject each hunk individually
- Open the affected file directly from the diff
- Ask for a revision before accepting, using the same conversation thread
This matters for larger refactors. Instead of copy-pasting a full file rewrite from a terminal into your editor, you review changes the same way you'd review a pull request — hunk by hunk, in context, with syntax highlighting intact.
Useful keybindings and commands
A few defaults worth knowing (check Keyboard Shortcuts and search "claude" if your version differs):
- Send selection to Claude Code: highlight code, then trigger the command to add it as context for your next prompt.
- Open Claude Code panel: toggles the sidebar view without needing the terminal focused.
- Apply last suggestion: re-runs the accept action on the most recent diff without scrolling back.
Binding "send selection" to a key you use often (I map it near my "format document" shortcut) speeds up the loop of select → ask → review noticeably compared to describing the code location in plain text.
Multi-file context and project awareness
Claude Code indexes your project directory when it starts, which means it can reference files you haven't explicitly opened. This is different from many chat-based coding assistants that only see the current tab. Practical implications:
- Large monorepos take longer to index on startup — start the session before you go get coffee, not right when you need an answer.
- Ignore files (
.gitignore-style exclusion) matter: if yournode_modulesor build output isn't excluded, indexing slows down and irrelevant files pollute suggestions. - For very large repos, scoping Claude Code to a subdirectory (running it from that folder instead of the repo root) often gives faster, more relevant answers than trying to make it aware of everything at once.
When you need programmatic access instead
The VS Code extension is built for interactive, in-editor use — one developer, one session, reviewing diffs in real time. It's not designed for calling Claude from a script, a CI pipeline, or a backend service. If you need that kind of access — for example, generating code review comments automatically on pull requests, or running batch documentation updates — you need a proper API key rather than an editor extension.
That's a different problem than IDE integration, and it's where a service like SubToAPI is useful: it turns your existing Claude access into a standard HTTPS API with application keys (sub_live_...), streaming, and usage metadata, so you can call Claude from any script or CI job the same way you'd call any other API, without building your own auth and billing layer around it. Check the quickstart if you want to see how a basic request looks, or the streaming docs if your automation needs incremental output rather than a single blocking response.
Troubleshooting common issues
Extension shows "disconnected" repeatedly. Restart the integrated terminal and relaunch claude from it — don't reuse a terminal tab that was open before you installed or updated the extension.
Diffs don't apply cleanly. This usually means the file changed on disk after Claude Code read it (another process, a git pull, a formatter). Reload the file and re-ask.
Slow responses on large repos. Scope the session to a subfolder, or exclude build artifacts and dependency folders from indexing.
Context feels stale after switching branches. Restart the Claude Code session after a branch switch — it doesn't automatically detect that the underlying files changed identity.
Questions
Does the VS Code extension require a separate subscription from Claude Code itself? No — the extension is a UI layer on top of the CLI tool you already have installed and authenticated. It doesn't add its own billing.
Can I use Claude Code in VS Code without the integrated terminal? Not reliably. The extension connects to a running CLI session, and the integrated terminal is the connection point it's built to detect.
Is this the same as calling Claude through an API in my own application? No. The VS Code integration is for interactive editing in one session. For calling Claude programmatically from scripts or backend services, you need a direct API setup — see /docs for how that works separately from the editor extension.