AdrianBailador

Claude Agent Csharp — AI skill for Claude Code

AI community

Building a coding agent in C# with ToolRunner and Microsoft.Extensions.AI - companion sample for the blog post.

How to install Claude Agent Csharp

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

What Claude Agent Csharp does

Building a coding agent in C# with ToolRunner and Microsoft.Extensions.AI - companion sample for the blog post.

Alternatives in AI

  • Post Training — ai-research-skills GRPO, RLHF, DPO, SimPO 5.4k ★
  • Browser Operator Core — Browser Operator - The AI browser with built in Multi-Agent platform 500 ★
  • Academic Writing Skills — AI-powered post-writing toolkit for academic papers — format validation, grammar/style polishing, de-AI editin 430 ★

README

There's No Official Claude Agent SDK for C#. Here's What to Use Instead

Companion sample for the blog post [There's No Official Claude Agent SDK for C#. Here's What to Use Instead](https://adrianbailador.github.io/blog/71-claude-code-agent-csharp/).

Two runnable console apps, both building the same small coding agent — one that can read files, list a directory, write files, and run a shell command against a scoped workspace — using the two paths that actually exist in C# today.

Project Approach
ToolRunnerAgent The official Anthropic SDK's client.Beta.Messages.ToolRunner — the agent loop as an IAsyncEnumerable, one turn at a time
MeaiAgent The same loop through Microsoft.Extensions.AI's UseFunctionInvocation(), tools defined as plain C# methods

Requirements

export ANTHROPIC_API_KEY=sk-ant-...

Running it

dotnet run --project ToolRunnerAgent
dotnet run --project MeaiAgent

Both default to: *"Add a `.gitignore` for a .NET project to the workspace, then run `git status`"* (or *"...then show me its contents"* for the MEAI version, which doesn't wire up `run_command`). Pass your own task as arguments instead:

dotnet run --project ToolRunnerAgent -- List everything in the workspace, then read any file you find.

Each app creates a `workspace/` directory (or `$AGENT_WORKSPACE`, if set) next to the executable and scopes every file operation to it — the agent cannot read or write outside of it, `write_file` always asks for a `y/n` confirmation before it touches disk, and `run_command` (in `ToolRunnerAgent` only) checks the command's program name against an allowlist (`dotnet`, `git`, `ls`) before it even reaches the confirmation prompt.

What each project demonstrates

**`ToolRunnerAgent/Program.cs`**

  • BetaRunnableTool + BetaTool — defining a tool as hand-written JSON Schema plus a Run deleg