claude-agent-sdk

claude-agent-sdk is a skill for Claude Code from basher83/lunar-claude. It costs 35 tokens per session (3,793 once invoked), scanned C, original, MIT.

A guide for building Python applications with the Claude Agent SDK, a software library for creating applications that use Claude agents. It covers one-off requests, ongoing conversations, subagents, configuration, hooks, and permissions.

In plain words
What is it for?
Use it when creating Python agent applications, including orchestrators, subagent workflows, custom tools, event hooks, and permission rules.
Why use it?
It provides established patterns for choosing between a simple request and a continuing conversation, and for coordinating several agents. This helps avoid designing those application pieces from scratch.

Skill for Claude Code

Written for Claude Code: when-to-use in frontmatter. Also seen: reads .claude/ paths; mentions subagents; mentions Claude Code.

Part of the python-tools plugin — 3 skills, 3 commands shipped together

Good fit Use it when creating Python agent applications, including orchestrators, subagent workflows, custom tools, event hooks, and permission rules.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/basher83/lunar-claude/claude-agent-sdk
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.

Any agent
npx skills add basher83/lunar-claude --skill claude-agent-sdk
Clone the repo
git clone --depth 1 https://github.com/basher83/lunar-claude

Made for: Claude Code.

Or install python-tools, the plugin that ships this one along with the rest of its 3 skills, 3 commands.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/basher83/lunar-claude/claude-agent-sdk/github.svg)](https://agentmods.dev/skills/basher83/lunar-claude/claude-agent-sdk)
Your own site
<a href="https://agentmods.dev/skills/basher83/lunar-claude/claude-agent-sdk"><img src="https://agentmods.dev/badge/skills/basher83/lunar-claude/claude-agent-sdk/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for claude-agent-sdk

Your own site · 80×15
<a href="https://agentmods.dev/skills/basher83/lunar-claude/claude-agent-sdk"><img src="https://agentmods.dev/badge/skills/basher83/lunar-claude/claude-agent-sdk.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 35 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,793 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. A grade says what 26 rules found in the file — not that it is safe.
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.00035 $0.03793
Opus 5 $0.00017 $0.01896
Sonnet 5 $0.00007 $0.00759
Haiku 4.5 $0.00003 $0.00379

Measured 11d ago against content hash 087d30045b8e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade C, and why

claude-agent-sdk scanned grade C with 1 finding 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 11d ago.

The scan reads SKILL.md. This mod also ships 11 executable files (assets/sdk-template.py, examples/agents.py, examples/basic-orchestrator.py, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

Recursive force deletehighDestructive command

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

if tool_name == "Bash" and "rm -rf" in input_data.get("command", ""):
plugins/devops/python-tools/skills/claude-agent-sdk/SKILL.md · 564 lines

How it starts

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

Claude Agent SDK

Build production-ready applications using the Claude Agent SDK for Python.

SDK Version: This skill targets claude-agent-sdk>=0.1.6 (Python)

Overview

This skill provides patterns, examples, and best practices for building SDK applications that orchestrate Claude agents.

Quick Start

Copy the template and customize:

cp assets/sdk-template.py my-app.py
# Edit my-app.py - customize agents and workflow
chmod +x my-app.py
./my-app.py

The template includes proper uv script headers, agent definitions, and async patterns.

Choosing Between query() and ClaudeSDKClient

The SDK provides two ways to interact with Claude: the query() function for simple one-shot tasks, and ClaudeSDKClient for continuous conversations.

Quick Comparison

Feature query() ClaudeSDKClient
Conversation memory No - each call is independent Yes - maintains context across queries
Use case One-off tasks, single questions Multi-turn conversations, complex workflows
Complexity Simple - one function call More setup - context manager pattern
Hooks support No Yes
Custom tools No Yes
Interrupts No Yes - can interrupt ongoing operations
Session control New session each time Single persistent session

Important: Hooks and custom tools (SDK MCP servers) are only supported with ClaudeSDKClient, not with query(). If you need hooks or custom tools, you must use ClaudeSDKClient.

Note on Async Runtimes: The SDK works with both asyncio and anyio. The official SDK examples prefer anyio.run() for better async library compatibility, but asyncio.run() works equally well. Use whichever fits your project's async runtime.

When to Use query()

Use query() for simple, independent tasks where you don't need conversation history:

import anyio  # or: import asyncio
from claude_agent_sdk import query, ClaudeAgentOptions

async def analyze_file():
    """One-shot file analysis - no conversation needed."""
    options = ClaudeAgentOptions(
        system_prompt="You are a code analyzer",
        allowed_tools=["Read", "Grep", "Glob"],
        permission_mode="acceptEdits"
    )

    async for message in query(
        prompt="Analyze /path/to/file.py for bugs",
        options=options
    ):
        print(message)

anyio.run(analyze_file)  # or: asyncio.run(analyze_file())

Read the full file on GitHub · 564 lines

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. 11d ago First seen · 564 lines · 35 tokens per session scan C 087d30045b8e

Subscribe to this mod's changes

claude-agent-sdk is a skill published in the GitHub repository basher83/lunar-claude (23 stars, last pushed yesterday), licensed MIT. It adds 35 tokens to every session and 3,793 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

local-ai-agents

Build local-first AI agents that run entirely on a developer workstation with Microsoft Foundry Local and Qwen function-calling models. Covers Small Language Models (SLMs), the OpenAI-compatible local endpoint, sandboxed local tools, local RAG with Chroma, local MCP servers, hybrid cloud/local routing, and the…

microsoft/ai-agents-for-beginners · 200 tokens

next-cache-components-adoption

Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…

vercel/next.js · 95 tokens

insight-error-page

Write or audit an insight-kind error page for the Next.js dev overlay. Use when creating a new errors/ .mdx page, auditing an existing one, or checking that a page matches the framework fix cards. Covers page structure, title alignment, FixCard cards with Copy prompt button, code snippets, terminology verification…

vercel/next.js · 83 tokens

next-cache-components-optimizer

Drive a Next.js route to instant navigation by setting up an agentic loop, under Cache Components / PPR, on initial load (hard navigation) and client-side navigation (soft navigation). Encode the goal as a failing @next/playwright instant() e2e and work it to green, one verified route at a time; the shipped test then…

vercel/next.js · 170 tokens

next-partial-prefetching-adoption

Turn on Partial Prefetching in a Next.js app and work through the insights it surfaces. Use when the user wants to enable or adopt Partial Prefetching, flip the partialPrefetching flag, opt routes in with export const prefetch = 'partial', audit Link prefetch={true} behavior, preserve existing prefetched UI with…

vercel/next.js · 103 tokens