Fully open-source Claude Code project - Reconstructed from Anthropic's official source code
π Languages: δΈζ | English
This project sincerely thanks Anthropic for their open-source contributions!
Anthropic releases Claude Code via npm packages, enabling us to learn and study this excellent AI programming assistant architecture. The source code in this project is recovered from the official npm package's source maps, for learning and research purposes only.
"You're right, I shouldn't have published map files to npm. This is a very serious mistake."
We understand that source map files are intended for development debugging, not public release. Anthropic's recognition and handling of this issue is worth learning from.
Open-ClaudeCode is a complete open-source version of Claude Code, including:
- β Runnable CLI - Compiled executable files (v2.1.88)
- β TypeScript Source - 1,902 recovered source files for study
- β Official Plugins - 13 Anthropic official plugins
- β Configuration Examples - Settings configurations for various scenarios
- β Complete Documentation - Project instructions, user guides, CHANGELOG
Open-ClaudeCode/
βββ package/ # Runnable CLI
β βββ cli.js # Compiled CLI (12.5MB)
β βββ cli.js.map # Source Map (57MB)
β βββ package.json # Package configuration
β βββ bun.lock # Bun lock file
β βββ sdk-tools.d.ts # SDK type definitions (117KB)
β βββ vendor/ # Native binary modules
β βββ audio-capture/ # Audio capture (6 platforms)
β βββ ripgrep/ # Code search tool (6 platforms)
βββ src/ # Complete TypeScript source (1,902 files)
β βββ tools/ # 30+ tool implementations (184 files)
β βββ commands/ # 50+ command implementations (207 files)
β βββ services/ # API, MCP, OAuth services (130 files)
β βββ components/ # React UI components (389 files)
β βββ ink/ # Ink UI framework (96 files)
β βββ utils/ # Utility functions (564 files)
β βββ hooks/ # React Hooks (104 files)
β βββ bridge/ # Bridge modules (31 files)
β βββ vendor/ # Native module sources (4 files)
β βββ ... # More modules
βββ plugins/ # 13 official plugins
β βββ agent-sdk-dev/
β βββ claude-opus-4-5-migration/
β βββ code-review/
β βββ commit-commands/
β βββ explanatory-output-style/
β βββ feature-dev/
β βββ frontend-design/
β βββ hookify/
β βββ learning-output-style/
β βββ plugin-dev/
β βββ pr-review-toolkit/
β βββ ralph-wiggum/
β βββ security-guidance/
βββ examples/ # Configuration examples
β βββ settings/ # strict / lax / bash-sandbox
βββ docs/ # Documentation
βββ README.md # This file
βββ ACKNOWLEDGEMENTS.md # Acknowledgements
βββ CHANGELOG.md # Version changelog
βββ LICENSE # License description
βββ .gitignore # Git ignore rules
βββ .gitattributes # Git attributes
- Node.js 18+ (Download)
- API Key (choose one):
- π΅ Anthropic Official API β Register at console.anthropic.com to get API Key
- π’ Third-party Proxy β Recommended for users in certain regions, get proxy URL and API Key
β οΈ OpenAI format proxies (e.g., MiniMax, OpenRouter) require Universal-AI-Protocol-Bridge for protocol conversion- π΄ Claude Subscription β Login via OAuth after running (requires network access)
# 1. Clone the repository
git clone https://github.com/LING71671/Open-ClaudeCode.git
cd Open-ClaudeCode
# 2. Verify environment
node --version # Requires >= 18.0.0
node package/cli.js --version # Should show 2.1.88
# 3. Start!
node package/cli.jsAuthentication is required on first run, choose any one method:
- Get API URL and key from third-party proxy provider
- Create
settings.json:
{
"env": {
"ANTHROPIC_BASE_URL": "https://your-proxy-url",
"ANTHROPIC_AUTH_TOKEN": "sk-your-api-key"
}
}- Run:
node package/cli.js --settings settings.json
- Visit console.anthropic.com to register
- Get API Key (format:
sk-ant-...) - Create
settings.json:
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "sk-ant-your-key"
}
}- Run:
node package/cli.js --settings settings.json
Requires Claude subscription:
# Run directly, will open browser for login
node package/cli.jsRun directly, chat-like interface:
node package/cli.jsAfter entering, you'll see the interactive interface where you can input questions or commands:
> Create a Python Flask project for me
> Explain this code
> Help me fix this bug
Common operations:
- Type text β Press Enter to send
Ctrl+Cβ Interrupt current action/helpβ View all available commands/clearβ Clear conversation/exitβ Exit
For automation and scripting:
# Simple Q&A
node package/cli.js -p "Explain what is a closure"
# Process files
node package/cli.js -p "Help me refactor the getUser function in src/main.ts"
# Specify model
node package/cli.js -p "Write a sorting algorithm" --model sonnet
# JSON output (for program processing)
node package/cli.js -p "List files in current directory" --output-format json# Continue most recent conversation in current directory
node package/cli.js -c
# Resume specific session
node package/cli.js -r <session-id>If you use third-party API proxy services or have custom endpoints:
- Create configuration file:
// settings.json
{
"env": {
"ANTHROPIC_BASE_URL": "https://your-proxy-url",
"ANTHROPIC_AUTH_TOKEN": "sk-your-api-key"
}
}- Load configuration at runtime:
node package/cli.js --settings settings.json# Bash/Zsh
export ANTHROPIC_BASE_URL="https://your-proxy-url"
export ANTHROPIC_AUTH_TOKEN="sk-your-api-key"
node package/cli.js# PowerShell
$env:ANTHROPIC_BASE_URL = "https://your-proxy-url"
$env:ANTHROPIC_AUTH_TOKEN = "sk-your-api-key"
node package/cli.js# CMD
set ANTHROPIC_BASE_URL=https://your-proxy-url
set ANTHROPIC_AUTH_TOKEN=sk-your-api-key
node package/cli.jsClaude Code automatically reads ~/.claude/settings.json:
// C:\Users\YourUsername\.claude\settings.json (Windows)
// ~/.claude/settings.json (macOS/Linux)
{
"env": {
"ANTHROPIC_BASE_URL": "https://your-proxy-url",
"ANTHROPIC_AUTH_TOKEN": "sk-your-api-key"
}
}After configuration, every run of node package/cli.js will automatically use these settings.
# Common models
node package/cli.js --model sonnet # Claude Sonnet (default)
node package/cli.js --model opus # Claude Opus (most powerful)
node package/cli.js --model haiku # Claude Haiku (fastest)
# Full model names
node package/cli.js --model claude-sonnet-4-6
node package/cli.js --model claude-opus-4-6- Third-party proxies may not support all models, please refer to your provider's model list
ANTHROPIC_AUTH_TOKENandANTHROPIC_API_KEYeither one works- If both environment variables and settings file are configured, environment variables take precedence
- Do not share configuration files containing API keys in public repositories
# Sonnet (default, fast, good cost-performance)
node package/cli.js --model sonnet
# Opus (most powerful, but slower and more expensive)
node package/cli.js --model opus
# Haiku (fastest and cheapest)
node package/cli.js --model haiku# Default mode (requires confirmation for each action)
node package/cli.js
# Auto-accept edits (no confirmation needed for file modifications)
node package/cli.js --permission-mode acceptEdits
# Skip all permission checks (β οΈ sandbox environment only)
node package/cli.js --dangerously-skip-permissions# Load plugins from specified directory
node package/cli.js --plugin-dir ./plugins/code-review
# Load multiple plugins
node package/cli.js --plugin-dir ./plugins/code-review --plugin-dir ./plugins/commit-commands# Go to your project directory
cd your-project
# Start Claude
node /path/to/Open-ClaudeCode/package/cli.js
# Then input:
> Create a user login API using Express.js
> Add unit tests for this function
> Fix the type error in src/auth.ts# Using code-review plugin
node package/cli.js --plugin-dir ./plugins/code-review
# Or directly ask Claude to review
> Help me review the recent git diff
> Check if this PR has any potential issues# Using commit-commands plugin
node package/cli.js --plugin-dir ./plugins/commit-commands
# Or use built-in command directly
> /commit # Smart commit message generationIn interactive mode, type / for commands:
| Command | Description |
|---|---|
/help |
Show help |
/clear |
Clear conversation |
/compact |
Compress conversation history |
/model |
Switch model |
/theme |
Switch theme |
/vim |
Toggle Vim mode |
/cost |
View cost statistics |
/stats |
View usage statistics |
/share |
Share session |
/exit |
Exit |
A: First run requires authentication. After running, it will automatically open a browser for login with your Claude account. Or set the ANTHROPIC_API_KEY environment variable.
A: Check your network connection. If in certain regions, you may need a proxy:
export HTTPS_PROXY="http://127.0.0.1:7890"
node package/cli.jsA: In interactive mode, type /cost or /stats to view.
A: Create a settings.json file with the following content:
{
"env": {
"ANTHROPIC_BASE_URL": "https://your-proxy-url",
"ANTHROPIC_AUTH_TOKEN": "sk-your-api-key"
}
}Then run node package/cli.js --settings settings.json. You can also place it in ~/.claude/settings.json for global configuration.
A: Yes! But it's recommended to run in your project directory so Claude can access project files.
A: This repository provides complete source code recovered from the npm package, suitable for learning and research. Functionally identical to the npm-installed version.
A: Claude Code natively uses Anthropic API format. If you need to use OpenAI SDK format, you can use Universal-AI-Protocol-Bridge for protocol conversion:
Features:
- π Protocol Conversion - Convert OpenAI SDK format to Anthropic/Claude API format
- π Multi-Protocol Support - OpenAI, Anthropic, Google Gemini, AWS Bedrock, Azure, Ollama, etc.
- β‘ Streaming Optimization - Full support for SSE/NDJSON streaming responses
- π Secure Encryption - AES-GCM encryption to protect API keys
- βοΈ Cloudflare Workers - Edge deployment with global low latency
Usage:
- Visit the online test URL or self-deploy
- Select target protocol (e.g., Anthropic) and enter your API key
- Generate proxy URL, then point your OpenAI SDK
baseURLto this address
// Example: Using OpenAI SDK to call Claude
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://your-bridge-url/proxy/{token}/v1',
apiKey: 'any-key' // Actual key is encrypted in the token
});
// Now you can call Claude using OpenAI format!
const response = await client.chat.completions.create({
model: 'claude-3-5-sonnet-latest',
messages: [{ role: 'user', content: 'Hello!' }]
});Source code is located in the src/ directory, containing 1,902 source files:
# View entry point
cat src/main.tsx
# View tool implementations
ls src/tools/
# View command implementations
ls src/commands/Plugins are located in the plugins/ directory, containing 13 official plugins:
# View plugin list
ls plugins/
# View plugin details
cat plugins/ralph-wiggum/.claude-plugin/plugin.json| Category | Count |
|---|---|
| TypeScript source (.ts + .tsx) | 1,884 files |
| JavaScript source (.js) | 18 files |
| All source files total | 1,902 files |
| Tool implementations | 30+ |
| Command implementations | 50+ |
| Service modules | 15+ |
| UI components | 25+ |
| Official plugins | 13 |
| Native modules | 2 (audio-capture, ripgrep) |
| Supported platforms | 6 (macOS/Linux/Windows Γ arm64/x64) |
Source code copyright belongs to Anthropic PBC.
This repository is for learning and research purposes only and does not represent Anthropic's official position.
See LICENSE and ACKNOWLEDGEMENTS.md for details.
Last updated: 2026-04-01
