Claw Code: The Open-Source AI Coding Agent Built in Rust with 172k+ GitHub Stars

Claw Code has become the fastest-growing open-source AI coding agent on GitHub, reaching 172,000+ stars in just a few months. This Rust-based implementation reverse-engineers Claude Code's core architecture, offering developers a rare glimpse into how production-grade AI agents handle code generation, tool execution, and agentic workflows. With active development and a thriving community, Claw Code represents a significant milestone in democratizing AI-powered development tools.

What is Claw Code?

Claw Code is an open-source project that reimplements the core functionality of Anthropic's Claude Code—a proprietary terminal-based AI coding assistant. Built primarily in Rust (~4,000 lines) with a Python metadata layer (~1,500 lines), Claw Code provides a working implementation of an agentic conversation loop that can read files, execute shell commands, and iteratively solve coding problems.

The project is maintained by the UltraWorkers community and lives at github.com/ultraworkers/claw-code. Unlike Claude Code, which is closed-source and proprietary, Claw Code is fully open and inspectable—making it an invaluable learning resource for anyone building AI agents. The codebase demonstrates how to structure tool execution, manage permissions, stream API responses, and maintain conversation state across multiple turns.

Created by developers including Yeachan-Heo (Bellman), Sigrid Jin, and others, Claw Code hit 100,000 stars in a single day when it launched, then continued climbing to its current 172,000+ star count. This explosive growth reflects both the hunger for open-source AI tooling and the project's technical quality.

Core Features and Architecture

The Agentic Conversation Loop

At its heart, Claw Code implements the fundamental pattern that powers all AI coding agents: User message → API call → Parse response → Execute tools → Feed results back → Repeat. The Rust runtime uses trait-based abstractions over ApiClient and ToolExecutor, keeping model calls and tool execution decoupled and testable. This separation mirrors production systems and makes the codebase easy to extend or swap components.

Six Core Tools

Claw Code ships with six essential tools for code work:

  • Bash – Execute shell commands with output capture and error handling
  • Read – Load file contents into the agent's context
  • Write – Create or overwrite files (auto-creates parent directories)
  • Edit – Modify files using exact string matching (avoiding regex escaping bugs)
  • Glob – Search for files by pattern, sorted by modification time
  • Grep – Search file contents with context lines and pagination

Anthropic Messages API Integration

Claw Code's API client is arguably its most production-ready component. It implements Anthropic's Messages API v1 with Server-Sent Events (SSE) streaming, incremental frame parsing, retry logic with exponential backoff, and cache token tracking. For developers building custom Anthropic clients, this crate serves as a credible reference implementation.

Permission Model

Any agent that runs shell commands and edits files needs a permission layer. Claw Code implements a three-tier system (Allow, Deny, Prompt) with per-tool overrides via a PermissionPolicy struct. This prevents accidental destructive operations and gives users control over what the agent can do.

Session Persistence and Compaction

As conversations grow toward token limits, agents must compress older turns while keeping recent messages useful. Claw Code's compaction strategy summarizes earlier messages into the system prompt while retaining the last N turns—a practical approach that balances context preservation with token efficiency.

Get free AI agent insights weekly

Join our community of builders exploring the latest in AI agents, frameworks, and automation tools.

Join Free

Getting Started

Setting up Claw Code is straightforward. First, clone the repository and navigate to the Rust workspace:

git clone https://github.com/ultraworkers/claw-code.git
cd claw-code/rust
cargo build --workspace
./target/debug/claw --help

Authenticate using either an API key or the built-in OAuth flow:

export ANTHROPIC_API_KEY="sk-ant-..."
# or
./target/debug/claw login

Run your first command:

./target/debug/claw prompt "summarize this repository"

The workspace includes a comprehensive test suite. Verify everything works:

cd rust
cargo test --workspace

For container-first workflows, Claw Code includes a Containerfile for Docker and Podman users, documented in docs/container.md.

Real-World Use Cases

Rapid Prototyping

Developers can describe a feature in natural language, and Claw Code generates working code, runs tests, and iterates until the implementation passes. This dramatically accelerates the prototype-to-working-code cycle, especially for well-defined tasks like API endpoints or data processing scripts.

Code Review and Refactoring

Point Claw Code at a codebase and ask it to identify performance bottlenecks, suggest refactorings, or enforce style consistency. The agent can read files, run benchmarks, and propose changes—all without human intervention.

Bug Fixing and Debugging

When a test fails or a bug report arrives, Claw Code can read the error, search the codebase, hypothesize root causes, and propose fixes. The iterative loop—run test, parse output, modify code, repeat—mirrors how human developers debug.

Documentation Generation

Claw Code can read your entire codebase and generate accurate documentation, README files, and API docs that reflect the actual implementation. This keeps docs in sync with code and reduces manual maintenance.

How It Compares

vs. Claude Code (Anthropic)

Claude Code is proprietary, closed-source, and production-ready with full IDE integration, MCP (Model Context Protocol) support, subagent orchestration, and a complete skill system. Claw Code captures roughly 20–25% of Claude Code's functional surface—the core loop, file tools, and API client—but lacks MCP, subagents, IDE bridges, and the full prompt pipeline. For learning and experimentation, Claw Code is invaluable; for production workflows requiring full feature parity, Claude Code remains the choice.

vs. Aider

Aider is another terminal-based AI coding agent with 40,000+ stars. Aider focuses on pair-programming workflows and integrates with multiple LLM providers. Claw Code is more tightly coupled to Anthropic's API but offers deeper architectural transparency and a cleaner Rust implementation.

vs. OpenCode

OpenCode is a community-built AI coding agent with 100,000+ stars. Both Claw Code and OpenCode are open-source alternatives to Claude Code, but they differ in language (Claw Code is Rust-first; OpenCode is Python-first) and feature completeness. Claw Code's Rust implementation offers better performance and memory safety, while OpenCode may have broader ecosystem integrations.

What's Next

The Claw Code roadmap includes several high-impact features. MCP (Model Context Protocol) support is the most requested addition—it would enable dynamic tool discovery and extensibility, closing a major gap with Claude Code. Subagent orchestration would allow parallel task execution and nested conversations. IDE integration via LSP (Language Server Protocol) would bring Claw Code into VS Code and JetBrains editors. The team is also working on smarter context budgeting, cost tooling, and support for additional file types like notebooks and PDFs.

The project's philosophy emphasizes autonomous development—using AI agents to improve the agent itself. This self-improving loop has already yielded significant improvements in code quality, test coverage, and documentation.

Sources