Files
claw-code/rust
Yeachan-Heo 771f716625 Make the Rust CLI clone-and-run deliverable-ready
Polish the integrated Rust CLI so the branch ships like a usable deliverable instead of a scaffold. This adds explicit version handling, expands the built-in help surface with environment and workflow guidance, and replaces the placeholder rust README with practical build, test, prompt, REPL, and resume instructions. It also ignores OMX and agent scratch directories so local orchestration state stays out of the shipped branch.\n\nConstraint: Must keep the existing workspace shape and avoid adding new dependencies\nConstraint: Must not commit .omx or other local orchestration artifacts\nRejected: Introduce clap-based top-level parsing for the main binary | larger refactor than needed for release-readiness\nRejected: Leave help and version behavior implicit | too rough for a clone-and-use deliverable\nConfidence: high\nScope-risk: narrow\nReversibility: clean\nDirective: Keep README examples and --help output aligned whenever CLI commands or env vars change\nTested: cargo fmt --all; cargo build --release -p rusty-claude-cli; cargo test --workspace --exclude compat-harness; cargo run -p rusty-claude-cli -- --help; cargo run -p rusty-claude-cli -- --version\nNot-tested: Live Anthropic API prompt/REPL execution without credentials in this session
2026-03-31 22:44:06 +00:00
..
2026-03-31 17:43:09 +00:00

Rusty Claude CLI

rust/ contains the Rust workspace for the integrated rusty-claude-cli deliverable. It is intended to be something you can clone, build, and run directly.

Workspace layout

rust/
├── Cargo.toml
├── Cargo.lock
├── README.md
└── crates/
    ├── api/               # Anthropic API client + SSE streaming support
    ├── commands/          # Shared slash-command metadata/help surfaces
    ├── compat-harness/    # Upstream TS manifest extraction harness
    ├── runtime/           # Session/runtime/config/prompt orchestration
    ├── rusty-claude-cli/  # Main CLI binary
    └── tools/             # Built-in tool implementations

Prerequisites

  • Rust toolchain installed (rustup, stable toolchain)
  • Network access and Anthropic credentials for live prompt/REPL usage

Build

From the repository root:

cd rust
cargo build --release -p rusty-claude-cli

The optimized binary will be written to:

./target/release/rusty-claude-cli

Test

Run the verified workspace test suite used for release-readiness:

cd rust
cargo test --workspace --exclude compat-harness

Quick start

Show help

cd rust
cargo run -p rusty-claude-cli -- --help

Print version

cd rust
cargo run -p rusty-claude-cli -- --version

Usage examples

1) Prompt mode

Send one prompt, stream the answer, then exit:

cd rust
cargo run -p rusty-claude-cli -- prompt "Summarize the architecture of this repository"

Use a specific model:

cd rust
cargo run -p rusty-claude-cli -- --model claude-sonnet-4-20250514 prompt "List the key crates in this workspace"

2) REPL mode

Start the interactive shell:

cd rust
cargo run -p rusty-claude-cli --

Inside the REPL, useful commands include:

/help
/status
/model claude-sonnet-4-20250514
/permissions workspace-write
/cost
/compact
/memory
/config
/init
/exit

3) Resume an existing session

Inspect or maintain a saved session file without entering the REPL:

cd rust
cargo run -p rusty-claude-cli -- --resume session.json /status /compact /cost

You can also inspect memory/config state for a restored session:

cd rust
cargo run -p rusty-claude-cli -- --resume session.json /memory /config

Available commands

Top-level CLI commands

  • prompt <text...> — run one prompt non-interactively
  • --resume <session.json> [/commands...] — inspect or maintain a saved session
  • dump-manifests — print extracted upstream manifest counts
  • bootstrap-plan — print the current bootstrap skeleton
  • system-prompt [--cwd PATH] [--date YYYY-MM-DD] — render the synthesized system prompt
  • --help / -h — show CLI help
  • --version / -V — print the CLI version

Interactive slash commands

  • /help — show command help
  • /status — show current session status
  • /compact — compact local session history
  • /model [model] — inspect or switch the active model
  • /permissions [read-only|workspace-write|danger-full-access] — inspect or switch permissions
  • /clear [--confirm] — clear the current local session
  • /cost — show token usage totals
  • /resume <session-path> — load a saved session into the REPL
  • /config [env|hooks|model] — inspect discovered Claude config
  • /memory — inspect loaded instruction memory files
  • /init — create a starter CLAUDE.md
  • /exit — leave the REPL

Environment variables

Anthropic/API

  • ANTHROPIC_AUTH_TOKEN — preferred bearer token for API auth
  • ANTHROPIC_API_KEY — legacy API key fallback if auth token is unset
  • ANTHROPIC_BASE_URL — override the Anthropic API base URL
  • ANTHROPIC_MODEL — default model used by selected live integration tests

CLI/runtime

  • RUSTY_CLAUDE_PERMISSION_MODE — default REPL permission mode (read-only, workspace-write, or danger-full-access)
  • CLAUDE_CONFIG_HOME — override Claude config discovery root
  • CLAUDE_CODE_REMOTE — enable remote-session bootstrap handling when supported
  • CLAUDE_CODE_REMOTE_SESSION_ID — remote session identifier when using remote mode
  • CLAUDE_CODE_UPSTREAM — override the upstream TS source path for compat-harness extraction
  • CLAWD_WEB_SEARCH_BASE_URL — override the built-in web search service endpoint used by tooling

Notes

  • compat-harness exists to compare the Rust port against the upstream TypeScript codebase and is intentionally excluded from the requested release test run.
  • The CLI currently focuses on a practical integrated workflow: prompt execution, REPL operation, session inspection/resume, config discovery, and tool/runtime plumbing.