Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/create-release-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ jobs:
--title "Release v${{ steps.extract_version.outputs.version }}" \
--generate-notes \
--notes-start-tag "${{ steps.previous_tag.outputs.previous_tag }}" \
--notes "Published to PyPI: https://pypi.org/project/claude-code-sdk/${{ steps.extract_version.outputs.version }}/
--notes "Published to PyPI: https://pypi.org/project/claude-agent-sdk/${{ steps.extract_version.outputs.version }}/

### Installation
\`\`\`bash
pip install claude-code-sdk==${{ steps.extract_version.outputs.version }}
pip install claude-agent-sdk==${{ steps.extract_version.outputs.version }}
\`\`\`"
14 changes: 7 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
run: |
twine upload dist/*
echo "Package published to PyPI"
echo "Install with: pip install claude-code-sdk==${{ env.VERSION }}"
echo "Install with: pip install claude-agent-sdk==${{ env.VERSION }}"

- name: Create version update PR
env:
Expand All @@ -124,7 +124,7 @@ jobs:
echo "Getting SHA for pyproject.toml"
PYPROJECT_SHA=$(gh api /repos/$GITHUB_REPOSITORY/contents/pyproject.toml --jq '.sha')
echo "Getting SHA for _version.py"
VERSION_SHA=$(gh api /repos/$GITHUB_REPOSITORY/contents/src/claude_code_sdk/_version.py --jq '.sha')
VERSION_SHA=$(gh api /repos/$GITHUB_REPOSITORY/contents/src/claude_agent_sdk/_version.py --jq '.sha')

# Commit pyproject.toml via GitHub API (this creates signed commits)
message="chore: bump version to ${{ env.VERSION }}"
Expand All @@ -138,10 +138,10 @@ jobs:
-f branch="$BRANCH_NAME"

# Commit _version.py via GitHub API
base64 -i src/claude_code_sdk/_version.py > version.py.b64
base64 -i src/claude_agent_sdk/_version.py > version.py.b64
gh api \
--method PUT \
/repos/$GITHUB_REPOSITORY/contents/src/claude_code_sdk/_version.py \
/repos/$GITHUB_REPOSITORY/contents/src/claude_agent_sdk/_version.py \
-f message="$message" \
-F [email protected] \
-f sha="$VERSION_SHA" \
Expand All @@ -152,11 +152,11 @@ jobs:

## Changes
- Updated version in \`pyproject.toml\`
- Updated version in \`src/claude_code_sdk/_version.py\`
- Updated version in \`src/claude_agent_sdk/_version.py\`

## Release Information
- Published to PyPI: https://pypi.org/project/claude-code-sdk/${{ env.VERSION }}/
- Install with: \`pip install claude-code-sdk==${{ env.VERSION }}\`
- Published to PyPI: https://pypi.org/project/claude-agent-sdk/${{ env.VERSION }}/
- Install with: \`pip install claude-agent-sdk==${{ env.VERSION }}\`

🤖 Generated by GitHub Actions"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

- name: Run tests
run: |
python -m pytest tests/ -v --cov=claude_code_sdk --cov-report=xml
python -m pytest tests/ -v --cov=claude_agent_sdk --cov-report=xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ python -m pytest tests/test_client.py

# Codebase Structure

- `src/claude_code_sdk/` - Main package
- `src/claude_agent_sdk/` - Main package
- `client.py` - ClaudeSDKClient for interactive sessions
- `query.py` - One-shot query function
- `types.py` - Type definitions
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Claude Code SDK for Python
# Claude Agent SDK for Python

Python SDK for Claude Code. See the [Claude Code SDK documentation](https://docs.anthropic.com/en/docs/claude-code/sdk/sdk-python) for more information.
Python SDK for Claude Agent. See the [Claude Agent SDK documentation](https://docs.anthropic.com/en/docs/claude-code/sdk/sdk-python) for more information.

## Installation

```bash
pip install claude-code-sdk
pip install claude-agent-sdk
```

**Prerequisites:**
Expand All @@ -17,7 +17,7 @@ pip install claude-code-sdk

```python
import anyio
from claude_code_sdk import query
from claude_agent_sdk import query

async def main():
async for message in query(prompt="What is 2 + 2?"):
Expand All @@ -28,10 +28,10 @@ anyio.run(main)

## Basic Usage: query()

`query()` is an async function for querying Claude Code. It returns an `AsyncIterator` of response messages. See [src/claude_code_sdk/query.py](src/claude_code_sdk/query.py).
`query()` is an async function for querying Claude Code. It returns an `AsyncIterator` of response messages. See [src/claude_agent_sdk/query.py](src/claude_agent_sdk/query.py).

```python
from claude_code_sdk import query, ClaudeAgentOptions, AssistantMessage, TextBlock
from claude_agent_sdk import query, ClaudeAgentOptions, AssistantMessage, TextBlock

# Simple query
async for message in query(prompt="Hello Claude"):
Expand Down Expand Up @@ -79,7 +79,7 @@ options = ClaudeAgentOptions(
## ClaudeSDKClient

`ClaudeSDKClient` supports bidirectional, interactive conversations with Claude
Code. See [src/claude_code_sdk/client.py](src/claude_code_sdk/client.py).
Code. See [src/claude_agent_sdk/client.py](src/claude_agent_sdk/client.py).

Unlike `query()`, `ClaudeSDKClient` additionally enables **custom tools** and **hooks**, both of which can be defined as Python functions.

Expand All @@ -94,7 +94,7 @@ For an end-to-end example, see [MCP Calculator](examples/mcp_calculator.py).
#### Creating a Simple Tool

```python
from claude_code_sdk import tool, create_sdk_mcp_server, ClaudeAgentOptions, ClaudeSDKClient
from claude_agent_sdk import tool, create_sdk_mcp_server, ClaudeAgentOptions, ClaudeSDKClient

# Define a tool using the @tool decorator
@tool("greet", "Greet a user", {"name": str})
Expand Down Expand Up @@ -186,7 +186,7 @@ For more examples, see examples/hooks.py.
#### Example

```python
from claude_code_sdk import ClaudeAgentOptions, ClaudeSDKClient, HookMatcher
from claude_agent_sdk import ClaudeAgentOptions, ClaudeSDKClient, HookMatcher

async def check_bash_command(input_data, tool_use_id, context):
tool_name = input_data["tool_name"]
Expand Down Expand Up @@ -232,15 +232,15 @@ async with ClaudeSDKClient(options=options) as client:

## Types

See [src/claude_code_sdk/types.py](src/claude_code_sdk/types.py) for complete type definitions:
See [src/claude_agent_sdk/types.py](src/claude_agent_sdk/types.py) for complete type definitions:
- `ClaudeAgentOptions` - Configuration options
- `AssistantMessage`, `UserMessage`, `SystemMessage`, `ResultMessage` - Message types
- `TextBlock`, `ToolUseBlock`, `ToolResultBlock` - Content blocks

## Error Handling

```python
from claude_code_sdk import (
from claude_agent_sdk import (
ClaudeSDKError, # Base error
CLINotFoundError, # Claude Code not installed
CLIConnectionError, # Connection issues
Expand All @@ -259,7 +259,7 @@ except CLIJSONDecodeError as e:
print(f"Failed to parse response: {e}")
```

See [src/claude_code_sdk/_errors.py](src/claude_code_sdk/_errors.py) for all error types.
See [src/claude_agent_sdk/_errors.py](src/claude_agent_sdk/_errors.py) for all error types.

## Available Tools

Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/test_agents_and_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest

from claude_code_sdk import (
from claude_agent_sdk import (
AgentDefinition,
ClaudeAgentOptions,
ClaudeSDKClient,
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/test_dynamic_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from claude_code_sdk import (
from claude_agent_sdk import (
ClaudeAgentOptions,
ClaudeSDKClient,
)
Expand Down
4 changes: 2 additions & 2 deletions e2e-tests/test_include_partial_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import pytest

from claude_code_sdk import ClaudeSDKClient
from claude_code_sdk.types import (
from claude_agent_sdk import ClaudeSDKClient
from claude_agent_sdk.types import (
ClaudeAgentOptions,
StreamEvent,
AssistantMessage,
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/test_sdk_mcp_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import pytest

from claude_code_sdk import (
from claude_agent_sdk import (
ClaudeAgentOptions,
ClaudeSDKClient,
create_sdk_mcp_server,
Expand Down
6 changes: 3 additions & 3 deletions e2e-tests/test_stderr_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from claude_code_sdk import ClaudeCodeOptions, query
from claude_agent_sdk import ClaudeAgentOptions, query


@pytest.mark.e2e
Expand All @@ -15,7 +15,7 @@ def capture_stderr(line: str):
stderr_lines.append(line)

# Enable debug mode to generate stderr output
options = ClaudeCodeOptions(
options = ClaudeAgentOptions(
stderr=capture_stderr,
extra_args={"debug-to-stderr": None}
)
Expand All @@ -39,7 +39,7 @@ def capture_stderr(line: str):
stderr_lines.append(line)

# No debug mode enabled
options = ClaudeCodeOptions(stderr=capture_stderr)
options = ClaudeAgentOptions(stderr=capture_stderr)

# Run a simple query
async for _ in query(prompt="What is 1+1?", options=options):
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/test_tool_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from claude_code_sdk import (
from claude_agent_sdk import (
ClaudeAgentOptions,
ClaudeSDKClient,
PermissionResultAllow,
Expand Down
4 changes: 2 additions & 2 deletions examples/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import anyio

from claude_code_sdk import (
from claude_agent_sdk import (
AgentDefinition,
AssistantMessage,
ClaudeAgentOptions,
Expand Down Expand Up @@ -38,7 +38,7 @@ async def code_reviewer_example():
)

async for message in query(
prompt="Use the code-reviewer agent to review the code in src/claude_code_sdk/types.py",
prompt="Use the code-reviewer agent to review the code in src/claude_agent_sdk/types.py",
options=options,
):
if isinstance(message, AssistantMessage):
Expand Down
4 changes: 2 additions & 2 deletions examples/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import sys
from typing import Any

from claude_code_sdk import ClaudeAgentOptions, ClaudeSDKClient
from claude_code_sdk.types import (
from claude_agent_sdk import ClaudeAgentOptions, ClaudeSDKClient
from claude_agent_sdk.types import (
AssistantMessage,
HookContext,
HookJSONOutput,
Expand Down
4 changes: 2 additions & 2 deletions examples/include_partial_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"""

import asyncio
from claude_code_sdk import ClaudeSDKClient
from claude_code_sdk.types import (
from claude_agent_sdk import ClaudeSDKClient
from claude_agent_sdk.types import (
ClaudeAgentOptions,
StreamEvent,
AssistantMessage,
Expand Down
6 changes: 3 additions & 3 deletions examples/mcp_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import asyncio
from typing import Any

from claude_code_sdk import (
from claude_agent_sdk import (
ClaudeAgentOptions,
create_sdk_mcp_server,
tool,
Expand Down Expand Up @@ -99,7 +99,7 @@ async def power(args: dict[str, Any]) -> dict[str, Any]:

def display_message(msg):
"""Display message content in a clean format."""
from claude_code_sdk import (
from claude_agent_sdk import (
AssistantMessage,
ResultMessage,
SystemMessage,
Expand Down Expand Up @@ -137,7 +137,7 @@ def display_message(msg):

async def main():
"""Run example calculations using the SDK MCP server with streaming client."""
from claude_code_sdk import ClaudeSDKClient
from claude_agent_sdk import ClaudeSDKClient

# Create the calculator server with all tools
calculator = create_sdk_mcp_server(
Expand Down
2 changes: 1 addition & 1 deletion examples/quick_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import anyio

from claude_code_sdk import (
from claude_agent_sdk import (
AssistantMessage,
ClaudeAgentOptions,
ResultMessage,
Expand Down
2 changes: 1 addition & 1 deletion examples/setting_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import sys
from pathlib import Path

from claude_code_sdk import (
from claude_agent_sdk import (
ClaudeAgentOptions,
ClaudeSDKClient,
SystemMessage,
Expand Down
4 changes: 2 additions & 2 deletions examples/stderr_callback_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import asyncio

from claude_code_sdk import ClaudeCodeOptions, query
from claude_agent_sdk import ClaudeAgentOptions, query


async def main():
Expand All @@ -19,7 +19,7 @@ def stderr_callback(message: str):
print(f"Error detected: {message}")

# Create options with stderr callback and enable debug mode
options = ClaudeCodeOptions(
options = ClaudeAgentOptions(
stderr=stderr_callback,
extra_args={"debug-to-stderr": None} # Enable debug output
)
Expand Down
2 changes: 1 addition & 1 deletion examples/streaming_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import contextlib
import sys

from claude_code_sdk import (
from claude_agent_sdk import (
AssistantMessage,
ClaudeAgentOptions,
ClaudeSDKClient,
Expand Down
Loading
Loading