Getting Started
claude-p emulates claude -p. It spawns your installed claude binary inside an in-process zmux PTY, drives the interactive UI, and prints claude -p-shaped text and json results. stream-json emits Claude Code session-transcript lines plus a claude -p-shaped result envelope; see Stream Live JSON Output for how that differs from native claude -p.
Prerequisites
Section titled “Prerequisites”- OS & CPU: macOS or Linux on
arm64orx64. Windows is unsupported (forkptyis POSIX-only). claudeon$PATH:claude-pdrives the real Claude Code binary. Verify withclaude --version.- Runtime: Node
>= 18fornpx/npm, or Zig0.15.2to build from source.
Install
Section titled “Install”npx claude-p --versionnpm install -g claude-pclaude-p --versiongit clone https://github.com/smithersai/claude-pcd claude-pzig build -Doptimize=ReleaseSafe./zig-out/bin/claude-p --versionOn npm install, scripts/install.js fetches claude-p-<platform>-<arch>.gz from GitHub Releases and verifies its SHA-256 digest against the checksums.json bundled in the npm tarball before extracting the binary. A digest mismatch aborts installation with exit code 1. A connectivity failure (DNS, offline, HTTP error, timeout) prints a warning and exits 0 unless CLAUDE_P_STRICT_INSTALL=1; local filesystem errors such as ENOSPC exit 1. See Installation, Checksums, and Builds.
Three ways to run it
Section titled “Three ways to run it”1. Plain text (default)
Section titled “1. Plain text (default)”npx claude-p --dangerously-skip-permissions "Reply with the single word OK."OKIf you omit the positional prompt, claude-p reads stdin (up to 16 MiB) or --input-file <path>.
2. Single JSON result object
Section titled “2. Single JSON result object”npx claude-p --output-format json --dangerously-skip-permissions \ "Reply with the single word OK."{"type":"result","subtype":"success","session_id":"550e8400-e29b-41d4-a716-446655440000","result":"OK","is_error":false,"duration_ms":2410,"duration_api_ms":0,"num_turns":1,"total_cost_usd":0,"usage":{"input_tokens":6,"output_tokens":4,"cache_read_input_tokens":0,"cache_creation_input_tokens":0},"permission_denials":[]}3. Live per-message JSONL stream
Section titled “3. Live per-message JSONL stream”stream-json requires --verbose, matching native claude -p:
npx claude-p --output-format stream-json --verbose \ --dangerously-skip-permissions "Reply with OK." | jq -c '{type, subtype}'Each transcript line flushes to stdout as soon as claude writes it, followed by the final result envelope.
What just happened?
Section titled “What just happened?”claude-p never edits ~/.claude/settings.json. It builds an inline --settings JSON string pointing SessionStart, UserPromptSubmit, and Stop hooks to a temporary FIFO in $TMPDIR, runs claude on a real PTY, and reads the final answer from the session transcript JSONL.
Next steps
Section titled “Next steps”- Learn by building: Start the hands-on Build a Commit Reviewer tutorial.
- Keep one session alive: Walk through Drive a Multi-Turn Daemon.
- Look up a flag or exit code: Jump straight to the CLI Reference.