Pixelbadger.ClaudeAgentSdk
0.3.2
dotnet add package Pixelbadger.ClaudeAgentSdk --version 0.3.2
NuGet\Install-Package Pixelbadger.ClaudeAgentSdk -Version 0.3.2
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="Pixelbadger.ClaudeAgentSdk" Version="0.3.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Pixelbadger.ClaudeAgentSdk" Version="0.3.2" />
<PackageReference Include="Pixelbadger.ClaudeAgentSdk" />
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 Pixelbadger.ClaudeAgentSdk --version 0.3.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Pixelbadger.ClaudeAgentSdk, 0.3.2"
#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 Pixelbadger.ClaudeAgentSdk@0.3.2
#: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=Pixelbadger.ClaudeAgentSdk&version=0.3.2
#tool nuget:?package=Pixelbadger.ClaudeAgentSdk&version=0.3.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Pixelbadger.ClaudeAgentSdk
A C# port of the Anthropic Claude Agent SDK — the same tools, agent loop, and context management as Claude Code, for .NET.
Upstream TypeScript reference: typescript-sdk@0.2.117
Installation
dotnet add package Pixelbadger.ClaudeAgentSdk
Quick Start
V1 API — single query
using Pixelbadger.ClaudeAgentSdk;
using Pixelbadger.ClaudeAgentSdk.Messages;
await foreach (var message in AgentSdk.Query("What files are in the current directory?"))
{
if (message is SdkAssistantMessage assistant)
Console.WriteLine(assistant.Text);
}
V1 API — warm (pre-started) query
await using var warm = await AgentSdk.Startup();
await foreach (var msg in warm.Query("Hello!"))
Console.WriteLine(msg);
V2 API — session (multi-turn)
using Pixelbadger.ClaudeAgentSdk;
await using var session = await AgentSdkV2.CreateSession();
await foreach (var msg in session.Stream("List the files here"))
Console.WriteLine(msg);
await foreach (var msg in session.Stream("Now summarise them"))
Console.WriteLine(msg);
Options
using Pixelbadger.ClaudeAgentSdk.Options;
using Pixelbadger.ClaudeAgentSdk.Permissions;
var options = new AgentOptions
{
Model = "claude-opus-4-7",
PermissionMode = PermissionMode.AcceptEdits,
MaxTurns = 10,
SystemPrompt = new FixedSystemPromptConfig("You are a helpful assistant."),
};
await foreach (var msg in AgentSdk.Query("Do something", options))
Console.WriteLine(msg);
In-process MCP tools
AgentSdk.Tool("get_weather", "Return weather for a city", inputSchema, async (input, ct) =>
{
var city = input.GetProperty("city").GetString();
return new { temperature = 22, unit = "C", city };
});
var options = new AgentOptions
{
McpServers = [AgentSdk.CreateSdkMcpServer()]
};
await foreach (var msg in AgentSdk.Query("What's the weather in London?", options))
if (msg is SdkAssistantMessage a) Console.WriteLine(a.Text);
Live query control
var session = AgentSdk.QueryWithControl("Analyse this repo", options);
await foreach (var msg in session.Messages)
{
if (shouldStop) await session.Control.Interrupt();
}
Message Types
All messages derive from SdkMessage and are deserialized polymorphically:
| Type | Description |
|---|---|
SdkAssistantMessage |
Text response from the model |
SdkUserMessage |
User turn echoed back |
SdkResultMessage |
Final result (success or error) |
SdkSystemMessage |
SDK lifecycle events |
SdkStatusMessage |
Progress status updates |
SdkToolProgressMessage |
Tool execution progress |
SdkRateLimitEvent |
Rate limit notifications |
SdkCompactBoundaryMessage |
Context compaction boundary |
SdkPluginInstallMessage |
Plugin installation event |
SdkLocalCommandOutputMessage |
Local command output |
SdkTaskNotificationMessage |
Task notification |
See CHANGELOG.md for the full list of ported message types.
Requirements
- .NET 8.0 or later
- Claude Code CLI installed and on
PATH(npm install -g @anthropic-ai/claude-code)
License
MIT
| Product | Versions 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.
-
net8.0
- System.Text.Json (>= 8.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.