claude-p  by smithersai

CLI driver for interactive Claude Code TUI

Created 1 week ago

New!

325 stars

Top 83.7% on SourcePulse

GitHubView on GitHub
Project Summary

This project provides claude-p, a drop-in replacement for the claude -p command-line tool. It enables programmatic interaction with the interactive Claude Code TUI by running it within an in-process zmux PTY session. Aimed at developers and power users, it offers enhanced control and a stable interface for automating Claude interactions, while demonstrating the challenges of client-side usage restrictions.

How It Works

claude-p spawns the Claude CLI within a zmux NativeSession, simulating a real terminal environment. It employs a small ANSI scanner to respond to terminal queries from Claude's Ink runtime, preventing TUI hangs. The wrapper registers SessionStart and Stop hooks, automatically typing prompts and capturing the final assistant message and usage from the generated transcript JSONL. This approach allows direct manipulation of the TUI without altering user configurations.

Quick Start & Requirements

  • Installation: Build from source using Zig 0.15.2 (zig build -Doptimize=ReleaseSafe). Dependencies are fetched automatically. Can also be used via npx claude-p .... Can be added as a Zig library (zig fetch --save=claude_p git+https://github.com/smithersai/claude-p).
  • Prerequisites: claude CLI must be in $PATH. Requires Zig 0.15.2 for building. Node.js/npm recommended for npx usage.
  • Platform: macOS / Linux only (no Windows support).
  • Links: Source repository: https://github.com/smithersai/claude-p

Highlighted Details

  • Drop-in replacement for claude -p with byte-for-byte stdout compatibility.
  • Drives the interactive Claude Code TUI within an in-process zmux PTY session.
  • Supports output formats: text, json, stream-json.
  • Key flags (--model, --max-turns, --allowedTools, --resume, etc.) are supported and forwarded to the underlying claude CLI if unrecognized.

Maintenance & Community

No specific details on maintainers, community channels, or roadmap were found in the provided README. The project is explicitly stated to exist for educational purposes.

Licensing & Compatibility

  • License: MIT.
  • Compatibility: Permissive MIT license allows for commercial use and integration into closed-source projects.

Limitations & Caveats

Unsupported on Windows due to reliance on forkpty. Not true real-time streaming; waits for model completion. Introduces ~50–200 ms latency. Multiline prompts require --input-file or stdin for reliable shell escaping. Susceptible to breaking changes in future Claude Code releases affecting terminal probes or hook payloads.

Health Check
Last Commit

1 week ago

Responsiveness

Inactive

Pull Requests (30d)
1
Issues (30d)
2
Star History
327 stars in the last 13 days

Explore Similar Projects

Feedback? Help us improve.