Claw Code is a clean-room open-source reimplementation of the Claude Code agent harness, built in Python and Rust. This claw code getting started guide walks you through every step — from cloning the repo to running advanced CLI subcommands and building the Rust runtime.
설치
Clone the repository from GitHub to get started with claw code:
The repository is organized into four top-level directories: src/ for the Python layer, rust/ for the six Rust crates, tests/ for the test suite, and assets/ for static resources.
Python 퀵스타트
The Python layer provides the primary CLI interface. All commands use the python3 -m src.main entrypoint with a subcommand argument:
27개 CLI 서브커맨드 전체
Claw Code exposes 27 subcommands through the Python CLI. Each subcommand maps to a specific agent operation, from workspace inspection to full runtime mode selection:
| 서브커맨드 | 용도 |
|---|---|
summary | Render the porting progress summary |
manifest | Print the workspace manifest |
parity-audit | Audit against the original TypeScript archive |
setup-report | Show workspace setup report with prefetches and deferred init |
command-graph | Display the command dependency graph |
tool-pool | Show the tool registry pool |
bootstrap-graph | Visualize the 7-stage bootstrap sequence |
subsystems | List all modules/subsystems |
commands | List available slash commands |
tools | List registered tools |
route | Show mode routing table |
bootstrap | Run the full bootstrap sequence |
turn-loop | Execute the conversation turn loop |
flush-transcript | Flush the current transcript to disk |
load-session | Load a saved session |
remote-mode | Start in remote mode |
ssh-mode | Start in SSH tunnel mode |
teleport-mode | Start in teleport (workspace migration) mode |
direct-connect-mode | Start in direct-connect mode |
deep-link-mode | Start in deep-link mode |
show-command | Inspect a specific command |
show-tool | Inspect a specific tool |
exec-command | Execute a specific command |
exec-tool | Execute a specific tool |
Rust 빌드 및 CLI
The Rust layer compiles to the rusty-claude-cli binary. Build and test with standard Cargo commands:
The Rust CLI supports the following commands and flags:
| 명령어 / 플래그 | 설명 |
|---|---|
prompt | Submit a prompt to the agent |
--resume | Resume a previous session |
dump-manifests | Dump workspace manifests |
bootstrap-plan | Display the bootstrap execution plan |
system-prompt | Print the system prompt |
--help | Display help information |
--version | Print version |
--output-format text|json | Control output format |
--allowedTools | Restrict which tools the agent may use |
환경 변수
Claw Code reads the following environment variables to configure authentication, model selection, runtime behavior, and remote connectivity:
| 변수 | 용도 |
|---|---|
ANTHROPIC_API_KEY | Primary API key for Anthropic authentication |
ANTHROPIC_AUTH_TOKEN | Bearer token for proxy/OAuth authentication |
ANTHROPIC_BASE_URL | Override the default API base URL |
ANTHROPIC_MODEL | Override the default model selection |
RUSTY_CLAUDE_PERMISSION_MODE | Set the permission enforcement mode |
CLAUDE_CONFIG_HOME | Override the config directory (default: ~/.claude) |
CLAUDE_CODE_REMOTE | Enable remote mode |
CLAUDE_CODE_REMOTE_SESSION_ID | Session ID for remote connections |
CLAUDE_CODE_UPSTREAM | Upstream server URL for remote mode |
CLAWD_WEB_SEARCH_BASE_URL | Base URL for web search integration |
워크스페이스 설정 시스템
The WorkspaceSetup system automatically discovers your environment when claw code starts. It detects python_version, implementation (CPython, PyPy, etc.), platform_name, and the test_command (defaulting to python3 -m unittest discover -s tests -v).
The SetupReport includes two phases: prefetches (data gathered eagerly during setup) and deferred_init (initialization deferred until after the trust gate clears). This two-phase approach ensures fast startup while deferring expensive operations until they are actually needed.
부트스트랩 시퀀스: 7단계
Claw Code follows a strict 7-stage bootstrap sequence every time it starts. Each stage depends on the successful completion of the previous one:
| 단계 | 이름 | 설명 |
|---|---|---|
| 1 | Prefetch | Eagerly gather workspace metadata, environment variables, and configuration files |
| 2 | Warning Handler | Install warning and error handlers for graceful failure reporting |
| 3 | CLI Parser + Trust Gate | Parse command-line arguments and verify trust/permission requirements |
| 4 | Setup + Parallel Load | Run workspace setup while loading commands and agents in parallel |
| 5 | Deferred Init | Execute deferred initialization steps after trust gate clears |
| 6 | Mode Routing | Route to one of 6 runtime modes: standard, remote, SSH, teleport, direct-connect, or deep-link |
| 7 | Query Engine Submit Loop | Enter the main conversation loop, submitting queries to the LLM and processing tool calls |
저장소 구조
The claw code repository is organized into four top-level directories, each with a clear responsibility boundary:
| 디렉토리 | 언어 | 내용 |
|---|---|---|
src/ | Python | Agent orchestration, LLM integration, session management, CLI entrypoint, query engine, tool definitions, command handlers |
rust/ | Rust | 6 crates: rusty-claude-cli, runtime, api, commands, tools, compat-harness |
tests/ | Python | Unit and integration tests for the Python layer |
assets/ | Static | Static resources, configuration templates, and reference data |