A rabbit-fast Rust reimplementation inspired by Claude Code, with native TUI, deeper tooling, and a cleaner path for terminal-first AI development.
| Metric | TypeScript/Bun (v2.1.88) | Rust (claude-cli-rs) | Improvement |
|---|---|---|---|
| Cold startup | ~200 ms | ~15 ms | 13Γ faster |
| Warm startup | ~120 ms | ~8 ms | 15Γ faster |
| Memory (idle REPL) | ~150 MB | ~25 MB | 6Γ less |
| Memory (active session) | ~300 MB | ~60 MB | 5Γ less |
| Binary size | 22 MB bundle + Bun runtime | ~20 MB single static binary | No runtime dependency |
| File read (10k lines) | ~12 ms | ~1.5 ms | 8Γ faster |
| Glob (100k files) | ~800 ms | ~120 ms | 6.7Γ faster |
| Grep (large repo) | ~600 ms | ~80 ms | 7.5Γ faster |
| Diff generation | ~15 ms | ~2 ms | 7.5Γ faster |
| SSE parse throughput | ~40 MB/s | ~200 MB/s | 5Γ faster |
| First token latency | Network bound | Network bound | ~Same |
Note: numbers are projected estimates based on comparable Rust vs TypeScript benchmarks. Formal benchmarks will be added in a future release.
- Zero-runtime deployment: single static binary, no Node/Bun/npm required
- Deterministic memory: no GC pauses during streaming or tool execution
- Native async: Tokio task model vs Node event loop β better parallelism for concurrent tools
- Startup: JIT-free cold start means instant
claude --help, instant REPL
-
Rust toolchain (1.85+):
- Download and run rustup-init.exe
- During installation, you will be prompted to install Visual Studio Build Tools (select the "Desktop development with C++" workload). This is required for compiling Rust projects. If you already have Visual Studio 2019/2022 with the C++ desktop development components installed, you can skip this step.
- After installation, restart your terminal (PowerShell / CMD) and verify:
rustc --version # Should show rustc 1.85.0 or higher cargo --version
-
Network proxy (required if crates.io is unreachable): If you use a local proxy (e.g. Clash, V2Ray), configure cargo to route through it:
# Create or edit ~/.cargo/config.toml (i.e. C:\Users\<USERNAME>\.cargo\config.toml) # Add the following (change the port to match your proxy):
[http] proxy = "http://127.0.0.1:10809" [https] proxy = "http://127.0.0.1:10809"
Alternatively, use a mirror registry (no proxy needed):
[source.crates-io] replace-with = "ustc" [source.ustc] registry = "sparse+https://mirrors.ustc.edu.cn/crates.io-index/"
# Xcode command line tools (provides C linker)
xcode-select --install
# Rust toolchain
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/envsudo apt update && sudo apt install -y build-essential pkg-config libssl-dev
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/envgit clone https://github.com/liberbinjio/claude-cli-rs.git
cd claude-cli-rs
cargo build --releaseAfter building, the executable is located at:
- Windows:
target\release\claude.exe - macOS/Linux:
target/release/claude
Optional: install to your system PATH (so you can run claude from any directory):
cargo install --path crates/cli# Run from the project directory (no install needed)
cargo run -- --version
# Output: claude 0.1.0
cargo run -- --help
# Output:
# Claude Code (Rust) β AI coding assistant
#
# Usage: claude.exe [OPTIONS] [PROMPT] [COMMAND]
#
# Commands:
# self-test Run internal diagnostics
# help Print this message or the help of the given subcommand(s)
#
# Arguments:
# [PROMPT] Initial prompt to send (non-interactive when combined with --print)
#
# Options:
# -p, --print Print the response and exit (non-interactive mode)
# --model <MODEL> Model to use [default: claude-sonnet-4-20250514]
# --cwd <CWD> Working directory (defaults to current directory)
# --resume <RESUME> Resume a previous session by ID
# -v, --verbose Enable verbose/debug logging
# -h, --help Print help
# -V, --version Print version
# If installed to PATH, you can run directly:
claude --version
claude --helpYou must set an Anthropic API key before running:
Windows PowerShell:
$env:ANTHROPIC_API_KEY = "sk-ant-your-key-here"Windows CMD:
set ANTHROPIC_API_KEY=sk-ant-your-key-heremacOS / Linux:
export ANTHROPIC_API_KEY=sk-ant-your-key-hereTip: To persist the key, add the command to your shell profile (PowerShell:
$PROFILE, Bash:~/.bashrc, Zsh:~/.zshrc).
# Interactive REPL mode (default)
cargo run
# One-shot mode (print response and exit)
cargo run -- -p "Write a Hello World in Rust"
# Specify a model
cargo run -- --model claude-sonnet-4-20250514 -p "Explain this project architecture"
# Resume a previous session
cargo run -- --resume <session-id>
# If installed to PATH:
claude
claude -p "Explain this code"# AWS Bedrock
# Windows PowerShell:
$env:CLAUDE_CODE_USE_BEDROCK = "1"
$env:AWS_REGION = "us-east-1"
# macOS/Linux:
export CLAUDE_CODE_USE_BEDROCK=1
export AWS_REGION=us-east-1claude-cli-rs/
βββ Cargo.toml # Workspace root
βββ LICENSE # MIT
βββ README.md # This file
βββ rustfmt.toml # Code formatting
βββ clippy.toml # Lint config
β
βββ crates/
β βββ cli/ # Binary entry point
β β βββ src/
β β βββ main.rs # fn main β startup orchestration
β β βββ args.rs # CLI argument parsing (clap)
β β βββ setup.rs # Initialization flow
β β
β βββ core/ # Core types (shared by all crates)
β β βββ src/
β β βββ lib.rs
β β βββ message.rs # Message, ContentBlock, UserMessage, AssistantMessage
β β βββ tool.rs # Tool trait, ToolRegistry, ToolUseContext, ToolResult
β β βββ permission.rs # PermissionMode, PermissionResult, rules
β β βββ config.rs # ClaudeConfig, ProjectSettings, load/save
β β βββ state.rs # AppState, AppStateHandle
β β βββ task.rs # TaskType, TaskStatus, TaskState
β β
β βββ api/ # Anthropic API client
β β βββ src/
β β βββ lib.rs
β β βββ client.rs # ApiClient, provider routing
β β βββ streaming.rs # SSE parser, MessageStream
β β βββ errors.rs # ApiError classification
β β βββ retry.rs # Exponential backoff
β β βββ normalize.rs # Message β API request format
β β
β βββ tools/ # 28 built-in tools
β β βββ src/
β β βββ lib.rs
β β βββ registry.rs # ToolRegistry impl, register_all_tools()
β β βββ bash.rs # BashTool β command execution
β β βββ grep.rs # GrepTool β code search
β β βββ file_read.rs # FileReadTool β read with line ranges
β β βββ file_write.rs # FileWriteTool β atomic write
β β βββ file_edit.rs # FileEditTool β precise string replacement
β β βββ glob.rs # GlobTool β file matching
β β βββ web_fetch.rs # WebFetchTool β HTTP + HTMLβMarkdown
β β βββ web_search.rs # WebSearchTool β search API
β β βββ agent.rs # AgentTool β sub-agent orchestration
β β βββ mcp_tool.rs # MCPTool β MCP server tool proxy
β β βββ todo_write.rs # TodoWriteTool
β β βββ lsp.rs # LSPTool
β β βββ notebook_edit.rs # NotebookEditTool
β β βββ task_create.rs # TaskCreateTool
β β βββ task_get.rs # TaskGetTool
β β βββ task_update.rs # TaskUpdateTool
β β βββ task_list.rs # TaskListTool
β β βββ task_stop.rs # TaskStopTool
β β βββ task_output.rs # TaskOutputTool
β β βββ skill.rs # SkillTool
β β βββ config_tool.rs # ConfigTool
β β βββ team_create.rs # TeamCreateTool
β β βββ team_delete.rs # TeamDeleteTool
β β βββ send_message.rs # SendMessageTool
β β βββ utils.rs # Internal helpers
β β βββ shared/ # Cross-tool shared logic
β β β βββ mod.rs
β β βββ prompts/ # Tool description templates
β β βββ file_read.txt
β β βββ file_write.txt
β β βββ file_edit.txt
β β βββ glob.txt
β β βββ web_fetch.txt
β β βββ web_search.txt
β β βββ agent.txt
β β βββ mcp_tool.txt
β β
β βββ query/ # Conversation engine
β β βββ src/
β β βββ lib.rs
β β βββ engine.rs # QueryEngine β multi-turn orchestration
β β βββ query_loop.rs # Single-turn: APIβtoolβresultβcontinue
β β βββ compact.rs # Context window compaction
β β βββ system_prompt.rs # System prompt construction
β β
β βββ commands/ # Slash command system (/help, /compact, ...)
β β βββ src/
β β βββ lib.rs
β β βββ command.rs # Command trait, CommandContext, CommandResult
β β βββ registry.rs # CommandRegistry, slash parsing
β β βββ builtin/ # 20 built-in commands
β β βββ mod.rs
β β βββ help.rs
β β βββ exit.rs
β β βββ clear.rs
β β βββ compact.rs
β β βββ model.rs
β β βββ cost.rs
β β βββ config.rs
β β βββ version.rs
β β βββ resume.rs
β β βββ session.rs
β β βββ permissions.rs
β β βββ mcp.rs
β β βββ init.rs
β β βββ memory.rs
β β βββ diff.rs
β β βββ commit.rs
β β βββ theme.rs
β β βββ vim.rs
β β βββ status.rs
β β βββ voice.rs
β β
β βββ mcp/ # MCP (Model Context Protocol) client
β β βββ src/
β β βββ lib.rs
β β βββ client.rs # McpClient β single server connection
β β βββ transport.rs # stdio / SSE transport
β β βββ types.rs # MCP protocol types
β β βββ manager.rs # McpConnectionManager β multi-server
β β
β βββ tui/ # Terminal UI (ratatui + crossterm)
β β βββ src/
β β βββ lib.rs
β β βββ terminal.rs # Terminal init/restore, panic hook
β β βββ event.rs # Event loop (Key/Mouse/Resize/Tick)
β β βββ theme.rs # Color themes (light/dark/auto)
β β βββ app.rs # App struct, main render loop
β β βββ repl.rs # REPL layout (messages + status + input)
β β βββ message_view.rs # Message list rendering
β β βββ prompt_input.rs # Multi-line input widget
β β βββ spinner.rs # Loading animation
β β βββ diff_view.rs # Unified/side-by-side diff
β β βββ permission_dialog.rs # Modal permission dialog (y/n/always)
β β βββ onboarding.rs # First-run onboarding flow
β β βββ markdown_render.rs # Markdown + syntax highlighting
β β βββ status_line.rs # Bottom bar (model/cost/tokens)
β β βββ keybindings.rs # Vim mode (optional)
β β
β βββ auth/ # Authentication
β β βββ src/
β β βββ lib.rs
β β βββ oauth.rs # OAuth 2.0 PKCE flow
β β βββ api_key.rs # API key management
β β βββ keychain.rs # OS keychain (macOS/Windows/Linux)
β β βββ providers.rs # Provider routing (Anthropic/Bedrock/Vertex)
β β
β βββ services/ # Application services
β β βββ src/
β β βββ lib.rs
β β βββ session.rs # Session storage (JSONL save/load/list)
β β βββ analytics.rs # Event tracking (no-op by default)
β β βββ cost.rs # Token & cost tracking
β β βββ compact.rs # Compaction strategy
β β βββ plugins.rs # Plugin system skeleton
β β βββ tips.rs # Usage tips
β β
β βββ bridge/ # Remote bridge (claude.ai WebSocket relay)
β β βββ src/
β β βββ lib.rs
β β βββ websocket.rs # WebSocket connection management
β β βββ messaging.rs # Message protocol serialization
β β βββ session.rs # Remote session creation
β β βββ auth.rs # Bridge JWT authentication
β β
β βββ utils/ # Shared utilities
β βββ src/
β βββ lib.rs
β βββ git.rs # Git operations (root, diff, log, branch)
β βββ shell.rs # Subprocess execution, process tree kill
β βββ platform.rs # OS/platform detection
β βββ fs.rs # File I/O, binary detection, atomic write
β βββ diff.rs # Text diff, string replace & uniqueness
β βββ tokens.rs # Token count estimation
β βββ markdown.rs # Markdown rendering, HTMLβMarkdown
β βββ env.rs # Environment variables, CI detection
β
βββ tests/
βββ integration/ # End-to-end integration tests
βββ mod.rs
βββ helpers/
β βββ mod.rs
β βββ mock_api.rs # wiremock-based Anthropic API mock
βββ test_cli.rs # CLI argument tests
βββ test_query_loop.rs # Query loop cycle tests
βββ test_tools.rs # Tool execution tests
βββ test_commands.rs # Slash command tests
βββ test_session.rs # Session save/restore tests
βββ test_mcp.rs # MCP client tests
cli βββ¬ββ core
βββ api ββββββ core, auth
βββ query ββββ core, api, tools, commands, utils
βββ commands β core, utils
βββ tools ββββ core, utils, mcp
βββ tui ββββββ core, query, utils
βββ auth βββββ core
βββ services β core, api, utils
βββ bridge βββ core, api
βββ mcp ββββββ core
βββ utils ββββ (standalone)
cd claude-cli-rs # All commands must be run from the project root
# === Build ===
cargo check --workspace # Quick type-check all crates (no binary output)
cargo build # Compile debug build (~7s incremental)
cargo build --release # Compile release build (~3 min first time, with LTO)
# === Run ===
cargo run # Launch CLI (runs target/debug/claude)
cargo run -- --version # Show version
cargo run -- --help # Show help
cargo run -- -p "Your question" # One-shot mode
cargo run -- self-test # Run internal diagnostics
# === Test ===
cargo test --workspace # Run all unit tests
cargo test --workspace -- --test-threads=1 # Serial execution (avoids env var races)
cargo test -p claude_core # Run tests for a specific crate
cargo test --test integration # Run integration tests
# === Code Quality ===
cargo clippy --workspace -- -D warnings # Lint (zero warnings required)
cargo fmt --all # Auto-format
cargo fmt --all -- --check # Check formatting without modifying
# === Debug ===
cargo run -- -v # Verbose mode with detailed logging
RUST_LOG=debug cargo run # More detailed logging (macOS/Linux)
$env:RUST_LOG="debug"; cargo run # More detailed logging (Windows PowerShell)| Metric | Value |
|---|---|
| Rust source files | 121 |
| Lines of code | ~13,000 |
| Unit tests | 523 |
| Crates | 12 |
You may need to configure a proxy or a mirror registry. See the Prerequisites > Network proxy section above.
Install the C++ desktop development component of Visual Studio Build Tools. Run Visual Studio Installer, click Modify, and check "Desktop development with C++".
Ensure your root Cargo.toml has default-members = ["crates/cli"]. If it does not, run:
cargo run --bin claudeor specify the crate:
cargo run -p claude_cliYour Rust version is below 1.85. Update:
rustup update stable- Ensure your terminal supports UTF-8 (Windows Terminal is recommended; legacy CMD is not)
- Windows users should use Windows Terminal or PowerShell 7