Skip to main content

claude-sock: Use your Claude subscription with your Claw

CLI that wraps the Claude Code CLI to use Claude models just with a subscription, thus without paying through API or extra tokens.

Why

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.

Getting started

Prerequisites

  • Claude Code CLI installed and logged in (claude --version)
  • Python 3.10+
  • OpenClaw (or any tool that calls claude -p)

1. Install claude-sock

pipx install claude-sock 

2. Install OpenClaw

npm install -g openclaw@latest
openclaw onboard --install-daemon

During onboard, pick "Anthropic Claude CLI" when asked for the provider.

3. Point OpenClaw to claude-sock

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).

4. Restart and chat

openclaw daemon restart
openclaw dashboard

Standalone usage

claude-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-json

How it works

claude-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)
                   └──────────────┘

Known limitations

  • Each call spawns a fresh TUI process (~5s startup overhead)

Contributing

Feel free to open PRs to make it more stable / more feature prone.

Liability

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.

Metadata

Release files for claude-sock 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for claude-sock 0.1.2
File Size Uploaded
claude_sock-0.1.2.tar.gz 10.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for claude-sock 0.1.2
File Interpreter ABI Platform
claude_sock-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 20.0 kB

Release files / claude_sock-0.1.2.tar.gz

Download URL claude_sock-0.1.2.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4991723c988cfb423e73fe61bd9e5f23840113337f99e192adbe2ad0bf27ae63
BLAKE2b-256 checksum
How to use checksums
333f26f6ce76c925804a6923d0489345c3456f346bc2e52828f283a0bb8f20f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / claude_sock-0.1.2-py3-none-any.whl

Download URL claude_sock-0.1.2-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
afedf408ed5e694445ae1af8a706c01a499e7ea5be81f97fac7dea118778de80
BLAKE2b-256 checksum
How to use checksums
71156d185041afde2292d3f663403bc99eb0b56d91c5e25dcad495923bcb0b87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page