# claw-code: Open-Source Claude Code Reimplementation

This repository is a **clean-room rewrite of Anthropic's Claude Code CLI** — an agent harness for running Claude with tool execution, session management, and workflow orchestration.

## Origin & Context

Created by [@instructkr](https://github.com/instructkr) in March 2026 after Claude Code's source was leaked. Rather than host the leaked code, the author ported it from scratch to Python (and now Rust) to preserve the architectural patterns legally. The author is a power user featured in the Wall Street Journal who used 25 billion Claude Code tokens in 2025.

## What It Does

**claw-code** is an **AI agent runtime/harness** that allows you to run Claude (via Anthropic API) with:

- **Tool execution**: Bash commands, file operations (read/write/edit), web search, grep, glob, etc.
- **Session management**: Persistent conversations, history, context
- **MCP (Model Context Protocol)**: Connect external data sources/tools
- **Skills system**: Reusable prompt templates and workflows
- **Hooks**: Automation triggers (pre/post tool use)
- **Plugin architecture**: Extend with custom capabilities
- **OAuth/API integration**: Direct Anthropic API access
- **Multi-modal**: Code, images, PDFs, Jupyter notebooks

## Current Architecture

The project has **two implementations**:

1. **Python (`src/`)**: Original port from TypeScript — functional but not feature-complete
2. **Rust (`rust/crates/`)**: Active development focus — faster, memory-safe, production-ready

**Rust crates structure:**
- `api/` - Anthropic API client
- `runtime/` - Core conversation loop, session management, MCP
- `tools/` - Tool registry and execution
- `commands/` - Slash command handlers
- `rusty-claude-cli/` - Main CLI binary
- `compat-harness/` - Compatibility layer

## Parity Status

The Rust port is **not feature-parity** with original Claude Code (per PARITY.md):

**✅ Working:**
- Core Anthropic API/OAuth
- Tool loop with 15+ built-in tools
- MCP stdio/bootstrap
- CLAUDE.md discovery
- Session persistence
- Basic CLI commands

**❌ Missing:**
- **Plugins**: No plugin system yet
- **Hooks**: Parsed but not executed
- **Many commands**: `/agents`, `/hooks`, `/mcp`, `/plan`, `/review`, `/tasks`, `/skills`
- **Advanced orchestration**: Remote transports, structured I/O
- **Service ecosystem**: Analytics, settings sync, team memory

## Use Case

This is for developers who want:
- Open-source alternative to official Claude Code
- Self-hosted AI agent runtime
- Tool-use enabled Claude workflows
- Customizable harness for research/experimentation
- Faster Rust-based implementation

**Not a drop-in replacement** — still under active development toward feature parity.

## Key Files

- `README.md` - Project overview and backstory
- `CLAUDE.md` - Claude Code instructions for working with this repo
- `PARITY.md` - Detailed gap analysis between Rust port and original TypeScript
- `rust/` - Rust implementation (primary focus)
- `src/` - Python implementation (reference)
- `tests/` - Verification suite
