A buildable, modifiable, and runnable version of the Claude Code source.
Based on the Claude Code source snapshot publicly exposed on 2026-03-31 via an npm source map leak. The original snapshot contained only raw TypeScript source with no build configuration — it could not be compiled or run. This fork reconstructs the full build system and fixes all missing components to make it functional.
Quick Start | Architecture | Feature Flags | Extension Guide
- Bun >= 1.3.x
- Valid Anthropic authentication (OAuth via
claude loginorANTHROPIC_API_KEY)
git clone https://github.com/beita6969/claude-code.git
cd claude-code
# Install dependencies (auto-creates bun:bundle polyfill via postinstall)
bun install
# Run directly
bun src/main.tsx -p "your prompt here" --output-format text# Compile to single bundle (~20MB)
bun build src/main.tsx --outdir=dist --target=bun# Headless print mode (no TTY needed)
bun src/main.tsx -p "your prompt here" --output-format text
# JSON output
bun src/main.tsx -p "your prompt here" --output-format json
# Interactive REPL mode (needs TTY)
bun src/main.tsxNote: If
ANTHROPIC_API_KEYis set in your environment, it must be valid. To use OAuth instead, unset it:unset ANTHROPIC_API_KEY
The original snapshot shipped no package.json, no tsconfig.json, no lockfile, and no build scripts. Over 100 internal/feature-gated modules were also missing from the source map.
| File | Purpose |
|---|---|
package.json |
60+ npm dependencies reverse-engineered from ~1,900 source files |
tsconfig.json |
TypeScript config (ESNext + JSX + Bun bundler resolution) |
bunfig.toml |
Bun runtime configuration |
scripts/postinstall.sh |
Auto-creates bun:bundle runtime polyfill after bun install |
.gitignore |
Excludes node_modules/, dist/, lockfiles |
The original source imports many Anthropic-internal packages and feature-gated modules that were not included in the leak. Minimal stubs were created so the build completes:
| Category | Count | Examples |
|---|---|---|
Anthropic internal packages (@ant/*) |
4 | computer-use-mcp, computer-use-swift, claude-for-chrome-mcp |
| Native addons | 3 | color-diff-napi, audio-capture-napi, modifiers-napi |
| Cloud provider SDKs | 6 | Bedrock/Foundry/Vertex SDK, AWS STS, Azure Identity |
| OpenTelemetry exporters | 10 | OTLP gRPC/HTTP/Proto exporters |
| Other optional packages | 2 | sharp, turndown |
| Feature-gated source modules | ~90 | Tools, commands, services, components excluded from the source map |
| File | Change |
|---|---|
src/main.tsx |
Runtime MACRO constant injection (compile-time define in production) |
src/main.tsx |
Fixed Commander.js -d2e short flag incompatibility |
src/bootstrap/state.ts |
Added missing isReplBridgeActive() export |
src/types/connectorText.ts |
Added isConnectorTextBlock function stub |
src/tools/WorkflowTool/constants.ts |
Added WORKFLOW_TOOL_NAME export |
src/
├── main.tsx # CLI entrypoint (Commander.js + React/Ink)
├── QueryEngine.ts # Core LLM API engine
├── query.ts # Agentic loop (async generator)
├── Tool.ts # Tool type definitions
├── tools.ts # Tool registry
├── commands.ts # Command registry
├── context.ts # System prompt context
│
├── tools/ # 40+ tool implementations
│ ├── AgentTool/ # Sub-agent spawning & coordination
│ ├── BashTool/ # Shell command execution
│ ├── FileReadTool/ # File reading
│ ├── FileEditTool/ # File editing
│ ├── GrepTool/ # ripgrep-based search
│ ├── MCPTool/ # MCP server tool invocation
│ ├── SkillTool/ # Skill execution
│ └── ...
│
├── services/ # External integrations
│ ├── api/ # Anthropic API client
│ ├── mcp/ # MCP server management
│ └── ...
│
├── memdir/ # Persistent memory system
├── skills/ # Skill system (bundled + user)
├── components/ # React/Ink terminal UI
├── hooks/ # React hooks
├── coordinator/ # Multi-agent orchestration
└── stubs/ # Stub packages for missing internals
| System | Files | Description |
|---|---|---|
| Agentic Loop | query.ts, QueryEngine.ts |
while(true) async generator: query -> tool calls -> results -> loop |
| Memory | memdir/ |
4-type file-based memory (user/feedback/project/reference) with MEMORY.md index |
| MCP | services/mcp/ |
Model Context Protocol server management (stdio/http/sse/ws) |
| Skills | skills/, tools/SkillTool/ |
Reusable workflow templates (SKILL.md format) |
| Agents | tools/AgentTool/ |
Custom agent types via .claude/agents/*.md |
| System Prompt | constants/prompts.ts |
Layered prompt: static -> dynamic -> memory -> agent |
| Mechanism | Location | Format |
|---|---|---|
| Custom Skills | .claude/skills/name/SKILL.md |
YAML frontmatter + Markdown |
| Custom Agents | .claude/agents/name.md |
YAML frontmatter + Markdown |
| MCP Servers | .mcp.json |
JSON config |
| Hooks | ~/.claude/settings.json |
JSON event-action mappings |
The bun:bundle feature() function controls feature gating. In this build, all features default to disabled. To enable features, edit node_modules/bundle/index.js (auto-generated by bun install):
const ENABLED_FEATURES = new Set([
// Uncomment to enable:
// 'KAIROS', // Assistant mode
// 'PROACTIVE', // Proactive mode
// 'BRIDGE_MODE', // IDE bridge
// 'VOICE_MODE', // Voice input
// 'COORDINATOR_MODE', // Multi-agent coordinator
// 'EXTRACT_MEMORIES', // Background memory extraction
// 'TEAMMEM', // Team memory
])| Layer | Technology |
|---|---|
| Runtime | Bun |
| Language | TypeScript (strict) |
| Terminal UI | React + Ink |
| CLI | Commander.js |
| Validation | Zod v4 |
| Search | ripgrep |
| Protocols | MCP SDK, LSP |
| API | Anthropic SDK |
| Telemetry | OpenTelemetry |
- ~1,900 source files
- 512,000+ lines of TypeScript
- 40+ tools, 100+ commands, 140+ UI components
- 20MB compiled bundle
- This repository is for educational and research purposes only.
- The original Claude Code source is the property of Anthropic.
- This repository is not affiliated with, endorsed by, or maintained by Anthropic.
- Original source exposure: 2026-03-31 via npm source map leak.
If this helps your research, please give it a ⭐!