Setup
Claude in VS Code: Pair Programming
Claude Code is Anthropic's official CLI for Claude — and it integrates directly into VS Code as an extension. Once connected, Claude can read your open files, understand your project context, and work alongside you inside the editor rather than in a separate browser tab. This chapter covers installation, sign-in, and the key ways you interact with Claude from inside VS Code.
What You're Installing
There are two distinct things, and it's worth being clear about both:
- Claude Code CLI — the command-line tool that runs Claude. This is the engine. It can be used standalone in a terminal, or surfaced through the VS Code extension.
- Claude Code VS Code extension — the editor integration. It adds a Claude panel, inline code actions, and keyboard shortcuts. Underneath, it talks to the same CLI.
You need both. The extension alone does nothing without the CLI installed. Most installation flows handle this automatically — but it's useful to know the two layers exist.
Installation
Claude Code CLI requires Node.js 18 or later. Check with
node --version. If you need it, download from nodejs.org — the LTS version is fine.
Open a terminal and run:
npm install -g @anthropic-ai/claude-codeThis installs the
claude command globally. Verify with claude --version.
In VS Code: open the Extensions panel (Ctrl+Shift+X), search for Claude Code, and install the extension published by Anthropic. You'll see the Claude icon appear in the Activity Bar on the left.
Click the Claude icon in the Activity Bar (or press Ctrl+Shift+P → Claude: Sign In). A browser window opens for OAuth sign-in with your Anthropic account. Once authenticated, return to VS Code — the panel activates.
Claude Code is much more useful with a folder open (Ctrl+K Ctrl+O) than with a single file. When a folder is open, Claude can see all files in the project and understand the overall structure — not just the active tab.
Type a message in the Claude panel: "What files are in this project?" — Claude should respond with a summary of the folder contents. If it can, the setup is working correctly.
The VS Code Interface — What's Where
claude CLI commands directly. Useful for running slash commands or scripted tasks that go beyond the chat panel.Key Keyboard Shortcuts
Ctrl+K Ctrl+S), search for "Claude", and reassign any binding that conflicts with your existing setup. On macOS, Ctrl is typically Cmd.
Two Ways to Work with Claude in VS Code
- Full conversation — multi-turn, with history
- Good for questions, explanations, and planning
- Claude can reference multiple files at once
- Responses include code blocks you can insert
- Best for: "explain how this module works" or "help me design this feature"
- Single instruction, applied directly to selected code
- No conversation history — one-shot per invocation
- Result appears as a diff you can accept or reject
- Best for: "rename this variable", "add error handling", "convert to async"
- Fastest path for small, precise changes
In practice you'll use both: the chat panel for anything that needs thought or context, and the inline editor for quick targeted changes. The two modes complement each other — use chat to plan and understand, use inline to execute.
Your First Real Interaction
With the extension installed and a project folder open, try this sequence to get a feel for the tool:
- Open a source file you know well.
- In the Claude panel, type: "Give me a one-paragraph summary of what this file does." — Claude reads the open file and responds.
- Select a function in the editor, right-click, and choose Explain with Claude. Read the explanation.
- Select the same function, press Ctrl+I, and type: "Add a docstring." Accept the diff.
- In the chat panel, ask: "What files in this project relate to authentication?" — Claude searches across the project, not just the open file.
These five steps cover the core interaction patterns. Everything in the following chapters builds on them.