> ## Content Index
> Fetch the complete content index at: https://wuu73.org/aiguide-ghost/llms.txt
> Use this file to discover other available public pages before exploring further.

# Open Claude Code 2.0 (Nightly): The Reverse-Engineered Clone
- URL: https://wuu73.org/aiguide-ghost/coding-agents-openclaudecode/
- Published: 2026-05-29T00:26:00.000Z
- Updated: 2026-05-29T00:26:00.000Z
- Description: Part of Agent Harness Field Guide.
- Author: WUU73
- Tags: Deep Dives, Agent Harness Field Guide, #Deep Dive Child, #Import 2026-09-12 06:38

Clean-Room Implementation • v2.1.91 • 61 Files • 1,581 Tests • Nightly Releases

Open Claude Code is a ground-up open source rebuild of Anthropic's Claude Code CLI, targeting v2.1.91, created via "ruDevolution" — an AI-powered decompilation of the published npm package. With 1,581 passing tests and automated nightly releases, it demonstrates functional parity while adding unique architectural choices like multi-agent teams and git worktree isolation.

Shameless Plug[While we're deep-diving into complex CLI tools... let's be honest. Are you tired of feeling like nerds are trying to gatekeep the terminal life by having you memorize 30 key combos just to do basic stuff? Do you lie awake at night dreading the moment you have to edit a cryptic dotfile just to change a font size? Same. It's the AI age, we can have a crazy UI on top of the terminal with shameless amounts of AI built in to do things for you.**ButtonsCLI**: The terminal for](https://buttonscli.com/?ref=wuu73.org)

(Alright, ad over. Back to the serious technical analysis.)

## What is Open Claude Code?

Open Claude Code claims to be a **clean-room implementation** of Claude Code — not a fork, not a wrapper, but a complete rebuild informed by AI-assisted decompilation. The project uses a process called "ruDevolution" (Reverse Evolution through AI) to analyze the published npm package and generate functionally equivalent TypeScript code.

The key difference from a simple fork: this is an *independent implementation* that happens to produce the same results. It can be studied, modified, and redistributed under the MIT license.

📦

#### Archive vs v2

The repository contains both an `archive/` directory with the decompiled original source (7.3MB!) and a `v2/` directory with the clean-room reimplementation. The archive is for reference; v2 is the working implementation.

## Core Architecture — Async Generator Agent Loop

The heart of Open Claude Code is an **async generator function** that yields 13 distinct event types. This is architecturally unique in this field — most agents use a callback or promise-based loop:

| Event Type             | Description                  |
| ---------------------- | ---------------------------- |
| stream\_request\_start | Beginning of API request     |
| stream\_event          | Raw SSE event from API       |
| thinking               | Extended thinking blocks     |
| assistant              | Assistant message content    |
| tool\_progress         | Streaming tool input         |
| result                 | Tool call result             |
| compaction             | Context compaction triggered |
| hookPermissionResult   | Permission hook response     |
| error                  | Error during execution       |
| stop                   | Agent requested to stop      |

Key characteristics of the loop:

- **Recursive execution:** After tool calls, recursively calls itself with `yield* run(null, { continuation: true })`
- **Token tracking:** Accumulates input/output tokens from API responses
- **Auto-compaction:** Triggers context compaction at 80% threshold
- **Hook integration:** Runs PreToolUse/PostToolUse hooks, can block tool execution
- **Permission checking:** Before tool execution, checks permissions

## Context Manager — Two-Tier Compaction

Open Claude Code implements a sophisticated two-tier compaction system:

### Micro-Compaction

Truncates tool results older than 5 turns to just 100 characters. This preserves the fact that something happened while dramatically reducing token usage for repeated read operations.

### Full Compaction

Summarizes older messages using the LLM, keeping the last 6 messages (\~3 turns). More expensive but preserves semantic meaning for complex interactions.

Token estimation uses a simple character-based heuristic: **4 characters ≈ 1 token**. No external tokenizer dependency.

## Tools System — 25 Tools

Tools follow a consistent `validateInput/call` interface pattern:

```
const Tool = {
    name: 'ToolName',
    description: '...',
    inputSchema: { type: 'object', properties: {...}, required: [...] },
    validateInput(input) { return []; },  // Returns array of errors
    async call(input) { return result; }
};
```

| Category          | Tools                                                             |
| ----------------- | ----------------------------------------------------------------- |
| **Core file ops** | Read, Edit, Write, Glob, Grep                                     |
| **Shell**         | Bash (SIGTERM→SIGKILL, background jobs, 1MB limit)                |
| **Agent**         | Agent (spawn subagents), SendMessage, EnterWorktree, ExitWorktree |
| **Web**           | WebFetch, WebSearch, ToolSearch (deferred discovery)              |
| **Task**          | TodoWrite, CronCreate/Delete/List, NotebookEdit, MultiEdit        |
| **System**        | Skill, AskUser, LSP, ReadMcpResource                              |

🔧

#### Git Worktree Isolation

The `EnterWorktree` and `ExitWorktree` tools provide isolated git worktrees for parallel agent tasks. This is unique among the agents in this set — most use simple process spawning for subagents.

## Multi-Agent Teams System

Open Claude Code implements a full agent-to-agent messaging system:

| Operation                | Description                    |
| ------------------------ | ------------------------------ |
| register(agent)          | Register a named agent         |
| send(agentName, message) | Send message to specific agent |
| broadcast(message)       | Send message to all teammates  |
| getTeammates()           | List all registered agents     |

Custom agents are loaded from `.claude/agents/{name}/agent.md` with YAML frontmatter specifying name, description, model, and tools.

## Hooks System — 7 Event Types

The hook system provides deep extensibility with 7 event types:

| Hook         | Can Block? | Description                              |
| ------------ | ---------- | ---------------------------------------- |
| PreToolUse   | Yes        | Before tool execution                    |
| PostToolUse  | No         | After tool execution, can modify results |
| Stop         | Yes        | Prevent agent from stopping              |
| Notification | No         | Fire-and-forget events                   |
| PrePrompt    | No         | Modify user input                        |
| PostResponse | No         | Modify assistant output                  |

Hooks support both **command** (shell) and **function** implementations, configured via `settings.json`.

## Permissions System — 6 Modes

Open Claude Code has a comprehensive permission system:

| Mode              | Behavior                                |
| ----------------- | --------------------------------------- |
| default           | Interactive permission prompts          |
| auto              | Approve known safe operations           |
| plan              | Read-only mode, no edits                |
| acceptEdits       | Accept all edits without prompting      |
| bypassPermissions | No permission checks                    |
| dontAsk           | Silent denial for unapproved operations |

Additional security layers include **sandboxing** (bubblewrap on Linux, seatbelt on macOS), **injection check** for command injection detection, and **path check** for file path validation.

## MCP Implementation — 4 Transports

More comprehensive MCP support than most agents:

| Transport       | Description                                     |
| --------------- | ----------------------------------------------- |
| stdio           | Spawn child process, stdin/stdout communication |
| SSE             | Server-Sent Events over HTTP                    |
| WebSocket       | Bidirectional WebSocket                         |
| streamable-http | POST with SSE response (latest MCP spec)        |

Auto-detection from server config prioritizes: explicit transport > command (stdio) > URL pattern (ws:// → websocket, /sse → SSE, else streamable-http).

## Settings Chain — 4 Sources

Configuration uses a 4-source deep merge chain:

1. `.claude/settings.local.json` — local, gitignored
2. `.claude/settings.json` — project, shared
3. `~/.claude/settings.json` — user global
4. Managed policy — enterprise

Environment variables: **104 supported** via `config/env.mjs`.

## Unique Features Summary

### Async Generator Architecture

13 distinct event types via async generator — more sophisticated event model than most agents in this set.

### Extended Thinking Support

Native support for thinking blocks with configurable budget, built into the core loop.

### Git Worktree Isolation

Subagents can run in isolated git worktrees — unique among these agents.

### File Checkpointing + Undo

Native undo support via `checkpoints.mjs` — checkpoints files before dangerous operations.

### Session Teleport

Export/import sessions between machines — useful for moving a session to a different environment.

### Cron Scheduling

Built-in task scheduler with cron syntax for recurring tasks.

## Comparison to Claude Code

As a clean-room implementation, Open Claude Code aims for functional parity with Claude Code. Key similarities and differences:

| Aspect           | Claude Code                   | Open Claude Code                        |
| ---------------- | ----------------------------- | --------------------------------------- |
| Architecture     | Bun + React/Ink TUI           | TypeScript/Node                         |
| Agent Loop       | Callback-based                | Async generator (13 events)             |
| Tool Count       | 40+                           | 25                                      |
| Slash Commands   | 40+                           | 40                                      |
| MCP Transports   | 3 (stdio, SSE, WS)            | 4 (+ streamable-http)                   |
| Permission Modes | 6                             | 6                                       |
| AI Providers     | Anthropic-first               | 5 (Anthropic, OpenAI, Google, AWS, GCP) |
| Hooks            | PreToolUse, PostToolUse, Stop | 7 event types                           |
| Tests            | Extensive                     | 1,581 passing                           |

## Architecture Patterns Used

- **Factory pattern** — for agent loop, tools, permissions
- **Registry pattern** — for tools (`tools.get('ToolName')`)
- **Event-driven** — via async generator yielding events
- **Middleware hooks** — for extensibility
- **Transport abstraction** — for MCP (stdio/SSE/WS/http)
- **Character-based token estimation** — no external tokenizer

## Key Files

| File                               | Size   | Purpose                   |
| ---------------------------------- | ------ | ------------------------- |
| v2/src/core/agent-loop.mjs         | 16KB   | Main async generator loop |
| v2/src/ui/commands.mjs             | 16.8KB | 40 slash commands         |
| v2/src/tools/bash.mjs              | 4.7KB  | Shell execution           |
| v2/src/tools/grep.mjs              | 4.8KB  | Regex search              |
| v2/src/core/providers.mjs          | 7.4KB  | Multi-provider support    |
| v2/src/config/env.mjs              | 12.8KB | 104 env vars              |
| v2/src/tools/registry.mjs          | 3.3KB  | Tool registration         |
| archive/open\_claude\_code/cli.mjs | 7.3MB  | Decompiled original       |

## Bottom Line

Open Claude Code is remarkable for being the most complete **clone implementation** in this set — a functional recreation of Claude Code through reverse engineering. Its **async generator architecture** and **7-type hook system** represent architectural choices that differ from most other agents, while features like **git worktree isolation**, **file checkpointing**, and **session teleport** add capabilities the original doesn't have.

The 1,581 passing tests demonstrate functional parity in core functionality. For anyone wanting to understand how Claude Code works internally, this is the most transparent view available outside of Anthropic.