Show HN:用于 Visual Studio 的 Claude Code(支持原生差异对比,可接受/拒绝修改)
Show HN: Claude Code for Visual Studio (native diff with accept/reject)

原始链接: https://github.com/firish/claude_code_vs

“Claude Code for Visual Studio” 是一款社区驱动的扩展插件,旨在将 Claude Code CLI 与 Visual Studio 2026 进行连接,实现原生的 IDE 集成。Claude CLI 负责执行智能代理工作,而该插件则作为 IDE 协议处理器,通过精简的原生体验取代了手动终端交互。 **主要功能包括:** * **原生差异对比工作流:** Claude 的编辑内容直接在 Visual Studio 的差异对比查看器中打开,支持一键“接受”或“拒绝”。 * **上下文感知:** 该插件可向 Claude 提供当前选中的文件及编译器诊断信息(C#/C++),以提高代码准确性。 * **实时仪表盘:** 一个可停靠的面板,用于监控连接状态、编辑历史记录以及估算的 Token 使用量。 * **灵活控制:** 用户可以选择“带反馈拒绝”以进行迭代优化,或启用“自动接受”以实现快速执行。 该插件仅作为协议桥梁,不直接进行模型调用,并要求安装已通过身份验证的 Claude Code CLI。它通过 localhost WebSocket 和特定项目的钩子(hooks)进行集成。该项目目前仅适用于 Visual Studio 2026,采用开源协议(MIT),并鼓励社区贡献,以保持与不断演进的 Claude 集成协议的兼容性。

一位开发者发布了一款新的 Visual Studio 扩展,将原生的 Claude Code 集成到了该 IDE 中,填补了官方插件留下的空白。该扩展通过实现标准的 Claude CLI 协议,实现了无需额外配置即可无缝连接。 该工具的突出特点是与 Visual Studio 原生差异查看器(diff viewer)的集成。用户无需自动应用更改,而是可以直接在 IDE 内审查、接受或拒绝编辑。被拒绝的编辑包含一个可选的反馈环节,允许 Claude 对其工作进行迭代。此外,该扩展会自动向 CLI 提供相关上下文,例如当前选定的文本以及现有的 C# 或 C++ 编译器错误。 其他功能包括用于跟踪会话状态和 Token 成本的可停靠面板,以及为偏好自动应用更改的用户提供的“狂野运行”(run wild)模式。该扩展充当了现有 Claude CLI 的桥梁,现已在 Visual Studio Marketplace 上架。
相关文章

原文

Bring Claude Code into Visual Studio 2026 - a native diff window with accept/reject, automatic selection + compiler-diagnostics context, and a live stats panel. The claude CLI does the agent work; this extension is the IDE half of Claude Code's integration protocol.

Demo

Status: community project, not affiliated with Anthropic. Visual Studio 2026 only, for now.


Claude Code has first-class IDE integration for VS Code and JetBrains, but not Visual Studio - see anthropics/claude-code#15942. This extension implements that same IDE-integration protocol natively for VS, so the CLI drives a real Visual Studio diff window and sees your selection and build errors - instead of you copy-pasting into a terminal.

  • Native diff with a single accept/reject gate - Claude's edits open in Visual Studio's diff viewer, and approving there is the only step (no duplicate y/n prompt in the terminal).
  • Reject with feedback - reject an edit and tell Claude what to change; it reconsiders with your note.
  • Run wild (auto-accept) - a panel toggle to apply edits without opening the diff, for when you want to let it cook. Resets each session.
  • Diagnostics sharing - Claude reads Visual Studio's compiler errors/warnings (C# and C++) and fixes them.
  • Selection context - Claude automatically knows the file and lines you're looking at.
  • Live panel - a dockable Claude Code panel: connection status, edit decisions, and token usage + estimated cost (latest call vs cumulative session).
  • Visual Studio 2026.
  • The Claude Code CLI, installed and authenticated - see the Claude Code docs. This extension makes no model calls and does no agent work itself; it requires the CLI.
  • Tested against claude 2.1.173.
  • Marketplace: search "Claude Code for Visual Studio" in Extensions -> Manage Extensions, or install from the Visual Studio Marketplace.
  • Sideload: download the .vsix from Releases and double-click it.
  1. Open your project or solution in Visual Studio 2026.
  2. Open the Claude Code panel (View -> Other Windows -> Claude Code) and click Launch Claude Code (also available on the Tools menu).
  3. A terminal opens running claude, already connected to the IDE (no /ide needed). The panel pill turns green - Connected.
  4. Ask Claude to make a change. Its edit opens as a diff - click Accept, Reject, or Reject with feedback….

Diagnostics need a loaded project (not a loose file in Open-Folder mode) for the compiler to analyze it.

This is a protocol bridge, not a re-implementation of the agent. On launch the extension:

  1. Starts a localhost WebSocket server and writes a lockfile at ~/.claude/ide/<port>.lock.
  2. Launches claude with ENABLE_IDE_INTEGRATION and the bridge port, so it auto-connects and speaks MCP / JSON-RPC over the socket.
  3. Implements the IDE tools the CLI drives - openDiff, openFile, getDiagnostics, selection updates, and diff-tab lifecycle.

To make the VS diff the single approval gate, the extension installs a small PreToolUse hook into your workspace's .claude/settings.json that routes proposed edits through the diff. The CLI does all agent work; the extension never makes model calls.

  • The bridge binds to 127.0.0.1 only and validates an auth token (from the lockfile) on every connection. The token is never logged.
  • The extension makes no network calls and no LLM calls of its own. All AI work is the claude CLI, under your own authentication.
  • On Launch, it writes these into your workspace's .claude/ folder and merges hook entries into .claude/settings.json (preserving existing content):
    • vs-permission-hook.ps1 - routes Edit/Write/MultiEdit edits through the VS diff.
    • vs-usage-hook.ps1 - reports the transcript path so the panel can show token stats.
  • Token cost is an estimate (hardcoded per-tier prices), shown only when you click Show est. cost.

Limitations & known issues

  • Visual Studio 2026 only for now (a VS 2022 backfill is planned if there's demand).
  • The IDE-integration protocol is undocumented and version-fragile - a claude update could change it. Known-good: 2.1.173.
  • Diagnostics need a loaded project (the Error List / Roslyn won't analyze loose files).
  • Token stats refresh on edits (the reliable hook trigger), so a chat-only turn may not update them immediately.
  • Cost figures are estimates, not billing.
  • Panel says "Waiting for CLI": click Launch Claude Code, or run /ide in a claude terminal and pick Visual Studio.
  • New files land in the wrong folder: launch from the extension (it pins the working directory to your workspace), or run claude from inside the repo.
  • getDiagnostics returns nothing: open the code as a project and confirm the error appears in the Error List.
  • Filing a bug: include the Output -> Claude Code pane contents and your claude --version.

Requires Visual Studio 2026 with the Visual Studio extension development workload.

msbuild src/ClaudeCodeVS/ClaudeCodeVS.csproj /t:Rebuild /p:Configuration=Release

Press F5 (or launch devenv /rootsuffix Exp) to debug in the experimental instance. Architecture and contributor guidance live in CLAUDE.md. Future work lives in ROADMAP.md.

Issues and PRs welcome. The protocol contract is undocumented and has regressed before - if you bump the claude CLI, please run the spike smoke test (spike/) and note the version.

MIT © 2026 Rishi Gulati. Not affiliated with Anthropic. "Claude" and "Claude Code" are trademarks of Anthropic, used here only to describe interoperability.

联系我们 contact @ memedata.com