DEV Community

Sangmin Lee
Sangmin Lee

Posted on • Originally published at claudeguide.io

Claude Agent SDK Guide: Build Automation Agents with Tool Use

Originally published at claudeguide.io/claude-agent-sdk-guide

Claude Agent SDK Guide: Build Automation Agents with Tool Use

The "Claude Agent SDK" is the Anthropic Python/TypeScript SDK combined with the tool use feature — it's not a separate package. An agent is just a loop: send a message, Claude calls a tool, you execute the tool, send the result back, repeat until done in 2026. This guide covers the complete pattern for building reliable production agents.


Quick Start

pip install anthropic
Enter fullscreen mode Exit fullscreen mode
import anthropic

client = anthropic.Anthropic()

# Minimal agent with one tool
tools = [{
    "name": "get_weather",
    "description": "Get current weather for a location",
    "input_schema": {
        "type": "object",
        "properties": {
            "location": {"type": "string", "description": "City name"}
        },
        "required": ["location"]
    }
}]

messages = [{"role": "user", "content": "What's the weather in Seoul?"}]

response = client.messages.create(
    model="claude-sonnet-4-5",
    max_tokens=1024,
    tools=tools,
    messages=messages
)

print(response.stop_reason)  # "tool_use" if Claude wants to call a tool
Enter fullscreen mode Exit fullscreen mode

The Agentic Loop

The core pattern: run until stop_reason == "end_turn".


python
import anthropic
import json

client = anthropic.Anthropic()

def run_agent(tools: list, tool_executor: callable, initial_message: str) -

[→ Get the Agent SDK Cookbook — $49](https://shoutfirst.gumroad.com/l/ogxhmy?utm_source=claudeguide&utm_medium=article&utm_campaign=claude-agent-sdk-guide)

*30-day money-back guarantee. Instant download.*
Enter fullscreen mode Exit fullscreen mode

Top comments (0)