Skip to main content

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 โญ

Star History Chart


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:

  1. โœ… Check Ollama installed
  2. โœ… Detect your system RAM
  3. โœ… Recommend best model
  4. โœ… Pull model (first time: ~2-5 min)
  5. โœ… Verify everything works
  6. โœ… 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:

Discord

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"

WSJ Feature


Porting Status

The main source tree is now Python-first.

  • src/ contains the active Python porting workspace
  • tests/ 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 structure
  • models.py โ€” dataclasses for subsystems, modules, and backlog state
  • commands.py โ€” Python-side command port metadata
  • tools.py โ€” Python-side tool port metadata
  • query_engine.py โ€” renders a Python porting summary from the active workspace
  • main.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.

  • $team mode: used for coordinated parallel review and architectural feedback
  • $ralph mode: 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

OmX workflow screenshot 1

Ralph/team orchestration view while the README and essay context were being reviewed in terminal panes.

OmX workflow screenshot 2

Split-pane review and verification flow during the final README wording pass.

Community

instructkr

Join the instructkr Discord โ€” the best Korean language model community. Come chat about LLMs, harness engineering, agent workflows, and everything in between.

Discord

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

claw_code-0.2.0.tar.gz (67.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

claw_code-0.2.0-py3-none-any.whl (86.3 kB view details)

Uploaded Python 3

File details

Details for the file claw_code-0.2.0.tar.gz.

File metadata

  • Download URL: claw_code-0.2.0.tar.gz
  • Upload date:
  • Size: 67.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for claw_code-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ff708fee378660bd5cd3e0223167e13a0fe7ea936350c810b8e1626a9621d119
MD5 c8dabd28e49f352b6b9e379c0b5a7b8d
BLAKE2b-256 9015862d565f234f32e2b6bbda20dac5d2a3f5bd675b09d7c718b5efaa6e9805

See more details on using hashes here.

File details

Details for the file claw_code-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: claw_code-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 86.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for claw_code-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e1be66926c81a6de14eb7d2f3c66c01fa148ef1424c4b9af617a553c70417c26
MD5 159fcc63404d5f45457ac829a99007bc
BLAKE2b-256 bf4ac61830d4b9ef421f240c48ecb7197376b7d5bdc188d3bcbd4ff07b060aad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page