Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
aj-geddes avatar

Circuit Breaker Pattern

  • 426 installs
  • 305 repo stars
  • Updated March 4, 2026
  • aj-geddes/useful-ai-prompts

circuit-breaker-pattern is an agent skill that implements circuit breakers with open, half-open, and closed thresholds, fallbacks, and observability hooks for developers calling flaky downstream HTTP, queue, or microserv

About

circuit-breaker-pattern from aj-geddes/useful-ai-prompts guides resilient integration code for external APIs, microservices, databases, and third-party services. A quick-start TypeScript example defines CircuitState CLOSED, OPEN, and HALF_OPEN with configurable failureThreshold, successThreshold, timeout, and resetTimeout plus per-dependency stats tracking. Five reference guides cover a TypeScript circuit breaker, monitoring instrumentation, Opossum-style Node.js patterns, Python implementations, and Resilience4j-style Java setups. Best practices stress per-dependency breakers, fallback functions, exponential backoff, state-transition logging, and health checks while warning against shared breakers and skipped fallbacks. Reach for circuit-breaker-pattern when wrapping HTTP clients, message consumers, or microservice calls that need graceful degradation, rate-limit protection, and timeout handling to prevent cascading outages.

  • Models open, half-open, closed states
  • Sets failure thresholds and cooldown windows
  • Defines fallback and bulkhead strategies
  • Emits metrics for breaker transitions

Circuit Breaker Pattern by the numbers

  • 426 all-time installs (skills.sh)
  • Ranked #1,034 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill circuit-breaker-pattern

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs426
repo stars305
Last updatedMarch 4, 2026
Repositoryaj-geddes/useful-ai-prompts

How do you implement a circuit breaker pattern?

Add circuit breakers around flaky downstream HTTP, queue, or microservice calls with open/half-open thresholds, fallbacks, and observability hooks.

Who is it for?

Backend developers integrating external APIs or microservices who need resilience patterns with thresholds, fallbacks, and observability on flaky dependencies.

Skip if: Pure frontend apps with no downstream service calls, or teams already standardized on a single library with no customization needs.

When should I use this skill?

The user asks to add circuit breakers, prevent cascading failures, implement fallbacks for external services, or handle flaky HTTP and microservice calls.

What you get

Circuit breaker implementation with state machine, configurable thresholds, fallback handlers, monitoring hooks, and language-specific reference code.

  • circuit breaker class
  • fallback handlers
  • monitoring hooks

By the numbers

  • Ships 5 language-specific reference guides for TypeScript, Python, Node.js Opossum, Java Resilience4j, and monitoring
  • Defines 3 circuit states: CLOSED, OPEN, and HALF_OPEN with configurable thresholds

Files

SKILL.mdMarkdownGitHub ↗

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;
}

class CircuitBreaker {
  private state: CircuitState = CircuitState.CLOSED;
  private stats: CircuitBreakerStats = {
    failures: 0,
// ... (see reference guides for full implementation)

Reference Guides

Detailed implementations in the references/ directory:

GuideContents
TypeScript Circuit BreakerTypeScript Circuit Breaker
Circuit Breaker with MonitoringCircuit Breaker with Monitoring
Opossum-Style Circuit Breaker (Node.js)Opossum-Style Circuit Breaker (Node.js)
Python Circuit BreakerPython Circuit Breaker
Resilience4j-Style (Java)Resilience4j-Style (Java)

Best Practices

✅ DO

  • Use appropriate thresholds for your use case
  • Implement fallback mechanisms
  • Monitor circuit breaker states
  • Set reasonable timeouts
  • Use exponential backoff
  • Log state transitions
  • Alert on frequent trips
  • Test circuit breaker behavior
  • Use per-dependency breakers
  • Implement health checks

❌ DON'T

  • Use same breaker for all dependencies
  • Set unrealistic thresholds
  • Skip fallback implementation
  • Ignore open circuit breakers
  • Use overly aggressive reset timeouts
  • Forget to monitor

Related skills

How it compares

Pick circuit-breaker-pattern for hand-rolled or library-guided breaker scaffolding across languages; use service-mesh or platform retries when infrastructure already owns fault isolation.

FAQ

Which languages does circuit-breaker-pattern cover?

circuit-breaker-pattern ships five reference guides for TypeScript, Node.js Opossum-style breakers, Python implementations, Java Resilience4j-style patterns, and monitoring instrumentation alongside a core TypeScript quick-start.

What states does the circuit breaker implement?

circuit-breaker-pattern models CLOSED, OPEN, and HALF_OPEN states with configurable failure and success thresholds, reset timeouts, and per-dependency statistics for graceful degradation when downstream services fail.

Backend & APIsbackendintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.