Skip to main content

Sockpuppet for Claude Code — drive the TUI programmatically, stream JSONL like claude -p

Project description

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.

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_sock-0.1.2.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

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

claude_sock-0.1.2-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file claude_sock-0.1.2.tar.gz.

File metadata

  • Download URL: claude_sock-0.1.2.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for claude_sock-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4991723c988cfb423e73fe61bd9e5f23840113337f99e192adbe2ad0bf27ae63
MD5 be295033d29e3ae6274bdc000b659cc5
BLAKE2b-256 333f26f6ce76c925804a6923d0489345c3456f346bc2e52828f283a0bb8f20f3

See more details on using hashes here.

File details

Details for the file claude_sock-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: claude_sock-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for claude_sock-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 afedf408ed5e694445ae1af8a706c01a499e7ea5be81f97fac7dea118778de80
MD5 93541bffe97626b7c46c8a14ecf662ae
BLAKE2b-256 71156d185041afde2292d3f663403bc99eb0b56d91c5e25dcad495923bcb0b87

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