mirror of
https://github.com/instructkr/claw-code.git
synced 2026-04-05 15:44:49 +08:00
The root and Rust-facing docs now point readers at a single task-oriented usage guide with build, auth, CLI, session, and parity-harness examples. This also fixes stale workspace references and updates the Rust workspace inventory to match the current crate set. Constraint: Existing README copy still referenced the old dev/rust status and needed to stay lightweight Rejected: Fold all usage details into README.md only | too much noise for the landing page Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep USAGE examples aligned with when CLI flags change Tested: cargo build --workspace; cargo test --workspace Not-tested: External links and rendered Markdown in GitHub UI
2.9 KiB
2.9 KiB
Claw Code Usage
This guide covers the current Rust workspace under rust/ and the claw CLI binary.
Prerequisites
- Rust toolchain with
cargo - One of:
ANTHROPIC_API_KEYfor direct API accessclaw loginfor OAuth-based auth
- Optional:
ANTHROPIC_BASE_URLwhen targeting a proxy or local service
Build the workspace
cd rust
cargo build --workspace
The CLI binary is available at rust/target/debug/claw after a debug build.
Quick start
Interactive REPL
cd rust
./target/debug/claw
One-shot prompt
cd rust
./target/debug/claw prompt "summarize this repository"
Shorthand prompt mode
cd rust
./target/debug/claw "explain rust/crates/runtime/src/lib.rs"
JSON output for scripting
cd rust
./target/debug/claw --output-format json prompt "status"
Model and permission controls
cd rust
./target/debug/claw --model sonnet prompt "review this diff"
./target/debug/claw --permission-mode read-only prompt "summarize Cargo.toml"
./target/debug/claw --permission-mode workspace-write prompt "update README.md"
./target/debug/claw --allowedTools read,glob "inspect the runtime crate"
Supported permission modes:
read-onlyworkspace-writedanger-full-access
Model aliases currently supported by the CLI:
opus→claude-opus-4-6sonnet→claude-sonnet-4-6haiku→claude-haiku-4-5-20251213
Authentication
API key
export ANTHROPIC_API_KEY="sk-ant-..."
OAuth
cd rust
./target/debug/claw login
./target/debug/claw logout
Common operational commands
cd rust
./target/debug/claw status
./target/debug/claw sandbox
./target/debug/claw agents
./target/debug/claw mcp
./target/debug/claw skills
./target/debug/claw system-prompt --cwd .. --date 2026-04-04
Session management
REPL turns are persisted under .claw/sessions/ in the current workspace.
cd rust
./target/debug/claw --resume latest
./target/debug/claw --resume latest /status /diff
Useful interactive commands include /help, /status, /cost, /config, /session, /model, /permissions, and /export.
Config file resolution order
Runtime config is loaded in this order, with later entries overriding earlier ones:
~/.claw.json~/.config/claw/settings.json<repo>/.claw.json<repo>/.claw/settings.json<repo>/.claw/settings.local.json
Mock parity harness
The workspace includes a deterministic Anthropic-compatible mock service and parity harness.
cd rust
./scripts/run_mock_parity_harness.sh
Manual mock service startup:
cd rust
cargo run -p mock-anthropic-service -- --bind 127.0.0.1:0
Verification
cd rust
cargo test --workspace
Workspace overview
Current Rust crates:
apicommandscompat-harnessmock-anthropic-servicepluginsruntimerusty-claude-clitelemetrytools