skillfed

claude-code-sdk

Python SDK for Claude Code

claude-code-sdk v0.0.25 624.9K downloads/30d#5,698 on PyPI7,891
Permissive license MIT Active released

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 on this page — 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

claude-code-sdk on PyPI

pip

pip install claude-code-sdk

uv

uv add claude-code-sdk

poetry

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 the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 3 — anyio, mcp, typing-extensions
Maintenance actively maintained — 319 days since the last release
Last repo commit
First released
Downloads 624,903/month — #5,698 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: claude_code_sdk-0.0.25-py3-none-any.whl

Keywords: ai, anthropic, claude, sdk

Development Status :: 3 - AlphaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Typing :: Typed

Tags

claude code python sdkanthropic claude agent integrationasync claude ai queriesmcp custom tools pythonclaude code hooks automation
deprecatedasync-sdkmcp-tools

More Artificial Intelligence packages

litellm

LiteLLM provides a unified Python interface to…

permissive · top 100 on PyPI

huggingface-hub

Client library and CLI tool for downloading,…

permissive · top 100 on PyPI

langchain

LangChain provides a framework for building…

permissive · top 1,000 on PyPI

hf-xet

hf-xet provides chunk-based deduplication and…

permissive · top 1,000 on PyPI

tokenizers

Tokenizers converts raw text into token…

permissive · top 1,000 on PyPI

transformers

Transformers provides a unified framework for…

permissive · top 1,000 on PyPI

claude-agent-sdk

Python SDK for building and interacting with…

permissive · top 1,000 on PyPI

anthropic

Provides Python bindings to the Claude API,…

permissive · top 1,000 on PyPI

openinference-instrumentation-claude-agent-sdk

Auto-instruments Claude Agent SDK calls to emit…

permissive · top 15,000 on PyPI

llm-anthropic

A plugin for the LLM command-line tool that…

permissive · top 15,000 on PyPI

claude-tap

claude-tap is a local proxy and trace viewer…

permissive · top 15,000 on PyPI

pydantic-deep

A Python framework and terminal assistant for…

permissive · top 15,000 on PyPI

livekit-plugins-anthropic

Integrates Anthropic's Claude models into…

permissive · top 5,000 on PyPI

langchain-anthropic

Provides LangChain integration for Anthropic's…

permissive · top 1,000 on PyPI

agent-framework-claude

Integrates Claude with Microsoft Agent…

permissive · top 15,000 on PyPI

trinity-agent

Trinity orchestrates multiple AI coding agents…

permissive · top 15,000 on PyPI

Further reading