anthropics/skills · skills/claude-api/SKILL.md
claude-api
“Anthropic's own Claude API reference: precise and current, but a 28k-token tome that fires on any LLM task”
What it does
An official reference for writing code against the Claude API and Anthropic SDKs. It covers model IDs, prices, thinking, caching, tool use, Managed Agents and cloud clients. Bare subcommands (migrate, cost-optimize, build-eval and others) run guided workflows.
- When the agent uses it
- Whenever a prompt names Claude or Anthropic, asks about LLM pricing or model choice, or is any LLM-shaped coding task with no other provider in sight.
- Who it is for
- For developers building on the Claude API who want exact, current SDK usage. Not for OpenAI or Gemini shops, or anyone short on context budget.
- What it costs
- 420 lines, about 28k tokens once the agent loads it.
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file).
What it tells the agent to do
- Grep the project for other-provider markers; if any are found, stop and ask before writing Claude code
- Detect the project language from its files, and ask the user if it is ambiguous
- Pick the surface: a single call, a workflow, Tool Runner, or Managed Agents
- Write code with the official SDK from documented bindings only, defaulting to claude-opus-5-5, adaptive thinking and streaming
- If ANTHROPIC_API_KEY is unset, run `ant auth status` before asking the user for a key
- For a bare subcommand, read the linked guide (e.g. model-migration.md) and execute it step by step
Lines worth reading
Straight from the file, with why each one matters.
line 5don't skip because it "looks like a one-liner
The trigger argues with the agent in advance about skipping it. That is pushy, and it tells you how broadly this skill wants to load.
line 227that just means they were released after your training data cutoff - they are real models
A neat fix for a real problem: it stops the model from 'correcting' new model IDs it doesn't recognize.
line 25don't reach for `requests`/`fetch` in a Python or TypeScript project just because it feels lighter
A sharp, specific rule that blocks a common shortcut models take.
line 200Never downgrade for cost - that's the user's decision, not yours.
A firm stance on model choice. It respects the user, but it also locks every default to the Opus tier.
line 62every run that exercises the model spends real money, so get the user's approval first
A good guard: workflows that run the model ask before spending.
Watch out for
- Medium
Tells the agent to look up local credentials and print a live OAuth access token instead of asking the user, which puts the token in the agent's context.
line 237When you need to call the API and `ANTHROPIC_API_KEY` is unset, don't ask the user for a key.
- Medium
The trigger is so broad that about 28k tokens load for almost any LLM-flavored task, even tiny ones, crowding out other context.
line 5OR the task is LLM-shaped with provider unstated
- Low
Hard-codes the Opus default and turns on server-side fallbacks by default, so generated code may cost more than the user expects.
line 200This is non-negotiable.
- Low
Fetches SDK repos and docs from the web at write time, so output depends on outside content and network access.
line 27WebFetch the relevant SDK repo from `shared/live-sources.md` before writing code
The scorecard
- TriggerSays when to use it5/10
Rich keywords, but over the 1,024-character limit and far too broad.
- FocusOne clear job5/10
One domain, but a reference plus six workflows bundled together.
- LeanLight to load2/10
About 105k characters and 28k tokens; huge tables that belong in reference files.
- ConcreteSteps you can follow8/10
Exact model IDs, parameters, per-language snippets and commands throughout.
- SafeSafe to run6/10
Prints auth tokens without asking; otherwise asks before spending money.
What it does well
- The API-drift table names exactly where a stale training prior goes wrong and what replaced it.
- Per-language tables give exact client classes and beta flags, so the agent has no reason to guess SDK names.
- Workflows that spend money or edit files ask for scope and approval first.
How it could be better
Cut the description under 1,024 characters
It breaks the standard's cap, and the long trigger lists bury the key use.
Adddescription: Write and debug code that calls the Claude API or Anthropic SDKs (model IDs, pricing, thinking, streaming, tool use, caching, Managed Agents, migration). Use when the request names Claude, Anthropic, Opus, Sonnet, Haiku or `anthropic` imports, or asks which LLM to use. Skip when the project uses OpenAI, Gemini or another provider.
Move per-model notes into reference files
Model sections, thinking tables and provider clients take most of the 28k tokens and are only needed now and then.
Add## Models Default: `<default model id>`. For per-model behavior, thinking rules and pricing, read `shared/models.md`. For cloud clients, read `shared/provider-clients.md`.
Ask before reading or printing credentials
Printing an OAuth token into the agent's context should be the user's call.
AddIf `ANTHROPIC_API_KEY` is unset, tell the user and offer to run `ant auth status`. Only run `ant auth print-credentials --access-token` after the user agrees.
Narrow the provider-unstated trigger
Loading the full reference for every 'summarize this text' task wastes context.
AddUse this skill for LLM tasks with no provider named only when the user is writing code that will call a model API, not for one-off text work.
Kin reviews against Anthropic’s Extend Claude with skills and agentskills.io’s the Agent Skills standard. It reads SKILL.md only, so a script beside it can still do things the file does not say.