Claude CLI
Define a Claude Code agent in C# and run it with local CLI authentication, permissions, and Runiq tools.
UseClaude(...) selects the locally installed Claude Code CLI. Set the model explicitly in the agent definition, just as with Codex. Authentication continues to use the host account's existing CLI configuration; no agent API key is required.
Define the Claude agent
The configuration callback and Model are required. Calling UseClaude() without arguments does not compile with this API; leaving the model blank fails validation when creating the agent.
This callback API is introduced in the Claude agent options source branch. Use a framework build containing this change. Earlier package versions expose only the parameterless method; this documentation update does not publish a new NuGet package.
Create Agents/ClaudeAgent.cs in your .NET 10 ASP.NET Core project:
Register the agent
Create the definition through its factory in Program.cs:
AddRuniqServer automatically registers the Claude executor. Execution requires Claude Code CLI installed and authenticated under the host account.
Definition and registration do not launch or authenticate the CLI. Follow Running agents with claude-analyst as the agent id, or enable Studio.
Choose model settings
| Setting | Behavior |
|---|---|
Model | Required CLI model name or alias, such as sonnet or opus. |
ReasoningEffort | Defaults to High. Accepts Low, Medium, High, XHigh, or Max. |
Runiq copies the validated settings into agent.Executor!.Claude and sends --model and --effort on every invocation, including resumed turns. The selected CLI/account determines model availability and supported reasoning levels; account policy can limit effective effort. Studio displays the configured model and requested reasoning effort.
Claude has no Runiq ServiceTier option. Use ClaudeReasoningEffort for Claude and CodexReasoningEffort for Codex. Both require an explicit model. See the Claude CLI reference for the underlying flags.
Understand permissions
Runiq invokes Claude in non-interactive dontAsk mode. Actions requiring approval are denied, while existing CLI permission allow rules still apply. This does not guarantee a read-only filesystem; configure permissions under the trusted host account and project. Runiq does not enable permission bypass.
Runiq preserves the account's CLI authentication. It removes CLAUDE_CODE_EFFORT_LEVEL from the child environment so that inherited effort cannot override the agent's selection. Agent instructions and the user message are passed through standard input.
Attach Runiq tools
Attach a typed tool to the definition before registration:
See Defining tools for the complete TextStatsTool definition. Runiq creates an authenticated per-run HTTP MCP bridge and allows the agent's exact tool names. Use a Claude Code installation with HTTP MCP support. No additional MCP registration is required; a failed bridge connection returns ClaudeToolBridgeFailed.
Tools run in the host process with host permissions and must validate business input and honor cancellation. Their start, completion and failure events appear in Studio. Native Claude tool activity is not republished as Runiq tool events. Active Runiq RAG bindings are unsupported and return ClaudeCapabilityNotSupported.
Execute and continue a conversation
Resolve AgentExecutionRuntime through dependency injection for completed responses or streaming. Claude text deltas become AssistantDelta events. To continue persisted CLI history, pass the confirmed ProviderSessionId from a previous result; see CLI conversation continuation.
Missing installation returns ClaudeNotInstalled; authentication failure returns ClaudeAuthenticationFailed. Timeout returns ClaudeTimeout. Failures do not fall back to Codex or a model provider.