explaingit

wezzard/toll-free-harness

19TypeScriptAudience · developerComplexity · 3/5LicenseSetup · easy

TLDR

A TypeScript library that lets you automate Claude Code and similar AI coding assistants by programmatically sending prompts, answering questions, and approving plans, no human at the keyboard needed.

Mindmap

mindmap
  root((repo))
    What it does
      Automates AI assistants
      Intercepts PTY prompts
      Injects keystrokes
    User Actions
      Send text prompt
      Answer multiple-choice
      Approve or reject plan
    Usage Modes
      npx one-liner
      Node.js library
    How it works
      PTY virtual terminal
      Unix socket server
      Temp plugin directory
      Auto cleanup
Click or tap to explore — scroll the page freely

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

Things people build with this

USE CASE 1

Script a multi-turn Claude Code session that sends prompts, auto-approves safe tool calls, and collects outputs without a human watching the terminal.

USE CASE 2

Use the npx one-liner to route a single Claude Code session through the harness and answer plan-approval prompts from a script instead of the keyboard.

USE CASE 3

Build a CI pipeline that runs Claude Code on a pull request, auto-approves read-only actions, and rejects destructive ones based on a policy you define.

USE CASE 4

Listen to agent events in a Node.js script to log every tool the AI runs and build an audit trail of what happened during an automated coding session.

Tech stack

TypeScriptNode.js

Getting it running

Difficulty · easy Time to first run · 5min

Works on macOS, Linux, and recent Windows, no persistent system changes, run via npx with no install required for simple use cases.

Use freely for any purpose, including commercial use, as long as you keep the copyright and license notices.

In plain English

toll-free-harness is a TypeScript library that lets you write automated scripts to control a local AI coding assistant as though a human were sitting at the keyboard. It is primarily aimed at Claude Code, a terminal-based AI tool that normally requires a person to type prompts, answer questions, and approve or reject plans during a session. This library intercepts those interactive moments and lets code handle them instead. The way it works is by running the coding agent inside a PTY, which is the type of virtual terminal that normally connects a program to a real keyboard and screen. The library watches what the agent outputs and, when it pauses waiting for user input, such as when it asks a question or presents a plan for review, injects the correct keystrokes on behalf of your script. Events from the agent, like which tool it is about to run or when it finishes, are exposed as typed callbacks you can listen to in your code. There are three things you can tell the library to do on behalf of a user: send a text prompt (with optional image attachments), select an answer when the agent asks a multiple-choice question, and approve or reject a plan with optional feedback. Everything else is read-only observation. The library translates your decisions into the keystrokes the UI expects, so you never write raw terminal escape sequences yourself. You can use it from the command line without installing anything, by replacing the usual invocation of the coding agent with an npx command that routes the session through the harness. Or you can install it as a Node.js library and build more sophisticated automation with event handlers, timeouts for specific events, and multi-turn conversations. Under the hood, each session creates a temporary plugin directory, starts a small HTTP server over a Unix socket for inter-process communication, spawns the agent with that plugin loaded, and cleans everything up when the session ends. No persistent changes are made to the user's system configuration. The library works on macOS, Linux, and recent versions of Windows. The license is Apache-2.0.

Copy-paste prompts

Prompt 1
Show me how to use toll-free-harness to run a Claude Code session that automatically approves plans and answers yes to all questions, using the npx one-liner.
Prompt 2
I want to build a Node.js script with toll-free-harness that sends a prompt to Claude Code, waits for it to propose a plan, reviews the plan programmatically, and either approves or rejects it based on which tools it wants to run.
Prompt 3
How do I listen to tool-call events in toll-free-harness so I can log every action Claude Code takes during an automated session?
Prompt 4
Can toll-free-harness handle multi-turn conversations where Claude Code asks follow-up questions mid-session? Show me how to set up event handlers for each question type.
Prompt 5
How does toll-free-harness avoid leaving anything behind on my system after a session ends? Walk me through the temp plugin directory and Unix socket cleanup.
Open on GitHub → Explain another repo

← wezzard on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.