Build Guide
How to build and run Claude Code from the recovered source.
Credit
The source recovery and build setup used in this guide is based on the work by Janlaywss/cloud-code, who extracted the original TypeScript source from the npm package's source map and created the build scaffolding (stubs, patches, build script). We followed their steps to get the source building and running locally.
Prerequisites
| Tool | Version | Purpose |
|---|---|---|
| Node.js | v18+ | Runtime |
| Bun | v1.3.11 | Build tool (uses bun:bundle feature) |
| pnpm | v10+ | Package manager |
Quick Start
# 1. Install Bun
curl -fsSL https://bun.sh/install | bash
# Restart your shell or run: exec /bin/zsh
# 2. Install pnpm (if needed)
npm install -g pnpm
# 3. Install dependencies
pnpm install --registry https://registry.npmjs.org
# 4. Build
bun run build.ts
# 5. Verify
bun dist/cli.js --version
# Expected: 2.1.88 (Claude Code)
Running
# Interactive mode
bun dist/cli.js
# Show help
bun dist/cli.js --help
# Dev mode (runs source directly, no build needed)
bun src/entrypoints/cli.tsx
You'll need an ANTHROPIC_API_KEY for actual usage:
export ANTHROPIC_API_KEY="sk-ant-..."
bun dist/cli.js
How the Build Works
The build uses Bun's bundler with a custom build.ts script that:
- Bundles
src/entrypoints/cli.tsx→dist/cli.js(ESM format, Node target) - Injects feature flags via a custom
bun:bundleplugin that replacesfeature()calls with compile-time booleans - Embeds text files —
.mdand.txtfiles are loaded as strings - Injects MACRO constants — version, build time, URLs
- Adds shebang —
#!/usr/bin/env nodeprepended, file made executable
Private Package Stubs
Internal Anthropic packages are replaced with functional stubs in stubs/:
| Package | Stub Behavior |
|---|---|
color-diff-napi | Disables native syntax highlighting |
modifiers-napi | Returns empty modifier state |
@ant/claude-for-chrome-mcp | Disables Chrome MCP |
@anthropic-ai/mcpb | Minimal MCP bundle processor |
@anthropic-ai/sandbox-runtime | Minimal sandbox interface |
Commander Patch
A patch in patches/commander@14.0.3.patch allows multi-character short options (e.g., -d2e). Applied automatically by pnpm during install.
Notes
- This build runs independently from any globally installed Claude Code (
claudecommand) - Both share config at
~/.claude/and API credentials - The build output is
dist/cli.js(~22MB ESM bundle with source maps)