Clau.Rs banner
kcodes0 kcodes0

Clau.Rs

Development community

Description

clau.rs is a type-safe SDK for the Claude Code tool by Anthropic

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

clau.rs 🦀

A type-safe, async-first Rust SDK for [Claude Code](https://github.com/anthropics/claude-code) that transforms the CLI tool into a powerful programmatic API.

Features

  • Type-Safe API: Strongly typed request/response models with compile-time safety
  • Async/Await: Built on Tokio for efficient async operations
  • Raw JSON Access: Full access to Claude CLI responses for maximum flexibility
  • Timeout Support: Configurable timeouts for all operations
  • Streaming Support: Real-time streaming responses with async iterators
  • Session Management: First-class session support with persistence
  • MCP Integration: Type-safe Model Context Protocol configuration
  • Error Handling: Comprehensive error types with detailed messages

Installation

Add this to your `Cargo.toml`:

[dependencies]
clau = "0.1.0"

Quick Start

use clau::{Client, Config};

#[tokio::main]
async fn main() -> Result<(), clau::Error> {
    let client = Client::new(Config::default());

    let response = client
        .query("Write a hello world in Rust")
        .send()
        .await?;

    println!("{}", response);
    Ok(())
}

Advanced Features

Raw JSON Access

Access the complete response with metadata and raw JSON for maximum flexibility:

use clau::{Client, StreamFormat};

let client = Client::builder()
    .stream_format(StreamFormat::Json)
    .build();

let response = client
    .query("What is Rust?")
    .send_full()
    .await?;

println!("Content: {}", response.content);

// Access metadata
if let Some(metadata) = &response.metadata {
    println!("Cost: ${:.6}", metadata.cost_usd.unwrap_or(0.0));
    println!("Session: {}", metadata.session_id);
}

// Access raw JSON for custom parsing
if let Some(raw_json) = &response.raw_json {
    // Extract any field from the Claude CLI response
    let custom_data = raw_json.get("duration_api_ms");
}

// Serialize the entire response for storage
let json_string = se