The shipped CLI surface lives in `src/main.rs`, which only wires `init`, `input`, and `render`. The legacy `app.rs` and `args.rs` prototypes were not in the module tree and had no inbound references, so this change deletes those orphaned files instead of widening scope into a larger refactor. It also aligns the TUI enhancement plan with that reality so the document no longer describes the removed prototypes as current tracked structure. Constraint: Must preserve shipped CLI parsing and slash-command behavior Rejected: Refactor main.rs into smaller modules now | widens scope beyond behavior-safe cleanup Rejected: Leave TUI plan wording untouched | leaves low-risk stale documentation behind Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep this slice deletion-first; do not reintroduce alternate CLI surfaces without wiring them into main.rs and its tests Tested: cargo test -p rusty-claude-cli defaults_to_repl_when_no_args Tested: cargo test -p rusty-claude-cli parses_login_and_logout_subcommands Tested: cargo test -p rusty-claude-cli parses_direct_agents_mcp_and_skills_slash_commands Tested: cargo test -p rusty-claude-cli direct_slash_commands_surface_shared_validation_errors Tested: cargo test -p rusty-claude-cli parses_resume_flag_with_multiple_slash_commands -- --nocapture Tested: cargo test -p rusty-claude-cli resumed_binary_accepts_slash_commands_with_arguments -- --nocapture Tested: cargo check -p rusty-claude-cli Tested: git diff --check Not-tested: cargo clippy -p rusty-claude-cli --all-targets -- -D warnings (pre-existing failures in rust/crates/runtime/* and existing warnings outside this diff)
🦞 Claw Code — Rust Implementation
A high-performance Rust rewrite of the Claw Code CLI agent harness. Built for speed, safety, and native tool execution.
For a task-oriented guide with copy/paste examples, see ../USAGE.md.
Quick Start
# Inspect available commands
cd rust/
cargo run -p rusty-claude-cli -- --help
# Build the workspace
cargo build --workspace
# Run the interactive REPL
cargo run -p rusty-claude-cli -- --model claude-opus-4-6
# One-shot prompt
cargo run -p rusty-claude-cli -- prompt "explain this codebase"
# JSON output for automation
cargo run -p rusty-claude-cli -- --output-format json prompt "summarize src/main.rs"
Configuration
Set your API credentials:
export ANTHROPIC_API_KEY="sk-ant-..."
# Or use a proxy
export ANTHROPIC_BASE_URL="https://your-proxy.com"
Or authenticate via OAuth and let the CLI persist credentials locally:
cargo run -p rusty-claude-cli -- login
Mock parity harness
The workspace now includes a deterministic Anthropic-compatible mock service and a clean-environment CLI harness for end-to-end parity checks.
cd rust/
# Run the scripted clean-environment harness
./scripts/run_mock_parity_harness.sh
# Or start the mock service manually for ad hoc CLI runs
cargo run -p mock-anthropic-service -- --bind 127.0.0.1:0
Harness coverage:
streaming_textread_file_roundtripgrep_chunk_assemblywrite_file_allowedwrite_file_deniedmulti_tool_turn_roundtripbash_stdout_roundtripbash_permission_prompt_approvedbash_permission_prompt_deniedplugin_tool_roundtrip
Primary artifacts:
crates/mock-anthropic-service/— reusable mock Anthropic-compatible servicecrates/rusty-claude-cli/tests/mock_parity_harness.rs— clean-env CLI harnessscripts/run_mock_parity_harness.sh— reproducible wrapperscripts/run_mock_parity_diff.py— scenario checklist + PARITY mapping runnermock_parity_scenarios.json— scenario-to-PARITY manifest
Features
| Feature | Status |
|---|---|
| Anthropic API + streaming | ✅ |
| OAuth login/logout | ✅ |
| Interactive REPL (rustyline) | ✅ |
| Tool system (bash, read, write, edit, grep, glob) | ✅ |
| Web tools (search, fetch) | ✅ |
| Sub-agent orchestration | ✅ |
| Todo tracking | ✅ |
| Notebook editing | ✅ |
| CLAUDE.md / project memory | ✅ |
| Config file hierarchy (.claude.json) | ✅ |
| Permission system | ✅ |
| MCP server lifecycle | ✅ |
| Session persistence + resume | ✅ |
| Extended thinking (thinking blocks) | ✅ |
| Cost tracking + usage display | ✅ |
| Git integration | ✅ |
| Markdown terminal rendering (ANSI) | ✅ |
| Model aliases (opus/sonnet/haiku) | ✅ |
| Slash commands (/status, /compact, /clear, etc.) | ✅ |
| Hooks (PreToolUse/PostToolUse) | 🔧 Config only |
| Plugin system | 📋 Planned |
| Skills registry | 📋 Planned |
Model Aliases
Short names resolve to the latest model versions:
| Alias | Resolves To |
|---|---|
opus |
claude-opus-4-6 |
sonnet |
claude-sonnet-4-6 |
haiku |
claude-haiku-4-5-20251213 |
CLI Flags
claw [OPTIONS] [COMMAND]
Options:
--model MODEL Override the active model
--dangerously-skip-permissions Skip all permission checks
--permission-mode MODE Set read-only, workspace-write, or danger-full-access
--allowedTools TOOLS Restrict enabled tools
--output-format FORMAT Non-interactive output format (text or json)
--resume SESSION Re-open a saved session or inspect it with slash commands
--version, -V Print version and build information locally
Commands:
prompt <text> One-shot prompt (non-interactive)
login Authenticate via OAuth
logout Clear stored credentials
init Initialize project config
status Show the current workspace status snapshot
sandbox Show the current sandbox isolation snapshot
agents Inspect agent definitions
mcp Inspect configured MCP servers
skills Inspect installed skills
system-prompt Render the assembled system prompt
For the current canonical help text, run cargo run -p rusty-claude-cli -- --help.
Slash Commands (REPL)
Tab completion expands slash commands, model aliases, permission modes, and recent session IDs.
| Command | Description |
|---|---|
/help |
Show help |
/status |
Show session status (model, tokens, cost) |
/cost |
Show cost breakdown |
/compact |
Compact conversation history |
/clear |
Clear conversation |
/model [name] |
Show or switch model |
/permissions |
Show or switch permission mode |
/config [section] |
Show config (env, hooks, model) |
/memory |
Show CLAUDE.md contents |
/diff |
Show git diff |
/export [path] |
Export conversation |
/resume [id] |
Resume a saved conversation |
/session [id] |
Resume a previous session |
/version |
Show version |
See ../USAGE.md for examples covering interactive use, JSON automation, sessions, permissions, and the mock parity harness.
Workspace Layout
rust/
├── Cargo.toml # Workspace root
├── Cargo.lock
└── crates/
├── api/ # Anthropic API client + SSE streaming
├── commands/ # Shared slash-command registry
├── compat-harness/ # TS manifest extraction harness
├── mock-anthropic-service/ # Deterministic local Anthropic-compatible mock
├── plugins/ # Plugin registry and hook wiring primitives
├── runtime/ # Session, config, permissions, MCP, prompts
├── rusty-claude-cli/ # Main CLI binary (`claw`)
├── telemetry/ # Session tracing and usage telemetry types
└── tools/ # Built-in tool implementations
Crate Responsibilities
- api — HTTP client, SSE stream parser, request/response types, auth (API key + OAuth bearer)
- commands — Slash command definitions and help text generation
- compat-harness — Extracts tool/prompt manifests from upstream TS source
- mock-anthropic-service — Deterministic
/v1/messagesmock for CLI parity tests and local harness runs - plugins — Plugin metadata, registries, and hook integration surfaces
- runtime —
ConversationRuntimeagentic loop,ConfigLoaderhierarchy,Sessionpersistence, permission policy, MCP client, system prompt assembly, usage tracking - rusty-claude-cli — REPL, one-shot prompt, streaming display, tool call rendering, CLI argument parsing
- telemetry — Session trace events and supporting telemetry payloads
- tools — Tool specs + execution: Bash, ReadFile, WriteFile, EditFile, GlobSearch, GrepSearch, WebSearch, WebFetch, Agent, TodoWrite, NotebookEdit, Skill, ToolSearch, REPL runtimes
Stats
- ~20K lines of Rust
- 9 crates in workspace
- Binary name:
claw - Default model:
claude-opus-4-6 - Default permissions:
danger-full-access
License
See repository root.