Brandon Redmond's Claude SDK for Rust

Table of content
Brandon Redmond's Claude SDK for Rust

Brandon Redmond taught high school math and computer science for five years before teaching himself programming and transitioning into AI engineering. He built claude-sdk-rs, a type-safe Rust SDK that wraps the Claude Code CLI, letting Rust developers build AI agents with compile-time guarantees.

Background

GitHub | LinkedIn | DEV.to

The Rust SDK Problem

When Anthropic released the Claude Code CLI, official SDKs existed for Python and TypeScript. Rust developers had to shell out to the CLI or build their own wrappers. Redmond saw this gap and filled it.

From his DEV.to announcement:

“The Rust ecosystem lacked a comprehensive, type-safe SDK for Claude AI. I discovered that while the technology was incredibly powerful, the tooling often created unnecessary barriers for developers who just wanted to build useful things.”

SDK Architecture

claude-sdk-rs wraps the Claude Code CLI with idiomatic Rust patterns:

use claude_sdk_rs::{Client, Config};

#[tokio::main]
async fn main() -> Result<(), claude_sdk_rs::Error> {
    let client = Client::new(Config::default());
    let response = client.query("Explain Rust ownership").send().await?;
    println!("{}", response);
    Ok(())
}

The builder pattern allows custom configuration:

let client = Client::builder()
    .model("claude-3-sonnet-20240229")
    .system_prompt("You are a Rust programming assistant")
    .timeout_secs(60)
    .build();

Core Features

FeatureDescription
Type-safe responsesCompile-time guarantees on response structures
Async-firstBuilt on Tokio for concurrent operations
StreamingReal-time response chunks via stream().await
Session managementAutomatic context preservation across queries
MCP supportModel Context Protocol tool integration
Security levelsConfigurable permission controls (Strict/Balanced/Relaxed)

Feature Flags

The SDK uses Cargo feature flags for modularity:

[dependencies]
claude-sdk-rs = { version = "1.0", features = ["full"] }
tokio = { version = "1.40", features = ["full"] }
FlagPurpose
cliCommand-line interface
analyticsUsage metrics tracking
mcpModel Context Protocol support
sqlitePersistent session storage
fullAll features enabled

Installation

Requires Claude Code CLI:

npm install -g @anthropic-ai/claude-code
claude auth

Then add to your project:

[dependencies]
claude-sdk-rs = "1.0"
tokio = { version = "1.40", features = ["full"] }

Streaming Example

let mut stream = client.query("Write a story about robots").stream().await?;

while let Some(chunk) = stream.next().await {
    match chunk {
        Ok(text) => print!("{}", text),
        Err(e) => eprintln!("Error: {}", e),
    }
}

Key Takeaways

PrincipleImplementation
Fill ecosystem gapsRust had no Claude SDK, so he built one
Type safety mattersCompile-time checks catch integration errors
Modularity via featuresOnly include what you need
Open source by defaultMIT license, publicly available

Next: Jesse Vincent’s Superpowers Framework

Topics: rust claude-code sdk open-source