A lightweight Python SDK for Claude Code CLI using subprocess
Project description
Claude SDK Lite
A lightweight Python SDK for Claude Code CLI using subprocess.
Why This Project
The official claude-agent-sdk is a comprehensive solution that bundles the Claude Code CLI (~100MB) and only provides an async API. For many use cases, this is overkill.
claude-sdk-lite is designed for developers who:
- Already have Claude Code CLI installed
- Need a simple sync API without asyncio complexity
- Want a lightweight package with minimal dependencies
Installation
# Prerequisites
npm install -g @anthropic-ai/claude-code
# Install the SDK
pip install claude-sdk-lite
Quick Start
from claude_sdk_lite import query, AssistantMessage, TextBlock
for message in query(prompt="What is the capital of France?"):
if isinstance(message, AssistantMessage):
for block in message.content:
if isinstance(block, TextBlock):
print(block.text)
Comparison with Official SDK
| Feature | claude-sdk-lite | claude-agent-sdk |
|---|---|---|
| Package Size | ~50KB | ~100MB+ |
| Dependencies | 1 (Pydantic) | 3+ |
| API | Sync + Async | Async only |
| CLI | User installed | Bundled |
| Custom MCP servers | ❌ | ✅ |
| Hooks system | ❌ | ✅ |
Choose claude-sdk-lite if you need a lightweight, simple API for basic queries and multi-turn conversations.
Choose claude-agent-sdk if you need custom MCP servers, hooks, or a standalone deployment with bundled CLI.
Documentation
Full API documentation, examples, and migration guides: → DOCS.md
Changelog
[0.3.0] - 2026-02-13
- Enhanced Message Parsing - Improved robustness with
UnknownMessagefallback for forward compatibility - Better User Message Handling - Proper display of user input when
replay_user_messagesis enabled - Interrupt Signal Support - Add
InterruptBlockcontent type for interrupt signal display - Async Interrupt Handling - Improved
CancelledErrorpropagation in async client - Extended Type Support - Add
ControlResponseMessagefor control request acknowledgments - API Improvements - Moved
build_subprocess_kwargs()toClaudeOptionsfor better encapsulation
[0.2.1] - 2025-02-10
- Echo Mode - New
echo_modeoption to echo user input and interrupt signals through message stream
[0.2.0] - 2025-02-10
- Session-Based Clients -
ClaudeClientandAsyncClaudeClientfor multi-turn conversations - Event-Driven Architecture - Real-time message handling via
MessageEventListener - Default Handlers - Built-in message buffering and synchronization helpers
[0.1.0] - Initial Release
- Basic query functions with full Claude Code CLI parameter support
License
MIT License - see LICENSE file for details.
Acknowledgments
Inspired by Anthropic's official claude-agent-sdk.
Project details
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_sdk_lite-0.3.0.tar.gz.
File metadata
- Download URL: claude_sdk_lite-0.3.0.tar.gz
- Upload date:
- Size: 67.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4953284d6479202f66dc65271ba84e72464f441b1b1e465363f81bf14943249b
|
|
| MD5 |
f4ea64d43ff0914c41ddc6fe038ea986
|
|
| BLAKE2b-256 |
607d81084347758fd83cc0b2c13952667305e490fbfc50d490ad284d82f60d41
|
File details
Details for the file claude_sdk_lite-0.3.0-py3-none-any.whl.
File metadata
- Download URL: claude_sdk_lite-0.3.0-py3-none-any.whl
- Upload date:
- Size: 36.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e16906c9423cea027c8275fbe83077252e7e171bfdad547b523e49f78aedcf42
|
|
| MD5 |
ec189f5cc3ffb35e2d0b752c7af1e7cf
|
|
| BLAKE2b-256 |
679aad2f67a2e73b9612f7f1b8d825a4a272517716c40dd5bc6866934bd8bfa7
|