circuit-breaker-pattern

Short-circuit failing external dependency calls with configurable thresholds and fallbacks.

Updated Apr 14, 2026
One-click install
npx skills add https://github.com/BrunoAMSilva/my-config --skill circuit-breaker-pattern
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: circuit-breaker-pattern
Source: https://github.com/BrunoAMSilva/my-config/tree/main/coding/skills/circuit-breaker-pattern
Command: npx skills add https://github.com/BrunoAMSilva/my-config --skill circuit-breaker-pattern

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Prevents cascading failures in distributed systems by monitoring calls to external dependencies and fast-failing when repeated errors occur, so the rest of the system stays healthy.

Core Features & Use Cases

  • Three-state state machine: closed, open, and half-open with probe logic to verify recovery.
  • Per-dependency tuning: configure failure thresholds, sliding windows, recovery timeouts, and probe counts per service.
  • Fallbacks and observability: require graceful fallbacks (cache, defaults, queue) and emit state-change events and metrics for alerting and dashboards.
  • Use Case: Protect payment, inventory, or third-party APIs from cascading load when they become slow or return server errors.

Quick Start

Wrap your external API call with a circuit breaker configured with failureThreshold, windowMs, recoveryTimeoutMs, and a fallback such as returning a cached value or a safe default.

Frequently Asked Questions about circuit-breaker-pattern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent cascading failures when calling external APIs in TypeScript?

To prevent cascading failures in TypeScript, wrap external API calls in a circuit breaker that short-circuits failing requests. Configure a sliding-window failure threshold to stop repeated calls to unhealthy dependencies and protect overall system availability.

How does the half-open state work in a circuit breaker pattern?

The half-open state in a circuit breaker works by sending limited probe requests to a previously failing dependency to verify recovery. If probes succeed, the circuit closes; if they fail, it reopens, preventing full load from hitting the still-unhealthy service.

Can I configure separate failure thresholds for different service dependencies?

Yes, you can configure separate failure thresholds per dependency. Circuit breakers support per-dependency tuning for sliding windows, recovery timeouts, and probe counts, allowing distinct resilience policies for external APIs, databases, and third-party integrations.

What fallback strategies should I use with a circuit breaker for fault tolerance?

Fallback strategies for circuit breaker fault tolerance include returning cached values, safe defaults, or queueing requests for later processing. These graceful degradation methods ensure your application remains functional when external dependencies fail or timeout.

How do I add observability and metrics to a circuit breaker for alerting?

Add observability to a circuit breaker by emitting state-change events and metrics for monitoring dashboards and alerts. Track transitions between closed, open, and half-open states alongside failure counts to trigger alerts when external dependencies degrade.

When should I avoid using a circuit breaker for external service calls?

Avoid using a circuit breaker when external service calls require strict consistency or when transient failures are better handled by simple retries alone. Circuit breakers are designed for repeated, sustained failures where fast-failing protects availability better than continuing to attempt calls.