A lightweight Python SDK for Claude Code CLI using subprocess.
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
# Prerequisites
npm install -g @anthropic-ai/claude-code
# Install the SDK
pip install claude-sdk-litefrom 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)| 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.
Full API documentation, examples, and migration guides: → DOCS.md
- 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
- Echo Mode - New
echo_modeoption to echo user input and interrupt signals through message stream
- 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
- Basic query functions with full Claude Code CLI parameter support
MIT License - see LICENSE file for details.
Inspired by Anthropic's official claude-agent-sdk.