aj-geddes avatar

Circuit Breaker Pattern

Prevents cascading failures when your dependencies go down by wrapping calls in a state machine that trips open after repeated failures, then periodically tests if the service has recovered. Includes TypeScript, Python, and Java implementations with configurable failure thresholds, timeout handling, and half-open testing states. The monitoring examples are solid if you're running this in production. Honestly essential for any system calling flaky external APIs or microservices, though you'll want to tune the thresholds carefully since the defaults won't match your actual traffic patterns. The Opossum and Resilience4j style guides are nice if you're familiar with those libraries.

skills.sh installs
480
GitHub stars
379
last updated
Aug 21, 2026

Install

$ npx -y skills add aj-geddes/useful-ai-prompts --skill circuit-breaker-pattern --agent claude-code

Installs into .claude/skills of the current project.

Files

Circuit Breaker Pattern

Table of Contents

Overview

Implement circuit breaker patterns to prevent cascading failures and provide graceful degradation when dependencies fail.

When to Use

  • External API calls
  • Microservices communication
  • Database connections
  • Third-party service integrations
  • Preventing cascading failures
  • Implementing fallback mechanisms
  • Rate limiting protection
  • Timeout handling

Quick Start

Minimal working example:

enum CircuitState {
  CLOSED = "CLOSED",
  OPEN = "OPEN",
  HALF_OPEN = "HALF_OPEN",
}

interface CircuitBreakerConfig {
  failureThreshold: number;
  successThreshold: number;
  timeout: number;
  resetTimeout: number;
}

interface CircuitBreakerStats {
  failures: number;
  successes: number;
  consecutiveFailures: number;
  consecutiveSuccesses: number;
  lastFailureTime?: number;
}

Sponsors

Details

Repository
github.com/aj-geddes/useful-ai-prompts
Category
AI & Agent Building
First seen
Jun 3, 2026

More from aj-geddes/useful-ai-prompts

All 258
1aj-geddes avatarbatch-processing-jobsaj-geddes/useful-ai-promptsImplement robust batch processing systems with job queues, schedulers, background tasks, and distributed workers. Use when processing large datasets, scheduled 479skills.sh installs
2jwynia avatarflash-fictionjwynia/agent-skillsDiagnose and fix problems in flash fiction and micro fiction. Use when flash fiction feels weak, when writing stories under 1500 words, when working with micro 479skills.sh installs
3jwynia avatarrevisionjwynia/agent-skillsGuide the edit pass after drafting. Use when revision feels overwhelming, when changes cascade unpredictably, when you can't see problems anymore, or when editi479skills.sh installs
4aj-geddes avataraws-cloudfront-cdnaj-geddes/useful-ai-promptsDistribute content globally using CloudFront with caching, security headers, WAF integration, and origin configuration. Use for low-latency content delivery.478skills.sh installs
5aj-geddes avatarmutation-testingaj-geddes/useful-ai-promptsEvaluate test suite quality by introducing code mutations and verifying tests catch them. Use for mutation testing, test quality, mutant detection, Stryker, PIT478skills.sh installs
6rstackjs avatarrsdoctor-analysisrstackjs/agent-skillsUse when analyzing Rspack/Webpack bundles from local `rsdoctor-data.json` and producing evidence-based optimization recommendations.478skills.sh installs