Expand description
Rust bindings for the Claude Code CLI.
This crate provides a type-safe interface to interact with the Claude Code CLI, enabling programmatic interaction with Claude through JSON streaming.
§Features
- Bidirectional message streaming
- Custom tool definitions via in-process MCP servers
- Hook-based interception of tool execution
- Type-safe message handling with comprehensive error types
§Example
use clauders::{Client, Options};
#[tokio::main]
async fn main() -> Result<(), clauders::Error> {
let client = Client::new(Options::new()).await?;
client.query("Hello, Claude!").await?;
Ok(())
}Re-exports§
pub use agent::Agent;pub use client::Client;pub use conversation::Conversation;pub use conversation::Turn;pub use conversation::TurnBuilder;pub use error::Error;pub use handler::DefaultHandler;pub use handler::Handler;pub use handler::dispatch;pub use hooks::Hooks;pub use hooks::PostToolUseCallback;pub use hooks::PostToolUseDecision;pub use hooks::PostToolUseInput;pub use hooks::PostToolUseOutput;pub use hooks::PreToolUseCallback;pub use hooks::PreToolUseDecision;pub use hooks::PreToolUseInput;pub use hooks::PreToolUseOutput;pub use hooks::StopCallback;pub use hooks::StopDecision;pub use hooks::StopInput;pub use hooks::StopOutput;pub use hooks::UserPromptSubmitCallback;pub use hooks::UserPromptSubmitDecision;pub use hooks::UserPromptSubmitInput;pub use hooks::UserPromptSubmitOutput;pub use mcp_server::McpServer;pub use model::Model;pub use options::Options;pub use permissions::Callback as PermissionCallback;pub use permissions::Decision;pub use permissions::PermissionContext;pub use permissions::PermissionMode;pub use permissions::PermissionRule;pub use proto::incoming::RateLimitStatus;pub use proto::message::AssistantError;pub use proto::message::Usage;pub use response::CompleteResponse;pub use response::ErrorResponse;pub use response::HookLifecycleResponse;pub use response::InitResponse;pub use response::RateLimitResponse;pub use response::Response;pub use response::Responses;pub use response::TextResponse;pub use response::ThinkingResponse;pub use response::ToolResultResponse;pub use response::ToolUseResponse;pub use tool::Tool;pub use tool::ToolError;pub use tool::ToolInput;
Modules§
- agent
- Agent configuration for Claude Code subagents.
- client
- conversation
- High-level conversation API for multi-turn interactions with Claude.
- error
- handler
- hooks
- mcp_
server - model
- options
- permissions
- proto
- response
- tool
- transport