Claude AI for Visual Studio 2022
A native VSIX extension that brings Claude AI directly into Visual Studio 2022. No terminal, no browser, no copy-pasting. Powered by Anthropic Claude.
Complete Feature List
🧠 Smart Auto-Context
Claude automatically reads your focused open file when your question is about code — without you clicking anything. A two-tier classifier decides silently:
- Tier 1 (instant, no API call): regex patterns that are unambiguously code-related → attaches file. Patterns that are clearly general → skips.
- Tier 2 (fast Haiku call, ~50 tokens): fired only for ambiguous messages.
Attaches file automatically: "why is this throwing a null reference?" · "refactor this" · "add xml doc comments" · "explain this method" · "write unit tests" · "is this thread-safe?"
Does NOT attach file: "what is dependency injection?" · "difference between abstract and interface?" · "best practice for error handling?" · "hello"
Priority rules: Manual 📄 Active file > @mentions > Smart auto-context. If no file is open, Claude answers from general knowledge.
- Open: View → Other Windows → Claude AI or
Ctrl+Alt+C
- Can be docked, floated, or tabbed like any VS tool window
- Full conversation history in chat bubbles
- Streaming responses — Claude's reply appears word-by-word as it is generated
- ⏹ Stop — the Send button becomes a red Stop button while Claude is responding; click it to cancel mid-stream
- Expanding input box — grows line-by-line as you type; capped at 25% of the panel height, then scrolls
- Context window warning — a warm banner appears above the input when ≥ 50% of the 200 K-token context window is used. Text reads "You've used 85% of your session limit · resets in 12m" (reset time comes from the
anthropic-ratelimit-tokens-reset response header; falls back to "new session resets it"). Includes a View usage link and a × to dismiss for the current session.
- Session auto-saved after every assistant reply
- Toggle with the ☰ button in the chat header
- Sessions grouped: TODAY, THIS WEEK, OLDER
- Each entry shows: title, first-message preview, timestamp
- 🔍 Search box — filters sessions by title, preview, and full message content in real time
- ✎ Rename button per session — opens an inline rename dialog
- 🗑 Delete button per session — with confirmation
- Delete all sessions button at the bottom of the sidebar
- Sessions stored at
%APPDATA%\ClaudeVS\sessions\ as plain JSON files (one per session)
- Resuming a session replays the full message history
✦ Inline Code Suggestions
- Ghost text appears after your cursor while typing in
.cs files
- Powered by claude-haiku-4-5-20251001 for low latency
- Tab — accept the suggestion
- Esc — dismiss
- *Alt+* — toggle on/off globally
- Configurable via Tools → Options → Claude AI → Inline Suggestions
✏ Diff View (Accept / Reject)
- Triggered by ✏ Ask to edit or the Fix & Build loop
- Side-by-side: original left, Claude's version right
- Green = added lines, red = removed lines
- Both panels scroll in sync
- ✓ Accept Changes — writes to disk, reloads in editor
- ✕ Reject — closes with no changes
- If Auto-accept is ON, diff is skipped and file is written directly
🔁 Fix & Build Loop
- Triggered by 🔁 Fix & Build in the chat toolbar
- Maximum 3 attempts
- Each attempt:
- Runs
dotnet build (SDK-style) or msbuild (legacy)
- Parses all compiler errors (file + line + column + code)
- Reads every affected source file
- Claude fixes all errors in one pass
- Writes corrected files (respects Auto-accept / diff setting)
- Waits 500ms then recompiles
- Live progress streams line-by-line into a single chat bubble
- If errors remain after 3 attempts: remaining errors listed in chat, partial fixes kept
🖼 Image Paste
- Ctrl+V in the chat input — captures clipboard image
- 🖼 Image toolbar button — same action
- Drag and drop image files onto the chat area
- Supported: PNG, JPG/JPEG, GIF, WebP, BMP
- Thumbnails appear in a strip above the input with × to remove before sending
- Can send images with no text
- Images base64-encoded and sent as multipart content — Claude sees the full image
- Manually force-attaches the focused open file
- If text is selected in the editor, attaches only the selection — useful for asking about a single method without sending the whole file
- Toggles on/off — turns blue when active
- Takes priority over smart auto-context
@ File Mentions
- Type
@ + 2+ characters of a filename in the chat input
- Fuzzy-matches all files in your solution
- Matched file appears as a chip/badge above the input
- Remove with × on the chip (tooltip: "Remove this file mention")
- Multiple files per message supported
- @ Mention file toolbar button pre-fills
@ in the input
📋 Output / @terminal
- Type
@terminal or @output in the chat input — an amber 📋 Output chip appears
- Click the 📋 Output toolbar button to add it with one click
- When sent, the VS Output window content (Build pane) is appended to the message
- Falls back to the recent command buffer if the Output window is empty
- Build errors are parsed and included in structured form alongside the raw log
- Useful for: "why did this build fail?", "what do these errors mean?", "fix these errors"
⚙ Auto-Accept Toggle
- The Auto badge (coloured dot) in the chat header
- Grey = OFF — diff view shown before every edit (default)
- Green = ON — edits applied directly to disk, no popup
- Click the badge to toggle
- When ON: optional VS status bar notification on apply
- Also in Tools → Options → Claude AI → Edit Behaviour
🛡 File Scope Protection
Before writing any file, the extension checks whether the target path is inside one of the solution's project directories. Projects can be anywhere on disk — including in a parent directory of the solution folder. If the target file is outside every project directory, an approval bubble appears in chat:
- ✅ Allow — proceed with this file operation
- ❌ Refuse — cancel; the file is not touched
This applies to: ✏ Ask to edit, the Fix & Build loop, and any auto-accepted edits.
🔒 Command Security
Every background command passes through CommandGuard before execution.
Tier 1 — Whitelisted (silent)
Default: dotnet, msbuild, nuget, git, npm, yarn, pnpm, node, tsc, webpack, cake, fake, nuke
Tier 2 — Needs approval (approval bubble in chat)
Unknown executables show a yellow bubble with the exact command and shell. Three buttons:
- ✅ Accept — run once, prompt again next time
- ✅ Accept & save to whitelist — run and add the executable to the whitelist permanently (disabled when no solution is loaded)
- ❌ Refuse — block and cancel the current operation
Tier 3 — Hard-blocked (no override possible)
- Filesystem:
format, del /s /f /q, rd /s /q, rmdir /s /q, Remove-Item -Recurse, rm -r
- Registry:
reg delete/add/import/export, Remove-ItemProperty, Set-ItemProperty HKLM
- Disk:
diskpart, cipher /w
- System:
shutdown, Restart-Computer, Stop-Computer
- Users:
net user, net localgroup, Add-LocalGroup, New-LocalUser
- Obfuscated PS:
-EncodedCommand, Invoke-Expression(, iex(, DownloadString
- Persistence:
schtasks /create, New-ScheduledTask
- Firewall:
netsh firewall/advfirewall/interface, Set-NetFirewallProfile
- Elevation:
runas /user:administrator, Start-Process -Verb runas
🔒 Whitelist editor
- Click the 🔒 button in the chat header
- Lists all whitelisted executables — add, remove, or reset to defaults
- Read-only view of all hard-blocked patterns
- Whitelist is saved to
{solutionDir}\.claude\command-whitelist.json — per-project and source-control friendly
- Save and Reset to defaults buttons are disabled when no solution is loaded (shown with an orange warning)
| Category |
Setting |
Default |
| Authentication |
API Key |
(optional — auto-detected from Claude Code or ANTHROPIC_API_KEY) |
| Model |
Claude Model |
claude-sonnet-4-6 |
| Inline Suggestions |
Enable Inline Suggestions |
true |
| Inline Suggestions |
Suggestion Delay (ms) |
800 |
| Chat |
Max Tokens |
4096 |
| Chat |
Enter key sends message |
true |
| Chat |
Show history sidebar on open |
false |
| Edit Behaviour |
Auto-accept edits |
false |
| Edit Behaviour |
Auto-accept notification |
true |
| Command Security |
Show security badge |
true |
| Command Security |
Build Shell |
PowerShell |
| Control |
What it does |
| ☰ |
Toggle session history sidebar |
| Session title (clickable) |
Rename current session |
| Auto dot |
Grey = show diff · Green = auto-apply edits |
| 🔒 |
Open whitelist / command security editor |
| + New |
New session (current auto-saved) |
| 🗑 |
Clear current conversation (with confirmation) |
| Button |
What it does |
| 📄 Active file |
Force-attach the open file (or selected text) |
| @ Mention file |
Pre-fill @ to fuzzy-attach a solution file |
| 📋 Output |
Attach VS Output window content as context (also: type @terminal) |
| ✏ Ask to edit |
Claude edits the active file → diff view |
| 🖼 Image |
Paste clipboard image (also Ctrl+V) |
| 🔁 Fix & Build |
Compile → fix errors → recompile (up to 3×) |
Keyboard Shortcuts
| Shortcut |
Action |
Ctrl+Alt+C |
Open Claude chat panel |
Enter |
Send message (when Enter key sends message is ON) |
Shift+Enter |
New line in input |
Ctrl+V (in chat input) |
Paste image from clipboard |
Tab |
Accept inline suggestion |
Esc |
Dismiss inline suggestion |
Alt+\ |
Toggle inline suggestions on/off |
Architecture
ClaudeVS/
├── ClaudeVSPackage.cs # Package entry + all VS options settings
├── Commands/
│ ├── OpenChatCommand.cs # Ctrl+Alt+C
│ ├── InlineSuggestCommand.cs # Alt+\ toggle
│ └── AtMentionCommand.cs # Focuses chat + prefills @
├── Models/
│ └── ChatMessage.cs # ChatMessage, AttachedImage, ChatSession, MentionedFile
├── Services/
│ ├── ClaudeApiService.cs # All Anthropic API calls
│ ├── SmartContextService.cs # Classifies questions → attach file or not
│ ├── EditorContextService.cs # Active file, selection, cursor, solution file list
│ ├── DiffService.cs # LCS diff + writes files to disk
│ ├── SessionService.cs # Save/load/delete sessions as JSON
│ ├── TerminalService.cs # Silent PS/CMD runner + error parser
│ ├── BuildFixLoopService.cs # Compile → fix → recompile loop
│ └── CommandGuard.cs # Whitelist + approval + hard-block gate
└── UI/
├── ClaudeChatWindow.cs # VS tool window wrapper
├── ClaudeChatWindowControl.xaml # Main sidebar layout
├── ClaudeChatWindowControl.xaml.cs # Chat logic, send, auto-context, images, Fix&Build
├── SessionHistoryControl.xaml # History sidebar layout
├── SessionHistoryControl.xaml.cs # Load, search, rename, delete sessions
├── CommandWhitelistDialog.cs # Whitelist editor dialog
├── DiffViewerWindow.cs # Diff popup host
├── DiffViewerControl.xaml # Side-by-side diff layout
├── DiffViewerControl.xaml.cs # Diff render, sync scroll, accept/reject
├── InlineSuggestionAdornment.cs # Ghost text renderer
└── InlineSuggestionAdornmentTagger.cs # MEF listener, debounce, Tab/Esc
Models Used
| Task |
Model |
| Chat, edits, Fix & Build |
Configurable — default: claude-sonnet-4-20250514 |
| Inline suggestions |
claude-haiku-4-5-20251001 (fast, low latency) |
| Smart context classification |
claude-haiku-4-5-20251001 (~50 tokens per message) |
Troubleshooting
| Problem |
Fix |
| Extension not visible |
Restart VS completely. Try reinstalling as Administrator. |
❌ No API key found |
Set ANTHROPIC_API_KEY, sign in via Claude Code, or enter key at Tools → Options → Claude AI → Authentication |
❌ Claude API error 401 |
Invalid credential — re-copy key from https://console.anthropic.com or re-authenticate Claude Code |
❌ Claude API error 429 |
Rate limit — wait or add billing at console.anthropic.com |
| Smart context not attaching |
File must be open and focused in the editor |
| Inline suggestions not appearing |
Options → Enable Inline Suggestions must be ON; must be a .cs file |
| Fix & Build blocked |
Add dotnet or msbuild to whitelist via 🔒 button |
| Sessions not saving |
Check %APPDATA%\ClaudeVS\sessions\ is writable |
| |