[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M796S3DYWFXFDMAXD9B5VH7N":3,"skill-same:01M796S3DYWFXFDMAXD9B5VH7N":56},{"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":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":33,"commitSha":34,"skillDirectory":35,"forksCount":36,"repositoryHtmlUrl":37,"repositoryHomepageUrl":6,"ownerHtmlUrl":38,"ownerBlogUrl":39,"ownerDescription":40,"updatedAt":41,"install":42,"resources":55},"01M796S3DYWFXFDMAXD9B5VH7N","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\".","jukeyman\u002Fjukeyman-skills","jukeyman","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F142960420?v=4","01M78FR4Y3DHMMCBCC0GXXNB3F","RICK JEFFERSON","01M78FR4Z8RVQRAD31Y5J7V6EB",1,"MIT","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fsaas-packs--twinmind-pack--twinmind-rate-limits\u002FSKILL.md",[],[],"2026-11-15 14:19:17",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\ntags: [saas, twinmind, api]\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,"tags":24,"author":28,"license":15,"version":29,"description":30,"allowed-tools":31,"compatible-with":32},[25,26,27],"saas","twinmind","api","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","main","99825ad3f3bcc6597ddcc7294a14e6e922f2b67b","skills\u002Fsaas-packs--twinmind-pack--twinmind-rate-limits",0,"https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills","https:\u002F\u002Fgithub.com\u002Fjukeyman","https:\u002F\u002FRJBUSINESSSOLUTIONS.ORG","Credit and Finance Expert | Developer\r\n\r\nI'm Rick Jefferson, a seasoned credit and finance expert with over a decade of experience in financial literacy,","2026-07-13 07:03:29",{"source":8,"skillName":5,"commands":43,"prompt":53,"zipAvailable":54},[44,47,50],{"tool":45,"command":46},"npx","npx skills add jukeyman\u002Fjukeyman-skills --skill twinmind-rate-limits",{"tool":48,"command":49},"bunx","bunx skills add jukeyman\u002Fjukeyman-skills --skill twinmind-rate-limits",{"tool":51,"command":52},"pnpm","pnpm dlx skills add jukeyman\u002Fjukeyman-skills --skill twinmind-rate-limits","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fsaas-packs--twinmind-pack--twinmind-rate-limits\u002FSKILL.md",true,[],[57,64,71,78,85,93],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M79ANS2SM329NEP5ZCX106RR","zustand-store-creator","Create zustand store creator operations. Auto-activating skill for Frontend Development.\nTriggers on: zustand store creator, zustand store creator\nPart of the Frontend Development skill category. Use when working with zustand store creator functionality. Trigger with phrases like \"zustand store creator\", \"zustand creator\", \"zustand\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzustand-store-creator\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M79AMZKP4YDEZ7EHG1Y7PP74","zero-trust-config-helper","Configure with zero trust config helper operations. Auto-activating skill for Security Advanced.\nTriggers on: zero trust config helper, zero trust config helper\nPart of the Security Advanced skill category. Use when configuring systems or services. Trigger with phrases like \"zero trust config helper\", \"zero helper\", \"zero\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzero-trust-config-helper\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M79AMJSBCEJQNBTYNAHYN5HM","zapier-integration-helper","Assist with zapier integration helper operations. Auto-activating skill for Business Automation.\nTriggers on: zapier integration helper, zapier integration helper\nPart of the Business Automation skill category. Use when working with APIs or building integrations. Trigger with phrases like \"zapier integration helper\", \"zapier helper\", \"zapier\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzapier-integration-helper\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M79AHJZGVMARS13VFQYRR1MP","yaml-config-validator","Validate yaml config validator operations. Auto-activating skill for DevOps Basics.\nTriggers on: yaml config validator, yaml config validator\nPart of the DevOps Basics skill category. Use when configuring systems or services. Trigger with phrases like \"yaml config validator\", \"yaml validator\", \"yaml\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fyaml-config-validator\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":89,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M79AHGDZRN0020RDQSQDPAM8","xvary-stock-research","Thesis-driven equity analysis from public SEC EDGAR and market data; \u002Fanalyze, \u002Fscore, \u002Fcompare workflows with bundled Python tools (Claude Code, Cursor, Codex).","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxvary-stock-research\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxvary-stock-research\u002FSKILL.md",[],[],{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":19},"01M79AHCYJ9FV9RMHQ24HDRN33","xss-vulnerability-scanner","Scan xss vulnerability scanner operations. Auto-activating skill for Security Fundamentals.\nTriggers on: xss vulnerability scanner, xss vulnerability scanner\nPart of the Security Fundamentals skill category. Use when working with xss vulnerability scanner functionality. Trigger with phrases like \"xss vulnerability scanner\", \"xss scanner\", \"xss\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxss-vulnerability-scanner\u002FSKILL.md",[],[]]