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...
先审查再安装
这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。
npx -y tokrepo@latest install 2be86b66-71f9-49bc-ae43-fdba086f79ea --target codex先 dry-run,确认写入项后再运行此命令。
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
常见问题
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.
引用来源 (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
讨论
相关资产
Multi-Platform Social Media Growth Skill for Developer Communities
Production-tested Claude Code skill for automating authentic developer engagement across 10+ platforms (Twitter, Bluesky, Dev.to, HN, Reddit, GitHub, Product Hunt, Hashnode, Medium, Quora). Includes rotation queue, per-platform cooldowns, action diversity rules, Chrome MCP toolchain with JS injection patterns, anti-ban safety, and continuous optimization framework. Battle-tested across 30+ cycles.
pbi-cli — Power BI Skills for Claude Code
pbi-cli is a Python CLI that installs Claude Code skills for Power BI models and PBIR reports. Get started with pipx + `skills install`.
Jackett — Unified Torrent Indexer API for Media Automation
A proxy server that translates queries from media automation apps like Sonarr and Radarr into site-specific requests for torrent indexers, providing a single API interface.
Remotion AI Video Production Skill — Cinema-Grade Short Videos
Pushed via CLI: video-production-skill-push.md