Claude Agent Sdk Rust banner
Wally869 Wally869

Claude Agent Sdk Rust

AI community

Description

Rust SDK for Claude Code CLI - Build production-ready AI agents with type safety

Installation

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

README

Claude Agent SDK for Rust

[![Crates.io](https://img.shields.io/crates/v/claude-agent-sdk-rust)](https://crates.io/crates/claude-agent-sdk-rust) [![docs.rs](https://img.shields.io/docsrs/claude-agent-sdk-rust)](https://docs.rs/claude-agent-sdk-rust)

Rust SDK for building production-ready AI agents with Claude. Replicate the full feature set of the Python Claude Agent SDK with idiomatic Rust patterns.

Overview

The Claude Agent SDK enables you to build powerful AI agents using Claude Code's agent harness. This SDK wraps the Claude Code CLI, providing type-safe access to:

  • Automatic context management and compaction
  • 20+ built-in tools (file operations, code execution, web search)
  • Custom MCP (Model Context Protocol) tools
  • Fine-grained permission controls
  • Hook system for deterministic behavior
  • Interactive bidirectional conversations
  • Usage tracking and quota monitoring (Max Plan)

Important Notes

**Structured output requires more than 1 turn.** When using `output_format` with a JSON schema, the CLI may need additional turns internally to produce structured JSON. Set `max_turns` to at least 2-3 (or omit it entirely) — using `max_turns(1)` will likely result in `error_max_turns` with no structured output.

**`max_budget_usd` is a soft cap.** The budget limit is checked between turns, not mid-generation. The current turn will always complete before the budget is evaluated, so actual spend may slightly exceed the configured limit.

**No nested Claude Code instances.** As of [CLI v2.1.41](https://code.claude.com/docs/en/changelog#2141), Claude Code prevents spawning nested instances of itself. The CLI sets `CLAUDECODE=1` in the environment; any child process that tries to start another Claude Code instance will detect this and refuse to launch. This means you cannot test SDK examples from within a Claude Code session (e.g. from Claude Code's Bash tool). Run them from a regular terminal instead. If you need to bypass this, unset the `CLAUDECODE`