Claude Agent SDK Demos — 8 Official Example Projects
Official demo collection by Anthropic showcasing the Claude Agent SDK: email agent, research agent, resume generator, chat app, Excel processing, and more. MIT license, 2,100+ stars.
What it is
This is the official demo collection by Anthropic showcasing the Claude Agent SDK. It includes eight example projects: an email agent, a research agent, a resume generator, a chat application, an Excel processing agent, and more. Each demo demonstrates a different SDK pattern for building production AI agents.
The collection targets developers learning the Claude Agent SDK who want working reference implementations rather than documentation alone.
How it saves time or tokens
Starting from a working demo eliminates the blank-page problem. Each example includes the agent loop, tool definitions, error handling, and state management patterns that you would otherwise build from scratch. Copy the closest example, modify it for your use case, and deploy.
The demos also serve as integration tests for the SDK. They demonstrate patterns that are verified to work, reducing debugging time.
How to use
- Clone the repository:
git clone https://github.com/anthropics/anthropic-cookbook - Navigate to the agent SDK demos directory
- Install dependencies:
pip install anthropic - Run any demo:
python email_agent.py
Example
# Simplified research agent pattern from the demos
import anthropic
client = anthropic.Anthropic()
def research_agent(query: str) -> str:
tools = [
{
'name': 'web_search',
'description': 'Search the web for information',
'input_schema': {
'type': 'object',
'properties': {
'query': {'type': 'string', 'description': 'Search query'}
},
'required': ['query']
}
}
]
messages = [{'role': 'user', 'content': query}]
while True:
response = client.messages.create(
model='claude-sonnet-4-20250514',
max_tokens=4096,
tools=tools,
messages=messages
)
if response.stop_reason == 'end_turn':
return response.content[0].text
# Handle tool use and continue the loop
messages.append({'role': 'assistant', 'content': response.content})
# Process tool calls...
Related on TokRepo
- AI agent tools -- Agent frameworks and SDKs
- Coding tools -- Developer tools and examples
Common pitfalls
- Demos use hardcoded API keys in some examples; replace with environment variables before deploying
- The agent loop pattern requires proper stop condition handling; infinite loops occur if tool results are not formatted correctly
- Some demos depend on external services (email, web search); configure those services before running
Frequently Asked Questions
The Claude Agent SDK is Anthropic's official library for building AI agents that use Claude. It provides tool use, multi-turn conversations, and agent loop patterns. The SDK is available in Python and TypeScript.
Start with the chat application demo for the simplest agent loop. Move to the research agent for tool use patterns. The email agent demonstrates multi-step workflows with real external service integration.
Yes. The demos work with any Claude model. Specify the model ID in the API call. Sonnet is recommended for most agent tasks due to its balance of quality and cost.
Yes. The patterns demonstrated in the demos (agent loops, tool handling, error recovery) are production-grade. Add authentication, logging, and rate limiting for your specific deployment.
Yes. The demos are released under the MIT license. You can use, modify, and distribute the code freely.
Citations (3)
- Anthropic Cookbook— Official Anthropic demo collection for Claude Agent SDK
- Anthropic Docs— Claude Agent SDK documentation
- Anthropic Docs— Tool use patterns for Claude agents
Related on TokRepo
Source & Thanks
Created by Anthropic. Licensed under MIT.
claude-agent-sdk-demos — ⭐ 2,100+
Thank you to Anthropic for providing these comprehensive SDK demonstrations.
Discussion
Related Assets
NAPI-RS — Build Node.js Native Addons in Rust
Write high-performance Node.js native modules in Rust with automatic TypeScript type generation and cross-platform prebuilt binaries.
Mamba — Fast Cross-Platform Package Manager
A drop-in conda replacement written in C++ that resolves environments in seconds instead of minutes.
Plasmo — The Browser Extension Framework
Build, test, and publish browser extensions for Chrome, Firefox, and Edge using React or Vue with hot-reload and automatic manifest generation.