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.
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.
More automation loops
Ship production-grade apps autonomously
Hand an idea to Claude Code; it authors specs, designs, builds, tests, secures, and ships until enterprise done or budget exhausted.
claude-progress.txt harness pattern (Anthropic)
Anthropic's first-party file-as-memory harness for long-running agents: every fresh-context session recovers state from a progress file and the git log, does one unit of work, updates the file, commits, and exits.
Complete all tasks in tasks.md
Work through your tasks.md file, completing each task until none remain or max iterations is reached.