Skip to content

dhartman-bot/ClaudeCodeVisualStudio

Repository files navigation

Claude Code for Visual Studio

A Visual Studio 2022 extension that integrates Claude Code AI assistant directly into your IDE.

Claude Code for Visual Studio

Features

Chat Interface

  • Dedicated tool window with full chat functionality
  • Streaming responses for real-time feedback
  • Markdown rendering for formatted responses
  • Conversation history within your session

Editor Integration

  • Right-click context menu for quick actions on selected code
  • Automatic context includes current file and selection
  • Solution awareness understands your project structure

Commands

Command Shortcut Description
Open Chat Ctrl+K, Ctrl+C Opens the Claude Code chat window
Ask About Selection Ctrl+K, Ctrl+A Ask about selected code
Explain Code Right-click menu Get detailed code explanation
Fix Error Right-click menu Ask Claude to fix errors
Generate Tests Right-click menu Generate unit tests

Installation

Prerequisites

  1. Visual Studio 2022 (version 17.0 or later)
  2. Claude Code CLI installed and authenticated

Install Claude Code CLI

# Using npm
npm install -g @anthropic-ai/claude-code

# Authenticate
claude auth login

Install the Extension

  1. Download the .vsix file from Releases
  2. Double-click to install, or use Extensions > Manage Extensions in Visual Studio
  3. Restart Visual Studio

Build from Source

# Clone the repository
git clone https://github.com/anthropics/claude-code-visual-studio.git
cd claude-code-visual-studio

# Open in Visual Studio
start ClaudeCodeVisualStudio.sln

# Build (or press F5 to debug)
dotnet build

Usage

Opening the Chat

  1. Press Ctrl+K, Ctrl+C or go to Tools > Open Claude Code Chat
  2. Type your question and press Enter or click Send

Asking About Code

  1. Select code in the editor
  2. Right-click and choose Ask Claude About Selection or Explain This Code
  3. The chat window opens with your code as context

Fixing Errors

  1. Right-click in the editor
  2. Choose Fix Error with Claude
  3. Claude analyzes current errors and suggests fixes

Generating Tests

  1. Select a class or method
  2. Right-click and choose Generate Tests
  3. Claude creates comprehensive unit tests

Configuration

Go to Tools > Options > Claude Code to configure:

Setting Default Description
CLI Path auto-detect Path to Claude Code CLI
Default Model Sonnet Claude model to use
Auto-Include Context true Include file context automatically
Max Context Lines 500 Maximum lines to include
Stream Responses true Stream responses as they arrive
Theme Auto Light/Dark/Auto

Architecture

┌─────────────────────────────────────────────────────────────┐
│                     Visual Studio 2022                       │
├─────────────────────────────────────────────────────────────┤
│  ┌─────────────┐    ┌─────────────┐    ┌─────────────────┐  │
│  │ Tool Window │    │  Commands   │    │ Editor Context  │  │
│  │  (Chat UI)  │    │  (Menu/KB)  │    │    Provider     │  │
│  └──────┬──────┘    └──────┬──────┘    └────────┬────────┘  │
│         └──────────────────┼───────────────────┘            │
│                     ┌──────▼──────┐                         │
│                     │ ClaudeCode  │                         │
│                     │   Service   │                         │
│                     └──────┬──────┘                         │
├────────────────────────────┼────────────────────────────────┤
│                     ┌──────▼──────┐                         │
│                     │ Claude CLI  │                         │
│                     └──────┬──────┘                         │
└────────────────────────────┼────────────────────────────────┘
                      ┌──────▼──────┐
                      │ Anthropic   │
                      │    API      │
                      └─────────────┘

Project Structure

ClaudeCodeVisualStudio/
├── src/
│   ├── ClaudeCodePackage.cs      # Extension entry point
│   ├── Commands/                  # VS commands
│   │   ├── OpenChatCommand.cs
│   │   ├── AskAboutSelectionCommand.cs
│   │   ├── ExplainCodeCommand.cs
│   │   ├── FixErrorCommand.cs
│   │   └── GenerateTestCommand.cs
│   ├── Services/                  # Core services
│   │   ├── ClaudeCodeService.cs
│   │   └── EditorContextProvider.cs
│   ├── ToolWindows/              # WPF UI
│   │   ├── ChatToolWindow.cs
│   │   └── ChatToolWindowControl.xaml
│   ├── Models/                   # Data models
│   └── Utils/                    # Utilities
├── assets/                       # Icons and images
├── ARCHITECTURE.md              # Detailed architecture docs
└── README.md

Development

Requirements

  • Visual Studio 2022 with Visual Studio extension development workload
  • .NET Framework 4.8 SDK
  • Claude Code CLI for testing

Debugging

  1. Open the solution in Visual Studio
  2. Press F5 to launch the experimental instance
  3. The extension loads automatically in the experimental VS

Building VSIX

dotnet build -c Release
# Output: bin/Release/ClaudeCodeVisualStudio.vsix

Troubleshooting

"Claude Code CLI not found"

  1. Ensure CLI is installed: npm install -g @anthropic-ai/claude-code
  2. Verify it's in PATH: claude --version
  3. Or set the path manually in Tools > Options > Claude Code

"Not authenticated"

Run claude auth login in your terminal to authenticate.

Responses are slow

  • Check your network connection
  • The first request may take longer due to CLI initialization
  • Consider using a faster model (Haiku) for quick tasks

Roadmap

v1.1

  • Inline code completions
  • Code lens integration
  • Multi-file refactoring preview

v1.2

  • Git integration (commit messages, PR descriptions)
  • Custom prompt templates
  • Team sharing

v2.0

  • MCP server support
  • Enterprise proxy configuration
  • Advanced caching

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

License

MIT License - see LICENSE for details.

Links

About

Visual Studio 2022 extension for Claude Code AI assistant

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors