usage-guard
A Claude Code plugin that warns Claude before you run out of plan usage, so it can wrap up cleanly instead of stopping mid-task.
- At the warn threshold (75% of your 5-hour limit, by default), Claude starts conserving usage: it finishes the current task before starting anything big and avoids spawning extra subagents.
- At the wind-down threshold (90%), Claude finishes or pauses the current step, stops its subagents, writes a handoff file (
HANDOFF.md) and, if usage resets soon, schedules itself to pick up where it left off.
You see a one-line notice when this happens, for example:
⚠️ usage-guard: 5-hour 91%, resets in 1h 12m
Which plans does it work with?
usage-guard reads the usage figures that Claude Code gives to your status line. Claude Code only provides them on some plans:
| You use Claude Code with… | Works? | What it watches |
|---|
| A claude.ai Pro or Max plan | ✅ Yes | 5-hour and weekly limits |
| A Claude apps gateway with spend limits (Claude Code 2.1.251 or later) | ✅ Yes | Your spend limit |
| Either of the above, rolled out by your admin | ✅ Yes | The same |
| A claude.ai Team or Enterprise seat without a gateway | ❌ No | — |
| An API key, Amazon Bedrock, Google Vertex AI or Microsoft Foundry | ❌ No | — |
On unsupported setups the plugin stays quiet, and /usage-guard:status tells you there's no usage data.
You also need:
- macOS or Linux. Windows with Git Bash may work but is untested.
jq. Check with jq --version. To install it, run brew install jq on macOS or sudo apt install jq on Debian/Ubuntu.
Install
Run these inside Claude Code:
/plugin marketplace add alexmoras/usage-guard-plugin
/plugin install usage-guard@usage-guard
This installs the latest release, never unreleased work from main.
Then start a new Claude Code session and run:
/usage-guard:setup
Setup is needed because Claude Code only gives usage figures to the status line, and plugins can't change your status line themselves. Setup puts a small relay in front of your status line:
- The relay records the usage figures, then runs your existing status line, so it looks the same as before.
- If you had no status line, you get a simple one showing the model and your usage.
- Your
settings.json is backed up before anything changes.
Check it's working. Send any message, then run:
/usage-guard:status
You should see the relay's "last ran" time and your current usage, for example 5-hour: 14%, resets in 4h 10m. Usage figures appear after the first reply in a session.
Trying unreleased changes
To run the current main, or any other branch, without installing it, clone the repository and load it for one session:
git clone https://github.com/alexmoras/usage-guard-plugin.git
claude --plugin-dir /path/to/usage-guard-plugin
Then run /usage-guard:setup. When you're done, run /usage-guard:setup uninstall.
Updating
Claude Code doesn't update third-party plugins automatically unless you turn it on. To get the latest release, run this in your shell, then start a new session:
claude plugin update usage-guard@usage-guard
To update automatically instead, open /plugin, go to Marketplaces, select usage-guard and turn on Enable auto-update.
Using it
Once it's set up there's nothing to do: alerts arrive with your next message, tool call or subagent start. Each session and each subagent is told about each threshold once per usage period.
| Command | What it does |
|---|
/usage-guard:status | Shows your current usage, your thresholds, whether the relay is working and what this session has been told. |
/usage-guard:setup | Installs the status line relay. It's safe to run again. |
/usage-guard:setup thresholds | Shows your alert thresholds. |
/usage-guard:setup thresholds 5h 80 95 | Warn at 80% and wind down at 95% of the 5-hour limit. The windows are 5h, weekly and spend. |
/usage-guard:setup thresholds reset | Puts all thresholds back to their defaults. Add a window name (reset 5h) to reset just one. |
/usage-guard:setup uninstall | Restores your original status line and turns alerts off. |
Threshold changes apply from your next message; you don't need to restart.
Settings
Change thresholds with /usage-guard:setup thresholds (above), or change any setting with /config: