Production-ready Anthropic SDK patterns — client config, retries, timeouts, Use when working with sdk-patterns patterns.

MITAuto-check passedDevelopment

Install Clade SDK Patterns

skills CLI
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill clade-sdk-patterns -a claude-code

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

GitHub CLI
$ gh skill install jeremylongshore/tons-of-skills-marketplace clade-sdk-patterns --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/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/.curated/clade-sdk-patterns .claude/skills/clade-sdk-patterns && 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
clade-sdk-patterns
GitHub stars
2.8k
Token cost
~1.6k tokens
SKILL.md length
136 words
Files
2 (incl. references)
Skills in repo
3,342
Repo updated
First seen
Licence
MIT

At a glance

Production-ready Anthropic SDK patterns — client config, retries, timeouts, Use when working with sdk-patterns patterns.

  • Works in 2 steps: TypeScript → Python
  • Working with sdk-patterns patterns
  • SKILL.md covers Overview, Client Configuration, Instructions and Output, plus 9 more sections
  • Reaches api.anthropic.com; needs ANTHROPIC_API_KEY

What it does

Clade SDK Patterns is an agent skill from jeremylongshore/tons-of-skills-marketplace. Production-ready Anthropic SDK patterns — client config, retries, timeouts, Use when working with sdk-patterns patterns. error handling, TypeScript types, and async patterns. Trigger with "anthropic sdk", "claude client setup", "anthropic typescript", "anthropic python patterns".

Its SKILL.md is about 1.6k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files, including reference files (for example `references/one-pager.md`). Compatibility notes: Designed for Claude Code

It sits in Development, covering Type safety, LLM API integration and Error handling. It works with TypeScript, Python and Anthropic API. The repository describes itself as: Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com. The licence is MIT.

When your agent uses it

  • Working with sdk-patterns patterns
  • With anthropic sdk
  • Claude client setup
  • Anthropic typescript

Example prompts

  • “anthropic sdk”
  • “claude client setup”
  • “anthropic typescript”
  • “/clade-sdk-patterns”

Requirements

  • Python 3
  • A credential in ANTHROPIC_API_KEY
  • Compatibility (from SKILL.md): Designed for Claude Code
  • Pre-approved tools (allowed-tools): Read, Write, Edit

Workflow steps

2 steps, taken from the step headings in SKILL.md.

  1. TypeScript
  2. Python

What it can do on your machine

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

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript and python).

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

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • api.anthropic.com

    Also links to:

    • platform.claude.com

    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.

  • Compatibility

    Designed for Claude Code

    From compatibility in the SKILL.md frontmatter.

Context cost

Clade SDK Patterns loads about 1.6k tokens when it runs, and up to ~2k if it reads all its reference files. Until then it costs about 75 tokens; SKILL.md has 136 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~75
When it runs · the whole SKILL.md, loaded when a task matches
~1.6k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~2k

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 jeremylongshore/tons-of-skills-marketplace at commit 80f86df, republished under its MIT licence (© jeremylongshore). 136 words, ~1,557 tokens.

Download SKILL.mdSave it as .claude/skills/clade-sdk-patterns/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
clade-sdk-patterns
description
Production-ready Anthropic SDK patterns — client config, retries, timeouts, Use when working with sdk-patterns patterns. error handling, TypeScript types, and async patterns. Trigger with "anthropic sdk", "claude client setup", "anthropic typescript", "anthropic python patterns".
allowed-tools
Read, Write, Edit
compatibility
Designed for Claude Code
version
1.1.0
license
MIT
author
Jeremy Longshore <jeremy@intentsolutions.io>
tags
saas, anthropic, claude, sdk, typescript, python

Anthropic SDK Patterns

Overview

Production patterns for the @claude-ai/sdk (TypeScript) and anthropic (Python) SDKs.

Client Configuration

Instructions

Step 1: TypeScript
typescript
import Anthropic from '@claude-ai/sdk';

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

// Full configuration
const client = new Anthropic({
  apiKey: process.env.ANTHROPIC_API_KEY,   // default: env var
  maxRetries: 3,                            // default: 2
  timeout: 60_000,                          // default: 10 minutes
  baseURL: 'https://api.anthropic.com',     // override for proxies
  defaultHeaders: {                         // custom headers
    'claude-beta': 'prompt-caching-2024-07-31',
  },
});
Step 2: Python
python
import anthropic

# Sync client
client = anthropic.Anthropic()

# Async client
client = anthropic.AsyncAnthropic()

# Full configuration
client = anthropic.Anthropic(
    api_key=os.environ["ANTHROPIC_API_KEY"],
    max_retries=3,
    timeout=60.0,
    base_url="https://api.anthropic.com",
    default_headers={"claude-beta": "prompt-caching-2024-07-31"},
)

Output

  • Properly configured client with retries, timeouts, and custom headers
  • Type-safe error handling with specific exception classes
  • Streaming implementation using your preferred pattern
  • Prompt caching enabled for repeated system prompts (90% cost savings)
  • Batch processing configured for bulk operations (50% cost savings)

Error Handling

typescript
import Anthropic from '@claude-ai/sdk';

try {
  const message = await client.messages.create({ ... });
} catch (err) {
  if (err instanceof Anthropic.AuthenticationError) {
    // 401 — bad API key
  } else if (err instanceof Anthropic.RateLimitError) {
    // 429 — back off and retry
  } else if (err instanceof Anthropic.APIError) {
    // All other API errors
    console.error(err.status, err.error?.type, err.message);
  } else if (err instanceof Anthropic.APIConnectionError) {
    // Network failure — DNS, timeout, etc.
  }
}
python
try:
    message = client.messages.create(...)
except anthropic.AuthenticationError:
    ...  # 401
except anthropic.RateLimitError:
    ...  # 429
except anthropic.APIStatusError as e:
    print(e.status_code, e.message)
except anthropic.APIConnectionError:
    ...  # network failure

Streaming Patterns

Event-Based (TypeScript)
typescript
const stream = client.messages.stream({
  model: 'claude-sonnet-4-20250514',
  max_tokens: 2048,
  messages,
});

stream.on('text', (text) => process.stdout.write(text));
stream.on('error', (err) => console.error('Stream error:', err));
stream.on('end', () => console.log('\nDone'));

const finalMessage = await stream.finalMessage();
Async Iterator (TypeScript)
typescript
const stream = await client.messages.create({
  model: 'claude-sonnet-4-20250514',
  max_tokens: 2048,
  messages,
  stream: true,
});

for await (const event of stream) {
  if (event.type === 'content_block_delta') {
    process.stdout.write(event.delta.text || '');
  }
}
Context Manager (Python)
python
with client.messages.stream(
    model="claude-sonnet-4-20250514",
    max_tokens=2048,
    messages=messages,
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)

message = stream.get_final_message()

TypeScript Types

typescript
import Anthropic from '@claude-ai/sdk';

// Message types
type Message = Anthropic.Message;
type MessageParam = Anthropic.MessageParam;
type ContentBlock = Anthropic.ContentBlock;
type TextBlock = Anthropic.TextBlock;
type ToolUseBlock = Anthropic.ToolUseBlock;

// Tool types
type Tool = Anthropic.Tool;
type ToolResultBlockParam = Anthropic.ToolResultBlockParam;

// Request/response
type MessageCreateParams = Anthropic.MessageCreateParams;

Prompt Caching (Beta)

typescript
const message = await client.messages.create({
  model: 'claude-sonnet-4-20250514',
  max_tokens: 1024,
  system: [
    {
      type: 'text',
      text: longSystemPrompt, // 1024+ tokens to be cacheable
      cache_control: { type: 'ephemeral' },
    },
  ],
  messages: [{ role: 'user', content: userQuestion }],
}, {
  headers: { 'claude-beta': 'prompt-caching-2024-07-31' },
});
// Cache hit: 90% cheaper on input tokens
// message.usage.cache_creation_input_tokens / cache_read_input_tokens

Message Batches

typescript
// Submit up to 10,000 messages as a batch (50% cheaper, 24h SLA)
const batch = await client.messages.batches.create({
  requests: items.map((item, i) => ({
    custom_id: `item-${i}`,
    params: {
      model: 'claude-sonnet-4-20250514',
      max_tokens: 1024,
      messages: [{ role: 'user', content: item.prompt }],
    },
  })),
});

// Poll for completion
let status = await client.messages.batches.retrieve(batch.id);
while (status.processing_status !== 'ended') {
  await new Promise(r => setTimeout(r, 30000));
  status = await client.messages.batches.retrieve(batch.id);
}

Examples

See Client Configuration, Error Handling, Streaming Patterns, TypeScript Types, Prompt Caching, and Message Batches sections above for complete code examples.

Resources

Next Steps

See clade-rate-limits for throughput optimization.

Prerequisites

  • Completed clade-install-auth
  • Familiarity with TypeScript generics or Python type hints
  • Understanding of async/await patterns

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

Files

SKILL.md and 1 other file (references) in skills/.curated/clade-sdk-patterns of jeremylongshore/tons-of-skills-marketplace.

  • SKILL.md
  • references/one-pager.md

Open the folder on GitHubat commit 80f86df

Compare with similar skills

Clade SDK Patterns 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.

Clade SDK Patterns compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Clade SDK Patterns this skilljeremylongshore/tons-of-skills-marketplace2.8k—~1.6kAutomated safety check: PassMIT
Strict Programming Practicescode-yeongyu/oh-my-openagent70k—~9.5kAutomated safety check: PassCustom licence
Claude APIloulanyue/awesome-claude-notes2722 repos~2.1kAutomated safety check: PassMIT
Claude APIloulanyue/awesome-claude-notes2721 repos~1.9kAutomated safety check: PassMIT
Cross-Language Coding Standardszereight/gitlab-mcp2k1 repos~1.4kAutomated safety check: PassMIT
Implement Type Annotationsambient-code/agentready154—~231Automated safety check: PassMIT

Similar skills

  • Strict Programming Practices

    code-yeongyu/oh-my-openagent

    Applies strict, type-first coding rules for Python, Rust, TypeScript and Go, loading the matching language reference before the agent writes or edits any code.

    70k GitHub stars~9.5k tokensUpdated today
    DevelopmentAuto-check passed
  • Claude API

    loulanyue/awesome-claude-notes

    Anthropic Claude API patterns for Python and TypeScript. An agent skill from loulanyue/awesome-claude-notes.

    272 GitHub starsUsed in 2 repos~2.1k tokens
    AI & LLM EngineeringAuto-check passed
  • Claude API

    loulanyue/awesome-claude-notes

    Anthropic Claude API 的 Python 和 TypeScript 使用模式。涵盖 Messages API、流式处理、工具使用、视觉功能、扩展思维、批量处理、提示缓存和 Claude Agent SDK。适用于使用 Claude API 或 Anthropic SDK 构建应用程序的场景。

    272 GitHub starsUsed in 1 repo~1.9k tokens
    AI & LLM EngineeringAuto-check passed
  • Shared reference for naming, function size, complexity and error handling rules that reviewer agents apply across TypeScript, Python, Go, Rust, Java, C# and Swift.

    2k GitHub starsUsed in 1 repo~1.4k tokens
    DevelopmentAuto-check passed
  • Implement Type Annotations

    ambient-code/agentready

    Add comprehensive type hints to Python/TypeScript code to improve IDE support, catch errors early, and enable better AI code understanding

    154 GitHub stars~231 tokensUpdated 9 days ago
    DevelopmentAuto-check passed
  • Typescript Rules

    shinpr/ai-coding-project-boilerplate

    Applies type safety and error handling rules. An agent skill from shinpr/ai-coding-project-boilerplate.

    233 GitHub stars~1.5k tokensUpdated 6 days ago
    DevelopmentAuto-check passed

More from jeremylongshore/tons-of-skills-marketplace

All 3,342 skills in this repo
  • Performing Security Code Review

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to conduct a security-focused code review using the security-agent plugin.

    2.8k GitHub starsUsed in 2 repos~1.3k tokens
    Auto-check: notes
  • Adapting Transfer Learning Models

    jeremylongshore/tons-of-skills-marketplace

    Build this skill automates the adaptation of pre-trained machine learning models using transfer learning techniques.

    2.8k GitHub stars~1.1k tokensUpdated yesterday
    Auto-check passed
  • Agent Context Loader

    jeremylongshore/tons-of-skills-marketplace

    Execute proactive auto-loading: automatically detects and loads agents.md files.

    2.8k GitHub stars~1.1k tokensUpdated yesterday
    Auto-check passed
  • Aggregating Performance Metrics

    jeremylongshore/tons-of-skills-marketplace

    Aggregate and centralize performance metrics from applications, systems, databases, caches, and services.

    2.8k GitHub stars~1.2k tokensUpdated yesterday
    Auto-check passed
  • Analyzing Capacity Planning

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to analyze capacity requirements and plan for future growth.

    2.8k GitHub stars~947 tokensUpdated yesterday
    Auto-check passed
  • Analyzing Database Indexes

    jeremylongshore/tons-of-skills-marketplace

    Process use when you need to work with database indexing. An agent skill from jeremylongshore/tons-of-skills-marketplace.

    2.8k GitHub stars~2k tokensUpdated yesterday
    Auto-check passed

Questions about Clade SDK Patterns

What does Clade SDK Patterns do?

Production-ready Anthropic SDK patterns — client config, retries, timeouts, Use when working with sdk-patterns patterns. Clade SDK Patterns is an agent skill from jeremylongshore/tons-of-skills-marketplace. Production-ready Anthropic SDK patterns — client config, retries, timeouts, Use when working with sdk-patterns patterns.

When should I use Clade SDK Patterns?

Clade SDK Patterns fits situations like: working with sdk-patterns patterns; with anthropic sdk; Claude client setup; anthropic typescript.

How do I install Clade SDK Patterns in Claude Code?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill clade-sdk-patterns -a claude-code`. Or copy the skill folder (skills/.curated/clade-sdk-patterns in jeremylongshore/tons-of-skills-marketplace) into .claude/skills/clade-sdk-patterns in your project. Claude Code loads it when a task matches its description.

How do I install Clade SDK Patterns in Codex?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill clade-sdk-patterns -a codex`. Or copy the skill folder (skills/.curated/clade-sdk-patterns in jeremylongshore/tons-of-skills-marketplace) into .agents/skills/clade-sdk-patterns in your project. Codex loads it when a task matches its description.

Can I use Clade SDK Patterns 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 jeremylongshore/tons-of-skills-marketplace --skill clade-sdk-patterns -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/clade-sdk-patterns, .gemini/skills/clade-sdk-patterns, .github/skills/clade-sdk-patterns and .opencode/skills/clade-sdk-patterns in your project.

What does Clade SDK Patterns need to run?

Going by SKILL.md and its folder, Clade SDK Patterns needs credentials named ANTHROPIC_API_KEY. Our summary lists: Python 3; A credential in ANTHROPIC_API_KEY. Its frontmatter pre-approves these tools: Read, Write, Edit. Compatibility (from SKILL.md): Designed for Claude Code.

Does Clade SDK Patterns access the network?

SKILL.md names 2 domains. In commands or code: api.anthropic.com; the agent is likely to contact it when it follows the instructions. As links in the text: platform.claude.com. This is read from the text; nothing was executed.

Is Clade SDK Patterns 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 Clade SDK Patterns use?

Clade SDK Patterns is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Clade SDK Patterns use?

About 1.6k tokens (SKILL.md is roughly 6.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 470 tokens, read only when the agent opens those files.

What are the alternatives to Clade SDK Patterns?

Skills that share tags, products or a category with Clade SDK Patterns: Strict Programming Practices (code-yeongyu/oh-my-openagent, 70k stars), Claude API (loulanyue/awesome-claude-notes, 272 stars), Claude API (loulanyue/awesome-claude-notes, 272 stars) and Cross-Language Coding Standards (zereight/gitlab-mcp, 2k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Clade SDK Patterns?

jeremylongshore (a GitHub user) maintains it in jeremylongshore/tons-of-skills-marketplace, which has 2,825 GitHub stars. The repository holds 3,342 skills in this directory. The repository was last updated on October 9, 2026.

Source: jeremylongshore/tons-of-skills-marketplace on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.