circuit-breaker

Implements circuit breaker patterns with state management, fallbacks, and monitoring for service failures.

1|Updated Mar 21, 2026
One-click install
npx skills add https://github.com/kalilurrahman/kr-claudiator-skills-original-prompts --skill circuit-breaker-kalilurrahman
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: circuit-breaker
Source: https://github.com/kalilurrahman/kr-claudiator-skills-original-prompts/tree/main/01-software-dev/circuit-breaker
Command: npx skills add https://github.com/kalilurrahman/kr-claudiator-skills-original-prompts --skill circuit-breaker-kalilurrahman

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires redis, prometheus_client, tenacity, pytest.

What problem does it solve? Downstream service failures can cascade through your system, exhausting resources and degrading the entire application. This Skill designs circuit breakers that detect failures, fail fast, and recover gracefully instead of repeatedly calling broken services. ## Core Features & Use Cases - State Machine Design: Defines closed, open, and half-open states with configurable failure thresholds, timeouts, and half-open test counts. - Fallback Strategies: Implements cached responses, default values, and degraded functionality when circuits open. - Monitoring & Testing: Integrates Prometheus metrics, alerting rules, and pytest-based state transition tests. - Use Case: Your payment API starts timing out. The circuit breaker opens after 5 consecutive failures, serves cached responses for 60 seconds, then probes recovery with 3 half-open test requests before closing. ## Quick Start Design a circuit breaker for my payment API with a 50% failure rate threshold, 60-second open duration, and a cached-response fallback.

Frequently Asked Questions about circuit-breaker

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

FAQPage Schema
How do I implement a circuit breaker in Python?

Create a CircuitBreaker class tracking state (closed, open, half-open), failure counts, and timestamps. Wrap service calls in its call method, which raises an exception when open and transitions to half-open after the configured timeout expires.

What failure threshold should I use for a circuit breaker?

Use 5-10 consecutive failures or a 50% failure rate across the last 10 requests. Rate-based breakers need a minimum request count (around 5) before evaluating the threshold to avoid opening on sparse traffic.

How does a circuit breaker work with retry logic?

Combine them by layering retries inside the breaker, such as tenacity's stop_after_attempt with exponential backoff. Retries handle transient errors while the breaker opens when failures persist beyond the threshold.

Can circuit breakers be shared across multiple servers?

Yes, use a distributed circuit breaker backed by Redis to share the open/closed state across servers. Each instance keeps a local breaker but publishes state changes to a shared Redis key with an expiration.

What fallback should I use when a circuit is open?

Common fallbacks include cached responses from Redis, safe default values, or degraded functionality like simple SQL search replacing ML-ranked results. User-facing features should always have a fallback defined.

Why does my circuit breaker never close after opening?

The half-open state requires all test requests (typically 3) to succeed before closing. If any test fails, the circuit reopens, so verify the downstream service has actually recovered and the timeout duration is sufficient.