Claw Code β€” Clean-Room Python Rewrite of Claude Code's Agent Harness

Claw Code β€” Clean-Room Python Rewrite of Claude Code's Agent Harness

At 4 AM on March 31, 2026, the Claude Code source was exposed. Within hours, Claw Code emerged β€” a clean-room Python rewrite of Claude Code’s agent harness architecture, built entirely through AI-assisted orchestration. It hit 50K GitHub stars in 2 hours, making it the fastest repo in history to reach that milestone.

*Source: GitHub β€” instructkr/claw-code Wall Street Journal: β€œThe Trillion Dollar Race to Automate Our Entire Lives” (March 21, 2026)*

What Happened

The Claude Code source code was exposed publicly. Instead of just archiving the leaked code, developer Sigrid Jin (@instructkr) β€” one of the most active Claude Code power users, having consumed 25 billion tokens β€” chose to study the harness architecture and port the core patterns to Python from scratch.

The key distinction: this is not a copy of proprietary source. It’s a clean-room reimplementation that captures the architectural patterns β€” tool wiring, agent orchestration, runtime context management β€” without copying Anthropic’s code.

How It Was Built

The entire rewrite was orchestrated using oh-my-codex (OmX), a workflow layer on top of OpenAI’s Codex:

OmX Mode How It Was Used
$team mode Parallel code review and architectural feedback
$ralph mode Persistent execution loops with architect-level verification
Codex-driven Turned the src/ tree into a Python-first porting workspace

From reading the original harness structure to producing a working Python tree with tests β€” all driven through OmX orchestration in a single session.

Repository Structure

claw-code/
β”œβ”€β”€ src/                     # Python porting workspace
β”‚   β”œβ”€β”€ main.py              # CLI entrypoint
β”‚   β”œβ”€β”€ commands.py           # Command port metadata
β”‚   β”œβ”€β”€ tools.py              # Tool port metadata
β”‚   β”œβ”€β”€ models.py             # Dataclasses for subsystems/modules
β”‚   β”œβ”€β”€ query_engine.py       # Porting summary renderer
β”‚   β”œβ”€β”€ port_manifest.py      # Workspace structure summary
β”‚   └── task.py               # Task management
β”œβ”€β”€ tests/                    # Python verification
└── dev/rust                  # Rust port (in progress)

What It Reveals About Claude Code’s Architecture

The porting process surfaces the internal structure of Claude Code’s agent harness:

  • Subsystem decomposition β€” How Claude Code splits into modules (commands, tools, models, tasks)
  • Command/tool inventory β€” The full set of built-in capabilities
  • Agent workflow patterns β€” How tasks are routed, orchestrated, and verified
  • Runtime context management β€” How the harness manages state across sessions

This is essentially a study guide for harness engineering β€” understanding the patterns matters more than the specific implementation.

Quickstart

# Render porting summary
python3 -m src.main summary

# Print workspace manifest
python3 -m src.main manifest

# List subsystems
python3 -m src.main subsystems --limit 16

# Run tests
python3 -m unittest discover -s tests -v

# Inspect command/tool inventories
python3 -m src.main commands --limit 10
python3 -m src.main tools --limit 10

Current Status

Aspect Status
Python workspace Functional β€” mirrors root-entry file surface, subsystem names, command/tool inventories
Runtime equivalence Not yet β€” fewer executable runtime slices than original TypeScript
Rust port In progress on dev/rust branch β€” faster, memory-safe harness runtime
Legal position Clean-room reimplementation, not a code copy. Essay on legal/ethical questions included in repo

The Creator

Sigrid Jin was featured in the Wall Street Journal (March 21, 2026) as one of the most dedicated Claude Code power users:

β€œAI startup worker Sigrid Jin single-handedly used 25 billion Claude Code tokens last year… Jin flew to San Francisco in February for Claude Code’s first birthday party.”

He noted that different tools have different strengths: β€œCodex is better at reasoning, while Claude Code generates cleaner, more shareable code.”

Why This Matters

  1. Harness > Model β€” The value isn’t in Claude’s weights, it’s in how the harness orchestrates tools, manages context, and enforces quality. Now that architecture is open for study.
  2. AI building AI tools β€” The entire rewrite was done through AI orchestration (OmX + Codex), demonstrating that agent systems can now reverse-engineer and reimplement other agent systems.
  3. Community velocity β€” 50K stars in 2 hours signals massive demand for open, inspectable agent infrastructure.

How LearnAI Team Could Use This

  • Study the Claw Code architecture as a teaching resource for agent orchestration patterns.
  • Compare Claude Code (TypeScript) and Claw Code (Python) implementations to understand framework design tradeoffs.
  • Use as a base for building custom agent harnesses for research or course-specific workflows.

Real-World Use Cases

  • Agent framework education: students trace how a tool call flows through the harness.
  • Prototyping custom agent loops with Python instead of TypeScript.
  • Open-source harness experimentation: fork and modify without Claude Code’s binary constraints.
  • Runtime architecture comparison exercises in systems design courses.