A VS Code extension that connects VS Code with Claude Code (Anthropic), allowing you to get AI-powered code assistance with a diff preview before applying changes.
- Run on Selection: Send selected code to Claude for modification
- Run on Current File: Send the entire file to Claude for modification
- Diff Preview: View changes side-by-side before accepting them
- Two modes: Use either the Anthropic API or a local Claude CLI
- Install the extension from the VS Code Marketplace (or compile from source)
- Configure your settings (see below)
Open VS Code settings (File > Preferences > Settings) and search for "Claude Code":
For API Mode (default):
claudeCode.apiKey: Your Anthropic API key- Get one at: https://console.anthropic.com/
For CLI Mode:
claudeCode.cliPath: Path to your Claude CLI executable- Default:
/usr/local/bin/claude
- Default:
claudeCode.mode: Choose betweenapiorcli(default:api)claudeCode.model: The Claude model to use (default:claude-sonnet-4-5-20250929)
{
"claudeCode.mode": "api",
"claudeCode.apiKey": "sk-ant-api03-...",
"claudeCode.model": "claude-sonnet-4-5-20250929"
}- Select the code you want Claude to modify
- Open the Command Palette (
Cmd+Shift+P/Ctrl+Shift+P) - Run:
Claude Code: Run on Selection - Enter your task (e.g., "Add error handling", "Refactor this function")
- View the diff and decide whether to accept the changes
- Open the file you want Claude to modify
- Open the Command Palette (
Cmd+Shift+P/Ctrl+Shift+P) - Run:
Claude Code: Run on Current File - Enter your task
- View the diff and decide whether to accept the changes
- API keys are stored in VS Code settings (not in code)
- CLI mode uses
execFile(no shell interpolation) - Maximum response size: 200,000 characters
- No automatic file modifications - all changes require manual review via diff
# Install dependencies
npm install
# Compile TypeScript
npm run compile
# Watch mode for development
npm run watch# Install vsce if you don't have it
npm install -g @vscode/vsce
# Package the extension
vsce packageMIT
ClaudeSandman - Connecting VS Code with Claude Code by Anthropic