Skip to content

claude-code-driverDrive interactive Claude Code from Node.js

The real Claude Code TUI runs in a private tmux pane on your subscription. Your code sends the prompts and reads every step as a typed event.

A tmux window with Claude Code in the top pane and the events your program receives in the bottom pane

Your code sees what Claude is doing ​

Hooks report each prompt and tool call as it happens. The transcript confirms what finished. The screen shows retries and dialogs that nothing else reports. One pure core merges the four sources into events and a live state snapshot.

ts
const turn = session.send('Fix the failing test.');
for await (const e of turn) {
  if (e.type === 'toolStarted') {
    console.log(e.data.name);
  }
}
const { outcome } = await turn.done;

Observation channels feeding the core, ranked by authority

What you can rely on ​

The library makes these guarantees in code and tests them.

Permissions fail closed.
A handler that throws, times out or returns nothing valid denies the request. Closing the session denies any request still held.
Every prompt is acknowledged.
A turn starts only after Claude's own UserPromptSubmit hook echoes the exact text you sent.
Nothing is left running.
If your process dies, a watchdog stops Claude and the tmux server within about two seconds.
Recorded traces replay exactly.
The core reads no clock and does no I/O, so a trace reproduces the same events and final state on every run.
No runtime dependencies.
The package is plain TypeScript for Node 20 and later, with Claude Code 2.1.316 pinned as the supported version.

Start here ​

Build from source, add it to your project next to the pinned Claude Code, and open a session in a folder you trust. The getting started guide takes about five minutes.

sh
pnpm add /path/to/claude-code-driver @anthropic-ai/claude-code@2.1.316

Released under the MIT License. Not affiliated with Anthropic.