Sandbox
@ruvnet/open-claude-code

Claude Code CLI rebuild for terminal agents

Open Claude Code is a clean-room implementation of the Claude Code CLI. It ships a REPL, slash commands, built-in tools, settings files, custom agents, skills, hooks, and MCP support, so you can work in a Claude Code-like flow from the terminal.

495 stars163 forksJavaScriptUpdated 7d ago
Who it's for

Builders who want a Claude Code-style terminal agent with commands, sessions, and tool access they can run locally.

What it delivers

You can run a Claude Code-like CLI, customize its behavior, and use its agent workflow without relying on the closed source app.

What it does

Interactive REPL and slash commands

Run `occ` for a chat loop with commands like `/help`, `/model`, `/tools`, `/resume`, `/sessions`, and `/hooks`.

Built-in tool set

Use tools such as Bash, Read, Edit, Write, Glob, Grep, Agent, WebFetch, WebSearch, and TodoWrite inside the CLI.

Project settings and CLAUDE.md

Configure behavior through `.claude/settings.json`, `~/.claude/settings.json`, and `CLAUDE.md` files across your project tree.

Custom agents and skills

Define agents in `.claude/agents/*.md` and skills in `.claude/skills/*/SKILL.md`, then invoke them from the REPL.

MCP integration

Connect external tools and services through `.mcp.json` and supported transports like stdio, SSE, Streamable HTTP, and WebSocket.

Multi-provider model support

Use Anthropic, OpenAI, Google, Bedrock, or Vertex models by setting the right API key and model flag.

How to get it

  1. 1Requires: ANTHROPIC_API_KEY environment variable set.
    export ANTHROPIC_API_KEY=sk-ant-...
    npx @ruvnet/open-claude-code "what files are in this directory?"
  2. 2Run
    npx @ruvnet/open-claude-code "your prompt here"
  3. 3Run
    npm install -g @ruvnet/open-claude-code
    occ "your prompt here"
  4. 4Run
    git clone https://github.com/ruvnet/open-claude-code.git
    cd open-claude-code/v2
    export ANTHROPIC_API_KEY=sk-ant-...
    node src/index.mjs "hello"
  5. 5Run
    occ "explain the auth module"
    occ "fix the bug in server.js"
    occ "create a REST API for user management"
    occ "find all TODO comments in this project"
  6. 6Run
    occ
    # > explain this codebase
    # > /help
    # > /tools
    # > /model claude-opus-4-6
    # > refactor the database layer
    # > /cost
    # > /exit

README

Open Claude Code

Open Source Claude Code CLI — Reverse Engineered & Rebuilt

A fully functional open source implementation of Anthropic's Claude Code CLI,
built from decompiled source intelligence using ruDevolution.

Tests Tools Commands npm License Nightly

Automated Nightly Releases — Open Claude Code automatically detects new Claude Code releases, runs 903+ tests to verify zero regressions, and publishes verified builds with AI-powered discovery analysis. See Releases | ADR-001 | pi.ruv.io


⚡ Quick Start

# Run instantly (no install)
npx @ruvnet/open-claude-code "explain this codebase"

# Or install globally
npm install -g @ruvnet/open-claude-code
occ "hello"

# Interactive mode
occ

Requires: ANTHROPIC_API_KEY environment variable set.

export ANTHROPIC_API_KEY=sk-ant-...
npx @ruvnet/open-claude-code "what files are in this directory?"

🧠 What Is This?

Open Claude Code is a ground-up open source rebuild of Anthropic's Claude Code CLI, informed by ruDevolution's AI-powered decompilation of the published npm package.

It's not a copy — it's a clean-room implementation that mirrors the actual Claude Code architecture: async generator agent loop, 25 tools, 4 MCP transports, 6 permission modes, hooks, settings chain, sessions, and more.

1,581 tests. 61 files. 8,314 lines. 100% functional.


📦 Installation

npx (no install needed)

npx @ruvnet/open-claude-code "your prompt here"

Global install

npm install -g @ruvnet/open-claude-code
occ "your prompt here"

From source

git clone https://github.com/ruvnet/open-claude-code.git
cd open-claude-code/v2
export ANTHROPIC_API_KEY=sk-ant-...
node src/index.mjs "hello"

🖥️ Usage

One-shot mode

occ "explain the auth module"
occ "fix the bug in server.js"
occ "create a REST API for user management"
occ "find all TODO comments in this project"

Interactive REPL

occ
# > explain this codebase
# > /help
# > /tools
# > /model claude-opus-4-6
# > refactor the database layer
# > /cost
# > /exit

CLI Options

occ [options] [prompt]

Options:
  -m, --model <model>          Model to use (default: claude-sonnet-4-6)
  -p, --print                  Print mode (non-interactive, output only)
  --permission-mode <mode>     Permission mode: default, auto, plan, acceptEdits, 
                               bypassPermissions, dontAsk
  --system-prompt <text>       Override system prompt
  --add-dir <path>             Additional CLAUDE.md directory
  --max-turns <n>              Maximum conversation turns
  --allowedTools <tools>       Comma-separated allowed tools
  --disallowedTools <tools>    Comma-separated denied tools
  --output-format <fmt>        Output: text, json, stream-json
  -v, --verbose                Verbose output
  -d, --debug                  Debug mode
  --version                    Show version
  -h, --help                   Show help

Examples

# Use a different model
occ -m claude-opus-4-6 "design a database schema for a blog"

# Print mode (for piping)
occ -p "list all functions in src/" > functions.txt

# Plan mode (read-only, no edits)
occ --permission-mode plan "review the security of auth.js"

# Restrict tools
occ --allowedTools "Read,Glob,Grep" "find all API endpoints"

# With custom system prompt
occ --system-prompt "You are a senior Go developer" "review main.go"

🔧 Interactive Commands

40 slash commands available in REPL mode:

CommandDescription
/helpShow all commands
/model <name>Switch model mid-conversation
/toolsList available tools
/tokensShow current token usage
/costShow session cost estimate
/compactCompact context window
/undoUndo last file edit
/clearClear conversation history
/doctorCheck API connectivity + health
/fastToggle fast mode (Haiku)
/effort <level>Set effort: low, medium, high, max
/resume [id]Resume a previous session
/sessionsList saved sessions
/agentsList custom agents
/skillsList available skills
/hooksShow active hooks
/configShow current settings
/permissionsShow permission mode
/mcpShow MCP server status
/memoryShow memory usage
/exitExit

🔨 Tools

25 built-in tools matching Claude Code's tool system:

ToolDescription
BashExecute shell commands (sandboxed)
ReadRead files with line numbers
EditReplace strings in files
WriteCreate/overwrite files
GlobFind files by pattern
GrepSearch file contents (regex)
LSList directory contents
AgentSpawn sub-agents
WebFetchFetch URL content
WebSearchWeb search
TodoWriteTask management
NotebookEditEdit Jupyter notebooks
MultiEditAtomic multi-file edits
ToolSearchDiscover deferred tools
AskUserPrompt user for input
SkillInvoke a skill
SendMessageAgent team messaging
CronCreate/Delete/ListScheduled tasks
EnterWorktree/ExitWorktreeGit worktree isolation
RemoteTriggerRemote execution
LSPLanguage server protocol
ReadMcpResourceRead MCP resources

⚙️ Configuration

Settings

Create .claude/settings.json in your project or ~/.claude/settings.json globally:

{
  "model": "claude-sonnet-4-6",
  "permissions": {
    "defaultMode": "auto"
  },
  "hooks": {
    "PreToolUse": [{
      "matcher": "Bash",
      "hooks": [{ "type": "command", "command": "echo 'Running bash...'" }]
    }]
  },
  "autoCompactEnabled": true,
  "alwaysThinkingEnabled": true
}

Settings are loaded from 4 sources (in priority order):

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

CLAUDE.md

Create a CLAUDE.md in your project root to customize behavior:

# Project Rules
- Always use TypeScript
- Follow TDD
- Keep files under 500 lines

CLAUDE.md files are loaded from: ~/.claude/CLAUDE.md → parent directories → project root → .claude/CLAUDE.md.

Custom Agents

Create .claude/agents/reviewer.md:

---
name: reviewer
description: Code review specialist
model: claude-sonnet-4-6
tools: [Read, Glob, Grep]
---

You are a thorough code reviewer. Check for bugs, security issues, and style.

Skills

Create .claude/skills/deploy/SKILL.md:

---
name: deploy
description: Deploy to production
---

1. Run tests: npm test
2. Build: npm run build
3. Deploy: ./scripts/deploy.sh

Invoke with /deploy in the REPL.


🔐 Multi-Provider Support

Works with 5 AI providers:

# Anthropic (default)
ANTHROPIC_API_KEY=... occ "hello"

# OpenAI
OPENAI_API_KEY=... occ -m gpt-4o "hello"

# Google
GOOGLE_AI_API_KEY=... occ -m gemini-2.5-flash "hello"

# AWS Bedrock
AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... occ -m bedrock/claude-sonnet "hello"

# Google Vertex
GOOGLE_APPLICATION_CREDENTIALS=... occ -m vertex/claude-sonnet "hello"

🔗 MCP Integration

Connect to MCP servers for additional tools:

// .mcp.json
{
  "mcpServers": {
    "my-server": {
      "command": "npx",
      "args": ["-y", "my-mcp-server"],
      "env": { "API_KEY": "..." }
    }
  }
}

Supports 4 transports: stdio, SSE, Streamable HTTP, WebSocket.


🔍 Background: The Claude Code Source Leak

On March 31, 2026, Anthropic accidentally shipped source maps in the Claude Code npm package, exposing the full TypeScript source. This project takes a different approach — we use ruDevolution to analyze the published npm package legally and rebuild from that intelligence.

What ruDevolution Found

DiscoveryEvidence
🤖 Agent TeamsCLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS
🌙 Auto Dream Modetengu_auto_dream_completed
🔮 claude-opus-4-6Unreleased model ID
🔐 6 "amber" codenamesInternal feature gates
☁️ Cloud Code RunnerBYOC compute
📡 MCP Streamable HTTPNew transport

Download decompiled releases →


⚖️ Legal

This is a clean-room implementation — no leaked source used. Architecture informed by analysis of the published npm package, legal under US DMCA §1201(f), EU Software Directive Art. 6, UK CDPA §50B.


📚 Related

Nightly Release Pipeline

Automated Nightly Verified Releases (ADR-001)

Open Claude Code includes an automated nightly CI/CD pipeline that:

  1. Detects new Claude Code releases from npm registry (03:00 UTC daily)
  2. Verifies compatibility with 903+ tests, npm audit, and smoke tests
  3. Analyzes changes using Claude Sonnet 4.6 AI-powered discovery
  4. Publishes verified releases with detailed notes — only if ALL gates pass
Cron 03:00 UTC → npm check → 903+ tests → npm audit → AI analysis → verified release

Manual trigger:

gh workflow run nightly.yml -f force_release=true

Required secrets:

  • GITHUB_TOKEN — automatic
  • ANTHROPIC_API_KEY — optional, for AI discovery analysis

See ADR-001 for full architecture.

rudevolution Integration

The rudevolution submodule provides AI-powered decompilation analysis of Claude Code releases, tracking 34,759+ functions with 95.7% name accuracy. Used by the nightly pipeline for change discovery.

📄 License

MIT

Files in the repo

Repository payload11 top-level entries
  • .github
  • archive
  • assets
  • docs
  • scripts
  • v2
  • .gitignore
  • .gitmodules
  • LICENSE
  • README.md
  • rudevolution

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More tools

JuliusBrussee/
caveman

🪨 why use many token when few token do trick — Claude Code skill that cuts 65% of tokens by talking like caveman

105k
1 add
MemPalace/
mempalace

The best-benchmarked open-source AI memory system. And it's free.

59k
stablyai/
orca

Orca is the ADE for working with a fleet of parallel agents. Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

66k

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

132k

Never stop coding. Free MIT AI gateway: one endpoint, 352 providers (150+ free), 1200+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 550+ contributors

64k
headroomlabs-ai/
headroom

Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.

71k