Skip to main content

Local backend bridge for Claude Code and Codex.

Project description

License: MIT Python 3.10+ CI Code style: ruff

Claude Code + Codex, running entirely on your machine

One alias (cc or cx) swaps the backend to a local model. Your skills, agents, MCP servers, and config stay untouched.

Get Started →


How It Works

graph LR
    A["cc / cx alias"] --> B["helper script<br>.claude-codex-local/bin/cc"]
    B -->|Ollama| C["ollama launch claude<br>--model gemma4:26b"]
    B -->|"LM Studio / llama.cpp"| D["inline env vars<br>+ exec claude"]
    C --> E["~/.claude<br>your real config"]
    D --> E

The wizard runs once and wires everything up. After that, cc just works. Your real ~/.claude and ~/.codex are never modified.


Features

Feature What you get
Ollama first-class ollama launch — no duplicated config, no custom Modelfiles
Config untouched All skills, statusline, agents, plugins, and MCP servers carry over
Smart model selection llmfit analyses your hardware and picks the best quantization that fits
Resume on failure Wizard persists progress — --resume picks up from the last completed step
Idempotent aliases Re-running the wizard replaces the existing alias block, never appends
Cloud fallback Run claude / codex directly (no prefix) to switch back instantly

Quick Start

One-command install (no clone required)

bash <(curl -sSL https://raw.githubusercontent.com/luongnv89/claude-codex-local/main/install.sh)

Or with wget:

bash <(wget -qO- https://raw.githubusercontent.com/luongnv89/claude-codex-local/main/install.sh)

Use bash <(...), not curl … | bash. The wizard is interactive and needs a real TTY — piping steals stdin.

Override defaults with env vars:

CCL_REF=v0.2.0 CCL_INSTALL_DIR=~/tools/claude-codex-local \
  bash <(curl -sSL https://raw.githubusercontent.com/luongnv89/claude-codex-local/main/install.sh)

Install from a clone

git clone https://github.com/luongnv89/claude-codex-local.git
cd claude-codex-local
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
./bin/claude-codex-local

After setup

Reload your shell so the alias is available:

source ~/.zshrc   # or source ~/.bashrc

Then run:

cc        # Claude Code → local model
cx        # Codex CLI → local model

Wizard Steps

graph TD
    A[1. Discover environment] --> B[2. Install missing components]
    B --> C[3. Pick harness + engine]
    C --> D[4. Pick model]
    D --> E[5. Smoke test engine]
    E --> F[6. Wire harness]
    F --> G[7. Install helper + aliases]
    G --> H[8. Verify launch end-to-end]
    H --> I[9. Generate guide.md]

See guide.example.md for the personalized daily-use guide the wizard generates.


Usage

./bin/claude-codex-local setup --harness claude --engine ollama   # skip prefs picker
./bin/claude-codex-local setup --non-interactive                  # CI-friendly
./bin/claude-codex-local setup --resume                           # resume after failure
./bin/claude-codex-local find-model                               # standalone model recommendation

Diagnostic helpers:

./bin/poc-doctor            # wizard state + presence check
./bin/poc-machine-profile   # full hardware profile as JSON
./bin/poc-recommend         # llmfit-only model recommendation

Prerequisites

  • macOS or Linux with zsh or bash
  • Python 3.10+
  • At least one harness: Claude Code or Codex CLI
  • At least one engine: Ollama (recommended), LM Studio, or llama.cpp
  • llmfit on PATH (optional — for automatic model selection)

Proven Paths

Harness Engine Model Status
Claude Code Ollama gemma4:26b Verified end-to-end
Codex CLI Ollama gemma4:26b Verified
Codex CLI Ollama qwen2.5-coder:0.5b Verified
Claude Code LM Studio Qwen3 family Blocked — 400 thinking.type; wizard warns and recommends alternatives
Any llama.cpp any Inline-env code path exists, no live proof yet

Rollback

# Remove the fenced block from ~/.zshrc (between the marker lines)
rm -rf .claude-codex-local

That's it. Your ~/.claude and ~/.codex are unchanged.


Architecture details

Three layers

  1. Machine profile + model recommendation (poc_bridge.py) — dumps a JSON snapshot of installed harnesses/engines/llmfit/disk, runs llmfit for ranked model recommendations, and provides a doctor command for pretty-printing wizard state.

  2. Interactive wizard (wizard.py) — 9 steps from discovery to ready-to-use daily alias. Persists progress in .claude-codex-local/wizard-state.json so --resume picks up after a failure.

  3. Helper scripts + shell aliases.claude-codex-local/bin/cc (or cx) is a short bash wrapper. For Ollama it runs ollama launch claude|codex --model <tag>. For LM Studio / llama.cpp it sets inline env vars and execs the real harness. A fenced block in ~/.zshrc / ~/.bashrc declares the aliases.

Why ollama launch

ollama launch claude --model <tag> is an official Ollama subcommand that sets the right env vars internally and execs the user's real claude binary against the local daemon — using ~/.claude as-is.

This means:

  • No duplicated ~/.claude directory
  • No custom Modelfile or ollama create
  • No ANTHROPIC_CUSTOM_MODEL_OPTION to manage manually
  • cc just works

Claude Code → LM Studio / llama.cpp env vars

Env var LM Studio llama.cpp
ANTHROPIC_BASE_URL http://localhost:1234 http://localhost:8001
ANTHROPIC_API_KEY lmstudio sk-local
ANTHROPIC_CUSTOM_MODEL_OPTION <tag> <tag>
ANTHROPIC_CUSTOM_MODEL_OPTION_NAME Local (lmstudio) <tag> Local (llamacpp) <tag>
CLAUDE_CODE_ATTRIBUTION_HEADER "0" "0"
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC "1" "1"

Codex CLI → Ollama

ollama launch codex --model <tag> -- --oss --local-provider=ollama

The --oss --local-provider=ollama flags are required after -- because Codex otherwise tries to route through the ChatGPT account and rejects non-OpenAI model names.

Qwen3 + Claude Code

Claude Code sends a thinking payload that Qwen3 reasoning models interpret as an unterminated <think> block. The wizard detects Qwen3 model names at pick time and recommends Gemma 3 or Qwen 2.5 Coder instead.

Project structure
.
├── bin/
│   ├── claude-codex-local      # Main wizard entrypoint
│   ├── poc-doctor              # Diagnostic: wizard state
│   ├── poc-machine-profile     # Diagnostic: hardware profile
│   └── poc-recommend           # Diagnostic: model recommendation
├── scripts/
│   └── e2e_smoke.sh            # End-to-end smoke test
├── docs/
│   ├── poc-wizard.md           # 9-step wizard architecture
│   ├── poc-architecture.md     # System design overview
│   ├── poc-bootstrap.md        # Bootstrap / install flow
│   └── poc-proof.md            # Design rationale
├── tests/                      # pytest test suite
├── wizard.py                   # Interactive setup wizard (core logic)
├── poc_bridge.py               # Backend bridge / harness wiring
├── install.sh                  # One-command remote installer
└── pyproject.toml              # Project metadata and tool config
Tech stack
Layer Tool
Language Python 3.10+
UI / prompts questionary, rich
Linting ruff
Type checking mypy
Testing pytest + pytest-cov
Security bandit, detect-secrets
Pre-commit pre-commit
Local state

Everything written by the bridge goes under .claude-codex-local/. Override with CLAUDE_CODEX_LOCAL_STATE_DIR.

Contributing

Contributions are welcome. Read CONTRIBUTING.md before opening a PR.

For security issues, see SECURITY.md.


MIT — © 2024 Luong NGUYEN

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

claude_codex_local-0.2.0.tar.gz (69.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

claude_codex_local-0.2.0-py3-none-any.whl (31.6 kB view details)

Uploaded Python 3

File details

Details for the file claude_codex_local-0.2.0.tar.gz.

File metadata

  • Download URL: claude_codex_local-0.2.0.tar.gz
  • Upload date:
  • Size: 69.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for claude_codex_local-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9d16501cf07b69592bcc13f7ee700e6cfd415c5fca0af1f05b3f18dcc51a0aa4
MD5 c1c28a49b8d71310f469306f9ac46cbd
BLAKE2b-256 4d861911c31f56b7f16452fa686d4d62a96ef2c6eda1ae015517716bda34de83

See more details on using hashes here.

File details

Details for the file claude_codex_local-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for claude_codex_local-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af72bf0269100ac03c9880defe28aeeee19e2b0de37a8df6dfc79750fa7fe78d
MD5 eda6643f0b87ee6abf47d9d012d055ec
BLAKE2b-256 e773059bb24b00cabd15fb2fa5deb1f39093a96fac20c45e92ba95ac7eb1f87f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page