Circuit Breaker Pattern
SkillAI & modelsImplement circuit breaker patterns for fault tolerance, automatic failure detection, and fallback mechanisms. Use when calling external services, handling cascading failures, or implementing resilience patterns.
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the Circuit Breaker Pattern skill
What this skill tells your AI
The instructions your AI receives, as published by aj-geddes/useful-ai-prompts in skills/circuit-breaker-pattern/SKILL.md and read by ahel’s review.
Table of Contents
- Overview
- When to Use
- Quick Start
- Reference Guides
- Best Practices
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:
| Guide | Contents |
|---|---|
| TypeScript Circuit Breaker | TypeScript Circuit Breaker |
| Circuit Breaker with Monitoring | Circuit Breaker with Monitoring |
| Opossum-Style Circuit Breaker (Node.js) | Opossum-Style Circuit Breaker (Node.js) |
| Python Circuit Breaker | Python 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
Signals
- GitHub stars
- 336
- Forks
- 55
- Last commit
- Mar 2026
Advanced
- Catalog kind
- skill
- Gateway key
circuit-breaker-pattern- Source
- github.com/aj-geddes/useful-ai-prompts