Skip to main content
Claw Code is a Python rewrite of Claude Code’s agent harness runtime. It mirrors the architectural patterns of Claude Code’s original TypeScript implementation — including tool routing, session management, command orchestration, and parity auditing — without copying any proprietary source.

The backstory

At 4 AM on March 31, 2026, the Claude Code source was exposed and the developer community erupted. Rather than retain a copy of the original TypeScript snapshot, the author sat down and ported the core harness features to Python from scratch before sunrise. The session was orchestrated end-to-end using oh-my-codex (OmX), a workflow layer built on top of OpenAI’s Codex. $team mode was used for parallel code review and architectural feedback; $ralph mode for persistent execution loops with architect-level verification. The result is a clean-room Python rewrite that captures the structural patterns of Claude Code’s agent harness. The repository became the fastest GitHub project in history to surpass 30,000 stars, reaching the milestone within a few hours of publication.

What problems it solves

Tool routing

Routes arbitrary prompts across a mirrored inventory of commands and tools using token-overlap scoring, selecting the best matches by kind.

Session management

Persists and replays conversation sessions, tracks token usage, enforces turn and budget limits, and compacts transcripts automatically.

Command orchestration

Mirrors Claude Code’s full command surface — over 200 entries — with execution shims, plugin filtering, and skill-command filtering.

Parity auditing

Compares the Python workspace against a locally available TypeScript archive snapshot to identify coverage gaps and surface divergences.

Key features

CLI entrypoint

A single python3 -m src.main entrypoint exposes every subsystem through subcommands with consistent argument parsing.

Manifest generation

port_manifest.py scans the src/ tree and generates a live inventory of Python files and top-level modules.

Query engine

query_engine.py orchestrates summary rendering, structured output, multi-turn loops, and session persistence on top of the manifest.

Remote runtime modes

Simulates remote-control, SSH, Teleport, direct-connect, and deep-link runtime branching — mirroring Claude Code’s connection modes.

Permission gating

permissions.py provides a ToolPermissionContext that blocks tool names and prefixes before routing, mirroring Claude Code’s trust model.

Bootstrap graph

bootstrap_graph.py mirrors the startup/runtime graph stages from the original harness, with a Markdown rendering path.

Architecture overview

The src/ directory is the active Python porting workspace. Each module corresponds to a distinct concern in the agent harness:
ModuleRole
main.pyCLI entrypoint; builds the argparse parser and dispatches to all subcommands
port_manifest.pyScans src/ and produces a PortManifest with file counts and module notes
query_engine.pySummary rendering, session persistence, multi-turn loop, structured output
runtime.pyPortRuntime — prompt routing, session bootstrapping, turn loop execution
commands.pyLoads the mirrored command inventory from reference_data/commands_snapshot.json
tools.pyLoads the mirrored tool inventory from reference_data/tools_snapshot.json
models.pyShared dataclasses: Subsystem, PortingModule, PermissionDenial, UsageSummary
setup.pyWorkspaceSetup and SetupReport — startup steps, prefetch side effects, deferred init
parity_audit.pyCompares the Python workspace against the local TypeScript archive when available
session_store.pyLoads and saves StoredSession objects to disk
permissions.pyToolPermissionContext — deny-list filtering by tool name and prefix
command_graph.pyCommand graph segmentation report
tool_pool.pyAssembled tool pool with default permission settings
bootstrap_graph.pyMirrored bootstrap/runtime graph stages
remote_runtime.pyRemote-control, SSH, Teleport runtime branching simulation
direct_modes.pyDirect-connect and deep-link runtime branching simulation
transcript.pyTranscriptStore — append, compact, flush, and replay session transcripts
task.pyTask-level planning structures
The reference_data/ subdirectory holds the JSON snapshots that back the command and tool inventories:
src/reference_data/
├── commands_snapshot.json      # 200+ mirrored command entries
├── tools_snapshot.json         # 150+ mirrored tool entries
└── archive_surface_snapshot.json

Next steps

Quick Start

Run your first Claw Code command in under a minute.

Build docs developers (and LLMs) love