last update
May 27, 2026
license
MITv1.0.0
format
SKILL.md
- Install
// Downloads SKILL.md into ~/.claude/skills/claude-api-helper/
$ curl -fsSL --create-dirs -o ~/.claude/skills/claude-api-helper/SKILL.md https://claudeskil.com/skills/claude-api-helper/SKILL.md - Invoke
// Inside Claude Code, type the skill name as a slash command
> /claude-api-helper scaffold a typed REST endpoint - Or just ask
// Claude loads the skill by itself when a request matches its description
> scaffold a typed REST endpoint
- name:
- Claude API Helper
- slug:
- claude-api-helper
- version:
- v1.0.0
- license:
- MIT
- author:
- @chiragthummar16
- categories:
- tags:
- #claude-api#anthropic-sdk#prompt-caching#tool-use#streaming
- description:
Build production-grade Claude API apps with prompt caching, tool use, streaming, and model migration baked in.
// What you can do with it
- Prompt caching — enforces the prefix-match invariant: stable content first (tools → system → messages), cachecontrol: {type: "ephemeral"} on the last shared block, volatile content (timestamps, UUIDs)
- Tool use — client.beta.messages.toolRunner with betaZodTool (TS) or @betatool (Python) for the automatic loop, or a manual loop that appends full response.content and handles stopreason: "pauseturn".
- Streaming — .stream() with .getFinalMessage() / .getfinalmessage(), the contentblockdelta event taxonomy, and a default of max_tokens ~64000 for streamed requests (~16000 non-streaming to dodge HTTP t
- Model migration — confirms scope first, classifies each file (caller vs. registry vs. opaque string), then applies the per-version breaking-change checklist: budgettokens → thinking: {type: "adaptive"
README.md
Claude API Helper
A coding-assistant skill that makes you write correct Claude API code instead of plausible-looking code that 400s. It carries the current model catalog, the real request shapes for prompt caching, tool use, streaming, and structured outputs, and a step-by-step migration guide between model versions. For anyone building on the Anthropic SDK (Python, TypeScript, Go, Java, Ruby, C#, PHP) or raw HTTP who is tired of hallucinated parameters and stale defaults.
When to use it
- Wiring up
messages.create/messages.streamand unsure of the current parameter shape - Adding prompt caching and your
cache_read_input_tokenskeeps coming back zero - Setting up tool use (tool runner vs. manual loop), server-side tools, or structured outputs
- Migrating code from Sonnet 4.5 → 4.6, or Opus 4.6 → 4.7 → 4.8, without breaking on removed parameters
- Debugging refusals,
pause_turn, truncated output, or "why won't my cache hit"
What it does
It reads your project to detect the language, then applies accurate, version-aware patterns:
- Prompt caching — enforces the prefix-match invariant: stable content first (
tools→system→messages),cache_control: {type: "ephemeral"}on the last shared block, volatile content (timestamps, UUIDs) after the last breakpoint. It audits for silent invalidators likeDate.now()in the system prompt and verifies viausage.cache_read_input_tokens. - Tool use —
client.beta.messages.toolRunnerwithbetaZodTool(TS) or@beta_tool(Python) for the automatic loop, or a manual loop that appends fullresponse.contentand handlesstop_reason: "pause_turn".strict: truegoes on the tool, nottool_choice; paralleltool_resultblocks go in one user message. - Streaming —
.stream()with.getFinalMessage()/.get_final_message(), thecontent_block_deltaevent taxonomy, and a default ofmax_tokens~64000 for streamed requests (~16000 non-streaming to dodge HTTP timeouts). - Model migration — confirms scope first, classifies each file (caller vs. registry vs. opaque string), then applies the per-version breaking-change checklist:
budget_tokens→thinking: {type: "adaptive"}, removedtemperature/top_p/top_k, dropped assistant prefills, GA beta-header cleanup.
Usage example
curl -fsSL --create-dirs -o ~/.claude/skills/claude-api-helper/SKILL.md https://claudeskil.com/skills/claude-api-helper/SKILL.md
// What the skill steers you toward — adaptive thinking, effort, cached prefix
const res = await client.messages.create({
model: "claude-opus-4-8",
max_tokens: 16000,
thinking: { type: "adaptive", display: "summarized" },
output_config: { effort: "high" },
system: [{ type: "text", text: BIG_PROMPT, cache_control: { type: "ephemeral" } }],
messages: [{ role: "user", content: "..." }],
});
Tips & gotchas
- On Opus 4.8/4.7 and Fable 5,
budget_tokensand sampling params (temperature,top_p,top_k) 400 — use adaptive thinking +output_config.effort. On Fable 5, eventhinking: {type: "disabled"}400s; omit the field. displaydefaults to"omitted"on 4.7/4.8 — your streamed thinking text will be empty unless you set"summarized".- Minimum cacheable prefix is model-dependent (4096 tokens on Opus 4.8, 2048 on Sonnet 4.6) — shorter prefixes silently won't cache.
- Use
count_tokensagainst the exact model, nevertiktoken(it undercounts Claude by 15–20%).
FAQ
Does it support providers other than the first-party API? Yes — it has the dedicated client classes for Amazon Bedrock (AnthropicBedrockMantle, anthropic.-prefixed IDs), Vertex AI (bare IDs), Claude Platform on AWS, and Foundry, plus a per-feature availability table.
Will it touch my OpenAI/Gemini code? No. It detects non-Anthropic providers and stops rather than rewriting provider-neutral code with Anthropic calls.
Can it migrate a whole repo at once? It asks you to confirm scope first (file, directory, or list) before editing, then runs the version-by-version checklist on each caller.
$ cat reviews/