ClaudeCodeWrapper 1.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package ClaudeCodeWrapper --version 1.1.1
                    
NuGet\Install-Package ClaudeCodeWrapper -Version 1.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ClaudeCodeWrapper" Version="1.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ClaudeCodeWrapper" Version="1.1.1" />
                    
Directory.Packages.props
<PackageReference Include="ClaudeCodeWrapper" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ClaudeCodeWrapper --version 1.1.1
                    
#r "nuget: ClaudeCodeWrapper, 1.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ClaudeCodeWrapper@1.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ClaudeCodeWrapper&version=1.1.1
                    
Install as a Cake Addin
#tool nuget:?package=ClaudeCodeWrapper&version=1.1.1
                    
Install as a Cake Tool

ClaudeCodeWrapper

C# wrapper for Claude Code CLI.

Requirements

  • .NET 8.0+
  • Claude Code CLI installed (npm install -g @anthropic-ai/claude-code)

Installation

dotnet add package ClaudeCodeWrapper

Quick Start

using ClaudeCodeWrapper;

// Initialize
var claude = ClaudeCode.Initialize();

// Send a message
var response = await claude.SendAsync("Hello Claude!");

Usage

With Options

var claude = ClaudeCode.Initialize(new ClaudeCodeOptions
{
    Model = "sonnet",
    WorkingDirectory = "/path/to/project",
    SystemPrompt = "You are a helpful assistant",
    PermissionMode = PermissionMode.AcceptEdits
});

Stream Activities

Monitor tool calls and results in real-time:

var response = await claude.StreamWithResponseAsync(
    "Refactor this code",
    activity => Console.WriteLine($"[{activity.Type}] {activity.Tool}: {activity.Summary}")
);

With Metrics

var response = await claude.SendWithResponseAsync("Explain this code");

Console.WriteLine($"Response: {response.Content}");
Console.WriteLine($"Tokens: {response.Tokens?.Input} in, {response.Tokens?.Output} out");
Console.WriteLine($"Session: {response.SessionId}");

Session Management

// Resume a previous session
var response = await claude.ResumeAsync("session-id", "Continue...");

// Continue the last session
var response = await claude.ContinueAsync("What were we discussing?");

Permission Modes

Mode Description
PermissionMode.Default Standard - asks permission for writes
PermissionMode.Plan Read-only, no modifications
PermissionMode.AcceptEdits Auto-accept file edits
PermissionMode.BypassPermissions No permission prompts

Usage Monitoring

Track your API usage limits:

var claude = ClaudeCode.Initialize(new ClaudeCodeOptions
{
    EnableUsageMonitoring = true
});

// Get current usage
var usage = await claude.GetUsageAsync();
if (usage != null)
{
    Console.WriteLine($"Session: {usage.FiveHour.Utilization}% used");
    Console.WriteLine($"Weekly:  {usage.SevenDay.Utilization}% used");
    Console.WriteLine($"Resets:  {usage.FiveHour.ResetsAt}");
}

// Check if within limits
if (await claude.IsWithinLimitsAsync(sessionThreshold: 90, weeklyThreshold: 80))
{
    await claude.SendAsync("Safe to send!");
}

Error Handling

The wrapper throws specific exceptions for rate limit errors:

try
{
    var response = await claude.SendAsync(prompt);
}
catch (RateLimitException ex)
{
    // HTTP 429 - Rate limit exceeded
    Console.WriteLine($"Rate limited: {ex.Message}");
    Console.WriteLine($"Request ID: {ex.RequestId}");
    // Implement your own retry logic
}
catch (OverloadedException ex)
{
    // HTTP 529 - API overloaded
    Console.WriteLine($"API overloaded, retry after: {ex.RetryAfter}");
}

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.5.0 84,945 2/15/2026
1.4.0 344 12/16/2025
1.3.0 300 12/15/2025
1.1.1 212 12/5/2025
1.1.0 218 12/5/2025
1.0.1 234 12/4/2025

v1.1.1: Fixed path sanitization bug in SessionMonitor - underscore characters are now properly replaced with dashes to match Claude CLI behavior.