一键导入
claude-agent-dev
Claude Agent SDK patterns and best practices
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Claude Agent SDK patterns and best practices
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Generate a structured pre-consultation patient briefing. Use when the physician asks for a briefing, a pre-consultation summary, or sends /briefing.
Search the live web or read a specific web page for recency-sensitive clinical information — drug recalls, newly published guidance, FDA/EMA safety communications — that the local clinical guidelines corpus does not cover. Use when the physician asks to "search the web", "look up the latest", or asks about something the guidelines search returned no results for.
Code review and refactoring guidelines
FastAPI backend patterns for AI Doctor Assistant
React frontend development patterns for AI Doctor Assistant
Architecture guidance for AI Doctor Assistant
| name | claude-agent-dev |
| description | Claude Agent SDK patterns and best practices |
uv add claude-agent-sdk
Tools are deterministic Python functions the agent can call:
from claude_agent_sdk import tool, create_sdk_mcp_server
@tool("tool_name", "Description of what it does", {"param": str})
async def my_tool(args: dict) -> dict:
result = do_something(args["param"])
return {
"content": [{
"type": "text",
"text": json.dumps(result)
}]
}
# Register tools as MCP server
tools_server = create_sdk_mcp_server(
name="my_tools",
version="1.0.0",
tools=[my_tool]
)
When referencing tools in allowed_tools:
"mcp__<server_name>__<tool_name>"
# Example: "mcp__briefing__fetch_patient"
Use JSON schema for validated output:
from claude_agent_sdk import ClaudeAgentOptions
options = ClaudeAgentOptions(
output_format={
"type": "json_schema",
"schema": {
"type": "object",
"properties": {
"result": {"type": "string"}
},
"required": ["result"]
}
}
)
from claude_agent_sdk import HookMatcher
async def log_hook(input_data, tool_use_id, context):
print(f"Tool called: {input_data.get('tool_name')}")
return {}
options = ClaudeAgentOptions(
hooks={
"PreToolUse": [HookMatcher(hooks=[log_hook])],
"PostToolUse": [HookMatcher(hooks=[log_hook])]
}
)
query() - One-off task, returns resultClaudeSDKClient - Continuous conversation with statefrom claude_agent_sdk import query
async for message in query(prompt="Do something", options=options):
if hasattr(message, "structured_output"):
return message.structured_output
NEVER call real LLM in tests. Always mock:
@pytest.fixture
def mock_agent_response():
return {"result": "mocked"}
async def test_agent(mock_agent_response, mocker):
mocker.patch("claude_agent_sdk.query", return_value=[mock_agent_response])
# ... test logic
from langfuse import Langfuse
langfuse = Langfuse()
async def langfuse_hook(input_data, tool_use_id, context):
langfuse.trace(
name=f"tool:{input_data.get('tool_name')}",
input=input_data.get('tool_input')
)
return {}