--- id: claude-code-sdk version: "0.0.25" license: MIT license_treatment: permissive maintenance: active --- # claude-code-sdk — Python SDK for Claude Code License: permissive · Maintenance: active · Downloads: 624.9K/mo ## What it is and what it does Claude Code SDK is a Python wrapper for querying Claude Code, an AI agent that can read, write, and execute code. It provides both a simple async query interface and a more advanced client for bidirectional conversations with custom tools and lifecycle hooks. The package depends on anyio for async I/O, mcp for Model Context Protocol support, and typing-extensions for type hints. The SDK is officially deprecated and no longer maintained; Anthropic recommends migrating to claude-agent-sdk. It supports Python 3.10 through 3.13 and is distributed as a pure wheel with low install friction. While the repository remains active and has accumulated significant GitHub stars, new projects should use the successor package. Use it for: - Query Claude Code for code generation or analysis tasks via a simple async interface. - Build interactive agents that maintain bidirectional conversation state with Claude Code. - Define custom tools as Python functions and expose them to Claude via in-process MCP servers. - Implement hooks to intercept and validate tool use (e.g., blocking unsafe bash commands before execution). - Migrate from external MCP server processes to in-process tool definitions for simpler deployment. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Python SDK for querying Claude Code and building interactive agents with custom tools and hooks, now deprecated in favor of claude-agent-sdk. No—the package is officially deprecated and no longer maintained. Install claude-agent-sdk instead. If you have an existing codebase using claude-code-sdk, plan a migration to the successor package rather than starting new projects with this one. ## Install pip install claude-code-sdk uv add claude-code-sdk poetry add claude-code-sdk ## Installing claude-code-sdk Before you install: Low install friction with a pure-wheel distribution. Active maintenance as of the latest release, though the package is officially deprecated and no longer maintained—users should migrate to claude-agent-sdk. License in practice: MIT license permits unrestricted use, modification, and distribution with minimal obligations, making it suitable for both open-source and commercial projects. Quickstart: pip install claude-code-sdk import anyio from claude_code_sdk import query async def main(): async for message in query(prompt="What is 2 + 2?"): print(message) anyio.run(main()) Requires Python 3.10+, Node.js, and Claude Code installed via npm (npm install -g @anthropic-ai/claude-code). Verify before relying: - Whether claude-agent-sdk is a direct drop-in replacement or requires code changes. - Current status of the Claude Code CLI and whether it remains actively maintained. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 624.9K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags claude code python sdk, anthropic claude agent integration, async claude ai queries, mcp custom tools python, claude code hooks automation, deprecated, async-sdk, mcp-tools [View on SkillFed](https://skillfed.io/packages/claude-code-sdk) · [View on PyPI](https://pypi.org/project/claude-code-sdk/)