anth-sdk-patterns

Featured

Apply production-ready Anthropic SDK patterns for TypeScript and Python. Use when implementing Claude integrations, building reusable wrappers, or establishing team coding standards for the Messages API. Trigger with phrases like "anthropic SDK patterns", "claude best practices", "anthropic code patterns", "production claude code".

AI & Automation 2,926 stars 433 forks Updated yesterday MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Anthropic SDK Patterns ## Overview Production-ready patterns for the Anthropic SDK covering client management, error handling, type safety, and multi-tenant configurations. ## Prerequisites - Completed `anth-install-auth` setup - Familiarity with async/await patterns - TypeScript 5+ or Python 3.10+ ## Pattern 1: Typed Wrapper with Retry ```typescript import Anthropic from '@anthropic-ai/sdk'; import type { Message, MessageCreateParams } from '@anthropic-ai/sdk/resources/messages'; class ClaudeService { private client: Anthropic; constructor(apiKey?: string) { this.client = new Anthropic({ apiKey: apiKey || process.env.ANTHROPIC_API_KEY, maxRetries: 3, // SDK handles 429 + 5xx automatically timeout: 60_000, }); } async complete( prompt: string, options: Partial<MessageCreateParams> = {} ): Promise<string> { const message = await this.client.messages.create({ model: options.model || 'claude-sonnet-4-20250514', max_tokens: options.max_tokens || 1024, messages: [{ role: 'user', content: prompt }], ...options, }); const textBlock = message.content.find((b) => b.type === 'text'); if (!textBlock || textBlock.type !== 'text') { throw new Error(`No text in response: ${message.stop_reason}`); } return textBlock.text; } async *stream(prompt: string, model = 'claude-sonnet-4-20250514'): AsyncGenerator<string> { const stream = this.client.messages.stream({ mode...

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
1 years ago
Last Updated
yesterday
Language
Python
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category