A pip-installable Python CLI that pipes stdin into Claude with Pydantic-validated structured outputs.
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file claude_pipe-0.1.0.tar.gz.
File metadata
- Download URL: claude_pipe-0.1.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6d4c6918664fd86f6fbfc3bc78e05211e7577f119ec02f6f0d254b454ea7776
|
|
| MD5 |
73f2e7e4001568b8d05dbc638164d47f
|
|
| BLAKE2b-256 |
c7110e81fa8c2f7343028ac593eeaa9939cc89820dc60764bc13916cea658add
|
File details
Details for the file claude_pipe-0.1.0-py3-none-any.whl.
File metadata
- Download URL: claude_pipe-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4aed4d4860a643e942713093fcbfed2367a836d95059df565523be7d0a1eb44
|
|
| MD5 |
ac1b1bf6a49a02b692bf37a0161ddeee
|
|
| BLAKE2b-256 |
8ab4a33615beb0d7c50211854ef242f6f227fa10afef3928a5ade900bb0fe7d0
|