claude-api

Build Claude API clients; not Agent SDK, other providers, or read-only review.

SKILL.md

GitHub

Claude API Integration

Implement the requested Claude API behavior using the project's exact SDK, platform and model constraints. Verify API shapes from primary sources and installed bindings. Do not import a cached model catalog, pricing table or broad provider preference into another project.

Adapted and substantially rewritten from Anthropic's claude-api skill at commit dbd4588f9e1033efb41dad4bef2f7947c8993d44. This modified file narrows triggers, separates agent products, removes fixed model/cost mandates, and adds evidence and side-effect boundaries. See LICENSE.anthropic-skills and NOTICE.anthropic-skills.

Route precisely

  • Use for creating or changing an explicitly requested Claude API/Anthropic SDK integration, structured response boundary, tool loop or streaming client. Python and TypeScript bindings are the initial supported authoring scope.
  • Do not activate merely because a task mentions AI, RAG, MCP, an agent, pricing or natural-language processing without choosing Anthropic. Preserve another provider or a provider-neutral interface.
  • Use code-review for a read-only diff review, vet-dependency for package adoption, deprecation-and-migration for a live contract migration and prove-checks for whether a green integration check detected its target.
  • Distinguish the Messages API/Tool Runner, Managed Agents, and Claude Agent SDK before writing code. This skill does not author Claude Agent SDK (query, built-in filesystem/Bash tools, hooks, sessions) code; use that product's official documentation without substituting a Messages tool loop.
  • For another SDK language, obtain its exact bindings from official docs/source and state the missing bundled coverage. Do not translate Python/TypeScript method names by intuition.

Establish the target

  1. Read repository instructions, working-tree state, manifests/lockfiles, existing clients, request builders and tests. Identify the owning package and preserve unrelated work.
  2. Record provider/platform, exact SDK/package version, supported runtime, endpoint surface, authentication mechanism, requested model or repository model policy, and the observable result. Distinguish direct Claude API from partner platforms and their feature availability.
  3. Choose the smallest surface matching the requested ownership: a call, bounded tool workflow, or explicitly requested managed service. Read references/sdk-contracts.md and the relevant primary sources in references/live-sources.md.
  4. Verify needed imports, helper signatures, field names and availability against installed declarations/source or release-matched official SDK docs. Record the evidence revision/date. Do not treat upstream main as the installed release. If evidence conflicts or is inaccessible, mark the binding unverified and retain an established supported path or resolve the missing contract before relying on it.

Implement the boundary

  • Preserve the selected provider, SDK and project model/cost policy. Resolve a required model choice from repository configuration or the user; do not hardcode a premium default, change the host agent's model or silently switch providers.
  • Use the project's official SDK when that is its chosen integration. Raw HTTP remains valid for explicitly requested HTTP interfaces or existing justified transports; do not rewrite them solely to match a preference.
  • For schema-constrained output, use supported native Structured Outputs and the SDK's typed parsing/validation helper when available. The Messages wire field is output_config.format; helper parameter names can differ. Verify their exact signature rather than globally replacing output_format in parsing helpers.
  • For tool inputs, use supported strict: true schemas when required, and validate data at the actual execution boundary. Schema compliance does not authorize an operation, validate business invariants, establish tenant ownership or make tool output trustworthy.
  • Prefer an installed supported Tool Runner for a simple custom-tool loop when it fits the contract. A manual loop is valid for required control; preserve tool-call IDs, structured content, error results and continuation semantics. Bound turns, tokens, retries, concurrency and side effects.
  • Accumulate streams with the SDK's supported helpers or explicit typed events. Handle incomplete output, refusals, disconnects, cancellation and non-success stop reasons before consuming parsed results or executing tools. Never execute partially streamed arguments as a complete call.
  • Distinguish retryable transport/rate-limit failures from invalid requests and authentication failures. Account for SDK retries before adding another retry loop. Retried tool execution needs an idempotency policy; do not assume a request timeout means no side effect occurred.
  • Keep credentials in the project's approved configuration and out of code, logs, fixtures and tool-visible text. Treat retrieved content and tool results as untrusted input. Do not provision managed resources, expose command/file tools or broaden network/permissions without that requested scope.

Verify without overstating

Run configured targeted type checks and offline tests first. Check request serialization, exact schema fields, stop/error branches, tool-result correlation, cancellation, malformed/truncated data and authorization with bounded fixtures. Mocks establish client behavior, not server support.

Inspect dependencies and test side effects before execution. A real API check transmits data and spends money: run it only within the user's authorized payload and budget; otherwise report it unrun. Do not obtain credentials, install tooling or create a sandbox just to clear a verification gap. Compile/import success does not prove remote feature availability or isolation.

Report

Return the implemented contract, exact SDK/runtime/platform/model evidence, files/dependency changes, observed checks and their limits. Distinguish offline fixture results from real API evidence, and name any unsupported or unverified behavior. Do not claim automatic freshness from a version string or cached documentation.