0xeb

Claude Agent SDK Dotnet — Development skill for Claude Code

Development community

A modern .NET library for interacting with the Claude Code CLI, with full Python SDK parity.

How to install Claude Agent SDK Dotnet

This entry records only its repository, not the path inside it, so there is no exact command to give. Open 0xeb/claude-agent-sdk-dotnet and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Claude Agent SDK Dotnet does

A modern .NET library for interacting with the Claude Code CLI, with full Python SDK parity.

Alternatives in Development

README

Claude Agent SDK for .NET

A modern .NET library for interacting with the Claude Code CLI, providing both a simple one-shot `QueryAsync()` API and a full bidirectional client with control-protocol support.

[![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS-blue)]() [![.NET](https://img.shields.io/badge/.NET-8.0%20%7C%209.0-blue)]() [![License](https://img.shields.io/badge/license-MIT-green)]()

**Disclaimer:** This is an independent, unofficial port and is not affiliated with or endorsed by Anthropic, PBC.

Features

  • Simple Claude.QueryAsync() API for one-shot requests
  • ClaudeSDKClient for multi-turn, bidirectional conversations
  • Control protocol support (interrupts, modes, dynamic model switching)
  • Hook system (PreToolUse, PostToolUse, UserPromptSubmit)
  • Tool permission callbacks with allow/deny control
  • In-process MCP server support (tools, prompts, resources)
  • Cross-platform: Windows, Linux, macOS
  • Source-generated JSON models for message types
  • Well-tested: 109 tests (90 unit + 19 integration; integration tests are disabled by default)

Prerequisites

  • .NET 8.0 or .NET 9.0
  • Claude Code CLI >= 2.0.0:
    npm install -g @anthropic-ai/claude-code

CLI Path Resolution

The SDK discovers the Claude Code CLI in this order:

  1. ClaudeAgentOptions.CliPath (explicit path)
  2. CLAUDE_CLI_PATH environment variable
  3. PATH search for claude (or claude.cmd on Windows)

Quick Start

One-Shot Query

using Claude.AgentSdk;

await foreach (var msg in Claude.QueryAsync("What is 2+2?"))
{
    if (msg is AssistantMessage am)
        foreach (var block in am.Content)
            if (block is TextBlock tb)
                Console.Write(tb.Text);
}

Multi-Turn Conversation

using Claude.AgentSdk;

await using var client = new ClaudeSDKClient();
await client.ConnectAsync();

await client.QueryAsync("Write a Python hello world");

await foreach (var msg in client.Re