Skip to content
This repository was archived by the owner on Apr 8, 2026. It is now read-only.

Commit 953513f

Browse files
committed
docs: add a current claw CLI usage guide
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
1 parent fbb2275 commit 953513f

4 files changed

Lines changed: 206 additions & 17 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</p>
2828

2929
> [!IMPORTANT]
30-
> **Rust port is now in progress** on the [`dev/rust`](https://github.com/instructkr/claw-code/tree/dev/rust) branch and is expected to be merged into main today. The Rust implementation aims to deliver a faster, memory-safe harness runtime. Stay tuned — this will be the definitive version of the project.
30+
> The active Rust workspace now lives in [`rust/`](./rust). Start with [`USAGE.md`](./USAGE.md) for build, auth, CLI, session, and parity-harness workflows, then use [`rust/README.md`](./rust/README.md) for crate-level details.
3131
3232
> If you find this work useful, consider [sponsoring @instructkr on GitHub](https://github.com/sponsors/instructkr) to support continued open-source harness engineering research.
3333

USAGE.md

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# Claw Code Usage
2+
3+
This guide covers the current Rust workspace under `rust/` and the `claw` CLI binary.
4+
5+
## Prerequisites
6+
7+
- Rust toolchain with `cargo`
8+
- One of:
9+
- `ANTHROPIC_API_KEY` for direct API access
10+
- `claw login` for OAuth-based auth
11+
- Optional: `ANTHROPIC_BASE_URL` when targeting a proxy or local service
12+
13+
## Build the workspace
14+
15+
```bash
16+
cd rust
17+
cargo build --workspace
18+
```
19+
20+
The CLI binary is available at `rust/target/debug/claw` after a debug build.
21+
22+
## Quick start
23+
24+
### Interactive REPL
25+
26+
```bash
27+
cd rust
28+
./target/debug/claw
29+
```
30+
31+
### One-shot prompt
32+
33+
```bash
34+
cd rust
35+
./target/debug/claw prompt "summarize this repository"
36+
```
37+
38+
### Shorthand prompt mode
39+
40+
```bash
41+
cd rust
42+
./target/debug/claw "explain rust/crates/runtime/src/lib.rs"
43+
```
44+
45+
### JSON output for scripting
46+
47+
```bash
48+
cd rust
49+
./target/debug/claw --output-format json prompt "status"
50+
```
51+
52+
## Model and permission controls
53+
54+
```bash
55+
cd rust
56+
./target/debug/claw --model sonnet prompt "review this diff"
57+
./target/debug/claw --permission-mode read-only prompt "summarize Cargo.toml"
58+
./target/debug/claw --permission-mode workspace-write prompt "update README.md"
59+
./target/debug/claw --allowedTools read,glob "inspect the runtime crate"
60+
```
61+
62+
Supported permission modes:
63+
64+
- `read-only`
65+
- `workspace-write`
66+
- `danger-full-access`
67+
68+
Model aliases currently supported by the CLI:
69+
70+
- `opus``claude-opus-4-6`
71+
- `sonnet``claude-sonnet-4-6`
72+
- `haiku``claude-haiku-4-5-20251213`
73+
74+
## Authentication
75+
76+
### API key
77+
78+
```bash
79+
export ANTHROPIC_API_KEY="sk-ant-..."
80+
```
81+
82+
### OAuth
83+
84+
```bash
85+
cd rust
86+
./target/debug/claw login
87+
./target/debug/claw logout
88+
```
89+
90+
## Common operational commands
91+
92+
```bash
93+
cd rust
94+
./target/debug/claw status
95+
./target/debug/claw sandbox
96+
./target/debug/claw agents
97+
./target/debug/claw mcp
98+
./target/debug/claw skills
99+
./target/debug/claw system-prompt --cwd .. --date 2026-04-04
100+
```
101+
102+
## Session management
103+
104+
REPL turns are persisted under `.claw/sessions/` in the current workspace.
105+
106+
```bash
107+
cd rust
108+
./target/debug/claw --resume latest
109+
./target/debug/claw --resume latest /status /diff
110+
```
111+
112+
Useful interactive commands include `/help`, `/status`, `/cost`, `/config`, `/session`, `/model`, `/permissions`, and `/export`.
113+
114+
## Config file resolution order
115+
116+
Runtime config is loaded in this order, with later entries overriding earlier ones:
117+
118+
1. `~/.claw.json`
119+
2. `~/.config/claw/settings.json`
120+
3. `<repo>/.claw.json`
121+
4. `<repo>/.claw/settings.json`
122+
5. `<repo>/.claw/settings.local.json`
123+
124+
## Mock parity harness
125+
126+
The workspace includes a deterministic Anthropic-compatible mock service and parity harness.
127+
128+
```bash
129+
cd rust
130+
./scripts/run_mock_parity_harness.sh
131+
```
132+
133+
Manual mock service startup:
134+
135+
```bash
136+
cd rust
137+
cargo run -p mock-anthropic-service -- --bind 127.0.0.1:0
138+
```
139+
140+
## Verification
141+
142+
```bash
143+
cd rust
144+
cargo test --workspace
145+
```
146+
147+
## Workspace overview
148+
149+
Current Rust crates:
150+
151+
- `api`
152+
- `commands`
153+
- `compat-harness`
154+
- `mock-anthropic-service`
155+
- `plugins`
156+
- `runtime`
157+
- `rusty-claude-cli`
158+
- `telemetry`
159+
- `tools`

rust/README.md

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,26 @@
22

33
A high-performance Rust rewrite of the Claw Code CLI agent harness. Built for speed, safety, and native tool execution.
44

5+
For a task-oriented guide with copy/paste examples, see [`../USAGE.md`](../USAGE.md).
6+
57
## Quick Start
68

79
```bash
8-
# Build
10+
# Inspect available commands
911
cd rust/
10-
cargo build --release
12+
cargo run -p rusty-claude-cli -- --help
13+
14+
# Build the workspace
15+
cargo build --workspace
1116

12-
# Run interactive REPL
13-
./target/release/claw
17+
# Run the interactive REPL
18+
cargo run -p rusty-claude-cli -- --model claude-opus-4-6
1419

1520
# One-shot prompt
16-
./target/release/claw prompt "explain this codebase"
21+
cargo run -p rusty-claude-cli -- prompt "explain this codebase"
1722

18-
# With specific model
19-
./target/release/claw --model sonnet prompt "fix the bug in main.rs"
23+
# JSON output for automation
24+
cargo run -p rusty-claude-cli -- --output-format json prompt "summarize src/main.rs"
2025
```
2126

2227
## Configuration
@@ -29,10 +34,10 @@ export ANTHROPIC_API_KEY="sk-ant-..."
2934
export ANTHROPIC_BASE_URL="https://your-proxy.com"
3035
```
3136

32-
Or authenticate via OAuth:
37+
Or authenticate via OAuth and let the CLI persist credentials locally:
3338

3439
```bash
35-
claw login
40+
cargo run -p rusty-claude-cli -- login
3641
```
3742

3843
## Mock parity harness
@@ -113,25 +118,32 @@ Short names resolve to the latest model versions:
113118
claw [OPTIONS] [COMMAND]
114119
115120
Options:
116-
--model MODEL Set the model (alias or full name)
121+
--model MODEL Override the active model
117122
--dangerously-skip-permissions Skip all permission checks
118123
--permission-mode MODE Set read-only, workspace-write, or danger-full-access
119124
--allowedTools TOOLS Restrict enabled tools
120-
--output-format FORMAT Output format (text or json)
121-
--version, -V Print version info
125+
--output-format FORMAT Non-interactive output format (text or json)
126+
--resume SESSION Re-open a saved session or inspect it with slash commands
127+
--version, -V Print version and build information locally
122128
123129
Commands:
124130
prompt <text> One-shot prompt (non-interactive)
125131
login Authenticate via OAuth
126132
logout Clear stored credentials
127133
init Initialize project config
128-
doctor Check environment health
129-
self-update Update to latest version
134+
status Show the current workspace status snapshot
135+
sandbox Show the current sandbox isolation snapshot
136+
agents Inspect agent definitions
137+
mcp Inspect configured MCP servers
138+
skills Inspect installed skills
139+
system-prompt Render the assembled system prompt
130140
```
131141

142+
For the current canonical help text, run `cargo run -p rusty-claude-cli -- --help`.
143+
132144
## Slash Commands (REPL)
133145

134-
Tab completion now expands not just slash command names, but also common workflow arguments like model aliases, permission modes, and recent session IDs.
146+
Tab completion expands slash commands, model aliases, permission modes, and recent session IDs.
135147

136148
| Command | Description |
137149
|---------|-------------|
@@ -146,9 +158,12 @@ Tab completion now expands not just slash command names, but also common workflo
146158
| `/memory` | Show CLAUDE.md contents |
147159
| `/diff` | Show git diff |
148160
| `/export [path]` | Export conversation |
161+
| `/resume [id]` | Resume a saved conversation |
149162
| `/session [id]` | Resume a previous session |
150163
| `/version` | Show version |
151164

165+
See [`../USAGE.md`](../USAGE.md) for examples covering interactive use, JSON automation, sessions, permissions, and the mock parity harness.
166+
152167
## Workspace Layout
153168

154169
```
@@ -160,8 +175,10 @@ rust/
160175
├── commands/ # Shared slash-command registry
161176
├── compat-harness/ # TS manifest extraction harness
162177
├── mock-anthropic-service/ # Deterministic local Anthropic-compatible mock
178+
├── plugins/ # Plugin registry and hook wiring primitives
163179
├── runtime/ # Session, config, permissions, MCP, prompts
164180
├── rusty-claude-cli/ # Main CLI binary (`claw`)
181+
├── telemetry/ # Session tracing and usage telemetry types
165182
└── tools/ # Built-in tool implementations
166183
```
167184

@@ -171,14 +188,16 @@ rust/
171188
- **commands** — Slash command definitions and help text generation
172189
- **compat-harness** — Extracts tool/prompt manifests from upstream TS source
173190
- **mock-anthropic-service** — Deterministic `/v1/messages` mock for CLI parity tests and local harness runs
191+
- **plugins** — Plugin metadata, registries, and hook integration surfaces
174192
- **runtime**`ConversationRuntime` agentic loop, `ConfigLoader` hierarchy, `Session` persistence, permission policy, MCP client, system prompt assembly, usage tracking
175193
- **rusty-claude-cli** — REPL, one-shot prompt, streaming display, tool call rendering, CLI argument parsing
194+
- **telemetry** — Session trace events and supporting telemetry payloads
176195
- **tools** — Tool specs + execution: Bash, ReadFile, WriteFile, EditFile, GlobSearch, GrepSearch, WebSearch, WebFetch, Agent, TodoWrite, NotebookEdit, Skill, ToolSearch, REPL runtimes
177196

178197
## Stats
179198

180199
- **~20K lines** of Rust
181-
- **7 crates** in workspace
200+
- **9 crates** in workspace
182201
- **Binary name:** `claw`
183202
- **Default model:** `claude-opus-4-6`
184203
- **Default permissions:** `danger-full-access`

rust/USAGE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Rust usage guide
2+
3+
The canonical task-oriented usage guide lives at [`../USAGE.md`](../USAGE.md).
4+
5+
Use that guide for:
6+
7+
- workspace build and test commands
8+
- authentication setup
9+
- interactive and one-shot `claw` examples
10+
- session resume workflows
11+
- mock parity harness commands

0 commit comments

Comments
 (0)