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

Circuit Breaker

  • 69 installs
  • 1 repo stars
  • Updated March 16, 2026
  • pixel-process-ug/superkit-agents

Helps with ai & agent building tasks.

About

circuit-breaker is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted development.

  • circuit-breaker
  • AI & Agent Building
  • AI-coding skill

Circuit Breaker by the numbers

  • 69 all-time installs (skills.sh)
  • +1 installs in the week ending Aug 4, 2026 (Skillselion tracking)
  • Ranked #5,786 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/pixel-process-ug/superkit-agents --skill circuit-breaker

Add your badge

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

Listed on Skillselion
Installs69
repo stars1
Last updatedMarch 16, 2026
Repositorypixel-process-ug/superkit-agents

What it does

Helps with ai & agent building tasks.

Files

SKILL.mdMarkdownGitHub ↗

Overview

The circuit-breaker skill is a safety mechanism that prevents infinite loops, resource exhaustion, and accidental destruction during autonomous development. It operates at the loop level (complementing resilient-execution which operates at the task level). Without circuit-breaker protection, autonomous loops can waste hours on stagnant problems, exhaust API limits, or accidentally destroy configuration files. This skill enforces hard boundaries that keep autonomous operations productive and safe.

Announce at start: "Circuit breaker is active — monitoring for stagnation, rate limits, and file protection."

---

Phase 1: Circuit State Check

Before each loop iteration, check the current circuit state:

+-----------+     threshold     +-----------+     cooldown     +------------+
|  CLOSED   |----exceeded----->|   OPEN    |----elapsed------>| HALF-OPEN  |
|  (normal) |                  |  (halted) |                  |  (probe)   |
+-----------+                  +-----------+                  +-----+------+
     ^                                                              |
     |                          success                             |
     +--------------------------------------------------------------+
     |                          failure                             |
     |                    +-----------+                              |
     +--------------------+   OPEN    |<----------------------------+
                          +-----------+
StateMeaningAction
CLOSEDNormal operationExecute iteration, monitor all thresholds
OPENHalted due to threshold breachReport status, wait for cooldown, or escalate
HALF-OPENProbing after cooldownAllow ONE iteration. If success: close. If failure: re-open.
STOP: Check circuit state BEFORE executing any loop iteration. Do NOT execute if circuit is OPEN.

---

Phase 2: Stagnation Detection

Monitor these thresholds continuously during autonomous operation:

ConditionThresholdDetection MethodAction
No progress3 consecutive loops with zero meaningful changesTrack files modified + tasks completed per loopOPEN circuit
Identical errors5 consecutive loops producing the same errorCompare error messages across iterationsOPEN circuit
Output decline70% decline in output volume across iterationsCompare output line count across last 3 iterationsOPEN circuit
Permission denials3 consecutive tool permission failuresTrack permission errorsOPEN circuit
Test fix loop>80% of effort spent on test fixes onlyTrack work type per iterationOPEN circuit, investigate root cause
Circular approachSame 2-3 approaches alternating without resolutionTrack approach historyOPEN circuit

Stagnation Scoring

Each iteration, compute a progress score:

IndicatorScore
New test passing that was previously failing+3
Task marked complete+5
File modified with meaningful changes+1
Build/lint error resolved+2
Same error as previous iteration-2
No files modified-3
Reverted previous changes-1

Threshold: If cumulative score across 3 iterations is negative, OPEN the circuit.

STOP: If any threshold is breached, OPEN the circuit immediately. Do NOT attempt "one more try."

---

Phase 3: Recovery Protocol

When the circuit opens, follow this recovery sequence:

Cooldown Period

  • Default: 30 minutes before retry
  • Purpose: Prevents rapid cycling through the same failing state
  • After cooldown: Circuit enters HALF-OPEN state

HALF-OPEN Behavior

1. Allow exactly ONE iteration to execute 2. If successful (positive progress score): Close circuit, resume normal operation 3. If failed (same stagnation pattern): Re-open circuit, double the cooldown timer

Recovery Strategy Decision Table

Stagnation TypeStrategy 1Strategy 2Strategy 3Strategy 4
No progress (stuck on same task)Regenerate plan with fresh analysisBreak stuck task into 3+ subtasksSkip to next task, return laterEscalate to user
Identical errors (same error repeating)Change approach entirelyCheck if error is environmentalSearch for known issue/workaroundEscalate with error log
Test fix loop (tests keep breaking)Review test assumptionsCheck if implementation approach is flawedSimplify implementation scopeEscalate with test analysis
Circular approach (alternating same fixes)Step back and re-analyze root causeTry approach NOT yet attemptedReduce scope to minimal working versionEscalate with approach history
STOP: After recovery, monitor the next 3 iterations closely. If stagnation recurs, escalate immediately.

---

Phase 4: Rate Limiting

Track and enforce API usage limits:

ParameterDefaultPurpose
MAX_CALLS_PER_HOUR100Prevents API overuse
Reset windowHourly (rolling)Automatic counter reset
Countdown displayActiveShows remaining calls before limit

Rate Limit Behavior

1. Track API calls per rolling hour 2. At 80% of limit: display warning, prioritize remaining calls 3. At 100% of limit: pause execution, display countdown to reset 4. Never exceed limit — wait for reset window

Three-Layer Timeout Detection

For long-running operations (especially API calls with extended limits):

LayerDetectionFallback
1. Timeout guardExit code 124 or timeout signalCapture partial output, log what completed
2. JSON validationParse response structureAttempt text extraction from raw response
3. Text fallbackRaw output captureLog everything, report for human review

---

Phase 5: File Protection

<HARD-GATE> Configuration files must NEVER be deleted during autonomous operations. This is non-negotiable. </HARD-GATE>

Protected Paths

PathTypeWhy Protected
.ralph/DirectoryLoop state and configuration
.ralphrcFileRalph configuration
IMPLEMENTATION_PLAN.mdFileCurrent plan — source of truth for loop
AGENTS.mdFileAgent definitions
specs/DirectorySpecifications — source of truth for features
.claude/DirectoryClaude Code configuration
CLAUDE.mdFileAgent operating manual
memory/DirectoryPersisted learnings across sessions

Protection Mechanisms

MechanismHow It WorksWhen It Triggers
Allowlist enforcementOnly permitted tools can modify protected filesBefore any file write to protected path
Integrity validationCheck protected files exist after each iterationEnd of every loop iteration
Pre-operation checksVerify protected files before destructive operationsBefore rm, git clean, git checkout .
Restricted commandsBlock git clean, git rm on protected paths, rm -rf on config dirsWhen command targets protected path

Pre-Destructive Operation Checklist

Before any rm, git clean, or git checkout .: 1. List all files that will be affected 2. Check each against the protected paths list 3. If ANY protected file would be affected: ABORT and report 4. If safe: proceed with caution 5. After operation: verify all protected files still exist

STOP: If a protected file is missing after any operation, halt immediately and restore it.

---

Phase 6: Monitoring and Metrics

Track these metrics across loop iterations:

MetricPurposeAlert Threshold
Loop countTotal iterations executed>20 for a single task
Tasks completedProgress measurement0 for 3+ iterations
Files modifiedChange velocity0 for 3+ iterations
Test pass rateQuality trendDeclining for 3+ iterations
Error frequencyStagnation early warningIncreasing for 3+ iterations
Output volumeProductivity trend70% decline
API calls remainingRate limit proximity<20% remaining
Progress scoreOverall healthNegative for 3 iterations

Per-Iteration Status Log

## Iteration [N] — [timestamp]
- Circuit state: CLOSED / HALF-OPEN
- Tasks completed: [N]
- Files modified: [list]
- Tests: [X passed, Y failed, Z skipped]
- Errors encountered: [list]
- Progress score: [+/- N]
- API calls remaining: [N]
- Stagnation risk: LOW / MEDIUM / HIGH

---

Anti-Patterns / Common Mistakes

What NOT to DoWhy It FailsWhat to Do Instead
Ignore stagnation signalsWastes hours on unsolvable problemsOpen circuit at threshold breach
Manually override open circuitBypasses safety mechanismFollow recovery protocol properly
Skip file protection checksConfig deletion derails entire projectAlways verify protected files after operations
Set cooldown to zeroRapid cycling through same failureRespect 30-minute minimum cooldown
Count test-fix-only iterations as progressMasks the real problem (flawed approach)Flag >80% test-fix effort as stagnation
Delete and recreate protected filesLoses configuration stateNever delete protected files, only update
Ignore rate limit warningsHits hard limit mid-operationPrioritize when at 80% of limit
Run destructive commands without pre-checksMay delete protected filesAlways check affected files first

---

Anti-Rationalization Guards

ThoughtReality
"One more try will fix it"That is what you said 3 iterations ago. Open the circuit.
"The error is almost fixed""Almost" for 5 iterations means the approach is wrong.
"I cannot stop now, I am so close"Sunk cost fallacy. Open circuit, reassess.
"The cooldown is too long"The cooldown prevents wasting more time on the same failure.
"These config files are not important"They are protected for a reason. Do not delete them.
"The rate limit will not be hit"Track it. Do not guess.
"This is a different error"Check if it is truly different or the same root cause manifesting differently.
Do NOT override an open circuit. Follow the recovery protocol.

---

Integration Points

SkillRelationship
resilient-executionTask-level retries (3 attempts). Circuit-breaker activates AFTER resilient-execution exhausts retries within individual tasks.
autonomous-loopCircuit-breaker monitors the loop. Opens circuit when loop-level stagnation detected.
ralph-statusStatus block provides metrics for stagnation detection.
verification-before-completionCircuit-breaker ensures verification passes before closing a loop.
self-learningStagnation patterns are persisted to memory for future avoidance.
auto-improvementCircuit-breaker events feed into improvement metrics.

Scope Clarification

ScopeSkillBehavior
Task-levelresilient-executionTry 3 approaches for a single failing task
Loop-levelcircuit-breakerHalt the entire loop when patterns indicate systemic failure

The circuit breaker activates AFTER resilient-execution has exhausted its retries within individual tasks. If tasks keep failing despite 3 retries each, the circuit breaker detects the pattern.

---

Process Summary

1. Before each loop iteration: Check circuit state (CLOSED/HALF-OPEN/OPEN) 2. If OPEN: Report status, wait for cooldown, or escalate 3. If HALF-OPEN: Allow one probe iteration, evaluate result 4. If CLOSED: Execute normally, monitor all thresholds 5. After each iteration: Update metrics, compute progress score, evaluate thresholds 6. If threshold exceeded: Open circuit, report reason, begin cooldown 7. After cooldown: Enter HALF-OPEN, allow one probe 8. After probe: Close if successful, re-open with doubled cooldown if failed

---

Skill Type

RIGID — Thresholds and protection rules must be followed exactly. Do not relax circuit breaker conditions. Do not override open circuits. Do not skip file protection checks. Do not ignore stagnation signals.

Related skills

This week in AI coding

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

unsubscribe anytime.