Local Claude Code alternative powered by Ollama - zero API costs
Project description
๐ Claw Code โ Local Claude Code Powered by Ollama
Free. Offline. No API Keys. Works on Your Laptop.
Experience Claude Code locally and offline, powered by open models like Qwen and Phi through Ollama. Zero API costs, zero data leakage, pure local execution.
โญ The fastest repo in history to surpass 50K stars, reaching the milestone in just 2 hours after publication โญ
Quick Start (3 Minutes)
Install
pip install claw-code
Setup (Auto-Detects Your Hardware)
claw-code init
# โ Detects your PC RAM
# โ Downloads perfect model for your system
# โ Creates ~/.claude.json
Start Coding
claw-code
claw> Write a Python function to merge sorted arrays
# Streams response real-time from local model...
claw> Refactor it to use less memory
# Continues the conversation locally
claw> /exit
# โ Session auto-saved to resume later
Why Claw Code?
| Feature | Claw Code | Claude API | ChatGPT |
|---|---|---|---|
| Cost | โ Free | โ $0.003/1K tokens | โ $20/month |
| Runs Offline | โ 100% local | โ Requires internet | โ Cloud only |
| Data Privacy | โ On your machine | โ ๏ธ Anthropic stores | โ OpenAI stores |
| Works on Laptop | โ 8GB+ RAM | โ Requires account | โ Requires account |
| Commands/Tools | โ Full support | โ Full support | โ Limited |
| Multi-Turn | โ Stateful sessions | โ Stateful sessions | โ Stateful sessions |
Hardware Requirements
Choose your model based on available RAM:
โค 8GB VRAM โ phi4-mini (3.8B) [M1 MacBook Air, budget laptops]
8-16GB VRAM โ qwen2.5-coder:7b โญ [Most users, recommended]
16GB+ VRAM โ qwen2.5-coder:14b [Complex tasks, power users]
All models run locally with zero internet after download.
Features
โ
Interactive REPL โ Slash commands for control
โ
Code Generation โ Write, refactor, optimize, debug code
โ
Multi-Turn Conversations โ Full context awareness
โ
Session Persistence โ Resume conversations later
โ
Local Execution โ No API, no costs, no tracking
โ
Streaming Output โ Real-time token responses
โ
Hardware Auto-Detection โ Picks best model for you
โ
Command Routing โ Smart matching to operations
โ
Tool System โ Permission-aware integrations
Available Commands (in REPL)
/help โ Show all commands
/model โ Display current model and settings
/session โ Show token usage and conversation stats
/resume โ Resume a previous session
/clear โ Clear conversation history
/exit โ Exit (optionally save session)
Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Claw Code REPL โ
โ (Your terminal, your machine) โ
โโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Query Engine + Session Management โ
โ (Multi-turn conversation, permissions) โ
โโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Ollama Adapter โ
โ (Local HTTP to Ollama server) โ
โโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Local Ollama Server + Model โ
โ (qwen2.5-coder:7b or similar) โ
โ (Runs on localhost:11434) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
All processing happens locally. No data leaves your machine.
Getting Started
Prerequisites
- Python 3.9+
- Ollama (download here)
- 5-10 GB free disk space (for model download)
Step 1: Install Python Package
pip install claw-code
Step 2: Run Setup Wizard
claw-code init
The wizard will:
- โ Check Ollama installed
- โ Detect your system RAM
- โ Recommend best model
- โ Pull model (first time: ~2-5 min)
- โ Verify everything works
- โ Create config (~/.claude.json)
Step 3: Start Coding
claw-code
claw> your first prompt here
Usage Examples
Write Code
claw> Write a async Python function to fetch data from an API
[Receives well-structured async code with error handling]
claw> Add retry logic with exponential backoff
[Gets updated code with retry mechanism]
Debug Code
claw> This function is slow. Why?
def find_duplicates(items):
result = []
for i in range(len(items)):
for j in range(i+1, len(items)):
if items[i] == items[j]:
result.append(items[i])
return result
[Gets analysis + optimized version]
Learn Concepts
claw> Explain what a closure is in JavaScript
[Gets clear explanation with examples]
claw> Show me 3 practical uses in modern code
[Gets real-world examples]
Configuration
Claw Code creates ~/.claude.json with sensible defaults:
{
"provider": "ollama",
"ollama_base_url": "http://localhost:11434",
"model": "qwen2.5-coder:7b",
"max_tokens": 4000,
"temperature": 0.7
}
Edit manually to:
- Change models:
"model": "phi4-mini"or"qwen2.5-coder:14b" - Point to remote Ollama: Edit
ollama_base_url - Adjust creativity:
"temperature": 0.5(lower = more focused)
Troubleshooting
"ollama: command not found"
Download Ollama from https://ollama.ai
"Connection refused" when initializing
Make sure Ollama is running:
ollama serve # In another terminal
"Not enough disk space"
Models are 3-14GB. Free up disk space or use smaller model:
claw-code config
# Edit ~/.claude.json to use "phi4-mini"
Slow responses
- First response warms up model (1-2 min)
- Subsequent responses faster
- Smaller models (phi4-mini) are faster than larger ones
Advanced: Extend Claw Code
See CONTRIBUTING.md for:
- Adding new commands
- Integrating custom tools
- Building plugins
- Custom routing logic
- Local model integration
Architecture & Technical Details
See ARCHITECTURE.md for deep dive on:
- System design
- Command/tool registry
- Permission model
- Session persistence
- Ollama integration
- Extension points
Roadmap
Phase 3: Tool Execution (Coming Soon)
Run actual shell/Python commands from the CLI
Phase 4: GUI & VSCode Integration
Web UI and VSCode extension
Phase 5: Advanced Features
Memory, file operations, plugins, custom models
Contributing
Want to help? See CONTRIBUTING.md for:
- How to set up dev environment
- Extension points (commands, tools, routing)
- PR process
- Code guidelines
We welcome contributors! All skill levels okay.
Community
Join our community to share ideas, ask questions, and collaborate:
GitHub Discussions for Q&A and feature requests
License
Apache License 2.0 โ See LICENSE
Summary: You can use, modify, and distribute Claw Code freely. Great for commercial use. Attribution appreciated but not required.
Performance Comparison
| Metric | Claw Code | Claude Code (API) |
|---|---|---|
| Setup time | 3 min | 5 min (account + API key) |
| Cost | FREE | $$$$ |
| Privacy | 100% local | Sent to Anthropic |
| Offline | โ Yes | โ No |
| Speed (first response) | 1-2 min* | <1 sec |
| Speed (subsequent) | 15-40 tok/s | 50-100 tok/s |
| Model choice | 3 options | Latest Claude |
*First response includes model loading. Subsequent responses are much faster.
FAQ
Q: Is this affiliated with Anthropic?
A: No. This is an independent open-source project. We rebuild Claude Code's architecture using local Ollama models.
Q: Can I use this commercially?
A: Yes! Apache 2.0 license allows commercial use. See LICENSE.
Q: Will my code be tracked?
A: No. Everything runs locally. Your code never leaves your computer.
Q: How much does it cost?
A: Free. One-time model download ($0). No subscriptions.
Q: Can I use a different model?
A: Yes! Edit ~/.claude.json and use any Ollama model.
Q: How do I update?
A: pip install --upgrade claw-code
Backstory
At 4 AM on March 31, 2026, the Claude Code source leaked. Rather than panic, I spent the morning clean-room porting the essential architecture to Python, then integrated it with Ollama for zero-cost local execution. The entire effort was orchestrated using oh-my-codex (OmX).
Result: A functional Claude Code alternative that costs nothing and runs offline.
Star History
See the chart at the top of this README.
AI startup worker Sigrid Jin, who attended the Seoul dinner, single-handedly used 25 billion of Claude Code tokens last year. At the time, usage limits were looser, allowing early enthusiasts to reach tens of billions of tokens at a very low cost.
Despite his countless hours with Claude Code, Jin isn't faithful to any one AI lab. The tools available have different strengths and weaknesses, he said. Codex is better at reasoning, while Claude Code generates cleaner, more shareable code.
Jin flew to San Francisco in February for Claude Code's first birthday party, where attendees waited in line to compare notes with Cherny. The crowd included a practicing cardiologist from Belgium who had built an app to help patients navigate care, and a California lawyer who made a tool for automating building permit approvals using Claude Code.
"It was basically like a sharing party," Jin said. "There were lawyers, there were doctors, there were dentists. They did not have software engineering backgrounds."
โ The Wall Street Journal, March 21, 2026, "The Trillion Dollar Race to Automate Our Entire Lives"
Porting Status
The main source tree is now Python-first.
src/contains the active Python porting workspacetests/verifies the current Python workspace- the exposed snapshot is no longer part of the tracked repository state
The current Python workspace is not yet a complete one-to-one replacement for the original system, but the primary implementation surface is now Python.
Why this rewrite exists
I originally studied the exposed codebase to understand its harness, tool wiring, and agent workflow. After spending more time with the legal and ethical questionsโand after reading the essay linked belowโI did not want the exposed snapshot itself to remain the main tracked source tree.
This repository now focuses on Python porting work instead.
Repository Layout
.
โโโ src/ # Python porting workspace
โ โโโ __init__.py
โ โโโ commands.py
โ โโโ main.py
โ โโโ models.py
โ โโโ port_manifest.py
โ โโโ query_engine.py
โ โโโ task.py
โ โโโ tools.py
โโโ tests/ # Python verification
โโโ assets/omx/ # OmX workflow screenshots
โโโ 2026-03-09-is-legal-the-same-as-legitimate-ai-reimplementation-and-the-erosion-of-copyleft.md
โโโ README.md
Python Workspace Overview
The new Python src/ tree currently provides:
port_manifest.pyโ summarizes the current Python workspace structuremodels.pyโ dataclasses for subsystems, modules, and backlog statecommands.pyโ Python-side command port metadatatools.pyโ Python-side tool port metadataquery_engine.pyโ renders a Python porting summary from the active workspacemain.pyโ a CLI entrypoint for manifest and summary output
Quickstart
Render the Python porting summary:
python3 -m src.main summary
Print the current Python workspace manifest:
python3 -m src.main manifest
List the current Python modules:
python3 -m src.main subsystems --limit 16
Run verification:
python3 -m unittest discover -s tests -v
Run the parity audit against the local ignored archive (when present):
python3 -m src.main parity-audit
Inspect mirrored command/tool inventories:
python3 -m src.main commands --limit 10
python3 -m src.main tools --limit 10
Current Parity Checkpoint
The port now mirrors the archived root-entry file surface, top-level subsystem names, and command/tool inventories much more closely than before. However, it is not yet a full runtime-equivalent replacement for the original TypeScript system; the Python tree still contains fewer executable runtime slices than the archived source.
Built with oh-my-codex
The restructuring and documentation work on this repository was AI-assisted and orchestrated with Yeachan Heo's oh-my-codex (OmX), layered on top of Codex.
$teammode: used for coordinated parallel review and architectural feedback$ralphmode: used for persistent execution, verification, and completion discipline- Codex-driven workflow: used to turn the main
src/tree into a Python-first porting workspace
OmX workflow screenshots
Ralph/team orchestration view while the README and essay context were being reviewed in terminal panes.
Split-pane review and verification flow during the final README wording pass.
Community
Join the instructkr Discord โ the best Korean language model community. Come chat about LLMs, harness engineering, agent workflows, and everything in between.
Star History
See the chart at the top of this README.
Ownership / Affiliation Disclaimer
- This repository does not claim ownership of the original Claude Code source material.
- This repository is not affiliated with, endorsed by, or maintained by Anthropic.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file claw_code-0.2.2.tar.gz.
File metadata
- Download URL: claw_code-0.2.2.tar.gz
- Upload date:
- Size: 64.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a838db7018c3c374739fec2cdda5cc5bfa2a194d157d48124dd885f29d88fe7a
|
|
| MD5 |
a1ad78ff1006c120d000b3bf1107289b
|
|
| BLAKE2b-256 |
c612dcbcd3d3adae7359e630060f2120c1a38ca0814fe2c37dfb5197d6f8a3c8
|
File details
Details for the file claw_code-0.2.2-py3-none-any.whl.
File metadata
- Download URL: claw_code-0.2.2-py3-none-any.whl
- Upload date:
- Size: 87.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d337579839e2a5b131dce62aa8aa6809c1ad795398e05d47651cb7b6515f0bfc
|
|
| MD5 |
09cadc46af4585e77b265b2dd1517b5a
|
|
| BLAKE2b-256 |
c16f9a9249dcbfd39663565b471d2bd0994f5a69f633b27a802b1c350befb26f
|