claude-agent-rs
A lightweight Rust binary that runs Claude as a full coding agent. Uses your Max subscription for $0 API costs, or pay-per-token via the API.
Install
Or build from source:
Requirements
- Rust 2021 edition (for building)
- One of:
claudeCLI installed + Claude Max subscription (CLI backend, $0)ANTHROPIC_API_KEY+AGENT_BACKEND=api(API backend, pay-per-token)
Usage
Interactive REPL
$ claude-agent
claude-agent v0.8.0 (Rust)
claude-opus-4-6 · backend: cli (Claude Max)
8 tools · no MCP servers
❯ write a fizzbuzz in Rust, compile it, run it
▸ write: /tmp/fizzbuzz.rs
✓ File written
▸ bash: rustc /tmp/fizzbuzz.rs -o /tmp/fizzbuzz && /tmp/fizzbuzz
✓ 1, 2, Fizz, 4, Buzz...
One-shot mode
CLI options
claude-agent Start interactive REPL
claude-agent -p "prompt" One-shot mode (run and exit)
claude-agent [directory] Start REPL in directory
claude-agent --resume <id> Resume a previous session
claude-agent --auto-route Auto-select Opus vs Haiku by complexity
claude-agent --system-prompt "…" Override the system prompt
claude-agent --help Show help
claude-agent --version Show version
Built-in Tools
| Tool | Description |
|---|---|
| bash | Execute shell commands with timeout |
| read | Read files with line numbers |
| write | Create or overwrite files |
| edit | Exact string replacement |
| glob | Pattern-based file search |
| grep | Regex content search (uses ripgrep) |
| web_fetch | HTTP GET requests |
| agent | Spawn sub-agents with optional git worktree isolation |
Two Inference Backends
CLI mode (default) — Pipes prompts to claude -p --output-format stream-json. Uses your Claude Max subscription's OAuth token. Zero per-token billing.
API mode — Direct POST to api.anthropic.com/v1/messages with SSE streaming. Set AGENT_BACKEND=api and ANTHROPIC_API_KEY.
Features
- 8 built-in tools — bash, read, write, edit, glob, grep, web_fetch, agent
- SSE streaming — real-time token output for both backends
- MCP client — full JSON-RPC 2.0 stdio transport, auto-discovers tools from
~/.mcp.json - Session persistence — SQLite-backed save/restore with
--resume - Sub-agents — spawn parallel
claude -pprocesses with optional git worktree isolation - Multi-model routing — auto-select Opus (complex) vs Haiku (simple) with
--auto-route - Skills — user-defined
/commandsloaded from~/.claude-agent/skills/*.md - Plugins — custom tools via
~/.claude-agent/plugins/(manifest.json + executable) - CLAUDE.md injection — reads project + home CLAUDE.md into system prompt
- Context management — auto-compaction when approaching token limits
- Permissions — blocks dangerous commands (rm -rf /, fork bombs, etc.)
- Library API — use as a crate:
Agent::new(config).await?.chat("...").await?
Configuration
MCP Servers
Place your MCP config at ~/.mcp.json:
Custom Skills
Create .md files in ~/.claude-agent/skills/:
Review the current codebase for security vulnerabilities. Focus on: {args}
Then use /review OWASP top 10 in the REPL.
Custom System Prompt
Place a system.md at ~/.claude-agent/system.md to override the default agent identity.
Stats
- Binary: ~5MB (release, LTO, stripped, SQLite + rustls bundled)
- Dependencies: 14 crates
- Startup: <100ms
- Zero warnings — clean clippy + rustc
License
MIT