Claude Code session

Claude P

Drop-in replacement for `claude -p` that drives the interactive Claude Code TUI inside an in-process zmux PTY session.

394 stars 35 forksSessions & history Source

Install

Install
npx claude-p "your prompt here"

Found in the project README. Check it for setup steps after installing.

From source
git clone https://github.com/smithersai/claude-p.git

From the README

claude-p
Use at your own risk. This package and repository exist for
educational purposes and demonstrates why client-side restrictions
on how a product is used are fundamentally unenforceable.

A drop-in replacement for claude -p that drives the interactive
claude UI inside an in-process [zmux][zmux] PTY session.

Built using smithers self-improving harness

Use

Output on stdout matches claude -p byte-for-byte.

How it works

1. Spawns claude interactively inside a [zmux][zmux] NativeSession
   (a real PTY with a reader thread and bounded scrollback).
2. A small ANSI scanner answers the DA1 / DA2 / DSR / XTVERSION /
   window-size queries Ink (the React-for-terminals runtime Claude
   Code uses) issues at startup. Without these, the TUI hangs.
3. Registers two hooks via --settings '' — never
   touches your ~/.claude/ config:
   - SessionStart — the wrapper types the prompt + Enter.
   - Stop — fires when the model finishes; payload carries
     transcript_path.
4. Reads the transcript JSONL, extracts the final assistant message
   plus usage, and prints in the requested format.

Flags

Unrecognized flags are forwarded verbatim to claude. -p/--print and
user-supplied --settings are rejected — claude-p emulates print mode and
injects its own settings to register the Stop hook.

Exit codes

Caveats

- macOS / Linux only. No Windows (no forkpty).
- Requires claude on $PATH. The wrapper invokes the real CLI.
- Per-message streaming, not per-token. With
  --output-format stream-json, transcript lines (user messages, tool
  uses, assistant turns, the trailing result envelope) are emitted
  to stdout the moment claude flushes them. Individual tokens within
  a single assistant message are not streamed — those require
  claude -p --include-partial-messages which is only…
Read the full README on GitHub

Details

Language
Zig
Last updated
17 June 2026

FAQ

What is Claude P?

Drop-in replacement for `claude -p` that drives the interactive Claude Code TUI inside an in-process zmux PTY session. It is a session for Claude Code, from smithersai/claude-p on GitHub.

How do I install Claude P?

Run npx claude-p "your prompt here", then follow the setup in the README.

Is Claude P popular?

smithersai/claude-p has 394 GitHub stars and 35 forks. It was last updated on 17 June 2026.

More sessions & history

Browse the most popular Claude Code mods, all sessions & history, or the skills and MCP server directories.