Skip to main content

claude-cli

A pip-installable Python CLI that pipes stdin into Claude with structured outputs.

cat samples/error.log | claude-cli --schema schemas.RootCause

…and you get back validated JSON, not a paragraph you have to parse.

Why

Built to scratch a real itch — I kept reaching for Claude in shell scripts and writing the same boilerplate every time. Production LLM tools live or die on output discipline, so this one bakes Pydantic validation in at the boundary.

Install

pip install claude-pipe
export ANTHROPIC_API_KEY=sk-ant-...

Or, from source:

git clone https://github.com/nishithabottu/claude-cli && cd claude-cli
pip install -e .

Worked example

schemas.py defines a RootCause Pydantic model. Pipe a log line through the CLI with --schema, and the response is a JSON object that matches the schema exactly:

echo '2026-05-09T14:32:11Z [ERROR] auth-api: jwt.ExpiredSignatureError at token_service.py:142' \
  | claude-cli --schema schemas.RootCause
{
  "severity": "error",
  "service": "auth-api",
  "summary": "JWT signature was expired during token issuance.",
  "likely_cause": "Stale signing key or clock skew in token_service.py.",
  "evidence": ["jwt.ExpiredSignatureError", "token_service.py"],
  "error_code": null
}

Flags

flag what it does
--system system prompt prepended to the request
--schema dotted path to a Pydantic model (e.g. schemas.RootCause)
--stream stream tokens to stderr while assembling the response
--model Anthropic model name (default: claude-sonnet-4-6)
--max-tokens response token cap (default: 1024)

Eval

The success metric: samples/error.log has 10 hand-authored log lines. scripts/eval.sh pipes each through the CLI with --schema schemas.RootCause and counts how many produce valid Pydantic-typed JSON. Target: ≥ 9 / 10.

./scripts/eval.sh
# Result: 10/10 valid responses (run on 2026-05-10, claude-sonnet-4-6)

Tests

pip install -e ".[dev]"
pytest

License

MIT.

Metadata

Release files for claude-pipe 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for claude-pipe 0.1.0
File Size Uploaded
claude_pipe-0.1.0.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for claude-pipe 0.1.0
File Interpreter ABI Platform
claude_pipe-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.4 kB

Release files / claude_pipe-0.1.0.tar.gz

Download URL claude_pipe-0.1.0.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f6d4c6918664fd86f6fbfc3bc78e05211e7577f119ec02f6f0d254b454ea7776
BLAKE2b-256 checksum
How to use checksums
c7110e81fa8c2f7343028ac593eeaa9939cc89820dc60764bc13916cea658add
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

Release files / claude_pipe-0.1.0-py3-none-any.whl

Download URL claude_pipe-0.1.0-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e4aed4d4860a643e942713093fcbfed2367a836d95059df565523be7d0a1eb44
BLAKE2b-256 checksum
How to use checksums
8ab4a33615beb0d7c50211854ef242f6f227fa10afef3928a5ade900bb0fe7d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page