/harness-claude:resilience-retry-patternfrom harness-claude
Implements retry logic with exponential backoff and jitter for handling transient failures in network requests, database connections, and rate-limited APIs.
Claude never picks this skill on its own
Its frontmatter has no description. Without a description, Claude Code leaves it out of the list Claude chooses from. Typing /harness-claude:resilience-retry-pattern still runs it.
What the skill costs in Claude's context, stage by stage
No description Claude Code can read, so Claude's list leaves it out: only you can start it.
SKILL.md joins the conversation and stays.
Handle transient failures with configurable retry strategies, exponential backoff, and jitter
delay = baseDelay * 2^attempt. This prevents thundering herd.delay = baseDelay * 2^attempt * (0.5 + random()). This spreads retry storms.// utils/retry.ts
interface RetryOptions {
maxAttempts: number;
baseDelay: number;
maxDelay: number;
shouldRetry?: (error: unknown, attempt: number) => boolean;
onRetry?: (error: unknown, attempt: number, delay: number) => void;
}
const DEFAULT_OPTIONS: RetryOptions = {
maxAttempts: 3,
baseDelay: 1000,
maxDelay: 30000,
shouldRetry: () => true,
};
export async function withRetry<T>(
fn: () => Promise<T>,
options: Partial<RetryOptions> = {}
): Promise<T> {
const opts = { ...DEFAULT_OPTIONS, ...options };
let lastError: unknown;
for (let attempt = 0; attempt < opts.maxAttempts; attempt++) {
try {
return await fn();
} catch (error) {
lastError = error;
if (attempt === opts.maxAttempts - 1) break;
if (!opts.shouldRetry!(error, attempt)) break;
// Exponential backoff with full jitter
const exponentialDelay = opts.baseDelay * Math.pow(2, attempt);
const jitter = Math.random();
const delay = Math.min(exponentialDelay * jitter, opts.maxDelay);
opts.onRetry?.(error, attempt + 1, delay);
await new Promise((resolve) => setTimeout(resolve, delay));
}
}
throw lastError;
}
// Usage
import { withRetry } from './utils/retry';
const user = await withRetry(
() =>
fetch('/api/users/123').then((r) => {
if (!r.ok) throw new Error(`HTTP ${r.status}`);
return r.json();
}),
{
maxAttempts: 3,
baseDelay: 1000,
shouldRetry: (error) => {
if (error instanceof Error && error.message.includes('HTTP 4')) return false;
return true; // Retry 5xx and network errors
},
onRetry: (error, attempt, delay) => {
console.warn(`Retry ${attempt} after ${delay}ms: ${error}`);
},
}
);
Backoff strategies:
delay = baseDelay * attempt. Gentle ramp-up.delay = baseDelay * 2^attempt. Standard for APIs.Jitter types:
random(0, baseDelay * 2^attempt) — most spread, lowest contentionbaseDelay * 2^attempt / 2 + random(0, baseDelay * 2^attempt / 2) — guaranteed minimum waitmin(maxDelay, random(baseDelay, prevDelay * 3)) — Amazon recommendationRetry-After header: Some APIs return Retry-After with 429 or 503 responses. Always respect this header over your calculated backoff.
What NOT to retry:
Libraries: p-retry, async-retry, cockatiel (composable policies), axios-retry.
https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
retry-pattern, exponential-backoff, jitter, fault-tolerance, resilience
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeRead when SKILL.md points to them.
793 skills in this plugin
/a11y-aria-patternsARIA Patterns> Apply ARIA roles, states, and properties correctly to enhance assistive technology support for custom widgets/a11y-color-contrastColor Contrast and Color Independence> Ensure sufficient color contrast ratios and never use color as the sole means of conveying information/a11y-form-patternsAccessible Form Patterns> Build accessible forms with proper labeling, grouped controls, inline validation, and clear error communicationOther plugins' skills for the same job