AI

Claw Code: Open-Source Claude Code Alternative in Rust (Install and Getting Started)

Claw Code hit 179,000 GitHub stars in nine days. That alone should tell you something about the demand for an open-source, terminal-first AI coding assistant that works with your own API key instead of a monthly subscription. Built in Rust by the UltraWorkers team, Claw Code is a from-scratch reimplementation of the Claude Code workflow: agentic coding in your terminal, with tool use, file operations, sandboxing, and multi-provider support.

Original content from computingforgeeks.com - post 165443

The project ships a full event-driven architecture with a state machine runtime, crash recovery, and native Linux sandboxing. It supports not just Anthropic’s Claude models but also OpenAI, xAI/Grok, Alibaba’s Qwen, and any OpenAI-compatible endpoint (Ollama, OpenRouter, LiteLLM). This guide walks through building Claw Code from source on Fedora, Ubuntu/Debian, and macOS, configuring providers, and running your first prompts.

Tested April 2026 on Fedora 42 (kernel 6.14, x86_64) and macOS 26.3 (Apple Silicon). Claw Code built from main branch (commit 4730b66), Rust 1.94.1. No tagged releases as of this writing

What You’ll Learn

  • How Claw Code compares to Claude Code in architecture, cost, and features
  • Building Claw Code from source on Fedora/RHEL, Ubuntu/Debian, and macOS
  • Configuring API keys for Anthropic, OpenAI, xAI, and local models
  • Running one-shot prompts, interactive sessions, and JSON output mode
  • Multi-provider setup with Ollama, OpenRouter, and DashScope
  • What works, what’s partial, and what to expect from this early-stage project

Claw Code vs Claude Code

Before building anything, here’s how the two tools compare across the dimensions that matter most.

DimensionClaw CodeClaude Code
Source codeOpen source (MIT/Apache 2.0)Proprietary
LanguageRustTypeScript/Node.js
Cost modelAPI key only (pay per token)Pro/Max subscription or API key
Supported modelsClaude, GPT, Grok, Qwen, any OpenAI-compatibleClaude models only
ArchitectureEvent-driven state machine with crash recoverySequential tool loop
SandboxLinux namespace isolation (unshare)macOS sandbox-exec, Docker on Linux
File operationsRead, write, edit, glob, grep (built-in tools)Read, write, edit, glob, grep
Permission modelread-only, workspace-write, danger-full-accessPer-tool approval with allow lists
MCP supportPartial (in progress)Full (stdio and SSE transports)
Plugin systemRust plugin crateSlash commands and MCP servers
Config formatJSON (hierarchical resolution)JSON + CLAUDE.md
MaturityPre-release (no tagged versions), 9 days oldProduction, 1+ year

Claw Code makes sense if you want full control over the source, need multi-provider support, or want to avoid a subscription entirely. The Rust implementation also means lower memory usage and faster startup compared to the Node.js-based Claude Code.

Claude Code is the safer choice for production workflows right now. It has a year of battle-testing, full MCP support, and a broader tool ecosystem. If you rely on Claude Code daily, Claw Code is worth watching but not yet a drop-in replacement.

The sweet spot for Claw Code today is experimentation, multi-model workflows, and contributing to an open-source tool that’s evolving fast.

Prerequisites

  • Rust toolchain: Rust 1.94+ with cargo (install via rustup)
  • Git: to clone the repository
  • Build tools: C compiler and development headers (gcc, make, openssl-dev)
  • API key: at minimum one of Anthropic, OpenAI, xAI, or a local model endpoint
  • Tested on: Fedora 42 (x86_64), macOS 26.3 (Apple Silicon), Rocky Linux 10, Ubuntu 24.04

Install on Fedora / RHEL / Rocky Linux

Fedora 42 was used for testing. The same steps apply to Rocky Linux 10, AlmaLinux 10, and RHEL 10 with minor package name differences.

Install Build Dependencies

Install the compiler toolchain and OpenSSL development headers:

sudo dnf install -y git gcc make curl openssl-devel pkg-config

If Rust is not already installed, grab it from rustup:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env"

Verify the Rust version:

rustc --version

You should see 1.94.1 or newer:

rustc 1.94.1 (9e136a06a 2026-03-23)

Clone and Build

Clone the repository and build the release binary:

git clone https://github.com/ultraworkers/claw-code.git
cd claw-code
cargo build --workspace --release

The build takes about 1 minute 51 seconds on a 4-vCPU cloud instance. The binary lands at target/release/claw.

Move it somewhere in your PATH:

sudo cp target/release/claw /usr/local/bin/
claw --version

The version output confirms a successful build:

Claw Code
  Version          0.1.0
  Git SHA          4730b66
  Target           x86_64-unknown-linux-gnu
  Build date       2026-04-09

The version 0.1.0 is hardcoded in Cargo.toml. There are no tagged releases or downloadable binaries on GitHub. The git SHA is the real version identifier.

Install on Ubuntu / Debian

The process is nearly identical. Package names differ slightly on Debian-based systems.

Install Build Dependencies

Install the required development packages:

sudo apt update
sudo apt install -y git build-essential curl libssl-dev pkg-config

Install Rust if you don’t have it:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env"

Clone, Build, and Install

Clone and build the workspace:

git clone https://github.com/ultraworkers/claw-code.git
cd claw-code
cargo build --workspace --release

Copy the binary to your PATH:

sudo cp target/release/claw /usr/local/bin/
claw --version

The output shows the build target matching your architecture (x86_64 or aarch64 depending on your system).

Install on macOS

macOS 26.3 on Apple Silicon was tested. Intel Macs follow the same steps.

Install Xcode Command Line Tools and Rust

macOS needs Xcode command-line tools for the C compiler. If you haven’t installed them:

xcode-select --install

Then install Rust:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env"

Build Claw Code

Clone and build:

git clone https://github.com/ultraworkers/claw-code.git
cd claw-code
cargo build --workspace --release

Build completed in 1 minute 32 seconds on an Apple Silicon Mac. Install the binary:

sudo cp target/release/claw /usr/local/bin/
claw --version

The version output on macOS:

Claw Code
  Version          0.1.0
  Git SHA          dc4fa55
  Target           aarch64-apple-darwin
  Build date       2026-04-09

Note the aarch64-apple-darwin target. On Intel Macs, this reads x86_64-apple-darwin.

Configure Your API Key

Claw Code reads API credentials from environment variables. The two Anthropic-specific variables behave differently, and getting them mixed up is a common source of 401 errors.

ANTHROPIC_API_KEY is for standard API keys (the ones starting with sk-ant-). Claw sends these in the x-api-key HTTP header. ANTHROPIC_AUTH_TOKEN is for OAuth tokens and uses the Authorization: Bearer header instead. Most users want the first one.

Export your API key in your shell profile:

echo 'export ANTHROPIC_API_KEY="sk-ant-your-key-here"' >> ~/.bashrc
source ~/.bashrc

For Zsh users (default on macOS):

echo 'export ANTHROPIC_API_KEY="sk-ant-your-key-here"' >> ~/.zshrc
source ~/.zshrc

Claw Code supports multiple providers through dedicated environment variables. Here’s the full matrix:

ProviderEnvironment VariableAuth Header
Anthropic (API key)ANTHROPIC_API_KEYx-api-key
Anthropic (OAuth)ANTHROPIC_AUTH_TOKENAuthorization: Bearer
OpenAI / OpenRouterOPENAI_API_KEYAuthorization: Bearer
xAI (Grok)XAI_API_KEYAuthorization: Bearer
Alibaba (Qwen/DashScope)DASHSCOPE_API_KEYAuthorization: Bearer

Run Doctor

The claw doctor command checks your environment: authentication, config files, workspace detection, sandbox status, and system metadata. Run it after installation to catch configuration issues early.

claw doctor

On Fedora 42 with ANTHROPIC_API_KEY set, all five checks passed:

Doctor

Summary
  OK               5
  Warnings         0
  Failures         0

Auth
  Status           ok
  Summary          environment credentials are configured
  Details
    - Environment       api_key=present auth_token=absent

Config
  Status           ok
  Summary          runtime config loaded successfully

Workspace
  Status           ok
  Summary          project root detected on branch main

Sandbox
  Status           ok
  Summary          sandbox protections are active
  Details
    - Enabled          true
    - Active           true
    - Supported        true
    - Filesystem mode  workspace-only

System
  Status           ok
  Summary          captured local runtime metadata
  Details
    - OS               linux x86_64
    - Version          0.1.0
    - Build target     x86_64-unknown-linux-gnu

On macOS, doctor reports 4 OK and 1 warning. The sandbox check warns that Linux namespace isolation (unshare) is unavailable on macOS, which is expected. Claw’s sandbox relies on Linux-specific kernel features for filesystem isolation.

Each doctor section tells you something specific:

  • Auth: which credential environment variables are detected. If both show “absent,” your API key export didn’t take effect
  • Config: whether Claw found and loaded a valid settings file
  • Workspace: whether the current directory is inside a Git repository (needed for workspace-scoped file operations)
  • Sandbox: whether Linux namespace sandboxing is active. On Linux, all four sub-checks should show true
  • System: OS, architecture, version, and build target metadata

Your First Prompt

Claw Code supports three modes: one-shot prompts, an interactive REPL, and JSON output for scripting.

One-Shot Mode

Pass a prompt directly with the prompt subcommand. The --compact flag strips formatting for cleaner terminal output:

claw --compact prompt "Reply with only: hello from claw"

The response comes back immediately:

hello from claw

A more practical example that exercises file listing:

claw --compact prompt "List the files in the current directory."

Claw uses its built-in tools (glob, read) to inspect the filesystem and returns a real directory listing.

Interactive REPL

Launch Claw without arguments to enter interactive mode:

claw

This opens a persistent session where Claw remembers context across prompts. Type your requests naturally. Use /quit or Ctrl+C to exit.

JSON Output Mode

For scripting and CI pipelines, Claw can emit structured JSON:

claw --output-format json prompt "What OS is this?"

The JSON response includes the model’s answer, tool calls, and metadata. Pipe it to jq for extraction in automation scripts.

Multi-Provider Setup

One of Claw Code’s strongest differentiators is native multi-provider support. You can switch between Claude, GPT, Grok, and local models without changing tools.

Built-in Model Aliases

Claw ships with shorthand aliases for common models:

AliasResolves To
opusclaude-opus-4-6
sonnetclaude-sonnet-4-6
haikuclaude-haiku-4-5-20251213
grokgrok-3

Use an alias with the --model flag:

claw --model sonnet prompt "Explain TCP three-way handshake in one sentence"

Output:

The TCP three-way handshake is a connection establishment process where the client sends
a SYN, the server responds with a SYN-ACK, and the client replies with an ACK, confirming
both sides are ready to exchange data.

OpenAI

Set your OpenAI API key and specify the model:

export OPENAI_API_KEY="your-openai-api-key"
claw --model gpt-4o prompt "Hello from OpenAI"

xAI / Grok

Export your xAI key and specify the model. Both grok-3 and grok-3-mini are supported:

export XAI_API_KEY="xai-your-key-here"
claw --compact --model grok-3 prompt "Reply with exactly: hello from Grok 3 via claw"

Tested output:

hello from Grok 3 via claw

The lighter grok-3-mini also works and is cheaper for quick tasks:

claw --compact --model grok-3-mini prompt "Reply with exactly: hello from Grok via claw"

Verified output:

hello from Grok via claw

DeepSeek

DeepSeek’s API is OpenAI-compatible, but there is a catch: Claw Code sends a max_tokens value that exceeds DeepSeek’s 8192 limit, causing a 400 error. The direct API does not work as of this writing. Use DeepSeek through OpenRouter instead:

export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
export OPENAI_API_KEY="sk-or-v1-your-openrouter-key"
claw --compact --model "deepseek/deepseek-chat-v3-0324" prompt "Reply with exactly: hello from DeepSeek via claw"

Verified output:

hello from DeepSeek via claw

Ollama (Local Models)

Claw connects to any OpenAI-compatible API endpoint. Point it at your local Ollama instance:

export OPENAI_BASE_URL="http://127.0.0.1:11434/v1"
unset OPENAI_API_KEY
claw --model llama3.2 prompt "Hello from Ollama"

OpenRouter

OpenRouter provides a unified API across dozens of models. Set the base URL and your OpenRouter key:

export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
export OPENAI_API_KEY="sk-or-v1-your-openrouter-key"

Then specify the model using OpenRouter’s naming convention:

claw --compact --model "openai/gpt-4.1-mini" prompt "Reply with: hello from OpenRouter"

Tested output:

hello from OpenRouter via claw

Google Gemini models also work through OpenRouter:

claw --compact --model "google/gemini-2.5-flash" prompt "Reply with: hello from Gemini"

Verified output:

hello from Gemini via OpenRouter

Any model available on OpenRouter’s model list works the same way. Just use the model’s full slug as the --model value.

DashScope (Alibaba Qwen)

For Alibaba’s Qwen models via DashScope:

export DASHSCOPE_API_KEY="sk-your-dashscope-key"
claw --model qwen-max prompt "Hello from Qwen"

Key Commands Reference

Claw Code has an extensive CLI. These are the flags and slash commands you’ll use most often.

Command / FlagWhat It Does
claw prompt "..."One-shot prompt, returns response and exits
clawInteractive REPL session
claw doctorEnvironment and config health check
--model <name>Select model by name or alias
--compactMinimal output formatting
--output-format jsonStructured JSON output for scripting
OPENAI_BASE_URLOverride the API endpoint via env var (for Ollama, OpenRouter)
--permission-modeSet to read-only, workspace-write, or danger-full-access
--versionShow version, Git SHA, target, and build date
/quitExit the interactive REPL
/clearClear conversation history in REPL
/compactToggle compact mode during a session
/model <name>Switch models mid-session
/helpList available slash commands

Configuration Files

Claw Code uses a hierarchical configuration system. Settings are loaded in order, with later files overriding earlier ones:

  • ~/.claw.json (global defaults)
  • ~/.config/claw/settings.json (XDG config)
  • <repo>/.claw.json (project-level)
  • <repo>/.claw/settings.json (project-level, directory style)
  • <repo>/.claw/settings.local.json (local overrides, gitignored)

Create a global config to set your default model and permission mode:

mkdir -p ~/.config/claw
cat > ~/.config/claw/settings.json << 'SETTINGS'
{
  "model": "sonnet",
  "permission_mode": "workspace-write"
}
SETTINGS

For project-specific settings, create .claw/settings.json in your repository root. This is useful for pinning a model per project or adding custom model aliases.

The settings.local.json file is meant for personal overrides that shouldn’t be committed to version control. Add it to your .gitignore.

Build with Docker

The repository includes a Containerfile based on rust:bookworm. This image sets up the build environment but does not compile claw for you. Clone the repo and build the image:

git clone https://github.com/ultraworkers/claw-code.git
cd claw-code
docker build -f Containerfile -t claw-code-dev .

Then compile and run claw inside the container by mounting the source code as a volume:

docker run --rm -it \
  -v "$PWD":/workspace \
  -e CARGO_TARGET_DIR=/tmp/claw-target \
  -e ANTHROPIC_API_KEY="$ANTHROPIC_API_KEY" \
  -w /workspace/rust \
  claw-code-dev \
  bash -c "cargo build --workspace --release && /tmp/claw-target/release/claw --version"

The build takes around 2 minutes inside the container. Once compiled, test with a prompt:

docker run --rm \
  -v "$PWD":/workspace \
  -e CARGO_TARGET_DIR=/tmp/claw-target \
  -e ANTHROPIC_API_KEY="$ANTHROPIC_API_KEY" \
  -w /workspace/rust \
  claw-code-dev \
  /tmp/claw-target/release/claw --compact prompt "Reply with exactly: hello from Docker container"

Tested output:

hello from Docker container

Doctor inside the container shows one warning because Docker containers don’t support Linux namespace isolation by default:

Sandbox
  Status           warn
  Summary          sandbox was requested but is not currently active
  Fallback reason  namespace isolation unavailable (requires Linux with `unshare`)

Run the test suite inside Docker to verify the build:

docker run --rm \
  -v "$PWD":/workspace \
  -e CARGO_TARGET_DIR=/tmp/claw-target \
  -w /workspace/rust \
  claw-code-dev \
  cargo test --workspace

Our Docker test run passed 846 tests across all 9 crates with 1 failure (the doctor resume test, a known issue) and 1 ignored.

For Podman on Fedora or RHEL, add the :Z volume flag for SELinux relabeling:

podman run --rm -it \
  -v "$PWD":/workspace:Z \
  -e CARGO_TARGET_DIR=/tmp/claw-target \
  -w /workspace/rust \
  claw-code-dev \
  cargo build --workspace --release

What Works and What Doesn’t

Claw Code is nine days old at the time of writing. Here’s an honest assessment based on testing.

Working Well

  • Bash tool execution: runs shell commands with output capture, same as Claude Code
  • File operations: read, write, edit, glob, and grep all work reliably
  • Permission model: three-tier access control (read-only, workspace-write, danger-full-access) enforced consistently
  • Configuration system: hierarchical config loading with global, project, and local layers
  • Plugin architecture: Rust plugin crate exists for extending tool capabilities
  • Multi-provider routing: tested with Anthropic and OpenAI-compatible endpoints
  • Linux sandbox: full namespace isolation with filesystem restrictions on Linux

Partial or In Progress

  • MCP support: the crate structure shows MCP work in progress, but it’s not production-ready yet
  • Interactive prompts: some interactive tool confirmations can be rough around the edges
  • macOS sandbox: sandbox depends on Linux unshare, so macOS runs without filesystem isolation

Test Results

Running the full test suite on Fedora 42:

cargo test --workspace

In our Docker test run, 846 tests passed across all 9 crates with 1 failure (the doctor resume test, a known issue) and 1 ignored. On bare-metal Fedora 42, the integrated CLI test suite showed 9 of 10 tests passing. The workspace includes nine Rust crates: api, commands, compat-harness, mock-anthropic-service, plugins, runtime, rusty-claude-cli, telemetry, and tools.

The UltraWorkers Ecosystem

Claw Code is part of the broader UltraWorkers ecosystem, which includes several related projects:

  • OmX: orchestration and agent management layer
  • clawhip: companion tooling for Claw Code workflows
  • OmO: model operations and routing infrastructure

If you’re exploring open-source Claude Code alternatives, check out our OpenCode vs Claude Code vs Cursor comparison and our OpenCode installation guide for another Rust-based option with a different design philosophy.

Troubleshooting

Sandbox Warning on macOS: “sandbox unavailable”

Running claw doctor on macOS shows a sandbox warning because Claw’s isolation relies on Linux kernel namespaces (unshare). This is expected and doesn’t prevent Claw from working. File operations still function, but without the filesystem sandboxing that Linux provides. If you need sandboxing on macOS, run Claw inside a Linux Docker container.

Error: 401 Unauthorized When Using API Key

The most common cause is using ANTHROPIC_AUTH_TOKEN instead of ANTHROPIC_API_KEY. Standard API keys (starting with sk-ant-) must use ANTHROPIC_API_KEY, which sends the key in the x-api-key header. The ANTHROPIC_AUTH_TOKEN variable is only for OAuth bearer tokens. Check which variable you exported:

env | grep ANTHROPIC

You should see ANTHROPIC_API_KEY with your key value. If you see ANTHROPIC_AUTH_TOKEN instead, update your shell profile to use the correct variable name.

Build Fails with “openssl/ssl.h: No such file or directory”

This means the OpenSSL development headers are missing. On Fedora/RHEL/Rocky, install openssl-devel. On Ubuntu/Debian, install libssl-dev. On macOS, Xcode command-line tools bundle the required headers, so run xcode-select --install if you haven’t already.

sudo dnf install -y openssl-devel   # Fedora/RHEL/Rocky
sudo apt install -y libssl-dev      # Ubuntu/Debian

Then re-run cargo build --workspace --release.

For more AI coding tool guides, see our Claude Code for DevOps Engineers setup guide, Aider AI pair programming, and using AI agents for Terraform, Ansible, and Kubernetes.

FAQ

Is Claw Code affiliated with Anthropic?

No. Claw Code is built by the UltraWorkers team and is not affiliated with, endorsed by, or connected to Anthropic in any way. It uses Anthropic’s public API (the same API anyone can access with a key) but is an independent, open-source project.

Do I need a Claude Pro/Max subscription to use Claw Code?

No. Claw Code works exclusively with API keys. You pay per token used, with no monthly subscription required. This makes it cheaper for light usage and more expensive for heavy usage compared to Claude Code on a Max plan. You can also point Claw at free or self-hosted models via Ollama to avoid API costs entirely.

Is Claw Code stable enough for production use?

Not yet. With no tagged releases and the project being nine days old, Claw Code is best suited for experimentation, learning, and contributing to the project. The 846/847 unit test pass rate is strong, but partial MCP support and one known CLI test failure indicate active development. For production coding workflows, Claude Code remains the more reliable option as of April 2026.

How does Claw Code compare to OpenCode?

Both are open-source, terminal-based AI coding assistants written in systems languages. OpenCode is written in Go and focuses on a clean TUI with multi-provider support. Claw Code is written in Rust and aims to replicate the full Claude Code workflow including event-driven architecture, crash recovery, and namespace sandboxing. OpenCode is more mature (several months old), while Claw Code has more architectural ambition but less stability. Both support multiple LLM providers.

Related Articles

AI Install Ollama on Rocky Linux 10 / Ubuntu 24.04 Ansible Ansible vs Chef vs Puppet vs Salt: Which Automation Tool to Choose Containers Rancher Projects, Namespaces, and RBAC Setup AI Run DeepSeek R1 Locally with Ollama on Linux

Leave a Comment

Press ESC to close