@rtedeschi/oc-claude-proxy-ubuntu
v0.1.28
Published
Install and manage the OpenClaw Claude Code proxy as a background service on Ubuntu.
Readme
openclaw-claudecode-proxy
About
This project routes Anthropic Messages API requests through the real Claude Code CLI so OpenClaw can use Claude Code with native client attestation.
It is not a perfect solution. It is a pragmatic bridge to avoid losing months of OpenClaw work while keeping that workflow usable.
The proxy now runs in a stateless per-turn mode: each OpenClaw turn is rebuilt from system instructions, a bounded recent-conversation window, and a deterministic memory digest instead of relying on Claude session resume for continuity.
Supported platforms
Published npm packages target Ubuntu and Windows separately.
- Ubuntu: published as
@rtedeschi/oc-claude-proxy-ubuntu - Windows: published as
@rtedeschi/oc-claude-proxy-windows - Other Linux distributions: not currently supported
- macOS: not currently supported
What this repo contains
Core/claude-code-proxy.js: Shared Node.js proxy implementation.Ubuntu/claude-code-proxy.sh: Ubuntu service manager for install, uninstall, status, logs, and foreground serve.Windows/claude-code-proxy.bat: Windows installer and startup-task runner kept in the repo for manual use.
Requirements
This repo includes separate Ubuntu and Windows entrypoints, and each supported platform has its own npm package.
Required tools:
claudeCLI installed and authenticatednodeopenclawalready installed and initialized
Ubuntu install also requires:
jqsystemctljournalctl
Windows install also requires:
powershellschtasks
Required OpenClaw files:
- Ubuntu: current user
~/.openclaw/openclaw.jsonor root/root/.openclaw/openclaw.json - Windows:
%USERPROFILE%\.openclaw\openclaw.json
On Ubuntu, the setup script resolves the target installation in this order:
- the invoking user's
~/.openclaw/openclaw.json - root's
/root/.openclaw/openclaw.json - fail if neither exists
This matters for global npm install -g runs under sudo: the script now prefers the calling user's OpenClaw install before falling back to root.
The setup script will stop if neither Ubuntu path exists. If needed, run:
openclaw wizardThe Claude CLI must also be usable before setup:
claude --versionIf that fails, run claude once and complete authentication first.
Getting started
Install from npm
Install Ubuntu globally:
npm install -g @rtedeschi/oc-claude-proxy-ubuntuInstall Windows globally:
npm install -g @rtedeschi/oc-claude-proxy-windowsInstall from GitHub Packages
GitHub Packages requires scoped registry configuration for install.
Add this to ~/.npmrc:
@rtedeschi:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=YOUR_GITHUB_PATThe token needs at least read:packages.
Install Ubuntu globally from GitHub Packages:
npm install -g @rtedeschi/oc-claude-proxy-ubuntuInstall Windows globally from GitHub Packages:
npm install -g @rtedeschi/oc-claude-proxy-windowsIf your npm client is still resolving the package from registry.npmjs.org, use an explicit registry override:
npm install -g @rtedeschi/oc-claude-proxy-ubuntu --registry=https://npm.pkg.github.comnpm install -g @rtedeschi/oc-claude-proxy-windows --registry=https://npm.pkg.github.compublishConfig.registry controls where this package is published, but it does not force other machines to install from GitHub Packages. Install clients still need either the scoped ~/.npmrc entry or the explicit --registry flag.
On Ubuntu global installs, the package postinstall hook immediately:
- resolves whether to target the invoking user's OpenClaw install or root's
- installs the proxy files into that OpenClaw workspace's
scripts/directory - patches that installation's
openclaw.json - installs the matching user
systemdservice - starts the background daemon right away
On Windows global installs, the package postinstall hook immediately:
- installs the proxy files into
%USERPROFILE%\.openclaw\workspace\scripts\ - patches
%USERPROFILE%\.openclaw\openclaw.json - registers the
ClaudeCodeProxyScheduled Task - starts the task right away
If you want a non-default Ubuntu port:
oc-claude-proxy-ubuntu install 8788If you want a non-default Windows port:
oc-claude-proxy-windows install 8788The Ubuntu package exposes these CLI names:
oc-claude-proxy-ubuntuopenclaw-claude-code-proxyoc-claude-proxy-ubuntu-uninstallopenclaw-claude-code-proxy-uninstall
The Windows package exposes these CLI names:
oc-claude-proxy-windowsopenclaw-claude-code-proxy-windowsoc-claude-proxy-windows-uninstallopenclaw-claude-code-proxy-windows-uninstall
With no arguments, the Ubuntu CLI prints current status. With no arguments, the Windows CLI runs the installer.
Manual installers
If you prefer not to use npm, run the platform installer directly.
Ubuntu
From this repository:
chmod +x Ubuntu/claude-code-proxy.sh
./Ubuntu/claude-code-proxy.shTo use a different local port:
./Ubuntu/claude-code-proxy.sh install 8788Windows
From this repository in an Administrator cmd.exe or elevated PowerShell:
Windows\claude-code-proxy.batTo use a different local port:
Windows\claude-code-proxy.bat install 8788On Windows, run the installer elevated. The batch script updates %USERPROFILE%\.openclaw\openclaw.json, copies runtime files into the OpenClaw workspace, and registers a startup Scheduled Task.
The Windows npm package lives in packages/windows/ in this repository and is meant to be published separately as @rtedeschi/oc-claude-proxy-windows.
What the script does
The Ubuntu entrypoint in install mode performs the following actions:
- Verifies the required platform tools,
node, andclaudeare installed. - Verifies Claude Code CLI is working.
- Backs up
openclaw.jsonwith a timestamp suffix. - Resolves the target OpenClaw installation on Ubuntu by checking the invoking user's
~/.openclaw/openclaw.jsonfirst and/root/.openclaw/openclaw.jsonsecond. - Copies the platform script and shared JS entrypoint to the target OpenClaw workspace on Linux or
%USERPROFILE%\.openclaw\workspace\scripts\on Windows. - Adds or updates
models.providers["claude-code-proxy"]inopenclaw.json. - Sets
agents.defaults.timeoutSeconds = 1800so OpenClaw matches the proxy request timeout. - Adds alias entries for
claude-code-proxy/claude-opus-4-8,claude-code-proxy/claude-opus-4-7,claude-code-proxy/claude-sonnet-4-5, andclaude-code-proxy/claude-haiku-4-5. - Installs persistent startup.
Ubuntu uses a user
systemdservice. Windows uses a Scheduled Task namedClaudeCodeProxy. - Starts the background service or task on port
8787by default. - Attempts to restart the OpenClaw gateway.
At runtime, the proxy composes each turn statelessly from:
- OpenClaw system instructions
- proxy tool-bridge rules
- a bounded recent conversation window
- a deterministic memory digest built from
MEMORY.mdand recent daily memory files - the current user message
The script does not automatically change agents.defaults.model.primary.
It prints a suggestion to set it to one of the proxy-backed models after install.
It does set agents.defaults.timeoutSeconds to 1800 so OpenClaw's timeout setting matches the proxy request timeout.
Installed model mapping
After setup, OpenClaw has this proxy provider available:
- Provider:
claude-code-proxy - Available model IDs:
claude-code-proxy/claude-opus-4-8,claude-code-proxy/claude-opus-4-7,claude-code-proxy/claude-opus-4-6,claude-code-proxy/claude-opus-4-5,claude-code-proxy/claude-sonnet-4-5, andclaude-code-proxy/claude-haiku-4-5
Suggested default model change:
agents.defaults.model.primary = claude-code-proxy/claude-opus-4-8- or
agents.defaults.model.primary = claude-code-proxy/claude-opus-4-7 - or
agents.defaults.model.primary = claude-code-proxy/claude-opus-4-6 - or
agents.defaults.model.primary = claude-code-proxy/claude-opus-4-5 - or
agents.defaults.model.primary = claude-code-proxy/claude-sonnet-4-5 - or
agents.defaults.model.primary = claude-code-proxy/claude-haiku-4-5
The proxy also normalizes these requested model names if they are sent by clients:
claude-sonnet-4-6->claude-sonnet-4-5claude-haiku-4-6->claude-haiku-4-5
Verify the installation
Check the proxy service:
oc-claude-proxy-ubuntu statusFollow logs:
oc-claude-proxy-ubuntu logs -fOn Windows, check the startup task:
schtasks /Query /TN "ClaudeCodeProxy"Restart it manually if needed:
oc-claude-proxy-ubuntu restartOn Windows, start it manually if needed:
schtasks /Run /TN "ClaudeCodeProxy"Restart OpenClaw if it did not restart automatically:
openclaw gateway restartThe proxy listens at:
http://localhost:8787If you used a custom PROXY_PORT, substitute that value.
The proxy request timeout is explicitly set to 1800 seconds by default, and the installers write the same value to agents.defaults.timeoutSeconds.
Uninstall and cleanup
For immediate, synchronous cleanup:
oc-claude-proxy-ubuntu uninstall
oc-claude-proxy-ubuntu-uninstallOn Windows:
oc-claude-proxy-windows uninstall
oc-claude-proxy-windows-uninstallThe same cleanup can always be run through the installed script copy:
~/.openclaw/workspace/scripts/claude-code-proxy.sh uninstallOn Windows, the installed script copy can also be used directly:
%USERPROFILE%\.openclaw\workspace\scripts\claude-code-proxy.bat uninstallAfter manual cleanup completes, remove the npm package if you no longer want the CLI installed:
npm uninstall -g @rtedeschi/oc-claude-proxy-ubuntunpm uninstall -g @rtedeschi/oc-claude-proxy-windowsManual run
If you do not want to use the systemd service, you can run the proxy directly:
oc-claude-proxy-ubuntu serveOr on a custom port:
oc-claude-proxy-ubuntu serve 8788On Windows, run the proxy directly:
Windows\claude-code-proxy.bat serveOr on a custom port:
Windows\claude-code-proxy.bat serve 8788The service uses the same script in serve mode, so install and runtime now share a single entrypoint.
Notes
- The proxy only handles
POST /v1/messages. - The proxy no longer depends on Claude
session_idresume for ordinary continuity; it rebuilds each turn from recent context plus memory digest. - Session state is stored in the system temp directory as
claude-code-proxy-state.json. - Debug logs are written to the system temp directory as
claude-code-proxy-debug.log. - The proxy limits Claude Code tool access to a restricted allowlist suitable for this bridge.
Publishing
The repository includes .github/workflows/publish-github-package.yml, which:
- runs
npm packon pull requests and pushes tomain - uploads the generated tarball as a workflow artifact
- publishes to GitHub Packages on
v*tags or manual workflow dispatch usingGITHUB_TOKEN
The package name published to GitHub Packages is @rtedeschi/oc-claude-proxy-ubuntu.
Development
This repository installs a tracked Git pre-commit hook from .githooks/pre-commit.
The hook updates package.json on each commit:
- normal commits bump the patch version
- if you manually change major or minor, the patch component is reset to
0
To re-install the hook path in a fresh clone:
npm run setup-hooksLicense
This project is licensed under the MIT License. See LICENSE.
