Skip to content

Commit c7f7660

Browse files
alabulei1claude
andcommitted
Add blog: echokit_pty - Giving Claude Code a Remote Control
Introduce echokit_pty, a WebSocket bridge that transforms Claude Code CLI into a programmable service with a clean JSON API. The article covers architecture, use cases, and getting started guide. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 0be4693 commit c7f7660

File tree

2 files changed

+159
-0
lines changed

2 files changed

+159
-0
lines changed
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
---
2+
slug: echokit-pty-websocket-claude-code
3+
title: "echokit_pty: Giving Claude Code a Remote Control"
4+
tags: [echokit-pty, claude-code, websocket, developer-tools]
5+
---
6+
7+
Claude Code is amazing. It writes code, fixes bugs, runs tests, explains errors. But it lives in your terminal. To use it, you type commands, get responses. It's a CLI tool, designed for terminal workflows.
8+
9+
But what if you want to build something on top of Claude Code? What if you want a web app? A mobile interface? A physical device? Voice control?
10+
11+
That's why we built **echokit_pty**.
12+
13+
## What Is echokit_pty?
14+
15+
**echokit_pty** is the web version of Claude Code with a superpower: a WebSocket interface.
16+
17+
It handles Claude Code's input and output, turning its CLI into a WebSocket service. Suddenly, Claude Code isn't just a terminal app—it's a service that *any application* can talk to.
18+
19+
**What makes it special?**
20+
- Full Claude Code capabilities (file editing, command execution, tool use)
21+
- **Clean JSON API for integrations**. Check out the full API documentation [here](https://github.com/second-state/echokit_pty?tab=readme-ov-file#api).
22+
- Bidirectional streaming (real-time responses)
23+
- Runs locally
24+
- Open source and extensible
25+
26+
## The Problem: Claude Code Is Trapped in the Terminal
27+
28+
Claude Code was designed as a CLI tool. You run it in your terminal, type commands, get responses. This works great for terminal workflows.
29+
30+
But what if you want to:
31+
- Build a web app that uses Claude Code?
32+
- Control Claude Code from your phone?
33+
- Create a physical device that talks to Claude Code?
34+
- Integrate Claude Code into another tool?
35+
36+
That's where echokit_pty comes in.
37+
38+
## The Solution: PTY + WebSocket
39+
40+
The bridge is **echokit_pty**.
41+
42+
**What does "pty" mean?**
43+
44+
PTY stands for "pseudo-terminal"—a Unix concept that allows a program to control a terminal as if a user were typing.
45+
46+
echokit_pty uses this technology to create a bridge between:
47+
- **WebSocket clients** → send JSON commands
48+
- **Claude Code CLI** → executes the commands
49+
- **Response streaming** → sends results back
50+
51+
## How It Works
52+
53+
echokit_pty is built with Rust. Here's the architecture:
54+
55+
```
56+
┌─────────────────┐ WebSocket ┌──────────────┐
57+
│ Any Client │ ◄─────────────────► │ echokit_pty │
58+
│ (Web, Mobile, │ (ws://localhost)│ (Rust) │
59+
│ Device, etc.) │ └──────┬───────┘
60+
└─────────────────┘ │
61+
│ PTY
62+
63+
┌──────────────┐
64+
│ Claude Code │
65+
│ CLI │
66+
└──────────────┘
67+
```
68+
69+
**The flow:**
70+
1. echokit_pty starts a WebSocket server (default: `ws://localhost:3000/ws`)
71+
2. Clients connect via WebSocket and send JSON commands
72+
3. echokit_pty forwards commands to Claude Code CLI through a pseudo-terminal
73+
4. Claude Code executes the command
74+
5. Results stream back through the WebSocket in real-time
75+
76+
**Example:**
77+
```json
78+
// Client sends
79+
{"type": "command", "content": "run the tests"}
80+
81+
// echokit_pty forwards to Claude Code
82+
83+
// Results stream back
84+
{"type": "response", "content": "Running tests...\n142 passed, 3 failed"}
85+
```
86+
87+
## Use Cases: What Can You Build?
88+
89+
The beauty of echokit_pty is that it turns Claude Code into a *platform*. Here's what you can build:
90+
91+
### Voice-Controlled Coding
92+
Speak commands, Claude Code executes, hear results. Perfect for hands-free workflows. This is what EchoKit + echokit_pty enables. But it's just one implementation. For more details, check out EchoKit's full integration [documentation](https://echokit.dev/docs/use-cases/claude-code).
93+
94+
### Web Apps
95+
Build a web interface for Claude Code. No terminal required. Just open a browser, connect to the WebSocket, and start coding. Great for presentations, teaching, or developers who prefer GUIs.
96+
97+
### Mobile Apps
98+
Control Claude Code from your phone. Run tests while walking. Check build status from the couch. Deploy from anywhere. Your coding environment fits in your pocket.
99+
100+
### Pair Programming Platforms
101+
Create a web app where multiple people can interact with Claude Code simultaneously. Real-time collaboration, shared context, better than screen sharing.
102+
103+
### Teaching & Demos
104+
Show Claude Code in presentations without terminal windows cluttering the screen. A clean web interface for live coding demos, tutorials, and workshops.
105+
106+
### Custom Developer Tools
107+
Build your own tools on top of Claude Code. Automations, dashboards, integrations—anything you can imagine. The WebSocket interface makes Claude Code a building block.
108+
109+
### IDE Integrations
110+
Embed Claude Code directly into your IDE. VS Code extension, JetBrains plugin, custom editor—give Claude Code a proper home in your development environment.
111+
112+
## Getting Started
113+
114+
**Installation:**
115+
116+
First, clone and build echokit_pty:
117+
118+
```bash
119+
git clone https://github.com/second-state/echokit_pty.git
120+
cd echokit_pty
121+
cargo build --release --bin echokit_cc
122+
```
123+
124+
**Running echokit_pty:**
125+
126+
Set your workspace directory and start the server:
127+
128+
```bash
129+
ECHOKIT_WORKING_PATH="/path/to/your/workspace" \
130+
./target/release/echokit_cc -c ./run_cc.sh -b "localhost:3000"
131+
```
132+
133+
The WebSocket server will start on `ws://localhost:3000/ws`.
134+
135+
![](./2026-02-25-echokit-pty.jpg)
136+
137+
## The Vision
138+
139+
Claude Code is the most capable AI coding assistant today. But it shouldn't be trapped in a terminal.
140+
141+
echokit_pty is the bridge that sets Claude Code free.
142+
143+
Imagine what we can build:
144+
145+
- Voice-controlled coding assistants
146+
- Mobile apps for coding on the go
147+
- Web-based teaching tools
148+
- Custom developer workflows
149+
- AI-powered IDE integrations
150+
151+
All built on top of echokit_pty.
152+
153+
**Claude Code as a platform, not just a tool.**
154+
155+
---
156+
157+
**Ready to build something?**
158+
159+
Start with the [echokit_pty repository](https://github.com/second-state/echokit_pty). See EchoKit's full integration [documentation](https://echokit.dev/docs/use-cases/claude-code) for a complete example. Join our [Discord community](https://discord.gg/Fwe3zsT5g3) to share your ideas.

doc/dev/2026-02-25-echokit-pty.jpg

403 KB
Loading

0 commit comments

Comments
 (0)