| name | claude-code-rust |
| description | High-performance Rust implementation of Claude Code with 2.5x faster startup, 97% smaller binary, and full MCP/REPL/plugin support |
| triggers | ["use claude code rust","install claude code rust version","set up rust claude code","configure claude code rust mcp","run claude code repl in rust","create claude code plugin rust","optimize claude code with rust","migrate to claude code rust"] |
Claude Code Rust
Skill by ara.so — Claude Code Skills collection.
Claude Code Rust is a complete Rust rewrite of Anthropic's Claude Code, delivering 2.5x faster startup (63ms vs 158ms), 97% smaller binary size (5MB vs 164MB), and zero runtime dependencies while maintaining 100% feature compatibility. It includes CLI tools, REPL mode, MCP server implementation, plugin system, and voice input support.
Installation
From Source (Recommended)
Linux/macOS:
git clone https://github.com/lorryjovens-hub/claude-code-rust.git
cd claude-code-rust
cargo build --release
sudo cp target/release/claude-code /usr/local/bin/
chmod +x scripts/install-linux.sh
./scripts/install-linux.sh
Windows (PowerShell):
# Clone repository
git clone https://github.com/lorryjovens-hub/claude-code-rust.git
cd claude-code-rust
# Build release binary
cargo build --release
# Run install script (copies to Program Files)
.\scripts\install-windows.ps1
Quick Build
cargo build
cargo build --release
cargo run -- --help
Configuration
API Configuration
Create ~/.claude-code/config.toml:
[api]
provider = "anthropic"
api_key_env = "ANTHROPIC_API_KEY"
model = "claude-3-5-sonnet-20241022"
max_tokens = 4096
Set environment variable:
export ANTHROPIC_API_KEY="your-key-here"
export DEEPSEEK_API_KEY="your-key-here"
MCP Server Configuration
Create ~/.claude-code/mcp-config.json:
{
"mcpServers": {
"filesystem": {
"command": "mcp-server-filesystem",
"args": ["/path/to/workspace"],
"env": {}
},
"git": {
"command": "mcp-server-git",
"args": [],
"env": {
"GIT_EDITOR": "vim"
}
}
}
}
CLI Usage
Basic Commands
claude-code "explain this code"
claude-code "refactor this function" -f src/main.rs
claude-code --repl
claude-code --voice
claude-code --version
claude-code --help
REPL Mode
claude-code --repl
> analyze the architecture
> /add src/api/client.rs
> /context
> /history
> /clear
> /save session.json
> /load session.json
> /exit
Memory Management
claude-code --repl --session my-project
claude-code --memory-stats
claude-code --consolidate-memory
MCP Server Usage
Starting MCP Server
use claude_code_rust::mcp::Server;
use claude_code_rust::config::McpConfig;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = McpConfig::load()?;
let server = Server::new(config);
server.serve_stdio().await?;
Ok(())
}
Registering Custom Tools
use claude_code_rust::mcp::{Tool, ToolRegistry};
use serde_json::Value;
struct MyTool;
impl Tool for MyTool {
fn name(&self) -> &str {
"my_custom_tool"
}
fn description(&self) -> &str {
"Performs custom analysis"
}
fn input_schema(&self) -> Value {
serde_json::json!({
"type": "object",
"properties": {
"input": {
"type": "string",
"description": "Input to analyze"
}
},
"required": ["input"]
})
}
async fn execute(&self, args: Value) -> Result<Value, Box<dyn std::error::Error>> {
let input = args["input"].as_str().unwrap();
Ok(serde_json::json!({
"result": format!("Analyzed: {}", input)
}))
}
}
let mut registry = ToolRegistry::new();
registry.register(Box::new(MyTool));
Resource Management
use claude_code_rust::mcp::{Resource, ResourceManager};
struct ProjectResource {
path: String,
}
impl Resource for ProjectResource {
fn uri(&self) -> String {
format!("file://{}", self.path)
}
fn name(&self) -> String {
"Project Files".to_string()
}
fn mime_type(&self) -> String {
"text/plain".to_string()
}
async fn read(&self) -> Result<String, Box<dyn std::error::Error>> {
std::fs::read_to_string(&self.path)
.map_err(|e| e.into())
}
}
let resource = ProjectResource {
path: "src/main.rs".to_string()
};
let content = resource.read().await?;
Plugin System
Creating a Plugin
use claude_code_rust::plugins::{Plugin, PluginContext};
use async_trait::async_trait;
pub struct MyPlugin;
#[async_trait]
impl Plugin for MyPlugin {
fn name(&self) -> &str {
"my-plugin"
}
fn version(&self) -> &str {
"1.0.0"
}
async fn initialize(&mut self, ctx: &PluginContext) -> Result<(), Box<dyn std::error::Error>> {
ctx.register_command("greet", |args| {
Box::pin(async move {
Ok(format!("Hello, {}!", args.get("name").unwrap_or(&"World".to_string())))
})
});
ctx.register_hook("before_query", |query| {
Box::pin(async move {
println!("Processing query: {}", query);
Ok(query)
})
});
Ok(())
}
}
#[no_mangle]
pub extern "C" fn _plugin_create() -> *mut dyn Plugin {
Box::into_raw(Box::new(MyPlugin))
}
Loading Plugins
claude-code --install-plugin ./my-plugin.so
claude-code --list-plugins
claude-code --plugin my-plugin greet --name Alice
API Client Usage
Making API Calls
use claude_code_rust::api::{ApiClient, Message, Role};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = ApiClient::from_env()?;
let messages = vec![
Message {
role: Role::User,
content: "Explain async/await in Rust".to_string(),
}
];
let response = client.create_message(messages).await?;
println!("{}", response.content);
Ok(())
}
Streaming Responses
use claude_code_rust::api::ApiClient;
use futures::StreamExt;
let mut stream = client.create_message_stream(messages).await?;
while let Some(chunk) = stream.next().await {
match chunk {
Ok(content) => print!("{}", content),
Err(e) => eprintln!("Stream error: {}", e),
}
}
Advanced Features
Voice Input
claude-code --voice
SSH Remote Execution
use claude_code_rust::advanced::ssh::SshClient;
let client = SshClient::connect("user@host:22", "~/.ssh/id_rsa").await?;
let result = client.execute("ls -la").await?;
println!("{}", result);
Project Initialization
claude-code --init my-new-project
claude-code --init my-app --template web-server
claude-code --init --interactive
Performance Optimization
Configuration Tuning
[performance]
consolidation_threshold = 20
max_context_tokens = 100000
parallel_tools = true
response_cache = true
cache_ttl_seconds = 3600
Memory Usage
use claude_code_rust::memory::{Session, ConsolidationStrategy};
let mut session = Session::new("my-session");
session.add_message(message);
if session.message_count() > 20 {
session.consolidate(ConsolidationStrategy::Summary).await?;
}
session.save("~/.claude-code/sessions/my-session.json")?;
Common Patterns
Error Handling
use claude_code_rust::error::{Error, Result};
fn process_query(query: &str) -> Result<String> {
if query.is_empty() {
return Err(Error::InvalidInput("Query cannot be empty".to_string()));
}
Ok("Result".to_string())
}
match process_query(input) {
Ok(result) => println!("{}", result),
Err(Error::ApiError(e)) => eprintln!("API error: {}", e),
Err(Error::ConfigError(e)) => eprintln!("Config error: {}", e),
Err(e) => eprintln!("Error: {}", e),
}
Context Management
use claude_code_rust::memory::Context;
let mut context = Context::new();
context.add_file("src/main.rs").await?;
context.add_directory("src/api", true).await?;
context.add_snippet("Custom context", "fn example() {}");
context.set_max_tokens(50000);
let truncated = context.truncate()?;
let formatted = context.to_string();
Troubleshooting
API Key Issues
echo $ANTHROPIC_API_KEY
claude-code "test" --debug
cat ~/.claude-code/config.toml
MCP Server Not Starting
cat ~/.claude-code/mcp-config.json
which mcp-server-filesystem
RUST_LOG=debug claude-code --repl
Build Errors
rustup update stable
cargo clean
cargo build --release --verbose
Performance Issues
export RUSTFLAGS="-C target-cpu=native"
cargo bloat --release
/usr/bin/time -v ./target/release/claude-code --help
claude-code --max-context 50000
Plugin Errors
claude-code --verify-plugin ./my-plugin.so
cat ~/.claude-code/plugins/my-plugin.log
cd my-plugin && cargo build --release
claude-code --uninstall-plugin my-plugin
claude-code --install-plugin ./target/release/libmy_plugin.so
Environment Variables
export ANTHROPIC_API_KEY="sk-ant-..."
export DEEPSEEK_API_KEY="sk-..."
export RUST_LOG=debug
export RUST_BACKTRACE=1
export CLAUDE_CODE_CACHE_DIR="~/.cache/claude-code"
export CLAUDE_CODE_MAX_WORKERS=4
export MCP_CONFIG_PATH="~/.claude-code/mcp-config.json"
Integration Examples
VS Code Extension
import { spawn } from 'child_process';
const claudeCode = spawn('claude-code', ['--repl']);
claudeCode.stdin.write('analyze this code\n');
claudeCode.stdout.on('data', (data) => {
console.log(`Response: ${data}`);
});
CI/CD Pipeline
name: AI Code Review
on: [pull_request]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Claude Code Rust
run: |
curl -L https://github.com/lorryjovens-hub/claude-code-rust/releases/latest/download/claude-code-linux-x64 -o /usr/local/bin/claude-code
chmod +x /usr/local/bin/claude-code
- name: Review PR
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
git diff origin/main...HEAD | claude-code "review this PR diff"