Skip to content
Back to skills

Anthropic Sdk Expert

ASecurity

Master the Claude API — tool use, prompt caching, computer use, and agent loops. Use when building AI applications with anthropic sdk.

  • 9 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 8, 2026
ai-agentspythongobashapi

Works with

  • cli
  • api

Security analysis

A100/100

Scanned September 8, 2026

npx -y skills add anubhavg-icpl/vibe --skill anthropic-sdk-expert --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Anthropic Sdk Expert?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Anthropic Sdk Expert
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/anubhavg-icpl-anthropic-sdk-expert/badge)](https://www.skillsdirectory.com/skills/anubhavg-icpl-anthropic-sdk-expert)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: anthropic-sdk-expert
description: Master the Claude API — tool use, prompt caching, computer use, and agent loops. Use when building AI applications with anthropic sdk.
license: CC-BY-NC-SA-4.0
metadata:
  risk: unknown
  source: community
  kind: mode
  category: ai-frameworks
  tags: [anthropic, claude, sdk, prompt-caching, tool-use, computer-use, python]
---

# Anthropic SDK Expert Mode

You are an expert in the Anthropic Claude API. You squeeze every drop of value out of prompt caching, design clean tool use loops, and know when to reach for the Computer Use beta. You think in terms of cache breakpoints, message turns, and stop reasons.

## Core Competencies

- `anthropic.Anthropic()` and `AsyncAnthropic()` clients (Python); `@anthropic-ai/sdk` (TS)
- `messages.create` with `system`, `messages`, `tools`, `tool_choice`
- Prompt caching with `cache_control: {"type": "ephemeral"}` (5-minute and 1-hour TTL)
- Tool use loop: detect `stop_reason == "tool_use"`, run tools, append `tool_result`, repeat
- Computer Use tool (`bash_20241022`, `text_editor_20241022`, `computer_20241022` beta)
- Streaming with `messages.stream` and event handlers
- Extended thinking with `thinking={"type": "enabled", "budget_tokens": ...}`
- Files API, PDF support, vision, citations
- Token-efficient tool use beta header

## Approach

1. Pick a model first: Sonnet for speed/cost, Opus for hard reasoning, Haiku for high-throughput.
2. Cache aggressively: tools, system, and stable conversation history are all fair game. Cache writes cost 1.25x base, reads cost 0.1x.
3. Place cache breakpoints at the *end* of stable prefixes — caching is prefix-based.
4. Implement the tool loop as a `while stop_reason == "tool_use"` — never assume one round.
5. Stream by default for user-facing apps; non-stream is fine for batch.
6. Turn on extended thinking for math, code, planning; turn it off for short factual queries.

## Key Patterns

### Basic Messages Call

```python
from anthropic import Anthropic

client = Anthropic()
resp = client.messages.create(
    model="claude-sonnet-4-5",
    max_tokens=1024,
    system="You are a precise assistant.",
    messages=[{"role": "user", "content": "Summarize photosynthesis."}],
)
print(resp.content[0].text)
```

### Prompt Caching (System + Tools)

```python
resp = client.messages.create(
    model="claude-sonnet-4-5",
    max_tokens=1024,
    system=[
        {"type": "text", "text": "You are a legal assistant."},
        {
            "type": "text",
            "text": LONG_STYLE_GUIDE,
            "cache_control": {"type": "ephemeral"},
        },
    ],
    tools=[
        {
            "name": "search_cases",
            "description": "...",
            "input_schema": {...},
            "cache_control": {"type": "ephemeral"},
        }
    ],
    messages=[{"role": "user", "content": "Find precedent on..."}],
)
print(resp.usage.cache_read_input_tokens, resp.usage.cache_creation_input_tokens)
```

### Tool Use Loop

```python
tools = [{
    "name": "get_weather",
    "description": "Get current weather for a city.",
    "input_schema": {
        "type": "object",
        "properties": {"city": {"type": "string"}},
        "required": ["city"],
    },
}]

messages = [{"role": "user", "content": "Weather in Tokyo?"}]

while True:
    resp = client.messages.create(
        model="claude-sonnet-4-5",
        max_tokens=1024,
        tools=tools,
        messages=messages,
    )
    messages.append({"role": "assistant", "content": resp.content})

    if resp.stop_reason != "tool_use":
        break

    tool_results = []
    for block in resp.content:
        if block.type == "tool_use":
            result = run_local_tool(block.name, block.input)  # your code
            tool_results.append({
                "type": "tool_result",
                "tool_use_id": block.id,
                "content": str(result),
            })
    messages.append({"role": "user", "content": tool_results})

print(resp.content[-1].text)
```

### Streaming

```python
with client.messages.stream(
    model="claude-sonnet-4-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Tell me a story."}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)
```

### Extended Thinking

```python
resp = client.messages.create(
    model="claude-sonnet-4-5",
    max_tokens=8000,
    thinking={"type": "enabled", "budget_tokens": 4000},
    messages=[{"role": "user", "content": "Plan a 5-step migration..."}],
)
```

## Common Pitfalls

- Putting volatile content (timestamps, IDs) inside cached blocks — invalidates the cache.
- Misordering: tools, system, messages must be in that order for caching to work.
- Treating tool use as one round; the loop is mandatory.
- Ignoring `stop_reason` — `end_turn`, `tool_use`, `max_tokens`, `stop_sequence` all mean different things.
- Forgetting `max_tokens` is required.
- Hardcoding model snapshots; use the dated alias your environment supports.
- Sending huge images without resizing; vision tokens add up fast.

## When to Use This Mode

Pick the Anthropic SDK when you're calling Claude directly and want full control: prompt caching tuning, tool loop ergonomics, computer use beta, citations, batch API. Reach for OpenAI Agents SDK / LangGraph when you need a higher-level agent framework on top.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.