Runaway-Bill Guardrail Loop (Watchdog Beside the Worker)

A cost-safety pattern that pairs every overnight loop with a second, dumber loop whose only job is stopping the first: spend alerts, a hard iteration cap, and a cron check that kills the worker when token burn spikes or the same command keeps repeating.

prompt
→ Claude
Pair every overnight loop with a watchdog: spend/usage alert thresholds, a hard `MAX_ITER`, and a cron check that kills the loop process if tokens-per-minute spikes or the same command repeats N times. The watchdog is a second, dumber loop whose only job is stopping the first one.
claude-code

Implementation note

When to use: alongside every overnight or unattended loop you run — this is not a work loop but the watchdog you pair with one, built for the wake-up-to-a-huge-bill failure mode. How it works: the worker loop gets a companion: spend and usage alert thresholds, a hard MAX_ITER cap, and a cron check that kills the worker process outright if tokens-per-minute spikes or the same command repeats N times in a row. The watchdog is deliberately a second, dumber loop whose only job is stopping the first one — it makes no judgment calls beyond its thresholds. Safety: the design principle is separation — the safety mechanism runs outside the worker's process and context, so a worker that has gone sideways cannot reason its way past its own limits. Repeated-command detection catches stuck loops that spend without progressing. Tune the thresholds to your loop's normal profile first, or the watchdog cries wolf.

Source: devtoolpicks

More automation loops

Run workflows with dynamic sub-agents

/goalnew

Split a task into packets, run sub-agents in parallel, synthesize results, and verify completion.

prompt
→ Claude
/goal loop and verify until complete
automationlow risk

Run agent turns until goal met

/goalnew

Agent executes repeated turns toward a condition, with a lightweight evaluator checking progress after each turn until the goal is reached.

prompt
→ Claude
/goal <condition turns a prompt into a durable objective. Thanos immediately starts a turn toward the condition, and after each turn a fresh, tool-less side-channel evaluator (a one-shot completeSimple call, not a subagent — so no extra agent turn and no re-entrancy) reads the last turn's evidence and returns MET / NOT MET . NOT MET auto-continues another turn with the reason as guidance; MET clears the goal and records the achievement. Unparseable evaluator output is treated as NOT MET (fail-safe: it never declares a false "done
automationmedium risk

Run agent until goal met

/goalnew

Queue agent turns with goal context until your objective is achieved, treating the goal as untrusted data.

prompt
→ Claude
/goal <objective , after /goal resume , and after every agent turn that leaves the goal active , the extension queues Codex's goal continuation prompt as hidden model-visible context. The objective is XML-escaped and wrapped as untrusted user data so it does not become higher-priority instructions
automationlow risk