Skip to content
-
Subscribe to our newsletter & never miss our best posts. Subscribe Now!
Just another Geek

Just another geek

Just another Geek

Just another geek

  • Home
  • Shop
    • Shop
    • Cart
    • Checkout
  • About
    • About Me
    • Coding Projects
    • Software Reqs
  • My Collections
    • Other Games
    • NES Games
    • Comics
      • Anime Insider
      • Simpsons
      • Animerica
  • My Extras …
    • My Flight Tracker
    • My Search
    • My Stream
    • My Videos
  • Hitt Hosting
  • Home
  • Shop
    • Shop
    • Cart
    • Checkout
  • About
    • About Me
    • Coding Projects
    • Software Reqs
  • My Collections
    • Other Games
    • NES Games
    • Comics
      • Anime Insider
      • Simpsons
      • Animerica
  • My Extras …
    • My Flight Tracker
    • My Search
    • My Stream
    • My Videos
  • Hitt Hosting
Close

Search

Subscribe
ProgrammingTech

Developing a Claude Code Addin for Visual Studio 2005

contact@paulhitt.com
By contact@paulhitt.com
February 23, 2026 4 Min Read
0

Introduction

Visual Studio 2005 (VS 2005) may feel dated compared to today’s modern IDEs, but it still serves a niche of legacy projects that require its specific toolchain. One powerful way to extend VS 2005 is through add‑ins written in .NET that hook into the IDE’s automation model. In this post we’ll walk through the process of building a VS 2005 add‑in that talks to Claude, the large‑language‑model (LLM) platform from Anthropic, allowing developers to generate, refactor, or explain code directly from the editor.

The complete source for the add‑in lives in the public Git repository:

https://git.flamenet.io/ezluzvaerus/ClaudeCodeAddin

Feel free to clone the repo, explore the implementation, and adapt it to your own workflow.


1. Prerequisites

RequirementWhy It Matters
Visual Studio 2005 (Professional or higher)Provides the extensibility SDK and the COM‑based automation model used by add‑ins.
.NET Framework 2.0VS 2005 targets this runtime; the add‑in must compile against it.
Anthropic API credentialsTo send prompts to Claude and receive responses.
Internet connectivityRequired for each request to the Claude endpoint.
Git clientTo clone the repository and manage future changes.

Tip: Even though VS 2005 predates NuGet, you can still reference external DLLs manually (e.g., System.Net.Http.dll for HTTP calls). The sample project includes a small wrapper library that abstracts the HTTP communication.


2. Project Layout

The repository follows a straightforward structure:

ClaudeCodeAddin/
│
├─ src/
│   ├─ ClaudeAddin/
│   │   ├─ AddIn.cs          // Core add‑in class implementing IDTExtensibility2
│   │   ├─ Command.cs        // Definition of the menu command that triggers Claude
│   │   └─ ClaudeClient.cs   // Thin HTTP client for Anthropic’s API
│   └─ ClaudeAddinPackage/
│       └─ AssemblyInfo.cs
│
├─ resources/
│   └─ icons/                // Toolbar icons used by the add‑in
│
└─ README.md                 // Build instructions, usage guide, contribution notes
  • AddIn.cs – Registers the add‑in with VS 2005, creates a new top‑level menu item under Tools → Claude, and wires the click event to our command handler.
  • Command.cs – Retrieves the active document text, sends it to Claude, and inserts the returned snippet back into the editor.
  • ClaudeClient.cs – Handles authentication, request serialization, and response parsing. It uses HttpWebRequest to stay compatible with .NET 2.0.

3. Core Logic Overview

Below is a high‑level walkthrough of the interaction flow:

  1. User selects text (or places the cursor) and clicks Tools → Claude → Generate.
  2. Command.Execute() extracts the selected code region via the DTE (EnvDTE) object.
  3. The extracted snippet, together with a short prompt (e.g., “Refactor this C# method for readability”), is handed to ClaudeClient.SendPromptAsync().
  4. ClaudeClient builds a JSON payload conforming to Anthropic’s API spec, injects the API key from an environment variable (ANTHROPIC_API_KEY), and posts to https://api.anthropic.com/v1/complete.
  5. Claude returns a JSON response containing the generated code.
  6. The add‑in parses the response, strips any surrounding markdown fences, and replaces the original selection with the new code.
  7. A status message appears in the VS 2005 status bar indicating success or any error encountered.

Key snippet from ClaudeClient.cs:

public string SendPrompt(string prompt, string codeSnippet)
{
    var request = (HttpWebRequest)WebRequest.Create(ApiEndpoint);
    request.Method = "POST";
    request.ContentType = "application/json";
    request.Headers["x-api-key"] = Environment.GetEnvironmentVariable("ANTHROPIC_API_KEY");

    var payload = new {
        model = "claude-v1",
        prompt = $"{prompt}\n\n{codeSnippet}",
        max_tokens_to_sample = 1024,
        temperature = 0.2
    };
    var json = new JavaScriptSerializer().Serialize(payload);

    using (var stream = request.GetRequestStream())
    using (var writer = new StreamWriter(stream))
    {
        writer.Write(json);
    }

    using (var response = (HttpWebResponse)request.GetResponse())
    using (var reader = new StreamReader(response.GetResponseStream()))
    {
        var respJson = reader.ReadToEnd();
        dynamic result = new JavaScriptSerializer().DeserializeObject(respJson);
        return result["completion"];
    }
}

Security note: The API key is never hard‑coded; it must be supplied via an environment variable or a secure configuration file outside the repository.


4. Building the Add‑in

  1. Clone the repogit clone https://git.flamenet.io/ezluzvaerus/ClaudeCodeAddin.git cd ClaudeCodeAddin/src/ClaudeAddin
  2. Open the solution (ClaudeAddin.sln) in VS 2005.
  3. Set the target framework to .NET 2.0 (the default).
  4. Add a reference to System.Web.Extensions if you wish to use JavaScriptSerializer.
  5. Build – the output will be ClaudeAddin.dll.
  6. Register the add‑in
    • Copy ClaudeAddin.dll to a folder of your choice, e.g., C:\Program Files\ClaudeAddin\.
    • Open the Add‑in Manager in VS 2005 (Tools → Add‑in Manager).
    • Click Add New Add‑in…, browse to the DLL, and confirm.
  7. Restart VS 2005 – you should now see a Claude submenu under Tools.

5. Using the Add‑in

ActionSteps
Generate codeSelect a region → Tools → Claude → Generate.
Explain codeSelect a region → Tools → Claude → Explain. The prompt sent to Claude will be “Explain what the following code does”.
RefactorPlace cursor inside a method → Tools → Claude → Refactor. Claude receives a prompt to improve readability and performance.

The status bar will display messages such as “Claude: Generation successful (1.2 s)” or “Claude: Error – invalid API key”.


6. Extending the Add‑in

The sample implementation is intentionally minimal, leaving plenty of room for customization:

  • Additional commands – Add menu items for unit‑test generation, doc‑string insertion, or security review.
  • Rich UI – Replace the simple status‑bar feedback with a custom tool window that shows Claude’s full response, including explanations or alternative suggestions.
  • Language support – Although the demo focuses on C#, the same pattern works for VB.NET, C++, or even plain text files. Adjust the prompt templates accordingly.
  • Caching – Store recent Claude responses locally to reduce latency and API costs for repetitive queries.

Because the add‑in runs inside VS 2005’s process, keep performance considerations in mind: avoid blocking the UI thread during network calls. The sample already uses asynchronous patterns (BeginInvoke/EndInvoke) to keep the IDE responsive.


7. Testing & Debugging

  • Unit tests – While VS 2005 doesn’t ship with a built‑in test runner, you can reference NUnit 2.x (compatible with .NET 2.0) to validate ClaudeClient behavior.
  • Logging – The repository includes a lightweight logger that writes to %TEMP%\ClaudeAddin.log. Enable it by setting DEBUG=1 in the environment.
  • Error handling – The add‑in catches WebException to surface HTTP errors (e.g., rate limits) in the status bar.
contact@paulhitt.com
Author

contact@paulhitt.com

Follow Me
Other Articles
Previous

Hitt Hosting

Next

Windows XP Hardening Script

No Comment! Be the first one.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Contact

Please enable JavaScript in your browser to complete this form.
Name *
Loading

Cart

Latest Posts

  • Calculate Radial Kepler Equation using Julia
  • Convert QCow2 Image to a Docker Volume
  • Convert QCow2 image to AWS AMI
  • How to Isolate QEMU Hosts
  • Windows 2000 Hardening Script
Copyright 2026 — Just another Geek. All rights reserved. Blogsy WordPress Theme