Claude Official Skill: claude-api
Build apps with the Claude API or Anthropic SDK. TRIGGER when: code imports `anthropic`/`@anthropic-ai/sdk`/`claude_agent_sdk`, or user asks to use Claude API, Anthropic SDKs, o...
What it is
The claude-api skill is an official Claude Code skill maintained by Anthropic. It activates automatically when your code imports anthropic, @anthropic-ai/sdk, or claude_agent_sdk, and provides Claude Code with the knowledge to build LLM-powered applications correctly. The skill covers prompt caching, streaming, tool use, vision, and the managed agents API.
This skill targets developers building production applications on the Claude API who want Claude Code to generate correct, idiomatic SDK code rather than guessing at API shapes.
How it saves time or tokens
Without this skill, Claude Code may generate outdated or incorrect API calls for Anthropic-specific features like prompt caching or extended thinking. The skill injects current API patterns so generated code works on first run. It also teaches Claude Code to use prompt caching by default, which can reduce token costs by up to 90% for repeated prefixes.
How to use
- Install the skill in Claude Code:
claude skill install anthropics/skills/claude-api
- Or manually place the skill file:
mkdir -p .claude/skills/claude-api
# Copy SKILL.md content to .claude/skills/claude-api/SKILL.md
- Start coding with the Claude API -- the skill activates automatically:
import anthropic
client = anthropic.Anthropic()
message = client.messages.create(
model='claude-sonnet-4-20250514',
max_tokens=1024,
messages=[{'role': 'user', 'content': 'Hello'}]
)
print(message.content[0].text)
Example
import anthropic
client = anthropic.Anthropic()
# Streaming with tool use
with client.messages.stream(
model='claude-sonnet-4-20250514',
max_tokens=1024,
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?'}]
) as stream:
for text in stream.text_stream:
print(text, end='', flush=True)
Related on TokRepo
- AI tools for coding -- Other developer tools and coding assistants
- Prompt library -- Curated prompts and skill files for AI coding tools
Common pitfalls
- Forgetting to set the ANTHROPIC_API_KEY environment variable before running -- the SDK throws a generic error that does not clearly indicate the missing key
- Using an outdated model identifier; always check the current model names in the Anthropic docs as they change with new releases
- Not enabling prompt caching for repeated system prompts, which wastes tokens on every request
Frequently Asked Questions
The skill triggers automatically when Claude Code detects imports of anthropic, @anthropic-ai/sdk, or claude_agent_sdk in your codebase. You can also invoke it manually. Once active, it provides Claude Code with current API patterns, model names, and best practices.
Yes. The skill covers both the Python SDK (anthropic) and the TypeScript SDK (@anthropic-ai/sdk). It detects your project language and provides the appropriate code patterns and import styles.
Prompt caching lets you mark portions of your prompt as cacheable. The API stores these portions and reuses them across requests, reducing input token costs by up to 90% for repeated system prompts or context. The skill teaches Claude Code to use cache_control blocks by default.
Yes. The skill includes knowledge of the Claude Agent SDK and managed agents API. It covers patterns for tool handoffs, agent orchestration, and the TeammateTool interface for multi-agent coordination.
Yes. The claude-api skill is from the official anthropics/skills repository on GitHub, maintained by the Claude Code team. It is updated as the API evolves to reflect current model names, parameters, and features.
Citations (3)
- Anthropic Skills GitHub— Official Claude Code skill from Anthropic skills repository
- Anthropic Prompt Caching Docs— Prompt caching reduces input token costs by up to 90%
- Anthropic API Reference— Claude API supports streaming, tool use, and vision
Related on TokRepo
Source & Thanks
Created by Anthropic. Licensed under MIT. anthropics/skills
Discussion
Related Assets
Claude-Flow — Multi-Agent Orchestration for Claude Code
Layers swarm and hive-mind multi-agent orchestration on top of Claude Code with 64 specialized agents, SQLite memory, and parallel execution.
ccusage — Real-Time Token Cost Tracker for Claude Code
CLI that reads ~/.claude logs and breaks down Claude Code token spend by day, session, and project — pluggable into your statusline.
SuperClaude — Workflow Framework for Claude Code
Adds 16+ slash commands, 9 cognitive personas, and a smart flag system to Claude Code in one pipx install.