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.
npx skills add miles990/claude-software-skills --skill claude-code-sdkgit clone --depth 1 https://github.com/miles990/claude-software-skillsWrote 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.
[](https://agentmods.dev/skills/miles990/claude-software-skills/claude-code-sdk)<a href="https://agentmods.dev/skills/miles990/claude-software-skills/claude-code-sdk"><img src="https://agentmods.dev/badge/skills/miles990/claude-software-skills/claude-code-sdk.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00020 | $0.03887 |
| Opus 5 | $0.00010 | $0.01944 |
| Sonnet 5 | $0.00004 | $0.00777 |
| Haiku 4.5 | $0.00002 | $0.00389 |
Grade A, and why
claude-code-sdk scanned grade A with 0 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 8d 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.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 513 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Claude Code SDK Integration
Overview
Claude Code SDK (claude-code-sdk) 是 Anthropic 官方提供的 Python 套件,用於在應用程式中整合 Claude AI Agent 功能。它支援 OAuth 認證(透過 claude login)和 API Key 認證,讓開發者可以利用 Claude Max/Pro 訂閱或 API 計費方案。這個 SDK 是建立 AI-powered 應用程式的關鍵工具,特別適合需要程式碼生成、檔案操作、或多輪對話的場景。
Key Concepts
認證方式
Description: Claude Code SDK 支援兩種認證方式 Key Features:
- OAuth 認證: 使用
claude login後存儲在~/.claude/的憑證 - API Key 認證: 透過
ANTHROPIC_API_KEY環境變數
Use Cases:
- OAuth:個人開發、有 Max/Pro 訂閱的用戶
- API Key:生產環境、需要計量計費的服務
SDK 核心 API
Description: query() 函數是主要的非同步介面
Key Features:
- 非同步迭代器回傳訊息
- 支援 streaming 和完整回應
- 可配置工具權限和執行限制
Use Cases: 程式碼生成、檔案操作、研究任務、唯讀分析
工具類型 (ToolType)
Description: SDK 支援多種內建工具 Key Features:
READ,WRITE,EDIT- 檔案操作BASH- 終端命令執行GLOB,GREP- 檔案搜尋WEB_FETCH- 網頁抓取
Best Practices
- 雙重認證檢查
- 同時支援 OAuth 和 API Key
- 優先使用 OAuth(免費使用 Max/Pro 配額)
- API Key 作為後備方案
def check_auth_status() -> dict:
status = {
'api_key_set': bool(os.environ.get('ANTHROPIC_API_KEY')),
'oauth_logged_in': False,
}
# 檢查 OAuth 登入狀態
claude_dir = os.path.expanduser('~/.claude')
if os.path.exists(claude_dir):
auth_files = ['credentials.json', 'settings.json', '.credentials.json']
for auth_file in auth_files:
if os.path.exists(os.path.join(claude_dir, auth_file)):
status['oauth_logged_in'] = True
break
# 只需要其中一種認證
status['auth_available'] = status['api_key_set'] or status['oauth_logged_in']
return status
- 增加 Buffer Size
- 預設 buffer 太小,處理大型回應會出錯
- 建議增加到 50MB
try:
from claude_code_sdk._internal.transport import subprocess_cli
subprocess_cli._MAX_BUFFER_SIZE = 50 * 1024 * 1024 # 50MB
except Exception as e:
print(f"Failed to patch SDK buffer size: {e}")
- 使用 Singleton Pattern
- 避免重複初始化
- 共享狀態和配置
_claude_service: Optional['ClaudeCodeService'] = None
def get_claude_code() -> 'ClaudeCodeService':
global _claude_service
if _claude_service is None:
_claude_service = ClaudeCodeService()
return _claude_service
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.
- 8d ago First seen · 513 lines · 20 tokens per session scan F 58501bf8aee8
claude-code-sdk is a skill published in the GitHub repository miles990/claude-software-skills (20 stars, last pushed 7mo ago), licensed MIT. It adds 20 tokens to every session and 3,887 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
fastapi-patterns
FastAPI production patterns — routing, dependency injection, background tasks, streaming, error handling, and async. Use when building or reviewing a FastAPI service.
fastapi-expert
Expert-level FastAPI development for high-performance Python APIs with async support. Use when the user mentions Python, API, async, REST, OpenAPI, or Pydantic, or when the task involves FastAPI Features.
fastapi-microservices-development
Comprehensive guide for building production-ready microservices with FastAPI including REST API patterns, async operations, dependency injection, and deployment strategies.
accelerate
Run PyTorch training across GPUs with minimal changes.
jupyter-notebook
Iterative Python via live Jupyter kernel (hamelnb).
temporal-python-testing
Test Temporal workflows with pytest, time-skipping, and mocking strategies. Covers unit testing, integration testing, replay testing, and local development setup. Use when implementing Temporal workflow tests or debugging test failures.