We assume you have the leaked source code of Claude Code, and it turns out that you cannot directly run it because it has some missing dependencies. This repository is right for you to make your source code work successfully.
This repository provides the necessary patching and stubbing infrastructure. It acts as a specialized optimization layer, enabling you to stay in sync with the upstream source while applying persistent local modifications for local LLM support (Ollama).
We use a consolidated install.sh script to handle the entire setup process, including source synchronization, patch application, and dependency management.
- Bun: Install Bun (v1.1.0 or higher).
- Claude Code Source: You must have the original Claude Code
srcdirectory available locally.
-
Run the Installer:
./install.sh /path/to/original/claude/src
If the path is not provided as an argument, the script will prompt you for it.
-
What the script does:
- Sync: Resets the local
src/directory to match the upstream source. - Patch: Copies files from the
patch/directory into the root, applying all custom logic and configurations. - Install: Runs
bun installto fetch all necessary dependencies. - Stub: Automatically triggers the local module stubber to prepare the environment for non-proprietary execution.
- Sync: Resets the local
-
Launch the CLI:
bun run dev
The patch includes an Ollama Integration that allows using local models like Llama 3 instead of the Anthropic API.
ollamaShim.ts: A translation layer that intercepts Anthropic SDK calls and maps them to OpenAI-compatible requests for Ollama.- Intelligent Routing: The API client is modified to automatically route requests to
localhost:11434when a local model name is detected.
The scripts/deep-sweep-stubber.ts enables the CLI to run without access to internal Anthropic dependencies or proprietary modules (like @ant/* or color-diff-napi).
- Dynamic Proxy Generation: Creates JavaScript
Proxyobjects that "catch-all" property access, preventing runtime crashes. - React 19 Compatibility: Automatically patches the React development bundle to bridge missing experimental features (like
useEffectEvent) in Bun environments.
This branch activates various internal or experimental commands (e.g., /buddy, /ultrareview) by providing local mocks or implementations.
install.sh: The main setup script.patch/: The source of truth for all modifications. Files here are applied to the root during installation.src/: The working source directory (generated/updated byinstall.sh).
For a full list of modified files and a detailed manifest, see patch/docs/patch.md.
Caution
Source of Truth: Always make modifications inside the patch/ directory. Changes made directly to the root src/ will be overwritten whenever install.sh is run.
For the best experience, you can create a global claude command that you can run from any terminal, automatically applying your local model settings.
A unified tool at scripts/create_launcher.sh (or patch/scripts/create_launcher.sh) is provided to handle the entire setup.
Run the script to configure your environment and link the command:
./patch/scripts/create_launcher.shThis script will:
- Prompt for Settings: Ask for your Ollama model name and base URL.
- Create
.env: Save these persistently to a local.envfile that Bun automatically loads. - Generate Launcher: Create a global launcher at
~/.local/bin/clauderepresenting your patched repository.
Once set up, you can start your local Claude Code by just typing:
claudeTo use the original unpatched version at any time, run:
claude --officialTip
Path Precedence: Ensure that ~/.local/bin is in your shell's PATH. If it is not, the official version in /opt/homebrew/bin may take precedence.
