whatisgithub

What is claude-pty-wrapper?

kcosr/claude-pty-wrapper — explained in plain English

Analysis updated 2026-05-18

20TypeScriptAudience · developerComplexity · 3/5Setup · moderate

In one sentence

A command line wrapper that runs Claude in a terminal emulator and streams its replies as text, JSON, or JSON lines for scripts.

Mindmap

mindmap
  root((claude-pty-wrapper))
    What it does
      Wraps Claude in a PTY
      Reads session log
      Streams assistant text
    Output modes
      Text
      JSON
      Stream JSON
    Tech stack
      TypeScript
      node-pty
    Use cases
      Scripting Claude
      Automation
      CI integration

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Pipe Claude's replies into another script or tool as clean text or JSON.

USE CASE 2

Automate Claude sessions from the command line without scraping terminal output.

USE CASE 3

Resume an existing Claude session and capture only the output from the new turn.

USE CASE 4

Integrate Claude output capture into a CI pipeline or custom tool.

What is it built with?

TypeScriptNode.jsnode-pty

How does it compare?

kcosr/claude-pty-wrapperadrianhajdin/job_pilotcneuralnetwork/pracdago
Stars202020
LanguageTypeScriptTypeScriptTypeScript
Setup difficultymoderatehardmoderate
Complexity3/54/52/5
Audiencedeveloperdevelopervibe coder

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires the Claude CLI already installed and available on PATH.

So what is it?

claude-pty-wrapper is a TypeScript tool that lets you run Claude, Anthropic's AI assistant, through a command-line interface in a way that makes its output easier to capture and work with programmatically. Normally, Claude's interactive mode is designed for human use in a terminal, but this wrapper adds a layer that can capture what Claude says and stream it out in structured formats that scripts and other tools can consume. The core idea is a PTY, a pseudo-terminal, which tricks Claude into thinking it is talking to a real user terminal, while the wrapper reads the session log files Claude writes and re-emits the assistant's responses. You can ask it to output plain text, a JSON object, or a streaming JSON format that resembles Claude's own verbose output. You can also resume previous conversations by providing a session ID. You would reach for this tool if you are building automation or pipelines around Claude's command-line interface and need to capture its responses reliably, rather than trying to scrape raw terminal output. For example, you might pipe Claude's answers into another script, integrate it with a CI step, or build a thin wrapper for your own tool. It is marked experimental, so it is best validated against your own workflow before depending on it in production. Installation is straightforward via npm, and the project includes a test suite with smoke tests that run against a fake Claude executable.

Copy-paste prompts

Prompt 1
Write a shell script that pipes claude-pty-wrapper's JSON output into a log file.
Prompt 2
Explain how PTY based CLI wrappers like this one differ from calling an API directly.
Prompt 3
Help me install and link this project locally with npm install and npm link.
Prompt 4
Show me how to use the resume flag to continue a previous Claude session with this wrapper.

Frequently asked questions

What is claude-pty-wrapper?

A command line wrapper that runs Claude in a terminal emulator and streams its replies as text, JSON, or JSON lines for scripts.

What language is claude-pty-wrapper written in?

Mainly TypeScript. The stack also includes TypeScript, Node.js, node-pty.

How hard is claude-pty-wrapper to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is claude-pty-wrapper for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.