explaingit

smithersai/claude-p

Analysis updated 2026-05-18

280ZigAudience · developerComplexity · 3/5LicenseSetup · moderate

TLDR

claude-p is a command-line wrapper that mimics Claude Code's non-interactive claude -p mode by secretly driving the full interactive terminal interface behind the scenes.

Mindmap

mindmap
  root((claude-p))
    What it does
      Mimics claude -p
      Drives interactive TUI
      PTY based wrapper
    Tech stack
      Zig
      PTY sessions
      Claude Code hooks
    Use cases
      Script automation
      CI pipelines
      Custom Zig integration
    Audience
      Developers
      DevOps engineers
    Setup
      Requires claude CLI
      macOS and Linux only
      MIT licensed

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

Automate Claude Code inside a script or CI pipeline when the built-in claude -p mode does not behave as needed.

USE CASE 2

Extract JSON or streaming JSON formatted output from a scripted Claude Code session.

USE CASE 3

Study how terminal automation tools drive interactive CLI programs through a pseudo-terminal.

USE CASE 4

Use Claude Code programmatically from a custom Zig application via the included library.

What is it built with?

ZigPTYClaude Code

How does it compare?

smithersai/claude-pcoder/booandrewrk/zig-general-purpose-allocator
Stars28036852
LanguageZigZigZig
Last pushed2020-08-08
MaintenanceDormant
Setup difficultymoderateeasyeasy
Complexity3/52/53/5
Audiencedeveloperdeveloperdeveloper

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

How do you get it running?

Difficulty · moderate Time to first run · 5min

Requires the real claude Claude Code CLI already installed on PATH, macOS or Linux only, no Windows support.

Use freely for any purpose, including commercial use, as long as you keep the copyright notice, under the MIT license.

In plain English

claude-p is a command line tool that acts as a drop in replacement for the claude -p command in Claude Code, Anthropic's coding assistant. The problem it addresses: the official claude -p flag runs Claude in a non interactive, one shot mode useful for scripting, but this wrapper replicates that same output by instead driving the full interactive Claude Code terminal interface behind the scenes and extracting the result. The way it works is by spawning the interactive Claude terminal application inside a simulated terminal session, called a PTY or pseudo terminal, feeding it your prompt automatically through hooks, waiting for the model to finish responding, reading the session transcript, and then printing the result in the format you requested, whether plain text, JSON, or streaming JSON. From the outside, it looks and behaves like the standard non interactive mode, accepting the same flags for output format, model selection, maximum turns, and more. The README lists several caveats: it only works on macOS and Linux, not Windows, it requires the real claude command line tool already installed on your system, it does not stream tokens live the way claude -p can, it adds a small delay of roughly 50 to 200 milliseconds compared to the original command, and multiline prompts need to be passed through a file or standard input rather than typed directly. You would use this if you are automating Claude Code in scripts or pipelines and run into cases where the standard non interactive mode does not behave as needed. The repository itself states it exists for educational purposes and to demonstrate that client side restrictions on how a tool is used are difficult to enforce. It is written in Zig and released under the MIT license.

Copy-paste prompts

Prompt 1
Explain how claude-p uses a PTY session and hooks to automate the interactive Claude Code terminal.
Prompt 2
Show me how to run npx claude-p with --output-format json to summarize a git diff.
Prompt 3
What are the tradeoffs of using claude-p instead of the official claude -p streaming mode?
Prompt 4
Help me build claude-p from source using Zig and integrate it as a library in my project.

Frequently asked questions

What is claude-p?

claude-p is a command-line wrapper that mimics Claude Code's non-interactive claude -p mode by secretly driving the full interactive terminal interface behind the scenes.

What language is claude-p written in?

Mainly Zig. The stack also includes Zig, PTY, Claude Code.

What license does claude-p use?

Use freely for any purpose, including commercial use, as long as you keep the copyright notice, under the MIT license.

How hard is claude-p to set up?

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

Who is claude-p for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.