[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6F87C3X8J9CZ6TP92Q1N4TS":3,"skill-same:01M6F87C3X8J9CZ6TP92Q1N4TS":77},{"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":54,"commitSha":55,"skillDirectory":56,"forksCount":57,"repositoryHtmlUrl":58,"repositoryHomepageUrl":59,"ownerHtmlUrl":60,"ownerBlogUrl":6,"ownerDescription":61,"updatedAt":62,"install":63,"resources":76},"01M6F87C3X8J9CZ6TP92Q1N4TS","clade-performance-tuning",null,"Optimize Anthropic API latency — streaming, prompt caching, model selection,\nUse when working with performance-tuning patterns.\nconnection reuse, and parallel requests.\nTrigger with \"anthropic slow\", \"claude latency\", \"speed up anthropic\",\n\"anthropic performance\", \"claude response time\".","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-performance-tuning\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"clade performance tuning","performance tuning","tuning","performance","edit","io","caching","time","optimize","patterns","selection","up","write","read","model","api","prompt caching","streaming","code","model selection","2026-11-10 10:12:30",false,"---\nname: clade-performance-tuning\ndescription: |\n  Optimize Anthropic API latency — streaming, prompt caching, model selection,\n  Use when working with performance-tuning patterns.\n  connection reuse, and parallel requests.\n  Trigger with \"anthropic slow\", \"claude latency\", \"speed up anthropic\",\n  \"anthropic performance\", \"claude response time\".\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, performance, latency]\n---\n\n# Anthropic Performance Tuning\n\n## Overview\nClaude latency has two components: **time to first token (TTFT)** and **tokens per second (TPS)**. Different strategies target each.\n\n## Latency Benchmarks (approximate)\n\n| Model | TTFT (p50) | TTFT (p95) | Output TPS |\n|-------|-----------|-----------|------------|\n| Claude Haiku 4.5 | 200ms | 600ms | ~150 |\n| Claude Sonnet 4 | 400ms | 1.2s | ~90 |\n| Claude Opus 4 | 800ms | 2.5s | ~40 |\n\n## Optimization Strategies\n\n## Instructions\n\n### Step 1: Always Stream\n```typescript\n\u002F\u002F Streaming delivers the first token ASAP — user sees response instantly\n\u002F\u002F instead of waiting for the full response to generate\n\nconst stream = client.messages.stream({\n  model: 'claude-sonnet-4-20250514',\n  max_tokens: 1024,\n  messages,\n});\n\n\u002F\u002F First token arrives in ~400ms (Sonnet)\n\u002F\u002F Full response may take 5-10s, but user sees progress immediately\nfor await (const event of stream) {\n  if (event.type === 'content_block_delta') {\n    yield event.delta.text;\n  }\n}\n```\n\n### Step 2: Prompt Caching — Faster TTFT\n```typescript\n\u002F\u002F Cached prompts skip re-processing — dramatically lower TTFT for large system prompts\nconst message = await client.messages.create({\n  model: 'claude-sonnet-4-20250514',\n  max_tokens: 1024,\n  system: [{\n    type: 'text',\n    text: largeSystemPrompt, \u002F\u002F 10K+ tokens\n    cache_control: { type: 'ephemeral' },\n  }],\n  messages,\n}, {\n  headers: { 'claude-beta': 'prompt-caching-2024-07-31' },\n});\n\u002F\u002F TTFT drops from ~2s to ~500ms on cache hit with large prompts\n```\n\n### Step 3: Use Haiku for Speed-Critical Paths\n```typescript\n\u002F\u002F Haiku is 2-4x faster than Sonnet with 80% quality for many tasks\n\u002F\u002F Use for: classification, extraction, simple Q&A, routing decisions\n\nconst route = await client.messages.create({\n  model: 'claude-haiku-4-5-20251001', \u002F\u002F 200ms TTFT\n  max_tokens: 10,\n  system: 'Classify the intent. Reply with exactly one word: search, create, update, delete.',\n  messages: [{ role: 'user', content: userInput }],\n});\n\n\u002F\u002F Then use Sonnet\u002FOpus for the actual task\n```\n\n### Step 4: Reuse Client Instance\n```typescript\n\u002F\u002F BAD — creates new connection pool per request\napp.get('\u002Fapi\u002Fchat', async (req, res) => {\n  const client = new Anthropic(); \u002F\u002F DON'T\n  \u002F\u002F ...\n});\n\n\u002F\u002F GOOD — single client shared across requests\nconst client = new Anthropic(); \u002F\u002F Module-level singleton\n\napp.get('\u002Fapi\u002Fchat', async (req, res) => {\n  const message = await client.messages.create({ ... });\n  \u002F\u002F ...\n});\n```\n\n### Step 5: Parallel Requests\n```typescript\n\u002F\u002F When you need multiple independent Claude calls, fire them in parallel\nconst [summary, sentiment, entities] = await Promise.all([\n  client.messages.create({ model: 'claude-haiku-4-5-20251001', max_tokens: 200,\n    messages: [{ role: 'user', content: `Summarize: ${text}` }] }),\n  client.messages.create({ model: 'claude-haiku-4-5-20251001', max_tokens: 20,\n    messages: [{ role: 'user', content: `Sentiment (positive\u002Fnegative\u002Fneutral): ${text}` }] }),\n  client.messages.create({ model: 'claude-haiku-4-5-20251001', max_tokens: 200,\n    messages: [{ role: 'user', content: `Extract named entities from: ${text}` }] }),\n]);\n```\n\n### Step 6: Minimize Output Tokens\n```typescript\n\u002F\u002F Fewer output tokens = faster response\nsystem: 'Be extremely concise. Use bullet points, not paragraphs.',\n\n\u002F\u002F Set tight max_tokens\nmax_tokens: 256, \u002F\u002F Don't use 4096 for short answers\n```\n\n## Output\n- Streaming enabled for all user-facing responses (first token in ~400ms with Sonnet)\n- Prompt caching reducing TTFT for large system prompts\n- Model routing to Haiku for speed-critical classification\u002Frouting tasks\n- Client instance reused across requests (no per-request connection overhead)\n- Parallel requests firing independent Claude calls concurrently\n\n## Error Handling\n| Issue | Cause | Fix |\n|-------|-------|-----|\n| TTFT > 3s | Large uncached prompt | Enable prompt caching |\n| Slow output | Using Opus for simple tasks | Downgrade to Haiku\u002FSonnet |\n| Timeouts | Long generation + default timeout | `new Anthropic({ timeout: 120_000 })` |\n| 529 overloaded | API capacity | SDK auto-retries; add fallback model |\n\n## Examples\nSee Latency Benchmarks table and six numbered strategy sections above, each with complete TypeScript code examples.\n\n## Resources\n- [Streaming Docs](https:\u002F\u002Fdocs.anthropic.com\u002Fen\u002Fapi\u002Fmessages-streaming)\n- [Prompt Caching](https:\u002F\u002Fdocs.anthropic.com\u002Fen\u002Fdocs\u002Fbuild-with-claude\u002Fprompt-caching)\n- [Models Comparison](https:\u002F\u002Fdocs.anthropic.com\u002Fen\u002Fdocs\u002Fabout-claude\u002Fmodels)\n\n## Next Steps\nSee `clade-deploy-integration` for production deployment patterns.\n\n## Prerequisites\n- Completed `clade-install-auth`\n- User-facing application where latency matters\n- Understanding of streaming and async patterns\n\n","# Anthropic Performance Tuning\n\n## Overview\nClaude latency has two components: **time to first token (TTFT)** and **tokens per second (TPS)**. Different strategies target each.\n\n## Latency Benchmarks (approximate)\n\n| Model | TTFT (p50) | TTFT (p95) | Output TPS |\n|-------|-----------|-----------|------------|\n| Claude Haiku 4.5 | 200ms | 600ms | ~150 |\n| Claude Sonnet 4 | 400ms | 1.2s | ~90 |\n| Claude Opus 4 | 800ms | 2.5s | ~40 |\n\n## Optimization Strategies\n\n## Instructions\n\n### Step 1: Always Stream\n```typescript\n\u002F\u002F Streaming delivers the first token ASAP — user sees response instantly\n\u002F\u002F instead of waiting for the full response to generate\n\nconst stream = client.messages.stream({\n  model: 'claude-sonnet-4-20250514',\n  max_tokens: 1024,\n  messages,\n});\n\n\u002F\u002F First token arrives in ~400ms (Sonnet)\n\u002F\u002F Full response may take 5-10s, but user sees progress immediately\nfor await (const event of stream) {\n  if (event.type === 'content_block_delta') {\n    yield event.delta.text;\n  }\n}\n```\n\n### Step 2: Prompt Caching — Faster TTFT\n```typescript\n\u002F\u002F Cached prompts skip re-processing — dramatically lower TTFT for large system prompts\nconst message = await client.messages.create({\n  model: 'claude-sonnet-4-20250514',\n  max_tokens: 1024,\n  system: [{\n    type: 'text',\n    text: largeSystemPrompt, \u002F\u002F 10K+ tokens\n    cache_control: { type: 'ephemeral' },\n  }],\n  messages,\n}, {\n  headers: { 'claude-beta': 'prompt-caching-2024-07-31' },\n});\n\u002F\u002F TTFT drops from ~2s to ~500ms on cache hit with large prompts\n```\n\n### Step 3: Use Haiku for Speed-Critical Paths\n```typescript\n\u002F\u002F Haiku is 2-4x faster than Sonnet with 80% quality for many tasks\n\u002F\u002F Use for: classification, extraction, simple Q&A, routing decisions\n\nconst route = await client.messages.create({\n  model: 'claude-haiku-4-5-20251001', \u002F\u002F 200ms TTFT\n  max_tokens: 10,\n  system: 'Classify the intent. Reply with exactly one word: search, create, update, delete.',\n  messages: [{ role: 'user', content: userInput }],\n});\n\n\u002F\u002F Then use Sonnet\u002FOpus for the actual task\n```\n\n### Step 4: Reuse Client Instance\n```typescript\n\u002F\u002F BAD — creates new connection pool per request\napp.get('\u002Fapi\u002Fchat', async (req, res) => {\n  const client = new Anthropic(); \u002F\u002F DON'T\n  \u002F\u002F ...\n});\n\n\u002F\u002F GOOD — single client shared across requests\nconst client = new Anthropic(); \u002F\u002F Module-level singleton\n\napp.get('\u002Fapi\u002Fchat', async (req, res) => {\n  const message = await client.messages.create({ ... });\n  \u002F\u002F ...\n});\n```\n\n### Step 5: Parallel Requests\n```typescript\n\u002F\u002F When you need multiple independent Claude calls, fire them in parallel\nconst [summary, sentiment, entities] = await Promise.all([\n  client.messages.create({ model: 'claude-haiku-4-5-20251001', max_tokens: 200,\n    messages: [{ role: 'user', content: `Summarize: ${text}` }] }),\n  client.messages.create({ model: 'claude-haiku-4-5-20251001', max_tokens: 20,\n    messages: [{ role: 'user', content: `Sentiment (positive\u002Fnegative\u002Fneutral): ${text}` }] }),\n  client.messages.create({ model: 'claude-haiku-4-5-20251001', max_tokens: 200,\n    messages: [{ role: 'user', content: `Extract named entities from: ${text}` }] }),\n]);\n```\n\n### Step 6: Minimize Output Tokens\n```typescript\n\u002F\u002F Fewer output tokens = faster response\nsystem: 'Be extremely concise. Use bullet points, not paragraphs.',\n\n\u002F\u002F Set tight max_tokens\nmax_tokens: 256, \u002F\u002F Don't use 4096 for short answers\n```\n\n## Output\n- Streaming enabled for all user-facing responses (first token in ~400ms with Sonnet)\n- Prompt caching reducing TTFT for large system prompts\n- Model routing to Haiku for speed-critical classification\u002Frouting tasks\n- Client instance reused across requests (no per-request connection overhead)\n- Parallel requests firing independent Claude calls concurrently\n\n## Error Handling\n| Issue | Cause | Fix |\n|-------|-------|-----|\n| TTFT > 3s | Large uncached prompt | Enable prompt caching |\n| Slow output | Using Opus for simple tasks | Downgrade to Haiku\u002FSonnet |\n| Timeouts | Long generation + default timeout | `new Anthropic({ timeout: 120_000 })` |\n| 529 overloaded | API capacity | SDK auto-retries; add fallback model |\n\n## Examples\nSee Latency Benchmarks table and six numbered strategy sections above, each with complete TypeScript code examples.\n\n## Resources\n- [Streaming Docs](https:\u002F\u002Fdocs.anthropic.com\u002Fen\u002Fapi\u002Fmessages-streaming)\n- [Prompt Caching](https:\u002F\u002Fdocs.anthropic.com\u002Fen\u002Fdocs\u002Fbuild-with-claude\u002Fprompt-caching)\n- [Models Comparison](https:\u002F\u002Fdocs.anthropic.com\u002Fen\u002Fdocs\u002Fabout-claude\u002Fmodels)\n\n## Next Steps\nSee `clade-deploy-integration` for production deployment patterns.\n\n## Prerequisites\n- Completed `clade-install-auth`\n- User-facing application where latency matters\n- Understanding of streaming and async patterns\n\n",{"name":5,"tags":44,"author":49,"license":15,"version":50,"description":51,"allowed-tools":52,"compatible-with":53},[45,46,47,22,48],"saas","anthropic","claude","latency","Jeremy Longshore \u003Cjeremy@intentsolutions.io>","1.0.0","Optimize Anthropic API latency — streaming, prompt caching, model selection,\nUse when working with performance-tuning patterns.\nconnection reuse, and parallel requests.\nTrigger with \"anthropic slow\", \"claude latency\", \"speed up anthropic\",\n\"anthropic performance\", \"claude response time\".\n","Read, Write, Edit","claude-code","main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Fjeremylongshore\u002Fclaude-code-plugins-plus-skills\u002Fclade-performance-tuning",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":64,"prompt":74,"zipAvailable":75},[65,68,71],{"tool":66,"command":67},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill clade-performance-tuning",{"tool":69,"command":70},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill clade-performance-tuning",{"tool":72,"command":73},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill clade-performance-tuning","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fjeremylongshore\u002Fclaude-code-plugins-plus-skills\u002Fclade-performance-tuning\u002FSKILL.md",true,[],[78,86,95,104,110,116],{"skillNo":79,"name":80,"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":81,"categories":82,"keywords":83,"publishedAt":39},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[],[33,84,85],"model hierarchy","model hierarchy skill",{"skillNo":87,"name":88,"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":89,"categories":90,"keywords":91,"publishedAt":39},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[],[92,93,94],"MCP","zoom","zoom mcp",{"skillNo":96,"name":97,"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":98,"categories":99,"keywords":100,"publishedAt":39},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[101,102,103,93],"sdk","zoom apps sdk","apps",{"skillNo":105,"name":106,"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":107,"categories":108,"keywords":109,"publishedAt":39},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[106],{"skillNo":111,"name":112,"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":113,"categories":114,"keywords":115,"publishedAt":39},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[],[112],{"skillNo":117,"name":118,"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":119,"categories":120,"keywords":121,"publishedAt":39},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[118]]