Skip to content

helloiamvu/clawbridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clawbridge

Route your OpenClaw through Claude Code CLI — with streaming, tools, and full workspace context.

Why?

Anthropic is restricting setup-token usage outside Claude Code (April 2026). Clawbridge is a local proxy that speaks the Anthropic Messages API but routes everything through claude -p under the hood. OpenClaw sees a normal API provider. Anthropic sees legitimate Claude Code usage.

How It Works

You → Telegram → OpenClaw → http://localhost:5555 (clawbridge)
                                   ↓
                     claude -p --output-format stream-json
                     (uses your Claude subscription)
                                   ↓
                     Anthropic SSE streamed back to OpenClaw

Clawbridge:

  1. Receives Anthropic Messages API requests from OpenClaw
  2. Strips the hard-coded "Tools are disabled" instruction
  3. Injects tool bridge paths so Claude Code can use exec for web/search/memory
  4. Spawns claude -p with streaming JSON output
  5. Translates Claude Code's stream-json → Anthropic SSE format
  6. Streams the response back to OpenClaw in real time

What You Get

Feature Direct API Clawbridge
Streaming
Conversation memory
SOUL.md / MEMORY.md
Web fetch ✅ native ✅ via exec
Web search ✅ native ✅ via exec
Memory search ✅ native ✅ via exec
File read/write/exec ✅ native ✅ Claude Code native
Browser automation
Auth setup-token Claude subscription

Quick Start

1. Copy files

# Tool bridges
cp bin/oc-* ~/.openclaw/bin/
chmod +x ~/.openclaw/bin/oc-*

# Proxy
cp proxy/server.mjs ~/.openclaw/bin/claude-proxy.mjs

2. Configure OpenClaw

Add to openclaw.json:

{
  agents: {
    defaults: {
      model: {
        primary: "claude-proxy/claude-opus-4-6"
      },
      models: {
        "claude-proxy/claude-opus-4-6":   { alias: "proxy-opus" },
        "claude-proxy/claude-sonnet-4-6": { alias: "proxy-sonnet" }
      },
      bootstrapMaxChars: 50000
    }
  },
  models: {
    providers: {
      "claude-proxy": {
        baseUrl: "http://127.0.0.1:5555",
        api: "anthropic-messages",
        allowPrivateNetwork: true,
        models: [
          { id: "claude-opus-4-6" },
          { id: "claude-sonnet-4-6" },
          { id: "claude-haiku-4-5" }
        ]
      }
    }
  }
}

3. Start the proxy

node ~/.openclaw/bin/claude-proxy.mjs

To run on boot (macOS):

cat > ~/Library/LaunchAgents/com.clawbridge.proxy.plist << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key><string>com.clawbridge.proxy</string>
  <key>ProgramArguments</key><array>
    <string>/usr/local/bin/node</string>
    <string>~/.openclaw/bin/claude-proxy.mjs</string>
  </array>
  <key>RunAtLoad</key><true/>
  <key>KeepAlive</key><true/>
  <key>StandardOutPath</key><string>~/.openclaw/logs/claude-proxy.log</string>
  <key>StandardErrorPath</key><string>~/.openclaw/logs/claude-proxy.log</string>
</dict>
</plist>
EOF
launchctl load ~/Library/LaunchAgents/com.clawbridge.proxy.plist

4. Restart OpenClaw

/restart

5. Switch backend (optional plugin)

Copy extensions/switch-backend/ to ~/.openclaw/extensions/ and add to config:

{
  plugins: {
    entries: {
      "switch-backend": { enabled: true }
    }
  }
}

Then use /switch_backend proxy or /switch_backend api to switch instantly.

Environment Variables

Variable Default Description
CLAUDE_PROXY_PORT 5555 Proxy listen port
CLAUDE_CLI_PATH claude Path to Claude Code CLI
OPENCLAW_TOOL_BRIDGE_DIR ~/.openclaw/bin Directory with oc-* scripts
OPENCLAW_WORKSPACE ~/.openclaw/workspace Working directory for Claude Code

Tool Bridges

Shell scripts that Claude Code calls via exec:

Script What it does
oc-web-fetch <url> Fetch + extract readable text from a URL
oc-search "query" Web search via DuckDuckGo (no API key)
oc-memory "query" Grep workspace memory files
oc-send <channel> <target> "msg" Send message via OpenClaw CLI

Key Settings

Setting Value Why
bootstrapMaxChars 50000 Default 20K truncates large MEMORY.md files
allowPrivateNetwork true Required for localhost proxy

Limitations

  • No browser automation — Claude Code doesn't have a browser tool
  • ~3-5s overhead per turn — spawning CLI process
  • ~10-15% more tokens — Claude Code's own system prompt on top of yours

Files

proxy/
  server.mjs           # The proxy server (Anthropic Messages API → Claude Code CLI)

bin/
  oc-web-fetch         # URL fetcher
  oc-search            # DuckDuckGo search
  oc-memory            # Memory grep
  oc-send              # Message sender

extensions/
  switch-backend/      # /switch_backend plugin for OpenClaw

License

MIT

About

Use your Claude subscription as an OpenClaw model backend via Claude Code CLI — with full tool access through shell bridges

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors