albeorla-claude-cli-bridge
Async Python wrapper for the Claude Code CLI with automatic session management.
Install
pip install albeorla-claude-cli-bridge
Requires the claude CLI to be installed and authenticated.
Usage
import asyncio
from claude_cli_bridge import ClaudeBridge
async def main():
bridge = ClaudeBridge(work_dir="~/my-project")
# First call creates a new session
resp = await bridge.query(key="chat-1", message="explain this codebase")
print(resp.text)
# Follow-up resumes the same session automatically
resp = await bridge.query(key="chat-1", message="now refactor the main module")
print(resp.text)
# One-shot (no session tracking)
resp = await bridge.ask("what is 2 + 2?")
print(resp.text)
asyncio.run(main())
API
ClaudeBridge
ClaudeBridge(
claude_binary="claude", # path to claude CLI
work_dir=".", # working directory for subprocess
system_prompt=None, # appended on first turn
permission_mode="bypassPermissions",
model=None, # e.g., "haiku", "sonnet"
allowed_tools=None, # e.g., ["Read", "WebSearch"]
)
Methods
| Method | Description |
|---|---|
await bridge.query(key, message) |
Send a message to a session. Creates one if needed, resumes on follow-up. |
await bridge.ask(message) |
One-shot query, no session reuse. |
bridge.get_session(key) |
Get session by key, or None. |
bridge.create_session(key) |
Explicitly create a session. |
bridge.remove_session(key) |
Remove a session. |
bridge.active_sessions |
Dict of all active sessions. |
Response
| Field | Type | Description |
|---|---|---|
text |
str |
The assistant's reply |
session_id |
str |
Claude session ID |
cost_usd |
float |
Cost of the query |
duration_ms |
int |
Wall-clock time |
num_turns |
int |
Number of agent turns |
is_error |
bool |
Whether the query failed |
raw |
dict |
Full JSON response from the CLI |
Session
| Field | Type | Description |
|---|---|---|
session_id |
str |
UUID for the Claude CLI session |
key |
Any |
Application-defined identifier |
turn_count |
int |
Messages sent in this session |
busy |
bool |
Whether a query is in progress |
Metadata
Release files for albeorla-claude-cli-bridge 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| albeorla_claude_cli_bridge-0.2.1.tar.gz | 4.9 kB | With provenance | Details for albeorla_claude_cli_bridge-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| albeorla_claude_cli_bridge-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for albeorla_claude_cli_bridge-0.2.1-py3-none-any.whl |
Total release size: 10.8 kB
Release files / albeorla_claude_cli_bridge-0.2.1.tar.gz
| Download URL | albeorla_claude_cli_bridge-0.2.1.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0119978d8e802bd4a0667020e9ec389fc515ad5a3bb0bab94cfb5a904114fc5f
|
|
BLAKE2b-256 checksum How to use checksums |
a070768e27f102bd703a4ade78eb56eb6df1532dbcba381a44ee4cd559c444d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 21, 2026.
Transparency logRelease files / albeorla_claude_cli_bridge-0.2.1-py3-none-any.whl
| Download URL | albeorla_claude_cli_bridge-0.2.1-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e466ed6601dfa39cd49feeca4dc2d6dcf067426180d9b103122a30b197bedb7e
|
|
BLAKE2b-256 checksum How to use checksums |
06235dd6efbbbe0a817632cd48306ce845a6f169ca860c6513b1aa23c56c2ed4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 21, 2026.
Transparency logSecurity for albeorla-claude-cli-bridge 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for albeorla_claude_cli_bridge-0.2.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.