Agent skill

Claude API

by kid-sid in kid-sid/claude-spellbook

A skill your agent uses when building or debugging apps that call the Claude API — implementing tool use, streaming, vision, prompt caching, batch processing, extended thinking, or an agentic loop…

MITAuto-check passedAI & LLM Engineering

Install Claude API

skills CLI
$ npx skills add kid-sid/claude-spellbook --skill claude-api -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install kid-sid/claude-spellbook claude-api --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/kid-sid/claude-spellbook.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/claude-api .claude/skills/claude-api && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
claude-api
GitHub stars
189
Token cost
~2.7k tokens
SKILL.md length
521 words
Files
1
Skills in repo
54
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses when building or debugging apps that call the Claude API — implementing tool use, streaming, vision, prompt caching, batch processing, extended thinking, or an agentic loop…

  • Debugging apps that call the Claude API — implementing tool use
  • SKILL.md covers When to Activate, Model Selection, Python SDK and TypeScript SDK, plus 11 more sections
  • Calls pip and npm; needs ANTHROPIC_API_KEY
  • Batch processing

What it does

Claude API is an agent skill from kid-sid/claude-spellbook. Use when building or debugging apps that call the Claude API — implementing tool use, streaming, vision, prompt caching, batch processing, extended thinking, or an agentic loop with the Anthropic SDK.

Its SKILL.md is about 2.7k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in AI & LLM Engineering, covering LLM API integration and LLM cost and token optimization. It works with Anthropic API. The repository describes itself as: A curated collection of skills, prompts, and workflows that extend Claude's capabilities — your personal grimoire for AI-powered development. The licence is MIT.

When your agent uses it

  • Debugging apps that call the Claude API — implementing tool use
  • Batch processing
  • Extended thinking
  • An agentic loop with the Anthropic SDK

Example prompts

  • “/claude-api”

Requirements

  • Python 3
  • Node.js
  • A credential in ANTHROPIC_API_KEY

What it can do on your machine

Read from SKILL.md and the folder at commit a7c2ac9. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • pip
    • npm

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use pip and npm, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • ANTHROPIC_API_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Claude API loads about 2.7k tokens when it runs. Until then it costs about 53 tokens; SKILL.md has 521 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~53
When it runs · the whole SKILL.md, loaded when a task matches
~2.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from kid-sid/claude-spellbook at commit a7c2ac9, republished under its MIT licence (© kid-sid). 521 words, ~2,663 tokens.

Download SKILL.mdSave it as .claude/skills/claude-api/SKILL.md (or your agent's skills folder).
name
claude-api
description
Use when building or debugging apps that call the Claude API — implementing tool use, streaming, vision, prompt caching, batch processing, extended thinking, or an agentic loop with the Anthropic SDK.

Claude API

Build applications with the Anthropic Claude API and SDKs.

When to Activate

  • Building applications that call the Claude API
  • Code imports anthropic (Python) or @anthropic-ai/sdk (TypeScript)
  • User asks about Claude API patterns, tool use, streaming, or vision
  • Implementing agent workflows with Claude Agent SDK
  • Optimizing API costs, token usage, or latency

Model Selection

ModelIDBest For
Opus 4.1claude-opus-4-1Complex reasoning, architecture, research
Sonnet 4claude-sonnet-4-0Balanced coding, most development tasks
Haiku 3.5claude-3-5-haiku-latestFast responses, high-volume, cost-sensitive

Default to Sonnet 4 unless the task requires deep reasoning (Opus) or speed/cost optimization (Haiku). For production, prefer pinned snapshot IDs over aliases.

Python SDK

Installation
bash
pip install anthropic
Basic Message
python
import anthropic

client = anthropic.Anthropic()  # reads ANTHROPIC_API_KEY from env

message = client.messages.create(
    model="claude-sonnet-4-0",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Explain async/await in Python"}
    ]
)
print(message.content[0].text)
Streaming
python
with client.messages.stream(
    model="claude-sonnet-4-0",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Write a haiku about coding"}]
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)
System Prompt
python
message = client.messages.create(
    model="claude-sonnet-4-0",
    max_tokens=1024,
    system="You are a senior Python developer. Be concise.",
    messages=[{"role": "user", "content": "Review this function"}]
)

TypeScript SDK

Installation
bash
npm install @anthropic-ai/sdk
Basic Message
typescript
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic(); // reads ANTHROPIC_API_KEY from env

const message = await client.messages.create({
  model: "claude-sonnet-4-0",
  max_tokens: 1024,
  messages: [
    { role: "user", content: "Explain async/await in TypeScript" }
  ],
});
console.log(message.content[0].text);
Streaming
typescript
const stream = client.messages.stream({
  model: "claude-sonnet-4-0",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Write a haiku" }],
});

for await (const event of stream) {
  if (event.type === "content_block_delta" && event.delta.type === "text_delta") {
    process.stdout.write(event.delta.text);
  }
}

Tool Use

Define tools and let Claude call them:

python
tools = [
    {
        "name": "get_weather",
        "description": "Get current weather for a location",
        "input_schema": {
            "type": "object",
            "properties": {
                "location": {"type": "string", "description": "City name"},
                "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
            },
            "required": ["location"]
        }
    }
]

message = client.messages.create(
    model="claude-sonnet-4-0",
    max_tokens=1024,
    tools=tools,
    messages=[{"role": "user", "content": "What's the weather in SF?"}]
)

# Handle tool use response
for block in message.content:
    if block.type == "tool_use":
        # Execute the tool with block.input
        result = get_weather(**block.input)
        # Send result back
        follow_up = client.messages.create(
            model="claude-sonnet-4-0",
            max_tokens=1024,
            tools=tools,
            messages=[
                {"role": "user", "content": "What's the weather in SF?"},
                {"role": "assistant", "content": message.content},
                {"role": "user", "content": [
                    {"type": "tool_result", "tool_use_id": block.id, "content": str(result)}
                ]}
            ]
        )

Vision

Send images for analysis:

python
import base64

with open("diagram.png", "rb") as f:
    image_data = base64.standard_b64encode(f.read()).decode("utf-8")

message = client.messages.create(
    model="claude-sonnet-4-0",
    max_tokens=1024,
    messages=[{
        "role": "user",
        "content": [
            {"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": image_data}},
            {"type": "text", "text": "Describe this diagram"}
        ]
    }]
)

Extended Thinking

For complex reasoning tasks:

python
message = client.messages.create(
    model="claude-sonnet-4-0",
    max_tokens=16000,
    thinking={
        "type": "enabled",
        "budget_tokens": 10000
    },
    messages=[{"role": "user", "content": "Solve this math problem step by step..."}]
)

for block in message.content:
    if block.type == "thinking":
        print(f"Thinking: {block.thinking}")
    elif block.type == "text":
        print(f"Answer: {block.text}")

Prompt Caching

Cache large system prompts or context to reduce costs:

python
message = client.messages.create(
    model="claude-sonnet-4-0",
    max_tokens=1024,
    system=[
        {"type": "text", "text": large_system_prompt, "cache_control": {"type": "ephemeral"}}
    ],
    messages=[{"role": "user", "content": "Question about the cached context"}]
)
# Check cache usage
print(f"Cache read: {message.usage.cache_read_input_tokens}")
print(f"Cache creation: {message.usage.cache_creation_input_tokens}")

Batches API

Process large volumes asynchronously at 50% cost reduction:

python
import time

batch = client.messages.batches.create(
    requests=[
        {
            "custom_id": f"request-{i}",
            "params": {
                "model": "claude-sonnet-4-0",
                "max_tokens": 1024,
                "messages": [{"role": "user", "content": prompt}]
            }
        }
        for i, prompt in enumerate(prompts)
    ]
)

# Poll for completion
while True:
    status = client.messages.batches.retrieve(batch.id)
    if status.processing_status == "ended":
        break
    time.sleep(30)

# Get results
for result in client.messages.batches.results(batch.id):
    print(result.result.message.content[0].text)

Claude Agent SDK

Build multi-step agents:

python
# Note: Agent SDK API surface may change — check official docs
import anthropic

# Define tools as functions
tools = [{
    "name": "search_codebase",
    "description": "Search the codebase for relevant code",
    "input_schema": {
        "type": "object",
        "properties": {"query": {"type": "string"}},
        "required": ["query"]
    }
}]

# Run an agentic loop with tool use
client = anthropic.Anthropic()
messages = [{"role": "user", "content": "Review the auth module for security issues"}]

while True:
    response = client.messages.create(
        model="claude-sonnet-4-0",
        max_tokens=4096,
        tools=tools,
        messages=messages,
    )
    if response.stop_reason == "end_turn":
        break
    # Handle tool calls and continue the loop
    messages.append({"role": "assistant", "content": response.content})
    # ... execute tools and append tool_result messages

Cost Optimization

StrategySavingsWhen to Use
Prompt cachingUp to 90% on cached tokensRepeated system prompts or context
Batches API50%Non-time-sensitive bulk processing
Haiku instead of Sonnet~75%Simple tasks, classification, extraction
Shorter max_tokensVariableWhen you know output will be short
StreamingNone (same cost)Better UX, same price

Error Handling

python
import time

from anthropic import APIError, RateLimitError, APIConnectionError

try:
    message = client.messages.create(...)
except RateLimitError:
    # Back off and retry
    time.sleep(60)
except APIConnectionError:
    # Network issue, retry with backoff
    pass
except APIError as e:
    print(f"API error {e.status_code}: {e.message}")

Environment Setup

bash
# Required
export ANTHROPIC_API_KEY="your-api-key-here"

# Optional: set default model
export ANTHROPIC_MODEL="claude-sonnet-4-0"

Never hardcode API keys. Always use environment variables.

Red Flags

  • Not setting max_tokens explicitly — omitting it uses the SDK default which may be far too low for your use case, causing truncated responses with no error raised
  • Using client.messages.create() in a tight loop without backoff — hitting rate limits with immediate retries amplifies the problem; use the SDK's built-in retry config or tenacity with exponential backoff
  • Passing raw user input directly as the user message — prompt injection can redirect the model's behavior; sanitize or structure user input within a constrained template
  • Enabling extended thinking (budget_tokens) without raising max_tokens — thinking tokens count against max_tokens; a small max_tokens causes the request to error before the model produces output
  • Polling the Batches API in a tight while True loop with time.sleep(1) — batches can take minutes to hours; use time.sleep(30) at minimum, or a webhook/callback if available
  • Caching the Anthropic client instance across forked processes — the underlying httpx session is not fork-safe; instantiate a new client per process in multiprocessing scenarios
  • Using an alias model ID (e.g., claude-sonnet-4-0) in production — aliases can be remapped to a new model version without warning, changing behavior; pin to a dated snapshot ID for reproducible production behavior
  • Logging the full request/response payload — responses may echo back sensitive user data; log only metadata (model, token counts, stop reason), never message content
Show full SKILL.md (78 more words)Show less

Checklist

  • API key loaded from environment variable, not hardcoded
  • Model pinned to a specific version (not latest)
  • max_tokens set explicitly for every request
  • Rate limit and API errors caught and retried with backoff
  • Streaming used for long responses to avoid timeout
  • Tool schemas validated; required fields listed explicitly
  • Prompt caching headers set for repeated system prompts
  • Costs estimated before running batch or high-volume jobs
  • Response content checked for stop_reason before use
  • No sensitive data logged from request/response payloads

© kid-sid, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/claude-api of kid-sid/claude-spellbook.

Open the folder on GitHubat commit a7c2ac9

Compare with similar skills

Claude API next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Claude API compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Claude API this skillkid-sid/claude-spellbook189—~2.7kAutomated safety check: PassMIT
Claude API Developmentwarpdotdev/warp65k3 repos~8.2kAutomated safety check: PassApache-2.0
Claude APImajiayu000/claude-skill-registry6663 repos~2.1kAutomated safety check: PassMIT
AIbutterbase-ai/butterbase-skills534—~1.1kAutomated safety check: PassMIT
Claude APIterrense/LilBot-agent121—~155Automated safety check: PassNone
LLM Cost Optimizationsickn33/agentic-awesome-skills47k1 repos~2.5kAutomated safety check: PassMIT

Similar skills

  • Claude API Development

    warpdotdev/warp

    Guides building, debugging and tuning apps on the Claude API and Anthropic SDK, including prompt caching, and migrating code between Claude model versions.

    65k GitHub starsUsed in 3 repos~8.2k tokens
    AI & LLM EngineeringAuto-check passed
  • Claude API

    majiayu000/claude-skill-registry

    Anthropic Claude API patterns for Python and TypeScript. An agent skill from majiayu000/claude-skill-registry.

    666 GitHub starsUsed in 3 repos~2.1k tokens
    AI & LLM EngineeringAuto-check passed
  • AI

    butterbase-ai/butterbase-skills

    A skill your agent uses when calling the app's AI gateway from agent tools — chat completions, embeddings, listing models, configuring defaults or BYOK, reading token/cost usage

    534 GitHub stars~1.1k tokensUpdated 2 days ago
    AI & LLM EngineeringAuto-check passed
  • Claude API

    terrense/LilBot-agent

    Help with Claude/LLM API usage, models, and integration patterns.

    121 GitHub stars~155 tokensUpdated 3 mo ago
    AI & LLM EngineeringAuto-check passed
  • LLM Cost Optimization

    sickn33/agentic-awesome-skills

    Reduce LLM API and infrastructure costs through model selection, prompt caching, batching, caching, quantization, and self-hosting strategies.

    47k GitHub starsUsed in 1 repo~2.5k tokens
    AI & LLM EngineeringAuto-check passed
  • Cost Aware LLM Pipeline

    majiayu000/claude-skill-registry

    Cost optimization patterns for LLM API usage — model routing by task complexity, budget tracking, retry logic, and prompt caching.

    666 GitHub starsUsed in 6 repos~1.4k tokens
    AI & LLM EngineeringAuto-check passed

More from kid-sid/claude-spellbook

All 54 skills in this repo
  • Accessibility

    kid-sid/claude-spellbook

    A skill your agent uses when building or reviewing UI components for keyboard and screen reader compatibility, adding ARIA to custom widgets, auditing a page for WCAG AA conformance, or preparing…

    189 GitHub stars~3.2k tokensUpdated 2 mo ago
    Auto-check passed
  • Agentex

    kid-sid/claude-spellbook

    A skill your agent uses when building, wiring, or debugging an Agentex agent — choosing agent type, configuring acp.py and manifest.yaml, using adk.messages or adk.state, or resolving…

    189 GitHub stars~2.2k tokensUpdated 2 mo ago
    Auto-check: notes
  • AI Engineer

    kid-sid/claude-spellbook

    A skill your agent uses when building production LLM applications — designing RAG pipelines, choosing vector databases, implementing agent orchestration, optimizing cost, or adding AI safety…

    189 GitHub stars~3.7k tokensUpdated 2 mo ago
    Auto-check passed
  • Angular

    kid-sid/claude-spellbook

    A skill your agent uses when building or refactoring Angular applications — choosing between signals, RxJS, and NgRx for state, configuring routing with guards and lazy loading, optimizing change…

    189 GitHub stars~5k tokensUpdated 2 mo ago
    Auto-check passed
  • API Design

    kid-sid/claude-spellbook

    A skill your agent uses when designing new REST endpoints, reviewing an existing API contract, adding pagination or filtering, planning a versioning strategy, or building a public or partner-facing…

    189 GitHub stars~3.6k tokensUpdated 2 mo ago
    Auto-check passed
  • Auth

    kid-sid/claude-spellbook

    A skill your agent uses when implementing login flows, issuing or validating JWTs, setting up OAuth2/OIDC with a provider, designing role-based or attribute-based access control, securing API…

    189 GitHub stars~3.2k tokensUpdated 2 mo ago
    Auto-check passed

Works with

Questions about Claude API

What does Claude API do?

A skill your agent uses when building or debugging apps that call the Claude API — implementing tool use, streaming, vision, prompt caching, batch processing, extended thinking, or an agentic loop…. Claude API is an agent skill from kid-sid/claude-spellbook. Use when building or debugging apps that call the Claude API — implementing tool use, streaming, vision, prompt caching, batch processing, extended thinking, or an agentic loop with the Anthropic SDK.

When should I use Claude API?

Claude API fits situations like: debugging apps that call the Claude API — implementing tool use; batch processing; extended thinking; an agentic loop with the Anthropic SDK.

How do I install Claude API in Claude Code?

Run `npx skills add kid-sid/claude-spellbook --skill claude-api -a claude-code`. Or copy the skill folder (skills/claude-api in kid-sid/claude-spellbook) into .claude/skills/claude-api in your project. Claude Code loads it when a task matches its description.

How do I install Claude API in Codex?

Run `npx skills add kid-sid/claude-spellbook --skill claude-api -a codex`. Or copy the skill folder (skills/claude-api in kid-sid/claude-spellbook) into .agents/skills/claude-api in your project. Codex loads it when a task matches its description.

Can I use Claude API in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add kid-sid/claude-spellbook --skill claude-api -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/claude-api, .gemini/skills/claude-api, .github/skills/claude-api and .opencode/skills/claude-api in your project.

What does Claude API need to run?

Going by SKILL.md and its folder, Claude API needs the command-line tools its instructions call (pip and npm) and credentials named ANTHROPIC_API_KEY. Our summary lists: Python 3; Node.js; A credential in ANTHROPIC_API_KEY.

Does Claude API access the network?

SKILL.md contains no URLs. Its commands use pip and npm, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Claude API safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Claude API use?

Claude API is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Claude API use?

About 2.7k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Claude API?

Skills that share tags, products or a category with Claude API: Claude API Development (warpdotdev/warp, 65k stars), Claude API (majiayu000/claude-skill-registry, 666 stars), AI (butterbase-ai/butterbase-skills, 534 stars) and Claude API (terrense/LilBot-agent, 121 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Claude API?

kid-sid (a GitHub user) maintains it in kid-sid/claude-spellbook, which has 189 GitHub stars. The repository holds 54 skills in this directory. The repository was last updated on August 5, 2026.

Source: kid-sid/claude-spellbook on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.