[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6H97Q32AVJ43F3FFKK5NDPD":3,"skill-same:01M6H97Q32AVJ43F3FFKK5NDPD":69},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":48,"commitSha":49,"skillDirectory":50,"forksCount":51,"repositoryHtmlUrl":52,"repositoryHomepageUrl":6,"ownerHtmlUrl":53,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":54,"install":55,"resources":68},"01M6H97Q32AVJ43F3FFKK5NDPD","twinmind-rate-limits",null,"Implement TwinMind rate limiting, backoff, and optimization patterns.\nUse when handling rate limit errors, implementing retry logic,\nor optimizing API request throughput for TwinMind.\nTrigger with phrases like \"twinmind rate limit\", \"twinmind throttling\",\n\"twinmind 429\", \"twinmind retry\", \"twinmind backoff\".","micsapp\u002Fmicstec-skills","micsapp","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F82411001?v=4","01M6GWCFQ6D3PV8EHNY62NN5VW","01M6GWCFVE1PA5HG0DKC7AMFJ3",4,"MIT","https:\u002F\u002Fgithub.com\u002Fmicsapp\u002Fmicstec-skills\u002Fblob\u002Fmaster\u002Fclaude-code\u002Fplugins-plus-skills\u002Fplugins\u002Fsaas-packs\u002Ftwinmind-pack\u002Fskills\u002Ftwinmind-rate-limits\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"twinmind rate limits","trigger","for","implementing","limit","errors","429","backoff","retry","with","codex","io","rate limiting","logic","use","api","throttling","Optimization","code","implement","2026-11-10 10:12:30",false,"---\nname: twinmind-rate-limits\ndescription: |\n  Implement TwinMind rate limiting, backoff, and optimization patterns.\n  Use when handling rate limit errors, implementing retry logic,\n  or optimizing API request throughput for TwinMind.\n  Trigger with phrases like \"twinmind rate limit\", \"twinmind throttling\",\n  \"twinmind 429\", \"twinmind retry\", \"twinmind backoff\".\nallowed-tools: Read, Write, Edit\nversion: 1.0.0\nlicense: MIT\nauthor: Jeremy Longshore \u003Cjeremy@intentsolutions.io>\ncompatible-with: claude-code, codex, openclaw\n---\n# TwinMind Rate Limits\n\n## Overview\nHandle TwinMind rate limits gracefully with exponential backoff and request optimization.\n\n## Prerequisites\n- TwinMind API access (Pro\u002FEnterprise)\n- Understanding of async\u002Fawait patterns\n- Familiarity with rate limiting concepts\n\n## Instructions\n\n### Step 1: Understand Rate Limit Tiers\n\n| Tier | Audio Hours\u002FMonth | API Requests\u002FMin | Concurrent Transcriptions | Burst |\n|------|-------------------|------------------|--------------------------|-------|\n| Free | Unlimited | 30 | 1 | 5 |\n| Pro ($10\u002Fmo) | Unlimited | 60 | 3 | 15 |\n| Enterprise | Unlimited | 300 | 10 | 50 |\n\n**Key Limits:**\n- Transcription: Based on audio duration ($0.23\u002Fhour with Ear-3)\n- AI Operations: Token-based (2M context for Pro)\n- Summarization: 10\u002Fminute (Free), 30\u002Fminute (Pro)\n- Memory Search: 60\u002Fminute (Free), 300\u002Fminute (Pro)\n\n### Step 2: Implement Exponential Backoff with Jitter\n\n```typescript\n\u002F\u002F src\u002Ftwinmind\u002Frate-limit.ts\ninterface RateLimitConfig {\n  maxRetries: number;\n  baseDelayMs: number;\n  maxDelayMs: number;\n  jitterMs: number;\n}\n\nconst defaultConfig: RateLimitConfig = {\n  maxRetries: 5,\n  baseDelayMs: 1000,  # 1000: 1 second in ms\n  maxDelayMs: 60000, \u002F\u002F Max 1 minute  # 60000: 1 minute in ms\n  jitterMs: 500,  # HTTP 500 Internal Server Error\n};\n\nexport async function withRateLimit\u003CT>(\n  operation: () => Promise\u003CT>,\n  config: Partial\u003CRateLimitConfig> = {}\n): Promise\u003CT> {\n  const { maxRetries, baseDelayMs, maxDelayMs, jitterMs } = {\n    ...defaultConfig,\n    ...config,\n  };\n\n  for (let attempt = 0; attempt \u003C= maxRetries; attempt++) {\n    try {\n      return await operation();\n    } catch (error: any) {\n      if (attempt === maxRetries) throw error;\n\n      const status = error.response?.status;\n      if (status !== 429 && status !== 503) throw error; \u002F\u002F Only retry on rate limits  # 503: HTTP 429 Too Many Requests\n\n      \u002F\u002F Check Retry-After header\n      const retryAfter = error.response?.headers?.['retry-after'];\n      let delay: number;\n\n      if (retryAfter) {\n        delay = parseInt(retryAfter) * 1000;  # 1 second in ms\n      } else {\n        \u002F\u002F Exponential backoff with jitter\n        const exponential = baseDelayMs * Math.pow(2, attempt);\n        const jitter = Math.random() * jitterMs;\n        delay = Math.min(exponential + jitter, maxDelayMs);\n      }\n\n      console.log(`Rate limited (attempt ${attempt + 1}). Waiting ${delay}ms...`);\n      await new Promise(r => setTimeout(r, delay));\n    }\n  }\n\n  throw new Error('Max retries exceeded');\n}\n```\n\n### Step 3: Implement Request Queue\n\n```typescript\n\u002F\u002F src\u002Ftwinmind\u002Fqueue.ts\nimport PQueue from 'p-queue';\n\ninterface QueueConfig {\n  concurrency: number;\n  intervalMs: number;\n  intervalCap: number;\n}\n\nconst tierConfigs: Record\u003Cstring, QueueConfig> = {\n  free: { concurrency: 1, intervalMs: 60000, intervalCap: 30 },  # 60000: 1 minute in ms\n  pro: { concurrency: 3, intervalMs: 60000, intervalCap: 60 },  # 1 minute in ms\n  enterprise: { concurrency: 10, intervalMs: 60000, intervalCap: 300 },  # 300: 1 minute in ms\n};\n\nexport class TwinMindQueue {\n  private queue: PQueue;\n  private tier: string;\n\n  constructor(tier: 'free' | 'pro' | 'enterprise' = 'pro') {\n    const config = tierConfigs[tier];\n    this.tier = tier;\n    this.queue = new PQueue({\n      concurrency: config.concurrency,\n      interval: config.intervalMs,\n      intervalCap: config.intervalCap,\n    });\n  }\n\n  async add\u003CT>(operation: () => Promise\u003CT>, priority?: number): Promise\u003CT> {\n    return this.queue.add(operation, { priority }) as Promise\u003CT>;\n  }\n\n  get pending(): number {\n    return this.queue.pending;\n  }\n\n  get size(): number {\n    return this.queue.size;\n  }\n\n  pause(): void {\n    this.queue.pause();\n  }\n\n  resume(): void {\n    this.queue.start();\n  }\n\n  clear(): void {\n    this.queue.clear();\n  }\n}\n\n\u002F\u002F Singleton instance\nlet queueInstance: TwinMindQueue | null = null;\n\nexport function getQueue(tier?: 'free' | 'pro' | 'enterprise'): TwinMindQueue {\n  if (!queueInstance) {\n    queueInstance = new TwinMindQueue(tier);\n  }\n  return queueInstance;\n}\n```\n\n### Step 4: Monitor Rate Limit Headers\n\n```typescript\n\u002F\u002F src\u002Ftwinmind\u002Frate-monitor.ts\nexport interface RateLimitStatus {\n  limit: number;\n  remaining: number;\n  reset: Date;\n  percentUsed: number;\n}\n\nexport class RateLimitMonitor {\n  private limits = new Map\u003Cstring, RateLimitStatus>();\n\n  updateFromResponse(endpoint: string, headers: Headers): void {\n    const limit = parseInt(headers.get('X-RateLimit-Limit') || '60');\n    const remaining = parseInt(headers.get('X-RateLimit-Remaining') || '60');\n    const resetTimestamp = headers.get('X-RateLimit-Reset');\n    const reset = resetTimestamp\n      ? new Date(parseInt(resetTimestamp) * 1000)  # 1000: 1 second in ms\n      : new Date(Date.now() + 60000);  # 60000: 1 minute in ms\n\n    this.limits.set(endpoint, {\n      limit,\n      remaining,\n      reset,\n      percentUsed: ((limit - remaining) \u002F limit) * 100,\n    });\n  }\n\n  getStatus(endpoint: string): RateLimitStatus | undefined {\n    return this.limits.get(endpoint);\n  }\n\n  shouldThrottle(endpoint: string, threshold = 10): boolean {\n    const status = this.limits.get(endpoint);\n    if (!status) return false;\n\n    \u002F\u002F Throttle if remaining \u003C threshold AND reset hasn't happened\n    return status.remaining \u003C threshold && new Date() \u003C status.reset;\n  }\n\n  getWaitTime(endpoint: string): number {\n    const status = this.limits.get(endpoint);\n    if (!status) return 0;\n\n    const now = Date.now();\n    const resetTime = status.reset.getTime();\n\n    return Math.max(0, resetTime - now);\n  }\n\n  getAllStatuses(): Map\u003Cstring, RateLimitStatus> {\n    return new Map(this.limits);\n  }\n}\n\nexport const rateLimitMonitor = new RateLimitMonitor();\n```\n\n### Step 5: Implement Adaptive Rate Limiting\n\n```typescript\n\u002F\u002F src\u002Ftwinmind\u002Fadaptive-limiter.ts\nexport class AdaptiveRateLimiter {\n  private successCount = 0;\n  private failureCount = 0;\n  private currentDelay = 0;\n  private minDelay = 0;\n  private maxDelay = 5000;  # 5000: 5 seconds in ms\n  private windowMs = 60000;  # 60000: 1 minute in ms\n  private windowStart = Date.now();\n\n  recordSuccess(): void {\n    this.maybeResetWindow();\n    this.successCount++;\n\n    \u002F\u002F Decrease delay on success (min 0)\n    if (this.currentDelay > 0) {\n      this.currentDelay = Math.max(0, this.currentDelay - 100);\n    }\n  }\n\n  recordFailure(isRateLimit: boolean): void {\n    this.maybeResetWindow();\n    this.failureCount++;\n\n    if (isRateLimit) {\n      \u002F\u002F Increase delay on rate limit\n      this.currentDelay = Math.min(this.maxDelay, this.currentDelay + 500);  # HTTP 500 Internal Server Error\n    }\n  }\n\n  private maybeResetWindow(): void {\n    const now = Date.now();\n    if (now - this.windowStart > this.windowMs) {\n      this.successCount = 0;\n      this.failureCount = 0;\n      this.windowStart = now;\n    }\n  }\n\n  getDelay(): number {\n    return this.currentDelay;\n  }\n\n  getMetrics(): { success: number; failure: number; delay: number; ratio: number } {\n    const total = this.successCount + this.failureCount;\n    return {\n      success: this.successCount,\n      failure: this.failureCount,\n      delay: this.currentDelay,\n      ratio: total > 0 ? this.successCount \u002F total : 1,\n    };\n  }\n\n  async wait(): Promise\u003Cvoid> {\n    if (this.currentDelay > 0) {\n      await new Promise(r => setTimeout(r, this.currentDelay));\n    }\n  }\n}\n```\n\n### Step 6: Batch Requests for Efficiency\n\n```typescript\n\u002F\u002F src\u002Ftwinmind\u002Fbatch.ts\nexport interface BatchOptions {\n  maxBatchSize: number;\n  maxWaitMs: number;\n}\n\nexport class TranscriptionBatcher {\n  private pending: Array\u003C{\n    audioUrl: string;\n    resolve: (value: any) => void;\n    reject: (error: any) => void;\n  }> = [];\n  private timer: NodeJS.Timeout | null = null;\n  private options: BatchOptions;\n\n  constructor(options: Partial\u003CBatchOptions> = {}) {\n    this.options = {\n      maxBatchSize: 5,\n      maxWaitMs: 1000,  # 1000: 1 second in ms\n      ...options,\n    };\n  }\n\n  async transcribe(audioUrl: string): Promise\u003Cany> {\n    return new Promise((resolve, reject) => {\n      this.pending.push({ audioUrl, resolve, reject });\n\n      if (this.pending.length >= this.options.maxBatchSize) {\n        this.flush();\n      } else if (!this.timer) {\n        this.timer = setTimeout(() => this.flush(), this.options.maxWaitMs);\n      }\n    });\n  }\n\n  private async flush(): Promise\u003Cvoid> {\n    if (this.timer) {\n      clearTimeout(this.timer);\n      this.timer = null;\n    }\n\n    const batch = this.pending.splice(0, this.options.maxBatchSize);\n    if (batch.length === 0) return;\n\n    try {\n      \u002F\u002F Use batch API if available\n      const results = await this.processBatch(batch.map(b => b.audioUrl));\n\n      batch.forEach((item, index) => {\n        item.resolve(results[index]);\n      });\n    } catch (error) {\n      batch.forEach(item => item.reject(error));\n    }\n  }\n\n  private async processBatch(audioUrls: string[]): Promise\u003Cany[]> {\n    const client = getTwinMindClient();\n    const response = await client.post('\u002Ftranscribe\u002Fbatch', {\n      audio_urls: audioUrls,\n      model: 'ear-3',\n    });\n    return response.data.transcripts;\n  }\n}\n```\n\n## Output\n- Reliable API calls with automatic retry\n- Request queue with rate limit awareness\n- Adaptive throttling based on response patterns\n- Batch processing for efficiency\n- Real-time rate limit monitoring\n\n## Error Handling\n\n| Header | Description | Action |\n|--------|-------------|--------|\n| X-RateLimit-Limit | Max requests per window | Monitor total quota |\n| X-RateLimit-Remaining | Remaining in window | Throttle when low |\n| X-RateLimit-Reset | Unix timestamp of reset | Wait until reset |\n| Retry-After | Seconds to wait | Honor this value |\n\n## Rate Limit Best Practices\n\n1. **Always handle 429 responses** - Never let rate limits crash your app\n2. **Use request queues** - Don't burst requests\n3. **Monitor remaining quota** - Throttle before hitting limits\n4. **Implement circuit breakers** - Fail fast when API is overloaded\n5. **Cache responses** - Avoid redundant requests\n6. **Batch when possible** - Reduce total request count\n\n## Resources\n- [TwinMind Rate Limits](https:\u002F\u002Ftwinmind.com\u002Fdocs\u002Frate-limits)\n- [p-queue Documentation](https:\u002F\u002Fgithub.com\u002Fsindresorhus\u002Fp-queue)\n- [Rate Limiting Patterns](https:\u002F\u002Fcloud.google.com\u002Farchitecture\u002Frate-limiting-strategies-techniques)\n\n## Next Steps\nFor security configuration, see `twinmind-security-basics`.\n\n## Examples\n\n**Basic usage**: Apply twinmind rate limits to a standard project setup with default configuration options.\n\n**Advanced scenario**: Customize twinmind rate limits for production environments with multiple constraints and team-specific requirements.","# TwinMind Rate Limits\n\n## Overview\nHandle TwinMind rate limits gracefully with exponential backoff and request optimization.\n\n## Prerequisites\n- TwinMind API access (Pro\u002FEnterprise)\n- Understanding of async\u002Fawait patterns\n- Familiarity with rate limiting concepts\n\n## Instructions\n\n### Step 1: Understand Rate Limit Tiers\n\n| Tier | Audio Hours\u002FMonth | API Requests\u002FMin | Concurrent Transcriptions | Burst |\n|------|-------------------|------------------|--------------------------|-------|\n| Free | Unlimited | 30 | 1 | 5 |\n| Pro ($10\u002Fmo) | Unlimited | 60 | 3 | 15 |\n| Enterprise | Unlimited | 300 | 10 | 50 |\n\n**Key Limits:**\n- Transcription: Based on audio duration ($0.23\u002Fhour with Ear-3)\n- AI Operations: Token-based (2M context for Pro)\n- Summarization: 10\u002Fminute (Free), 30\u002Fminute (Pro)\n- Memory Search: 60\u002Fminute (Free), 300\u002Fminute (Pro)\n\n### Step 2: Implement Exponential Backoff with Jitter\n\n```typescript\n\u002F\u002F src\u002Ftwinmind\u002Frate-limit.ts\ninterface RateLimitConfig {\n  maxRetries: number;\n  baseDelayMs: number;\n  maxDelayMs: number;\n  jitterMs: number;\n}\n\nconst defaultConfig: RateLimitConfig = {\n  maxRetries: 5,\n  baseDelayMs: 1000,  # 1000: 1 second in ms\n  maxDelayMs: 60000, \u002F\u002F Max 1 minute  # 60000: 1 minute in ms\n  jitterMs: 500,  # HTTP 500 Internal Server Error\n};\n\nexport async function withRateLimit\u003CT>(\n  operation: () => Promise\u003CT>,\n  config: Partial\u003CRateLimitConfig> = {}\n): Promise\u003CT> {\n  const { maxRetries, baseDelayMs, maxDelayMs, jitterMs } = {\n    ...defaultConfig,\n    ...config,\n  };\n\n  for (let attempt = 0; attempt \u003C= maxRetries; attempt++) {\n    try {\n      return await operation();\n    } catch (error: any) {\n      if (attempt === maxRetries) throw error;\n\n      const status = error.response?.status;\n      if (status !== 429 && status !== 503) throw error; \u002F\u002F Only retry on rate limits  # 503: HTTP 429 Too Many Requests\n\n      \u002F\u002F Check Retry-After header\n      const retryAfter = error.response?.headers?.['retry-after'];\n      let delay: number;\n\n      if (retryAfter) {\n        delay = parseInt(retryAfter) * 1000;  # 1 second in ms\n      } else {\n        \u002F\u002F Exponential backoff with jitter\n        const exponential = baseDelayMs * Math.pow(2, attempt);\n        const jitter = Math.random() * jitterMs;\n        delay = Math.min(exponential + jitter, maxDelayMs);\n      }\n\n      console.log(`Rate limited (attempt ${attempt + 1}). Waiting ${delay}ms...`);\n      await new Promise(r => setTimeout(r, delay));\n    }\n  }\n\n  throw new Error('Max retries exceeded');\n}\n```\n\n### Step 3: Implement Request Queue\n\n```typescript\n\u002F\u002F src\u002Ftwinmind\u002Fqueue.ts\nimport PQueue from 'p-queue';\n\ninterface QueueConfig {\n  concurrency: number;\n  intervalMs: number;\n  intervalCap: number;\n}\n\nconst tierConfigs: Record\u003Cstring, QueueConfig> = {\n  free: { concurrency: 1, intervalMs: 60000, intervalCap: 30 },  # 60000: 1 minute in ms\n  pro: { concurrency: 3, intervalMs: 60000, intervalCap: 60 },  # 1 minute in ms\n  enterprise: { concurrency: 10, intervalMs: 60000, intervalCap: 300 },  # 300: 1 minute in ms\n};\n\nexport class TwinMindQueue {\n  private queue: PQueue;\n  private tier: string;\n\n  constructor(tier: 'free' | 'pro' | 'enterprise' = 'pro') {\n    const config = tierConfigs[tier];\n    this.tier = tier;\n    this.queue = new PQueue({\n      concurrency: config.concurrency,\n      interval: config.intervalMs,\n      intervalCap: config.intervalCap,\n    });\n  }\n\n  async add\u003CT>(operation: () => Promise\u003CT>, priority?: number): Promise\u003CT> {\n    return this.queue.add(operation, { priority }) as Promise\u003CT>;\n  }\n\n  get pending(): number {\n    return this.queue.pending;\n  }\n\n  get size(): number {\n    return this.queue.size;\n  }\n\n  pause(): void {\n    this.queue.pause();\n  }\n\n  resume(): void {\n    this.queue.start();\n  }\n\n  clear(): void {\n    this.queue.clear();\n  }\n}\n\n\u002F\u002F Singleton instance\nlet queueInstance: TwinMindQueue | null = null;\n\nexport function getQueue(tier?: 'free' | 'pro' | 'enterprise'): TwinMindQueue {\n  if (!queueInstance) {\n    queueInstance = new TwinMindQueue(tier);\n  }\n  return queueInstance;\n}\n```\n\n### Step 4: Monitor Rate Limit Headers\n\n```typescript\n\u002F\u002F src\u002Ftwinmind\u002Frate-monitor.ts\nexport interface RateLimitStatus {\n  limit: number;\n  remaining: number;\n  reset: Date;\n  percentUsed: number;\n}\n\nexport class RateLimitMonitor {\n  private limits = new Map\u003Cstring, RateLimitStatus>();\n\n  updateFromResponse(endpoint: string, headers: Headers): void {\n    const limit = parseInt(headers.get('X-RateLimit-Limit') || '60');\n    const remaining = parseInt(headers.get('X-RateLimit-Remaining') || '60');\n    const resetTimestamp = headers.get('X-RateLimit-Reset');\n    const reset = resetTimestamp\n      ? new Date(parseInt(resetTimestamp) * 1000)  # 1000: 1 second in ms\n      : new Date(Date.now() + 60000);  # 60000: 1 minute in ms\n\n    this.limits.set(endpoint, {\n      limit,\n      remaining,\n      reset,\n      percentUsed: ((limit - remaining) \u002F limit) * 100,\n    });\n  }\n\n  getStatus(endpoint: string): RateLimitStatus | undefined {\n    return this.limits.get(endpoint);\n  }\n\n  shouldThrottle(endpoint: string, threshold = 10): boolean {\n    const status = this.limits.get(endpoint);\n    if (!status) return false;\n\n    \u002F\u002F Throttle if remaining \u003C threshold AND reset hasn't happened\n    return status.remaining \u003C threshold && new Date() \u003C status.reset;\n  }\n\n  getWaitTime(endpoint: string): number {\n    const status = this.limits.get(endpoint);\n    if (!status) return 0;\n\n    const now = Date.now();\n    const resetTime = status.reset.getTime();\n\n    return Math.max(0, resetTime - now);\n  }\n\n  getAllStatuses(): Map\u003Cstring, RateLimitStatus> {\n    return new Map(this.limits);\n  }\n}\n\nexport const rateLimitMonitor = new RateLimitMonitor();\n```\n\n### Step 5: Implement Adaptive Rate Limiting\n\n```typescript\n\u002F\u002F src\u002Ftwinmind\u002Fadaptive-limiter.ts\nexport class AdaptiveRateLimiter {\n  private successCount = 0;\n  private failureCount = 0;\n  private currentDelay = 0;\n  private minDelay = 0;\n  private maxDelay = 5000;  # 5000: 5 seconds in ms\n  private windowMs = 60000;  # 60000: 1 minute in ms\n  private windowStart = Date.now();\n\n  recordSuccess(): void {\n    this.maybeResetWindow();\n    this.successCount++;\n\n    \u002F\u002F Decrease delay on success (min 0)\n    if (this.currentDelay > 0) {\n      this.currentDelay = Math.max(0, this.currentDelay - 100);\n    }\n  }\n\n  recordFailure(isRateLimit: boolean): void {\n    this.maybeResetWindow();\n    this.failureCount++;\n\n    if (isRateLimit) {\n      \u002F\u002F Increase delay on rate limit\n      this.currentDelay = Math.min(this.maxDelay, this.currentDelay + 500);  # HTTP 500 Internal Server Error\n    }\n  }\n\n  private maybeResetWindow(): void {\n    const now = Date.now();\n    if (now - this.windowStart > this.windowMs) {\n      this.successCount = 0;\n      this.failureCount = 0;\n      this.windowStart = now;\n    }\n  }\n\n  getDelay(): number {\n    return this.currentDelay;\n  }\n\n  getMetrics(): { success: number; failure: number; delay: number; ratio: number } {\n    const total = this.successCount + this.failureCount;\n    return {\n      success: this.successCount,\n      failure: this.failureCount,\n      delay: this.currentDelay,\n      ratio: total > 0 ? this.successCount \u002F total : 1,\n    };\n  }\n\n  async wait(): Promise\u003Cvoid> {\n    if (this.currentDelay > 0) {\n      await new Promise(r => setTimeout(r, this.currentDelay));\n    }\n  }\n}\n```\n\n### Step 6: Batch Requests for Efficiency\n\n```typescript\n\u002F\u002F src\u002Ftwinmind\u002Fbatch.ts\nexport interface BatchOptions {\n  maxBatchSize: number;\n  maxWaitMs: number;\n}\n\nexport class TranscriptionBatcher {\n  private pending: Array\u003C{\n    audioUrl: string;\n    resolve: (value: any) => void;\n    reject: (error: any) => void;\n  }> = [];\n  private timer: NodeJS.Timeout | null = null;\n  private options: BatchOptions;\n\n  constructor(options: Partial\u003CBatchOptions> = {}) {\n    this.options = {\n      maxBatchSize: 5,\n      maxWaitMs: 1000,  # 1000: 1 second in ms\n      ...options,\n    };\n  }\n\n  async transcribe(audioUrl: string): Promise\u003Cany> {\n    return new Promise((resolve, reject) => {\n      this.pending.push({ audioUrl, resolve, reject });\n\n      if (this.pending.length >= this.options.maxBatchSize) {\n        this.flush();\n      } else if (!this.timer) {\n        this.timer = setTimeout(() => this.flush(), this.options.maxWaitMs);\n      }\n    });\n  }\n\n  private async flush(): Promise\u003Cvoid> {\n    if (this.timer) {\n      clearTimeout(this.timer);\n      this.timer = null;\n    }\n\n    const batch = this.pending.splice(0, this.options.maxBatchSize);\n    if (batch.length === 0) return;\n\n    try {\n      \u002F\u002F Use batch API if available\n      const results = await this.processBatch(batch.map(b => b.audioUrl));\n\n      batch.forEach((item, index) => {\n        item.resolve(results[index]);\n      });\n    } catch (error) {\n      batch.forEach(item => item.reject(error));\n    }\n  }\n\n  private async processBatch(audioUrls: string[]): Promise\u003Cany[]> {\n    const client = getTwinMindClient();\n    const response = await client.post('\u002Ftranscribe\u002Fbatch', {\n      audio_urls: audioUrls,\n      model: 'ear-3',\n    });\n    return response.data.transcripts;\n  }\n}\n```\n\n## Output\n- Reliable API calls with automatic retry\n- Request queue with rate limit awareness\n- Adaptive throttling based on response patterns\n- Batch processing for efficiency\n- Real-time rate limit monitoring\n\n## Error Handling\n\n| Header | Description | Action |\n|--------|-------------|--------|\n| X-RateLimit-Limit | Max requests per window | Monitor total quota |\n| X-RateLimit-Remaining | Remaining in window | Throttle when low |\n| X-RateLimit-Reset | Unix timestamp of reset | Wait until reset |\n| Retry-After | Seconds to wait | Honor this value |\n\n## Rate Limit Best Practices\n\n1. **Always handle 429 responses** - Never let rate limits crash your app\n2. **Use request queues** - Don't burst requests\n3. **Monitor remaining quota** - Throttle before hitting limits\n4. **Implement circuit breakers** - Fail fast when API is overloaded\n5. **Cache responses** - Avoid redundant requests\n6. **Batch when possible** - Reduce total request count\n\n## Resources\n- [TwinMind Rate Limits](https:\u002F\u002Ftwinmind.com\u002Fdocs\u002Frate-limits)\n- [p-queue Documentation](https:\u002F\u002Fgithub.com\u002Fsindresorhus\u002Fp-queue)\n- [Rate Limiting Patterns](https:\u002F\u002Fcloud.google.com\u002Farchitecture\u002Frate-limiting-strategies-techniques)\n\n## Next Steps\nFor security configuration, see `twinmind-security-basics`.\n\n## Examples\n\n**Basic usage**: Apply twinmind rate limits to a standard project setup with default configuration options.\n\n**Advanced scenario**: Customize twinmind rate limits for production environments with multiple constraints and team-specific requirements.",{"name":5,"author":43,"license":14,"version":44,"description":45,"allowed-tools":46,"compatible-with":47},"Jeremy Longshore \u003Cjeremy@intentsolutions.io>","1.0.0","Implement TwinMind rate limiting, backoff, and optimization patterns.\nUse when handling rate limit errors, implementing retry logic,\nor optimizing API request throughput for TwinMind.\nTrigger with phrases like \"twinmind rate limit\", \"twinmind throttling\",\n\"twinmind 429\", \"twinmind retry\", \"twinmind backoff\".\n","Read, Write, Edit","claude-code, codex, openclaw","master","3f5d983eb4ef375b749adcd6b07ec03bd82ae8a8","claude-code\u002Fplugins-plus-skills\u002Fplugins\u002Fsaas-packs\u002Ftwinmind-pack\u002Fskills\u002Ftwinmind-rate-limits",0,"https:\u002F\u002Fgithub.com\u002Fmicsapp\u002Fmicstec-skills","https:\u002F\u002Fgithub.com\u002Fmicsapp","2026-03-20 11:24:18",{"source":8,"skillName":5,"commands":56,"prompt":66,"zipAvailable":67},[57,60,63],{"tool":58,"command":59},"npx","npx skills add micsapp\u002Fmicstec-skills --skill twinmind-rate-limits",{"tool":61,"command":62},"bunx","bunx skills add micsapp\u002Fmicstec-skills --skill twinmind-rate-limits",{"tool":64,"command":65},"pnpm","pnpm dlx skills add micsapp\u002Fmicstec-skills --skill twinmind-rate-limits","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmicsapp\u002Fmicstec-skills\u002Fblob\u002Fmaster\u002Fclaude-code\u002Fplugins-plus-skills\u002Fplugins\u002Fsaas-packs\u002Ftwinmind-pack\u002Fskills\u002Ftwinmind-rate-limits\u002FSKILL.md",true,[],[70,104,132,152,172,197],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":86,"publishedAt":38},"01M6HBTJ02FXBFG9NYEHHYAP52","azure-apim-architecture","Analyzes and explains Azure API Management architecture decisions for enterprise API marketplace implementations using VNet Internal mode, Front Door, hybrid authentication, and multi-environment strategies. Use when discussing APIM component selection, network topology, cost optimization, or comparing alternatives like workspaces vs instances, VNet Internal vs External mode, or Front Door vs Application Gateway.","https:\u002F\u002Fgithub.com\u002Fmicsapp\u002Fmicstec-skills\u002Fblob\u002Fmaster\u002Fcopilot-cli\u002Fcopilot-agent-skills\u002F.github\u002Fskills\u002Fazure-apim-architecture\u002FSKILL.md",[76,81],{"categoryNo":77,"categoryName":78,"taxonomyType":79,"taxonomyTypeDesc":80},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",{"categoryNo":82,"categoryName":83,"taxonomyType":84,"taxonomyTypeDesc":85},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[87,88,89,90,91,92,93,35,94,33,95,96,97,98,99,100,101,102,103,20],"architecture","azure","azure apim architecture","component","authentication","gateway","topology","network","team","environment","multi-environment","workspaces","instances","selection","strategies","azure api management","mode",{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":118,"publishedAt":38},"01M6HBT7J4H082JEEA670B3EQ9","apiops-deployment","Guides deployment of Azure API Management infrastructure using Infrastructure as Code (Bicep\u002FTerraform), CI\u002FCD pipelines (GitHub Actions\u002FAzure DevOps), and APIOps workflows. Use when deploying APIM, creating pipelines, or implementing dev→test→prod promotion strategies.","https:\u002F\u002Fgithub.com\u002Fmicsapp\u002Fmicstec-skills\u002Fblob\u002Fmaster\u002Fcopilot-cli\u002Fcopilot-agent-skills\u002F.github\u002Fskills\u002Fapiops-deployment\u002FSKILL.md",[110,111,114,117],{"categoryNo":77,"categoryName":78,"taxonomyType":79,"taxonomyTypeDesc":80},{"categoryNo":112,"categoryName":113,"taxonomyType":79,"taxonomyTypeDesc":80},"01JBSEEDCAT000000000000011","运维与部署",{"categoryNo":115,"categoryName":116,"taxonomyType":79,"taxonomyTypeDesc":80},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":82,"categoryName":83,"taxonomyType":84,"taxonomyTypeDesc":85},[119,120,121,122,88,123,36,124,125,126,127,128,33,95,101,129,130,102,131,21],"deployment","apiops deployment","workflows","azure devops","infrastructure","infrastructure as code","actions","ci","github actions","github-actions","as","guides","CI\u002FCD",{"skillNo":133,"name":134,"nameZh":6,"description":135,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":136,"categories":137,"keywords":139,"publishedAt":38},"01M6HBT2HEA23THNE9E00GYQBE","apim-policy-authoring","Creates production-ready Azure API Management policy XML for authentication (OAuth 2.0, JWT validation, subscription keys), rate limiting, CORS configuration, error handling, and API transformations. Use when implementing API security, access control, or request\u002Fresponse processing logic.","https:\u002F\u002Fgithub.com\u002Fmicsapp\u002Fmicstec-skills\u002Fblob\u002Fmaster\u002Fcopilot-cli\u002Fcopilot-agent-skills\u002F.github\u002Fskills\u002Fapim-policy-authoring\u002FSKILL.md",[138],{"categoryNo":77,"categoryName":78,"taxonomyType":79,"taxonomyTypeDesc":80},[140,141,142,143,88,91,33,95,144,32,145,146,147,148,149,102,150,151,21,20],"policy","authoring","apim policy authoring","security","access","ready","api security","Access Control","error","processing","cors configuration","production-ready",{"skillNo":153,"name":154,"nameZh":6,"description":155,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":156,"categories":157,"keywords":160,"publishedAt":38},"01M6HBSY65SB29J9WE9KYD0K6T","api-security-review","Reviews Azure API Management configurations for security vulnerabilities, OWASP API Security Top 10 compliance, VNet Internal mode validation, Private Link verification, and Azure Security Benchmark alignment. Use when performing security audits, pre-deployment validation, or compliance reviews.","https:\u002F\u002Fgithub.com\u002Fmicsapp\u002Fmicstec-skills\u002Fblob\u002Fmaster\u002Fcopilot-cli\u002Fcopilot-agent-skills\u002F.github\u002Fskills\u002Fapi-security-review\u002FSKILL.md",[158,159],{"categoryNo":77,"categoryName":78,"taxonomyType":79,"taxonomyTypeDesc":80},{"categoryNo":82,"categoryName":83,"taxonomyType":84,"taxonomyTypeDesc":85},[161,143,162,33,146,163,88,119,164,165,166,167,95,168,102,169,170,171,103,20],"review","security review","api security review","benchmark","verification","owasp","owasp-api","alignment","azure security","reviews","top",{"skillNo":173,"name":174,"nameZh":6,"description":175,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":176,"categories":177,"keywords":178,"publishedAt":38},"01M6HBSRW4PDFE6K4F8JYPZQ05","jira-cli","Interact with Jira from the command line to create, list, view, edit, and transition issues, manage sprints and epics, and perform common Jira workflows. Use when the user asks about Jira tasks, tickets, issues, sprints, or needs to manage project work items.","https:\u002F\u002Fgithub.com\u002Fmicsapp\u002Fmicstec-skills\u002Fblob\u002Fmaster\u002Fcopilot-cli\u002Fawesome-copilot-agents\u002Fskills\u002Fjira-cli\u002FSKILL.md",[],[179,180,181,121,182,183,184,185,33,186,187,188,189,190,191,192,193,194,195,196],"cli","jira","jira cli","init","tasks","create","issues","common","work","command","edit","list","view","project","project work","token","line","sprints",{"skillNo":198,"name":199,"nameZh":6,"description":200,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":201,"categories":202,"keywords":203,"publishedAt":38},"01M6HBSNS3JHMW603G47TWE31H","calculator","Performs arbitrary-precision arithmetic calculations including addition, subtraction, multiplication, division, and exponents. Use when the user asks to calculate, compute, or evaluate math expressions, or when precise decimal arithmetic is needed to avoid floating-point errors.","https:\u002F\u002Fgithub.com\u002Fmicsapp\u002Fmicstec-skills\u002Fblob\u002Fmaster\u002Fcopilot-cli\u002Fawesome-copilot-agents\u002Fskills\u002Fcalculator\u002FSKILL.md",[],[199,204,205,206,207,208,209,32,210,23],"npm","js","calculate","node","math","user","compute"]