$ recombobulate _
home / tips / ask-claude-to-add-retry-logic-with-exponential-backoff
106

Ask Claude to Add Retry Logic with Exponential Backoff

recombobulate @recombobulate · Mar 26, 2026 · Workflows
ask-claude-to-add-retry-logic-with-exponential-backoff

A production API integration without retry logic is a support ticket waiting to happen. The problem is, writing it correctly — with jitter, header inspection, and circuit breaking — is tedious. Claude handles all of it.

Add retry logic with exponential backoff to the fetchUserData function
in src/api/users.ts. Retry up to 3 times on 429 and 5xx responses.
Use 500ms as the initial delay, double it each attempt, and add random
jitter to prevent thundering herd problems.

Claude covers the subtle bits you'd likely miss on a first pass: respecting Retry-After response headers, distinguishing retryable errors (429, 503) from non-retryable ones (400, 401, 404), and adding enough logging to diagnose retry storms in production.

// Ask for a reusable generic wrapper
Write a generic retry<T>(fn: () => Promise<T>, options: RetryOptions) utility
in src/utils/retry.ts. Include:
- Configurable max retries and base delay
- Exponential backoff with jitter
- An optional shouldRetry predicate for custom logic
- A circuit breaker that opens after N consecutive failures

You can also ask Claude to wrap an entire service class rather than individual functions, so the retry behaviour is applied consistently without repeating yourself.

Resilient API integrations aren't optional in production — Claude makes them trivial to add.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Run Claude Code in GitHub Actions to Automatically Review Every Pull Request

Set up Claude Code as an automated reviewer in your CI pipeline — on every pull request, it reads the diff, checks for bugs, security issues, missing tests, and convention violations, then posts its findings as a PR comment. Your human reviewers get a head start because the obvious issues are already flagged before they look.

recombobulate @recombobulate · 1 month ago
0
Ask Claude to Build a Deployment Checklist from Your Actual Infrastructure

Before deploying, tell Claude to read your project — migrations, environment variables, queue workers, scheduled tasks, caching, third-party integrations — and generate a deployment checklist that's specific to your app. Not a generic "did you run migrations?" list, but one that knows YOUR infrastructure and catches the things YOUR deploy can break.

recombobulate @recombobulate · 1 month ago
0
Ask Claude to Generate a README from Your Actual Codebase — Not a Template

Instead of writing a README from memory or copying a template, tell Claude to read your project and generate one that's actually accurate — real setup instructions from your config, real architecture from your directory structure, real API examples from your routes, and real prerequisites from your dependency files.

recombobulate @recombobulate · 1 month ago