Claude Code for VSCode
A VSCode extension that integrates Claude Code API with full tool access, allowing Claude to read/write files, execute commands, and interact with your workspace through the VSCode chat interface.
🚀 Current Status
Development Phase: Active Development ✅
Last Updated: November 21, 2025
Git Status: Fresh repository with privacy configurations
Recent Progress
- ✅ Major Refactoring: Migrated from custom tool execution to VS Code's native language model API
- ✅ Tool Call Parsing: Implemented robust parsing for embedded tool calls in Claude's responses
- ✅ Interactive Flow: Fixed tool execution flow using VS Code's callback mechanism
- ✅ Tool Name Mapping: Created comprehensive mapping between Claude function names and VS Code tools
- ✅ Privacy Setup: Configured for private repository with security workflows
- ✅ Clean Git History: Fresh repository with proper .gitignore and documentation
Current Implementation
- Uses VS Code's native
LanguageModelChatProvider API
- Supports streaming responses with embedded tool call detection
- Handles thinking blocks and complex response formats
- Comprehensive error handling and debugging capabilities
- Tool execution through VS Code's native tool system
Features
- Multi-Provider Support: Support for both Claude API and OpenAI-compatible APIs
- Chat Integration: Chat with AI models directly in VSCode's chat panel
- Tool Access: AI models can execute tools to interact with your workspace:
- File Operations: Read, write, edit, search files
- Terminal Commands: Execute shell commands
- Git Operations: Status, commit, push, branch management
- VSCode Integration: Open files, run tasks, get/set selections
- Streaming Responses: Real-time streaming of responses
- Advanced Tool Call Handling: Parses embedded tool calls from AI responses
- Native VS Code Integration: Uses VS Code's built-in language model and tool APIs
- Secure API Key Storage: API keys stored in VSCode's secure secret storage
- Provider Switching: Easy switching between different API providers
- Fallback Support: Automatic fallback to secondary provider on errors
- Configurable: Custom API endpoints and model selection
Supported Providers
Claude API
- Endpoint: Custom Claude-compatible proxy (default:
https://claude.chutes.ai)
- Models: moonshotai/Kimi-K2-Thinking, MiniMaxAI/MiniMax-M2, zai-org/GLM-4.6
- Features: Full tool support, streaming responses, thinking blocks
OpenAI API (Chutes AI)
- Endpoint:
https://llm.chutes.ai/v1/chat/completions
- Models: OpenAI-compatible models (GPT-3.5, GPT-4, etc.)
- Features: Tool calling support, streaming responses, vision capabilities (planned)
- API Key Format: Standard OpenAI
sk- keys
Requirements
- VSCode 1.90.0 or higher
- GitHub Copilot Chat extension (for the chat interface)
- Claude API key or proxy with Claude Code compatible API
Installation
From Source
- Clone or download this repository
- Run
npm install to install dependencies
- Run
npm run compile to compile TypeScript
- Open the project in VSCode
- Press F5 to launch a new VSCode window with the extension loaded
Packaging for Distribution
npm install
npm run compile
# Use vsce to package
npx vsce package
Setup
1. Initial Configuration
When you first activate the extension, you'll be prompted to configure it. You can also run:
Claude Code: Configure Claude Code Extension - Full configuration wizard
Claude Code: Set Claude API Key - Set API key only
2. Configuration Options
Configure via VSCode Settings (Settings > Claude Code):
Provider Settings
claude-code.provider: API provider to use (claude or openai, default: claude)
Claude API Settings
claude-code.apiUrl: Claude API proxy URL (default: https://claude.chutes.ai/)m
claude-code.model: Model to use (default: moonshotai/Kimi-K2-Thinking)
OpenAI API Settings
- Endpoint: Fixed to
https://llm.chutes.ai/v1/chat/completions
- API Key: Set via
Claude Code: Set OpenAI API Key command
- Models: OpenAI-compatible models (configure in
claude-code.model setting)
General Settings
claude-code.maxTokens: Maximum tokens in responses (default: 4096)
claude-code.enableTools: Enable VSCode tool execution (default: true)
claude-code.temperature: Controls randomness (0.0-1.0, default: 1.0)
claude-code.system: Custom system prompt (optional)
3. API Key Setup
Your API key is stored securely in VSCode's secret storage.
Claude API Key
Run Claude Code: Set Claude API Key command or use the configuration wizard.
Supported formats:
- Direct Anthropic API: Get from Anthropic Console
- Claude Code Proxy: Compatible proxy with Anthropic API format (starts with
cpk_)
- AWS Bedrock: If using AWS Bedrock with Claude
OpenAI API Key (Chutes AI)
Run Claude Code: Set OpenAI API Key command.
- Format: Standard OpenAI API keys (starts with
sk-)
- Endpoint: Automatically uses
https://llm.chutes.ai/v1/chat/completions
4. Provider Management
Switching Providers
- Run
Claude Code: Switch API Provider command
- Or configure via settings:
claude-code.provider
Provider Status
- Run
Claude Code: Show Provider Status to see current configuration
- Status bar shows current provider:
$(claude) Claude API or $(robot) OpenAI API
Usage
Starting a Chat
- Open the VSCode Chat panel (
Ctrl+Shift+I or Cmd+Shift+I on Mac)
- Type
@claude followed by your question or request
- Or use the default chat with
/claude command
Examples
Basic Chat
@claude How do I create a React component in TypeScript?
With File Context
@claude Read the file app.ts and explain what it does
Code Explanation
- Select code in the editor
- Type:
@claude /explain Explain this code
Code Fix
- Select code with errors
- Type:
@claude /fix Fix any errors in this code
@claude Read package.json, then run npm install to install dependencies
File Operations (file_operations)
read: Read a file
{"operation": "read", "path": "src/index.ts"}
write: Write or overwrite a file
{"operation": "write", "path": "src/new.ts", "content": "// code here"}
edit: Edit specific lines in a file
{"operation": "edit", "path": "src/index.ts", "start_line": 10, "end_line": 15, "new_content": "// new code"}
glob: Find files by pattern
{"operation": "glob", "pattern": "**/*.ts"}
grep: Search for text in files
{"operation": "grep", "pattern": "**/*.ts", "search": "function"}
Terminal (terminal)
Execute commands in the terminal:
{"command": "npm install", "working_directory": "."}
Git Operations (git)
status: Get git status
{"operation": "status"}
add: Stage files
{"operation": "add", "files": ["src/index.ts"]}
commit: Commit changes
{"operation": "commit", "message": "Your commit message"}
push: Push to remote
{"operation": "push"}
branch: Create/switch branch
{"operation": "branch", "branch_name": "feature/new-feature"}
VSCode Integration (vscode)
open_file: Open a file in editor
{"operation": "open_file", "file_path": "src/index.ts"}
run_task: Run a VSCode task
{"operation": "run_task", "task_name": "build"}
get_selection: Get current selection
{"operation": "get_selection"}
set_selection: Set selection text
{"operation": "set_selection", "text": "new text"}
show_information_message: Show info message
{"operation": "show_information_message", "message": "Hello!"}
Security Considerations
⚠️ Important: This extension allows Claude to execute commands and modify files on your system.
Safety Features
- Tool Permissions: All tools can be disabled via
claude-code.enableTools setting
- Path Validation: File operations are restricted to the workspace
- Confirmation: No actions are taken without your explicit request
- API Key Security: Keys stored in VSCode secure storage, not in plain text
Best Practices
- Review Tool Usage: Always review what tools Claude is executing
- Use Version Control: Ensure your code is in git before allowing modifications
- Check API Endpoint: Verify your API endpoint is correct and trusted
- Restrict Tools: Disable tools you don't need via settings
- Monitor Execution: Pay attention to the status bar showing tool execution
Troubleshooting
Run the configuration wizard:
- Press
Ctrl+Shift+P (or Cmd+Shift+P on Mac)
- Type "Configure Claude Code Extension"
- Enter your API key when prompted
Current Status: ✅ RESOLVED - Tool execution now works with VS Code native API
If you experience issues:
- Check VSCode Developer Console for tool call parsing logs
- Verify tool names are properly mapped in
mapToolName() function
- Ensure VS Code has the required tools available
- Check that
claude-code.enableTools: true in settings
Recent Fixes Applied:
- Fixed embedded tool call parsing from response text
- Implemented proper VS Code callback flow
- Added comprehensive tool name mapping
- Enhanced error handling and debugging
API Errors
- 401 Unauthorized: Check your API key is correct
- 403 Forbidden: Verify your API key has access to the model
- 404 Not Found: Check the API endpoint URL is correct
- 429 Rate Limit: You've hit rate limits, wait and try again
Extension Won't Activate
- Check VSCode version: Must be 1.90.0 or higher
- Check output panel: Select "Claude Code Extension" from dropdown
- Restart VSCode
- Verify the language model provider is registered correctly
- Ensure you have Git installed and in PATH
- Open a folder with a git repository initialized
- Check the Git extension is enabled in VSCode
For debugging tool execution issues:
- Open VSCode Developer Tools (
Help > Toggle Developer Tools)
- Check Console tab for
[Claude Provider] log messages
- Look for tool call parsing and execution logs
- Verify the interactive flow: parse → report → execute → callback
Known Issues & Solutions
| Issue |
Status |
Solution |
| Tool calls not executing |
✅ Fixed |
Implemented proper VS Code callback flow |
| Tool name mismatches |
✅ Fixed |
Added comprehensive tool name mapping |
| JSON parsing errors |
✅ Fixed |
Added malformed JSON fixing logic |
| Leading whitespace in tool calls |
✅ Fixed |
Enhanced regex parsing with trimming |
| Tool calls in thinking blocks |
✅ Fixed |
Updated parsing to handle thinking blocks |
Development
Building
# Install dependencies
npm install
# Compile TypeScript
npm run compile
# Watch mode for development
npm run watch
# Lint
npm run lint
Current Project Structure
src/
├── extension.ts # Main extension activation and registration
├── ClaudeLanguageModelProvider.ts # Core language model provider with VS Code native API
├── ClaudeApiClient.ts # Claude API client for communication
├── ConfigurationManager.ts # Settings and configuration management
└── types.ts # TypeScript type definitions
# Removed files (migrated to VS Code native tools):
# - ClaudeChatParticipant.ts (replaced by ClaudeLanguageModelProvider)
# - ToolService.ts (now using VS Code native tools)
# - ToolExecutor.ts (now using VS Code native tools)
# - tools/ directory (now using VS Code built-in tools)
Architecture Changes
Previous Architecture (Custom Tool System):
- Custom tool execution engine
- Manual tool registration and management
- Complex tool call handling
Current Architecture (VS Code Native):
- ✅ Uses VS Code's
LanguageModelChatProvider API
- ✅ Leverages VS Code's built-in tool system
- ✅ Simplified tool call parsing and execution
- ✅ Better integration with VS Code ecosystem
Key Implementation Details
- Claude generates responses with embedded tool calls
parseEmbeddedToolCalls() extracts tool calls from response text
- Tool names are mapped using
mapToolName() function
- Tool calls are reported to VS Code via
progress.report()
- VS Code executes tools and calls back with results
- Provider continues conversation with tool results
The extension includes comprehensive mapping between Claude's function names and VS Code tool names:
functions.read_file → read_file
functions.execute_command → run_in_terminal
functions.search_files → file_search
- And many more...
Development Notes
- Tool Execution: Now handled by VS Code's native tool system
- Streaming: Implemented with proper progress reporting
- Error Handling: Comprehensive error handling and logging
- Debugging: Extensive logging for troubleshooting tool execution
- Privacy: Configured for private repository with security workflows
To add support for new tools:
- Update the
toolMapping object in mapToolName() method
- Add the new tool name mapping:
'claude.function.name': 'vscode_tool_name'
- Test the tool execution flow
- Update documentation as needed
Privacy & Security
⚠️ Important: This repository should be kept PRIVATE as it may contain:
- API keys and configuration files
- Personal development settings
- Sensitive workspace information
Privacy Checklist
- [ ] Repository is set to Private on GitHub
- [ ] No API keys are committed to the repository
- [ ] Sensitive configuration files are in
.gitignore
- [ ] Environment variables are used for secrets
- [ ] Code is reviewed before committing
Making Repository Private on GitHub
- Go to your repository on GitHub
- Click Settings tab
- Scroll down to Danger Zone
- Click Change repository visibility
- Select Make private
- Confirm the change
License
MIT License - see LICENSE file for details
Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Submit a pull request with detailed description
Support
For issues and feature requests, please use the GitHub issue tracker.
Disclaimer: This extension is not affiliated with Anthropic. Claude is a product of Anthropic PBC.