[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6F8878QVVRHFSNAQ63VA86B":3,"skill-same:01M6F8878QVVRHFSNAQ63VA86B":76},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":53,"commitSha":54,"skillDirectory":55,"forksCount":56,"repositoryHtmlUrl":57,"repositoryHomepageUrl":58,"ownerHtmlUrl":59,"ownerBlogUrl":6,"ownerDescription":60,"updatedAt":61,"install":62,"resources":75},"01M6F8878QVVRHFSNAQ63VA86B","clade-sdk-patterns",null,"Production-ready Anthropic SDK patterns — client config, retries, timeouts,\nUse when working with sdk-patterns patterns.\nerror handling, TypeScript types, and async patterns.\nTrigger with \"anthropic sdk\", \"claude client setup\", \"anthropic typescript\",\n\"anthropic python patterns\".","ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fjeremylongshore\u002Fclaude-code-plugins-plus-skills\u002Fclade-sdk-patterns\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"clade sdk patterns","sdk","patterns","ready","types","anthropic sdk","retries","error","trigger","io","async","typescript","use","edit","write","read","python patterns","code","config","python","2026-11-10 10:12:30",false,"---\nname: clade-sdk-patterns\ndescription: |\n  Production-ready Anthropic SDK patterns — client config, retries, timeouts,\n  Use when working with sdk-patterns patterns.\n  error handling, TypeScript types, and async patterns.\n  Trigger with \"anthropic sdk\", \"claude client setup\", \"anthropic typescript\",\n  \"anthropic python patterns\".\nallowed-tools: Read, Write, Edit\nversion: 1.0.0\nlicense: MIT\nauthor: Jeremy Longshore \u003Cjeremy@intentsolutions.io>\ncompatible-with: claude-code\ntags: [saas, anthropic, claude, sdk, typescript, python]\n---\n\n# Anthropic SDK Patterns\n\n## Overview\nProduction patterns for the `@claude-ai\u002Fsdk` (TypeScript) and `anthropic` (Python) SDKs.\n\n## Client Configuration\n\n## Instructions\n\n### Step 1: TypeScript\n```typescript\nimport Anthropic from '@claude-ai\u002Fsdk';\n\n\u002F\u002F Default — reads ANTHROPIC_API_KEY from env\nconst client = new Anthropic();\n\n\u002F\u002F Full configuration\nconst client = new Anthropic({\n  apiKey: process.env.ANTHROPIC_API_KEY,   \u002F\u002F default: env var\n  maxRetries: 3,                            \u002F\u002F default: 2\n  timeout: 60_000,                          \u002F\u002F default: 10 minutes\n  baseURL: 'https:\u002F\u002Fapi.anthropic.com',     \u002F\u002F override for proxies\n  defaultHeaders: {                         \u002F\u002F custom headers\n    'claude-beta': 'prompt-caching-2024-07-31',\n  },\n});\n```\n\n### Step 2: Python\n```python\nimport anthropic\n\n# Sync client\nclient = anthropic.Anthropic()\n\n# Async client\nclient = anthropic.AsyncAnthropic()\n\n# Full configuration\nclient = anthropic.Anthropic(\n    api_key=os.environ[\"ANTHROPIC_API_KEY\"],\n    max_retries=3,\n    timeout=60.0,\n    base_url=\"https:\u002F\u002Fapi.anthropic.com\",\n    default_headers={\"claude-beta\": \"prompt-caching-2024-07-31\"},\n)\n```\n\n## Output\n- Properly configured client with retries, timeouts, and custom headers\n- Type-safe error handling with specific exception classes\n- Streaming implementation using your preferred pattern\n- Prompt caching enabled for repeated system prompts (90% cost savings)\n- Batch processing configured for bulk operations (50% cost savings)\n\n## Error Handling\n```typescript\nimport Anthropic from '@claude-ai\u002Fsdk';\n\ntry {\n  const message = await client.messages.create({ ... });\n} catch (err) {\n  if (err instanceof Anthropic.AuthenticationError) {\n    \u002F\u002F 401 — bad API key\n  } else if (err instanceof Anthropic.RateLimitError) {\n    \u002F\u002F 429 — back off and retry\n  } else if (err instanceof Anthropic.APIError) {\n    \u002F\u002F All other API errors\n    console.error(err.status, err.error?.type, err.message);\n  } else if (err instanceof Anthropic.APIConnectionError) {\n    \u002F\u002F Network failure — DNS, timeout, etc.\n  }\n}\n```\n\n```python\ntry:\n    message = client.messages.create(...)\nexcept anthropic.AuthenticationError:\n    ...  # 401\nexcept anthropic.RateLimitError:\n    ...  # 429\nexcept anthropic.APIStatusError as e:\n    print(e.status_code, e.message)\nexcept anthropic.APIConnectionError:\n    ...  # network failure\n```\n\n## Streaming Patterns\n\n### Event-Based (TypeScript)\n```typescript\nconst stream = client.messages.stream({\n  model: 'claude-sonnet-4-20250514',\n  max_tokens: 2048,\n  messages,\n});\n\nstream.on('text', (text) => process.stdout.write(text));\nstream.on('error', (err) => console.error('Stream error:', err));\nstream.on('end', () => console.log('\\nDone'));\n\nconst finalMessage = await stream.finalMessage();\n```\n\n### Async Iterator (TypeScript)\n```typescript\nconst stream = await client.messages.create({\n  model: 'claude-sonnet-4-20250514',\n  max_tokens: 2048,\n  messages,\n  stream: true,\n});\n\nfor await (const event of stream) {\n  if (event.type === 'content_block_delta') {\n    process.stdout.write(event.delta.text || '');\n  }\n}\n```\n\n### Context Manager (Python)\n```python\nwith client.messages.stream(\n    model=\"claude-sonnet-4-20250514\",\n    max_tokens=2048,\n    messages=messages,\n) as stream:\n    for text in stream.text_stream:\n        print(text, end=\"\", flush=True)\n\nmessage = stream.get_final_message()\n```\n\n## TypeScript Types\n```typescript\nimport Anthropic from '@claude-ai\u002Fsdk';\n\n\u002F\u002F Message types\ntype Message = Anthropic.Message;\ntype MessageParam = Anthropic.MessageParam;\ntype ContentBlock = Anthropic.ContentBlock;\ntype TextBlock = Anthropic.TextBlock;\ntype ToolUseBlock = Anthropic.ToolUseBlock;\n\n\u002F\u002F Tool types\ntype Tool = Anthropic.Tool;\ntype ToolResultBlockParam = Anthropic.ToolResultBlockParam;\n\n\u002F\u002F Request\u002Fresponse\ntype MessageCreateParams = Anthropic.MessageCreateParams;\n```\n\n## Prompt Caching (Beta)\n```typescript\nconst message = await client.messages.create({\n  model: 'claude-sonnet-4-20250514',\n  max_tokens: 1024,\n  system: [\n    {\n      type: 'text',\n      text: longSystemPrompt, \u002F\u002F 1024+ tokens to be cacheable\n      cache_control: { type: 'ephemeral' },\n    },\n  ],\n  messages: [{ role: 'user', content: userQuestion }],\n}, {\n  headers: { 'claude-beta': 'prompt-caching-2024-07-31' },\n});\n\u002F\u002F Cache hit: 90% cheaper on input tokens\n\u002F\u002F message.usage.cache_creation_input_tokens \u002F cache_read_input_tokens\n```\n\n## Message Batches\n```typescript\n\u002F\u002F Submit up to 10,000 messages as a batch (50% cheaper, 24h SLA)\nconst batch = await client.messages.batches.create({\n  requests: items.map((item, i) => ({\n    custom_id: `item-${i}`,\n    params: {\n      model: 'claude-sonnet-4-20250514',\n      max_tokens: 1024,\n      messages: [{ role: 'user', content: item.prompt }],\n    },\n  })),\n});\n\n\u002F\u002F Poll for completion\nlet status = await client.messages.batches.retrieve(batch.id);\nwhile (status.processing_status !== 'ended') {\n  await new Promise(r => setTimeout(r, 30000));\n  status = await client.messages.batches.retrieve(batch.id);\n}\n```\n\n## Examples\nSee Client Configuration, Error Handling, Streaming Patterns, TypeScript Types, Prompt Caching, and Message Batches sections above for complete code examples.\n\n## Resources\n- [TypeScript SDK](https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-sdk-typescript)\n- [Python SDK](https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-sdk-python)\n- [Prompt Caching](https:\u002F\u002Fdocs.anthropic.com\u002Fen\u002Fdocs\u002Fbuild-with-claude\u002Fprompt-caching)\n- [Message Batches](https:\u002F\u002Fdocs.anthropic.com\u002Fen\u002Fapi\u002Fcreating-message-batches)\n\n## Next Steps\nSee `clade-rate-limits` for throughput optimization.\n\n## Prerequisites\n- Completed `clade-install-auth`\n- Familiarity with TypeScript generics or Python type hints\n- Understanding of async\u002Fawait patterns\n\n","# Anthropic SDK Patterns\n\n## Overview\nProduction patterns for the `@claude-ai\u002Fsdk` (TypeScript) and `anthropic` (Python) SDKs.\n\n## Client Configuration\n\n## Instructions\n\n### Step 1: TypeScript\n```typescript\nimport Anthropic from '@claude-ai\u002Fsdk';\n\n\u002F\u002F Default — reads ANTHROPIC_API_KEY from env\nconst client = new Anthropic();\n\n\u002F\u002F Full configuration\nconst client = new Anthropic({\n  apiKey: process.env.ANTHROPIC_API_KEY,   \u002F\u002F default: env var\n  maxRetries: 3,                            \u002F\u002F default: 2\n  timeout: 60_000,                          \u002F\u002F default: 10 minutes\n  baseURL: 'https:\u002F\u002Fapi.anthropic.com',     \u002F\u002F override for proxies\n  defaultHeaders: {                         \u002F\u002F custom headers\n    'claude-beta': 'prompt-caching-2024-07-31',\n  },\n});\n```\n\n### Step 2: Python\n```python\nimport anthropic\n\n# Sync client\nclient = anthropic.Anthropic()\n\n# Async client\nclient = anthropic.AsyncAnthropic()\n\n# Full configuration\nclient = anthropic.Anthropic(\n    api_key=os.environ[\"ANTHROPIC_API_KEY\"],\n    max_retries=3,\n    timeout=60.0,\n    base_url=\"https:\u002F\u002Fapi.anthropic.com\",\n    default_headers={\"claude-beta\": \"prompt-caching-2024-07-31\"},\n)\n```\n\n## Output\n- Properly configured client with retries, timeouts, and custom headers\n- Type-safe error handling with specific exception classes\n- Streaming implementation using your preferred pattern\n- Prompt caching enabled for repeated system prompts (90% cost savings)\n- Batch processing configured for bulk operations (50% cost savings)\n\n## Error Handling\n```typescript\nimport Anthropic from '@claude-ai\u002Fsdk';\n\ntry {\n  const message = await client.messages.create({ ... });\n} catch (err) {\n  if (err instanceof Anthropic.AuthenticationError) {\n    \u002F\u002F 401 — bad API key\n  } else if (err instanceof Anthropic.RateLimitError) {\n    \u002F\u002F 429 — back off and retry\n  } else if (err instanceof Anthropic.APIError) {\n    \u002F\u002F All other API errors\n    console.error(err.status, err.error?.type, err.message);\n  } else if (err instanceof Anthropic.APIConnectionError) {\n    \u002F\u002F Network failure — DNS, timeout, etc.\n  }\n}\n```\n\n```python\ntry:\n    message = client.messages.create(...)\nexcept anthropic.AuthenticationError:\n    ...  # 401\nexcept anthropic.RateLimitError:\n    ...  # 429\nexcept anthropic.APIStatusError as e:\n    print(e.status_code, e.message)\nexcept anthropic.APIConnectionError:\n    ...  # network failure\n```\n\n## Streaming Patterns\n\n### Event-Based (TypeScript)\n```typescript\nconst stream = client.messages.stream({\n  model: 'claude-sonnet-4-20250514',\n  max_tokens: 2048,\n  messages,\n});\n\nstream.on('text', (text) => process.stdout.write(text));\nstream.on('error', (err) => console.error('Stream error:', err));\nstream.on('end', () => console.log('\\nDone'));\n\nconst finalMessage = await stream.finalMessage();\n```\n\n### Async Iterator (TypeScript)\n```typescript\nconst stream = await client.messages.create({\n  model: 'claude-sonnet-4-20250514',\n  max_tokens: 2048,\n  messages,\n  stream: true,\n});\n\nfor await (const event of stream) {\n  if (event.type === 'content_block_delta') {\n    process.stdout.write(event.delta.text || '');\n  }\n}\n```\n\n### Context Manager (Python)\n```python\nwith client.messages.stream(\n    model=\"claude-sonnet-4-20250514\",\n    max_tokens=2048,\n    messages=messages,\n) as stream:\n    for text in stream.text_stream:\n        print(text, end=\"\", flush=True)\n\nmessage = stream.get_final_message()\n```\n\n## TypeScript Types\n```typescript\nimport Anthropic from '@claude-ai\u002Fsdk';\n\n\u002F\u002F Message types\ntype Message = Anthropic.Message;\ntype MessageParam = Anthropic.MessageParam;\ntype ContentBlock = Anthropic.ContentBlock;\ntype TextBlock = Anthropic.TextBlock;\ntype ToolUseBlock = Anthropic.ToolUseBlock;\n\n\u002F\u002F Tool types\ntype Tool = Anthropic.Tool;\ntype ToolResultBlockParam = Anthropic.ToolResultBlockParam;\n\n\u002F\u002F Request\u002Fresponse\ntype MessageCreateParams = Anthropic.MessageCreateParams;\n```\n\n## Prompt Caching (Beta)\n```typescript\nconst message = await client.messages.create({\n  model: 'claude-sonnet-4-20250514',\n  max_tokens: 1024,\n  system: [\n    {\n      type: 'text',\n      text: longSystemPrompt, \u002F\u002F 1024+ tokens to be cacheable\n      cache_control: { type: 'ephemeral' },\n    },\n  ],\n  messages: [{ role: 'user', content: userQuestion }],\n}, {\n  headers: { 'claude-beta': 'prompt-caching-2024-07-31' },\n});\n\u002F\u002F Cache hit: 90% cheaper on input tokens\n\u002F\u002F message.usage.cache_creation_input_tokens \u002F cache_read_input_tokens\n```\n\n## Message Batches\n```typescript\n\u002F\u002F Submit up to 10,000 messages as a batch (50% cheaper, 24h SLA)\nconst batch = await client.messages.batches.create({\n  requests: items.map((item, i) => ({\n    custom_id: `item-${i}`,\n    params: {\n      model: 'claude-sonnet-4-20250514',\n      max_tokens: 1024,\n      messages: [{ role: 'user', content: item.prompt }],\n    },\n  })),\n});\n\n\u002F\u002F Poll for completion\nlet status = await client.messages.batches.retrieve(batch.id);\nwhile (status.processing_status !== 'ended') {\n  await new Promise(r => setTimeout(r, 30000));\n  status = await client.messages.batches.retrieve(batch.id);\n}\n```\n\n## Examples\nSee Client Configuration, Error Handling, Streaming Patterns, TypeScript Types, Prompt Caching, and Message Batches sections above for complete code examples.\n\n## Resources\n- [TypeScript SDK](https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-sdk-typescript)\n- [Python SDK](https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-sdk-python)\n- [Prompt Caching](https:\u002F\u002Fdocs.anthropic.com\u002Fen\u002Fdocs\u002Fbuild-with-claude\u002Fprompt-caching)\n- [Message Batches](https:\u002F\u002Fdocs.anthropic.com\u002Fen\u002Fapi\u002Fcreating-message-batches)\n\n## Next Steps\nSee `clade-rate-limits` for throughput optimization.\n\n## Prerequisites\n- Completed `clade-install-auth`\n- Familiarity with TypeScript generics or Python type hints\n- Understanding of async\u002Fawait patterns\n\n",{"name":5,"tags":44,"author":48,"license":15,"version":49,"description":50,"allowed-tools":51,"compatible-with":52},[45,46,47,20,30,38],"saas","anthropic","claude","Jeremy Longshore \u003Cjeremy@intentsolutions.io>","1.0.0","Production-ready Anthropic SDK patterns — client config, retries, timeouts,\nUse when working with sdk-patterns patterns.\nerror handling, TypeScript types, and async patterns.\nTrigger with \"anthropic sdk\", \"claude client setup\", \"anthropic typescript\",\n\"anthropic python patterns\".\n","Read, Write, Edit","claude-code","main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Fjeremylongshore\u002Fclaude-code-plugins-plus-skills\u002Fclade-sdk-patterns",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":8,"skillName":5,"commands":63,"prompt":73,"zipAvailable":74},[64,67,70],{"tool":65,"command":66},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill clade-sdk-patterns",{"tool":68,"command":69},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill clade-sdk-patterns",{"tool":71,"command":72},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill clade-sdk-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fjeremylongshore\u002Fclaude-code-plugins-plus-skills\u002Fclade-sdk-patterns\u002FSKILL.md",true,[],[77,91,101,109,115,122],{"skillNo":78,"name":79,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":87,"publishedAt":39},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[82],{"categoryNo":83,"categoryName":84,"taxonomyType":85,"taxonomyTypeDesc":86},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[88,89,90],"model","model hierarchy","model hierarchy skill",{"skillNo":92,"name":93,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":97,"publishedAt":39},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[96],{"categoryNo":83,"categoryName":84,"taxonomyType":85,"taxonomyTypeDesc":86},[98,99,100],"MCP","zoom","zoom mcp",{"skillNo":102,"name":103,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":39},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[20,107,108,99],"zoom apps sdk","apps",{"skillNo":110,"name":111,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":39},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[111],{"skillNo":116,"name":117,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":118,"categories":119,"keywords":121,"publishedAt":39},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[120],{"categoryNo":83,"categoryName":84,"taxonomyType":85,"taxonomyTypeDesc":86},[117],{"skillNo":123,"name":124,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":125,"categories":126,"keywords":127,"publishedAt":39},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[124]]