CLI that wraps the Claude Code CLI to use Claude models just with a subscription, thus without paying through API or extra tokens.
Anthropic recently limited support for third-party harnesses through subscription. It used to be possible to use Claude subscription to use a third-party harness such as Open Claw.
claude-sock bridges the gap: it speaks the claude -p protocol so tools like OpenClaw can use it as a drop-in backend.
- Claude Code CLI installed and logged in (
claude --version) - Python 3.10+
- OpenClaw (or any tool that calls
claude -p)
pipx install claude-sock npm install -g openclaw@latest
openclaw onboard --install-daemonDuring onboard, pick "Anthropic Claude CLI" when asked for the provider.
Add to ~/.openclaw/openclaw.json:
{
agents: {
defaults: {
model: {
primary: "claude-cli/claude-sonnet-4-6"
},
cliBackends: {
"claude-cli": {
command: "claude-sock"
}
}
}
}
}Note: it will use the model you use in your Claude Code (which means you can access the latest best models such as Opus 4.6 1M Context).
openclaw daemon restart
openclaw dashboardclaude-sock also works on its own:
# Positional argument
claude-sock "What is 2+2?"
# Pipe mode (same as claude -p)
echo "What is 2+2?" | claude-sock -p --output-format stream-jsonclaude-sock spawns the Claude Code TUI in a pty, types your prompt as keystrokes, then reads the response from Claude Code's session JSONL file. Output is translated to claude -p format (stdin/stdout JSONL) so any tool expecting that protocol works seamlessly.
Your code
│
▼ stdin (prompt)
┌─────────────┐
│ claude-sock │
└──────┬──────┘
│ keystrokes
▼
┌─────────┐ ┌──────────────┐
│ pty │───────>│ Claude Code │
│ (write) │ │ TUI │
└─────────┘ └──────┬───────┘
│ writes
▼
┌──────────────┐
│ session.jsonl │
└──────┬───────┘
│ reads + translates
▼
┌──────────────┐
│ claude -p │
│ format out │──> stdout (JSONL)
└──────────────┘
- Each call spawns a fresh TUI process (~5s startup overhead)
Feel free to open PRs to make it more stable / more feature prone.
This is a toy project provided as-is, with no warranty of any kind. Use it at your own risk. The author is not responsible for any consequences arising from its use, including but not limited to account restrictions, unexpected charges, or violations of Anthropic's terms of service. You are solely responsible for how you use this tool and for ensuring compliance with all applicable terms and policies.