Retry Helper With Jitter and a Budget
Write a small retry helper for calling someone else's API. Retry the failures that are transient. Do not retry a 400. CONTEXT Call: [HTTP JSON API] Idempotent: [YES | NO — if no, retries are off by default] Max attempts: [3] Budget: [2 SECONDS TOTAL] Respect Retry-After: [YES] DELIVER 1) The function signature: the operation, a classifier, and options. The classifier returns retry or throw for status codes and network errors. 2) Backoff: exponential plus full jitter, capped so the sum stays inside the budget. Show the numbers for the default. 3) Retry-After honored when present, still inside the budget. 4) Attempt count logged, no retry on abort. 5) Tests: a 500 then a 200, a 400 that does not retry, a Retry-After that delays, an operation that is not idempotent and therefore does not retry unless the caller opts in. 6) A note on where this must not wrap a non-idempotent charge unless the charge itself has an idempotency key. Keep it dependency-free unless I asked for a library.
🌟 Example Output / Preview
Prompt Metadata
Primary Use Cases:
- •Legacy code modernization & technical refactoring
- •Full-stack layout generation & component structuring
- •CI/CD workflow automation & unit/E2E testing suites
Associated Tags:
💡 Pro Tips & Advice
1. Use bracketed items: Be sure to fill out all [PLACEHOLDER] elements with specific details before sending the prompt to the AI model.
2. Adjust temperature: For creative tasks, set AI temperature higher (e.g., 0.8), or lower (e.g., 0.2) for strict coding/technical tasks.
🔗 Related AI Prompts
Full SaaS Landing Page Build Spec (SEO + Conversion)
You are a Staff Product Designer + Frontend Engineer + SEO strategist. Build a complete, production-ready marketing landing page f...
SaaS Analytics Dashboard Full Build Spec
You are a Principal Product Designer + Frontend Lead. Design and specify a complete [LIGHT | DARK] analytics dashboard for [PRODUC...
SaaS Admin Panel Dashboard Build Spec
Design a full internal Admin Dashboard for [PRODUCT_NAME] used by [ADMIN_ROLE: support | ops | super-admin]. --- 🎯 CONTEXT Adm...