# Runaway guard

> Runaway guard is an open-source agent skill for developer tools. Halts a Claude Code or Codex session on loops, failure streaks or a spend cap. It is available on Claude Code and Codex.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex
- **Website:** https://github.com/RyanAlberts/best-of-Agent-Harnesses/tree/main/skills/runaway-guard
- **Repository:** https://github.com/ryanalberts/best-of-agent-harnesses
- **GitHub stars:** 1,663
- **License:** MIT
- **Skill name:** runaway-guard
- **Collection:** https://github.com/RyanAlberts/best-of-Agent-Harnesses
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-03

## About

Runaway guard installs a hook that Claude Code or Codex runs before every tool call. It watches for three problems: the same call repeated a third time with nothing changed in between, five failed calls in a row, and session spending that passes a dollar cap. The cap is an estimate at API list prices, so on a subscription plan it measures usage rather than the bill. The guard warns at 80% of the cap and blocks further calls once it is reached, which covers interactive sessions where the built-in print-mode budget flag does not apply.

The install flow is designed to be previewed first. A dry run shows the headline limits and the exact settings change without writing anything, and the change is applied only when the user confirms. Status and reset commands report the counts for each session, and an uninstall removes only the guard's own entries and restores the settings file it changed. Everything runs locally on macOS or Linux with Python 3.9 or newer, reading the session transcripts and keeping small per-session counters.

The skill is written for developers who leave agents running unattended and want a ceiling on cost or a stop on repeated work. Prices for models missing from the built-in table are estimated from the most expensive known model in the same family, so the cap still applies.

## When your agent uses it

> Runaway guard: a hook that stops a live Claude Code or Codex session when the agent loops on the same tool call, keeps failing, or exceeds a dollar cap. Use when the user wants a spending cap, budget limit, or cost ceiling for interactive agent sessions (the built-in --max-budget-usd works only in print mode); wants to halt an agent that repeats the same command, is stuck in a loop, or runs up a bill unattended overnight; wants a circuit breaker for several failed tool calls in a row; or asks how much the current session has spent against its cap, why a call was blocked, or how to raise or reset the cap. Runs locally: reads the session transcripts before each tool call and sends nothing.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Runs Python scripts](https://github.com/RyanAlberts/best-of-Agent-Harnesses/tree/HEAD/skills/runaway-guard)
- [Network calls found in its scripts](https://github.com/RyanAlberts/best-of-Agent-Harnesses/tree/HEAD/skills/runaway-guard)
- [License: MIT](https://github.com/RyanAlberts/best-of-Agent-Harnesses/tree/HEAD/skills/runaway-guard)

## Features

- **Repeated call detection:** Blocks an identical tool call a third time when nothing has changed between attempts.
- **Failure streak circuit breaker:** Asks before the next call after five failed tool calls in a row, or blocks it where prompts are not possible.
- **Session dollar cap:** Tracks spend at API list prices and warns at 80% before blocking calls at the cap.
- **Guided install and uninstall:** Shows a dry-run headline and settings diff, then writes only when asked, and removes only its own entries.
- **Status and reset reporting:** Shows per-session spend, trip counts and recent events, and can restart a session's count.
- **Local-only operation:** Reads transcripts on the local machine and keeps counters and hashes without network calls.

## Good for

- Set a $20 spending ceiling on interactive Claude Code sessions
- Stop an agent that keeps re-running the same failing command
- Add a circuit breaker so an agent halts after several failed tool calls
- Check how much the current session has spent against its cap
- Find out why a tool call was blocked and how to raise the cap

## Install

### Claude Code

This skill ships in the `harness-skills` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add RyanAlberts/best-of-Agent-Harnesses
/plugin install harness-skills@agent-harnesses
```

Or copy only this skill to `~/.claude/skills/runaway-guard`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/RyanAlberts/best-of-Agent-Harnesses.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/runaway-guard &&
cp -R "$tmp/skills/runaway-guard" ~/.claude/skills/runaway-guard &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/runaway-guard` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/runaway-guard` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/RyanAlberts/best-of-Agent-Harnesses.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/runaway-guard &&
cp -R "$tmp/skills/runaway-guard" ~/.agents/skills/runaway-guard &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/runaway-guard` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/runaway-guard` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/RyanAlberts/best-of-Agent-Harnesses.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/runaway-guard &&
cp -R "$tmp/skills/runaway-guard" ~/.cursor/skills/runaway-guard &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/runaway-guard` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/RyanAlberts/best-of-Agent-Harnesses.git --path skills/runaway-guard
```

Or copy the folder to `~/.gemini/skills/runaway-guard` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/runaway-guard`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/RyanAlberts/best-of-Agent-Harnesses.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/runaway-guard &&
cp -R "$tmp/skills/runaway-guard" ~/.copilot/skills/runaway-guard &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/runaway-guard` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/RyanAlberts/best-of-Agent-Harnesses.git
```

Then copy `best-of-Agent-Harnesses/skills/runaway-guard` into your agent's skills folder as `runaway-guard`. Agents that support SKILL.md read one folder per skill.

## FAQ

### Which agents does Runaway guard work with?

It installs hooks for Claude Code and Codex. Codex hooks cannot ask the user, so after five failures the call is blocked and the agent is told to ask instead.

### Does Runaway guard send my data anywhere?

No. It reads local session transcripts and makes no network calls; it keeps small counters and hashes of recent calls per session.

### Does the dollar cap match my bill?

Not on a subscription plan. The figure is an estimate at API list prices and runs slightly low, so it measures usage rather than what you pay.

### Does the install change my settings right away?

No. It shows the planned change first and writes only when run with the write option after the user agrees.

### How do I install Runaway guard in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/runaway-guard to use it in all your projects, or to .claude/skills/runaway-guard in one project. Or install the harness-skills plugin, which includes it: /plugin marketplace add RyanAlberts/best-of-Agent-Harnesses, then /plugin install harness-skills@agent-harnesses.

### Does Runaway guard run scripts?

Yes. It runs Python scripts. Its scripts contain network calls. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Runaway guard?

Claude Code and Codex. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Runaway guard?

The closest alternatives to Runaway guard are Rules to guards, Guardrail tester, Regression finder, Session hardening and Delivery gate.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Rules to guards](https://ai-powered.com/skills/rules-to-guards): Rules to guards is an open-source agent skill for developer tools.
- [Guardrail tester](https://ai-powered.com/skills/guardrail-tester): Guardrail tester is an open-source agent skill for security.
- [Regression finder](https://ai-powered.com/skills/regression-finder): Regression finder is an open-source agent skill for developer tools.
- [Session hardening](https://ai-powered.com/skills/session-hardening): Session hardening is an open-source agent skill for developer tools.
- [Delivery gate](https://ai-powered.com/skills/delivery-gate): Delivery gate is an open-source agent skill for developer tools.
- [Session waste report](https://ai-powered.com/skills/session-waste-report): Session waste report is an open-source agent skill for developer tools.
- [Safe execution edho ferdian](https://ai-powered.com/skills/safe-execution-edho-ferdian): Safe execution edho ferdian is an open-source agent skill for developer tools.
- [Principle guard the context window](https://ai-powered.com/skills/principle-guard-the-context-window): Principle guard the context window is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/runaway-guard
