mirror of
https://github.com/ultraworkers/claw-code-parity.git
synced 2026-04-22 12:46:05 +02:00
7db400c54e
Replayed the CLI parity changes on top of the latest mainline so the direct command surface now includes a date-filtered git log view alongside the related config, hook, and branch helpers already in flight. Constraint: The local branch had diverged from origin/main and required a rebase before push Constraint: Keep the Rust CLI help text, parsing, and focused tests aligned Rejected: Push the pre-rebase commit directly | non-fast-forward and stale mainline base Confidence: medium Scope-risk: moderate Directive: Preserve the top-level log/config/hook/branch command wiring together when reconciling future CLI parity rebases Tested: cargo build --workspace; cargo test -p rusty-claude-cli parses_log_subcommand_with_since_filter; cargo test -p rusty-claude-cli rejects_invalid_log_arguments; cargo test -p rusty-claude-cli cli_git_log_args_include_since_when_requested; ./target/debug/claw log --since 2026-04-01 Not-tested: full cargo test --workspace after the rebase conflict resolution
161 lines
3.0 KiB
Markdown
161 lines
3.0 KiB
Markdown
# 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_KEY` for direct API access
|
|
- `claw login` for OAuth-based auth
|
|
- Optional: `ANTHROPIC_BASE_URL` when targeting a proxy or local service
|
|
|
|
## Build the workspace
|
|
|
|
```bash
|
|
cd rust
|
|
cargo build --workspace
|
|
```
|
|
|
|
The CLI binary is available at `rust/target/debug/claw` after a debug build.
|
|
|
|
## Quick start
|
|
|
|
### Interactive REPL
|
|
|
|
```bash
|
|
cd rust
|
|
./target/debug/claw
|
|
```
|
|
|
|
### One-shot prompt
|
|
|
|
```bash
|
|
cd rust
|
|
./target/debug/claw prompt "summarize this repository"
|
|
```
|
|
|
|
### Shorthand prompt mode
|
|
|
|
```bash
|
|
cd rust
|
|
./target/debug/claw "explain rust/crates/runtime/src/lib.rs"
|
|
```
|
|
|
|
### JSON output for scripting
|
|
|
|
```bash
|
|
cd rust
|
|
./target/debug/claw --output-format json prompt "status"
|
|
```
|
|
|
|
## Model and permission controls
|
|
|
|
```bash
|
|
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-only`
|
|
- `workspace-write`
|
|
- `danger-full-access`
|
|
|
|
Model aliases currently supported by the CLI:
|
|
|
|
- `opus` → `claude-opus-4-6`
|
|
- `sonnet` → `claude-sonnet-4-6`
|
|
- `haiku` → `claude-haiku-4-5-20251213`
|
|
|
|
## Authentication
|
|
|
|
### API key
|
|
|
|
```bash
|
|
export ANTHROPIC_API_KEY="sk-ant-..."
|
|
```
|
|
|
|
### OAuth
|
|
|
|
```bash
|
|
cd rust
|
|
./target/debug/claw login
|
|
./target/debug/claw logout
|
|
```
|
|
|
|
## Common operational commands
|
|
|
|
```bash
|
|
cd rust
|
|
./target/debug/claw status
|
|
./target/debug/claw sandbox
|
|
./target/debug/claw hook list
|
|
./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.
|
|
|
|
```bash
|
|
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:
|
|
|
|
1. `~/.claw.json`
|
|
2. `~/.config/claw/settings.json`
|
|
3. `<repo>/.claw.json`
|
|
4. `<repo>/.claw/settings.json`
|
|
5. `<repo>/.claw/settings.local.json`
|
|
|
|
## Mock parity harness
|
|
|
|
The workspace includes a deterministic Anthropic-compatible mock service and parity harness.
|
|
|
|
```bash
|
|
cd rust
|
|
./scripts/run_mock_parity_harness.sh
|
|
```
|
|
|
|
Manual mock service startup:
|
|
|
|
```bash
|
|
cd rust
|
|
cargo run -p mock-anthropic-service -- --bind 127.0.0.1:0
|
|
```
|
|
|
|
## Verification
|
|
|
|
```bash
|
|
cd rust
|
|
cargo test --workspace
|
|
```
|
|
|
|
## Workspace overview
|
|
|
|
Current Rust crates:
|
|
|
|
- `api`
|
|
- `commands`
|
|
- `compat-harness`
|
|
- `mock-anthropic-service`
|
|
- `plugins`
|
|
- `runtime`
|
|
- `rusty-claude-cli`
|
|
- `telemetry`
|
|
- `tools`
|