ccusage tells you what you spent.
LoopGuard stops you spending it.

Budget fuses and a runaway-loop killer for Claude Code, Codex CLI and Cursor. One install, no proxy, works on subscriptions — and it pings your phone when something trips.

npm i -g loopguard-cli  # installs the `loopguard` command (or try: npx loopguard-cli report)
loopguard init          # hooks into Claude Code, Codex and Cursor (backs up configs)
loopguard config set sessionCapUsd 20
loopguard report --by agent

# Pro: alerts + remote pause → https://tryloopguard.com/login
loopguard login --key lg_…   # then: loopguard sync

Hard caps

Per-session and daily dollar caps across every agent. When a cap trips, the tool call is denied and the session halts.

Loop killer

Catches the same tool call repeating with no progress (same files, same output) and cost spirals ($ per minute), before you notice them in the logs.

Local first

Reads the logs your agents already write. No API keys, no proxy. Only aggregate numbers ever leave your machine — and only if you turn on sync.

Away-from-keyboard alerts

Email, Slack or Discord the moment something trips, and pause or resume enforcement from your phone.

Guides

How to stop runaway Claude Code, Codex and Cursor agent loops

Why AI coding agents get stuck in loops, how to interrupt one now, and how to enforce limits with hooks: repeated-call detection, cost-spiral checks and session/daily dollar caps.

How to track AI coding agent token costs per session

Where Claude Code, Codex CLI and Cursor store token usage on your machine, how to turn it into an estimated dollar cost per session, and what the numbers tell you.

How to set a spending limit for Claude Code

Every native way to cap Claude Code spend (Console workspace limits, usage-credit limits, --max-budget-usd for headless runs) and how to add a per-session and daily dollar cap to interactive sessions with a hook.

How to limit Cursor agent usage costs

How Cursor bills agent usage, where to set the monthly spend limit (and what it does not cover), and how to add loop detection and per-session caps to the Cursor agent with hooks.

How to cap OpenAI Codex CLI spend

Hard spend limits for Codex CLI on an API key, credit and auto-reload limits on a ChatGPT plan, and how to add per-session and daily caps to Codex with hooks.

Claude Code usage limit reached: why it happens and how to monitor it

The 5-hour and weekly limits on Claude Pro and Max, what each "You've hit your limit" message means, why long sessions drain them, how to watch usage with /usage and a status line, and how to stop runaway sessions early.

How to set a hard budget for AI coding agents in CI

Per-run caps, job timeouts and key-level spend limits for Claude Code (claude -p), Codex CLI (codex exec) and Cursor CLI in GitHub Actions and other headless runs, plus loop detection with hooks.

Claude Code stuck in a loop: how to break it and stop it repeating the same command

How to interrupt Claude Code when it keeps rerunning the same failing command, undo what the loop changed with /rewind and git, restart without walking back into it, and make a hook refuse the next no-progress repeat.

Codex usage limit reached: 5-hour and weekly limits explained

The 5-hour and weekly Codex windows on ChatGPT plans, what each "You've hit your usage limit" message means, usage limits vs rate limits, how to check /status and /usage, your options when it runs out, and how to catch a looping session early.

Cursor agent stuck in a loop: how to stop it, roll back, and keep it from repeating

How to stop or steer the Cursor agent when it keeps rerunning the same failing fix, restore a checkpoint (and what it won't undo), restart in a fresh chat without walking back into the loop, and make a hook deny the next no-progress repeat.

Why Claude Code uses so many tokens, and how to use fewer

Where Claude Code's tokens actually go (re-sent context, cache misses, subagent fan-out, thinking, Opus, loops), how to find the culprit with /usage and /context, the changes that cut usage most, and how to cap runaway sessions.

How to set a budget limit for Aider

Aider has no built-in dollar cap. How to put a hard limit on the API key, read Aider's per-message and session cost, cut tokens per message with /tokens, /drop and --max-chat-history-tokens, and bound scripted and CI runs.

GitHub Copilot agent mode stuck in a loop: how to stop it and keep it from repeating

How to stop Copilot agent mode when it keeps rerunning the same failing fix, restore a checkpoint, restart without walking back into the loop, the settings and premium-request budget that bound it, and a preToolUse hook that denies identical repeats.

Cline stuck in a loop: how to stop it, roll back, and cap what it spends

How to stop Cline when it keeps rerunning the same failing fix, restore a checkpoint (and what it won't undo), restart in a fresh task without walking back into the loop, and the key limits, auto-approve settings and hooks that keep the next loop small.

Gemini CLI usage limits: daily quotas, the June 2026 change, and keeping costs in check

Gemini CLI's daily request limits by sign-in type, what changed for free, Pro and Ultra users on June 18, 2026, how to check usage with /stats, and the settings and billing controls that bound a runaway session.

Codex stuck in a loop: how to stop it, undo it, and keep it from repeating

How to interrupt Codex CLI when it keeps rerunning the same failing command, undo its edits with /diff and git, restart in a clean chat without walking back into the loop, and make a PreToolUse hook deny the next no-progress repeat.

Pricing

Free

$0

Open-source CLI (MIT). Caps, loop detection, local reports.

Pro

$9/mo

or $79/year. Dashboard, alerts, remote pause, history across machines.

Team

$19/dev/mo

Min 3 seats. Everything in Pro for your whole team.

Costs are estimates at API list prices. Not affiliated with Anthropic, OpenAI or Anysphere. Terms · Privacy