AIAny
AI Agent2025
GitHub

Claude Agent SDK for Python

Run Claude as a programmatic agent in Python: one-shot query() calls or a stateful ClaudeSDKClient for multi-turn loops. Define in-process tools, lifecycle hooks, and per-tool permissions; it bundles the Claude Code CLI and exposes its full toolset.

Introduction

When Anthropic renamed "Claude Code SDK" to the Claude Agent SDK, it signaled where the value really lives: not in the chat loop, but in turning Claude Code's agent harness — its tool execution, permission gating, and session management — into a library you call from your own code. You don't reimplement an agent; you drive the same one Claude Code runs, with deterministic hooks where it matters.

What Sets It Apart
  • Two interaction shapes, one engine. query() is a stateless async generator for fire-and-forget tasks; ClaudeSDKClient keeps a bidirectional session for interactive, multi-turn work with mid-stream control.
  • In-process MCP tools. Decorate a Python function with @tool and it becomes a callable tool with no separate process or transport — closing the latency and ops gap that external MCP servers impose.
  • Hooks make behavior deterministic. PreToolUse/PostToolUse callbacks let you inspect, rewrite, or block actions (e.g., veto a Bash command) instead of relying on the model to behave.
  • Real permission surface. allowed_tools allowlists, permission_mode, and a can_use_tool callback give code-level control over what the agent can touch.
Who It's For

Great fit if you want production agents that reuse Claude Code's battle-tested file/Bash/edit tools and need guardrails enforced in code rather than prompts. Look elsewhere if you only need plain text completions — the SDK bundles and manages the Claude Code CLI under the hood, which is overhead you don't need for a simple chat call. Note it targets Python 3.10+ and the agent runs through that bundled CLI.

More Items

Hugging Face

Evaluates coding agents on 141 executable tasks spanning frontend and application development, data analysis, and more. Each task includes a starting environment, reference solution, and verifier.

GitHub
AI Agent2026

Equips AI agents to create and manage Obsidian Markdown, Bases, and Canvas files, use Obsidian’s CLI, and sync vaults without the desktop app.

GitHub
AI Agent2026

Handles everyday tasks across real websites and apps, asking before actions that can have real-world consequences. Data and saved logins stay on the machine running it, and you choose the model.