claude-agent-sdk-python

claude-agent-sdk-python is a skill for Claude Code from WalterSumbon/claude-agent-sdk-skill. It costs 120 tokens per session (3,406 once invoked), scanned E, original, Apache-2.0.

A Python guide for building AI agents with the Claude Agent SDK. The SDK is a software library for writing programs that ask Claude to perform tasks, use tools, manage sessions, and connect to external services.

In plain words
What is it for?
Use it when working with the SDK's query functions, client sessions, agent definitions, custom tools, hooks, MCP servers, or Python integrations.
Why use it?
It helps developers choose between one-off requests and ongoing conversations, define custom tools, configure permissions, and understand the SDK's message types when writing or debugging Python code.

Skill for Claude Code

Written for Claude Code: PreToolUse hook event. Also seen: reads .claude/ paths; mentions CLAUDE.md; mentions subagents.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/waltersumbon/claude-agent-sdk-skill/claude-agent-sdk-python
Any agent
npx skills add WalterSumbon/claude-agent-sdk-skill --skill claude-agent-sdk-python
Clone the repo
git clone --depth 1 https://github.com/WalterSumbon/claude-agent-sdk-skill

Made for: Claude Code.

Its marketplace also offers this one on its own, as the plugin claude-agent-sdk-python/plugin install claude-agent-sdk-python after adding the marketplace above.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for claude-agent-sdk-python

README.md
[![agentmods](https://agentmods.dev/badge/skills/waltersumbon/claude-agent-sdk-skill/claude-agent-sdk-python.svg)](https://agentmods.dev/skills/waltersumbon/claude-agent-sdk-skill/claude-agent-sdk-python)
Your own site
<a href="https://agentmods.dev/skills/waltersumbon/claude-agent-sdk-skill/claude-agent-sdk-python"><img src="https://agentmods.dev/badge/skills/waltersumbon/claude-agent-sdk-skill/claude-agent-sdk-python.svg" alt="Measured on agentmods" height="20"></a>
Per session 120 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,406 The whole file, excluding the scripts and references it only reads on demand.
Security scan E 3 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00120 $0.03406
Opus 5 $0.00060 $0.01703
Sonnet 5 $0.00024 $0.00681
Haiku 4.5 $0.00012 $0.00341

Measured 5d ago against content hash a1d4a95570a6, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade E, and why

claude-agent-sdk-python scanned grade E with 3 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Downloads and executes remote codehighSupply chain

curl | sh runs whatever the server returns today, which is not necessarily what it returned when this was reviewed.

print("Claude Code CLI not found. Install: curl -fsSL https://claude.ai/install.sh | bash")

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

if any(danger in cmd for danger in ["rm -rf /", "DROP TABLE", "mkfs"]):

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

print("Claude Code CLI not found. Install: curl -fsSL https://claude.ai/install.sh | bash")
skills/claude-agent-sdk-python/SKILL.md · 414 lines

How it starts

The opening of the file, as written. The whole thing — 414 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Claude Agent SDK — Python Guide

Production guidance for building AI agents with the Claude Agent SDK in Python.

Naming: The Claude Code SDK was renamed to the Claude Agent SDK (v0.1.0+). Package: pip install claude-agent-sdk · Import: from claude_agent_sdk import ...

Message Types

All message types for type checking and isinstance() checks:

from claude_agent_sdk import (
    AssistantMessage,     # Claude's text/tool responses
    ResultMessage,        # Final result with subtype (success/error/cancelled)
    SystemMessage,        # System events (session_id, etc.)
    UserMessage,          # User prompts
    ToolUseMessage,       # Tool invocation requests
    ToolResultMessage,    # Tool execution results
)

Quick Reference — Two Interaction Modes

1. query() — Stateless, One-Shot

Best for: independent tasks, automation scripts, CI pipelines.

import asyncio
from claude_agent_sdk import query, ClaudeAgentOptions, AssistantMessage, ResultMessage

async def main():
    async for message in query(
        prompt="Review utils.py for bugs. Fix any issues you find.",
        options=ClaudeAgentOptions(
            allowed_tools=["Read", "Edit", "Glob"],
            permission_mode="acceptEdits",
        ),
    ):
        if isinstance(message, AssistantMessage):
            for block in message.content:
                if hasattr(block, "text"):
                    print(block.text)
                elif hasattr(block, "name"):
                    print(f"Tool: {block.name}")
        elif isinstance(message, ResultMessage):
            print(f"Done: {message.subtype}")

asyncio.run(main())

2. ClaudeSDKClient — Stateful, Multi-Turn

Best for: conversations, follow-up questions, interactive apps.

from claude_agent_sdk import ClaudeSDKClient, ClaudeAgentOptions

async with ClaudeSDKClient(
    options=ClaudeAgentOptions(
        allowed_tools=["Read", "Write", "Bash"],
        permission_mode="acceptEdits",
    )
) as client:
    await client.query("Analyze the codebase structure")
    async for msg in client.receive_messages():
        print(msg)
    # Continue the conversation with context preserved
    await client.query("Now refactor the largest file you found")
    async for msg in client.receive_messages():
        print(msg)

Read the full file on GitHub · 414 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 414 lines · 120 tokens per session scan E a1d4a95570a6

Subscribe to this mod's changes

claude-agent-sdk-python is a skill published in the GitHub repository WalterSumbon/claude-agent-sdk-skill (6 stars, last pushed 6mo ago), licensed Apache-2.0. It adds 120 tokens to every session and 3,406 once invoked, about $0.0006 per session on Opus 5. A static security scan graded it E with 3 findings (downloads and executes remote code, recursive force delete, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

astropy

Core Python library for astronomy and astrophysics workflows that need Astropy APIs, including units/quantities, coordinates, FITS I/O, tables, time systems, WCS, and cosmology. Use when implementing or debugging astronomical data analysis code with Astropy.

K-Dense-AI/scientific-agent-skills · 56 tokens

cobrapy

Constraint-based metabolic modeling (COBRA). FBA, FVA, gene knockouts, flux sampling, SBML models, for systems biology and metabolic engineering analysis.

K-Dense-AI/scientific-agent-skills · 38 tokens

dask

Distributed computing for larger-than-RAM pandas/NumPy workflows. Use when you need to scale existing pandas/NumPy code beyond memory or across clusters. Best for parallel file processing, distributed ML, integration with existing pandas code. For out-of-core analytics on single machine use vaex; for in-memory speed…

K-Dense-AI/scientific-agent-skills · 69 tokens

matlab

Build, review, migrate, and safely plan MATLAB or GNU Octave numerical workflows, including arrays, tabular/time data, tests, projects, graphics, MAT files, and explicit Python interoperability.

K-Dense-AI/scientific-agent-skills · 42 tokens

bioservices

Unified Python interface to 40+ bioinformatics services. Use when querying multiple databases (UniProt, KEGG, ChEMBL, Reactome) in a single workflow with consistent API. Best for cross-database analysis, ID mapping across services. For quick single-database lookups use gget; for sequence/file manipulation use…

K-Dense-AI/scientific-agent-skills · 73 tokens

optimize-for-gpu

GPU-accelerates scientific Python on NVIDIA hardware and verifies that the result is correct and faster. Use for CUDA/GPU optimization; CPU-bound NumPy, SciPy, pandas, scikit-learn, NetworkX, scikit-image, vector-search, image-processing, graph, simulation, or file-I/O workloads; CuPy, cuDF, cuML, cuGraph, cuVS…

K-Dense-AI/scientific-agent-skills · 151 tokens