Display your Claude Code API usage (5-hour and 7-day quotas) directly in your tmux status bar with color-coded thresholds and time-until-reset.
5h:14(3h) 7d:75(19h) │ 13:20 29-Jan
| Element | Meaning |
|---|---|
5h:14 |
14% of 5-hour rolling quota used |
(3h) |
Resets in 3 hours |
7d:75 |
75% of 7-day rolling quota used |
(19h) |
Resets in 19 hours |
~ |
Suffix shown when displaying stale cached data |
| Color | Threshold | Meaning |
|---|---|---|
| White (bold) | < 50% | You're fine |
| Goldenrod | 50-80% | Getting warm |
| Red | > 80% | Slow down or wait for reset |
Colors are customizable - see Configuration below.
- Minimal API calls: Caches results for 5 minutes (configurable)
- Secure: OAuth token hidden from process list
- Time-aware: Shows minutes/hours/days until quota reset
- Stale indicator: Shows
~when using cached data after API failure - User-specific cache: Safe on multi-user systems
- Configurable: Colors, thresholds, and cache TTL via environment variables
- Linux/WSL (uses GNU coreutils)
curl- HTTP clientjq- JSON processordate- GNU date with-dflagstat- GNU stat with-cflag- Claude Code with OAuth authentication (the
~/.claude/.credentials.jsonfile)
Note: Not compatible with BSD/macOS due to GNU-specific flags. PRs welcome for portability!
-
Download the script:
curl -o ~/.local/bin/claude-usage \ https://gist.githubusercontent.com/YOUR_USERNAME/GIST_ID/raw/claude-usage chmod +x ~/.local/bin/claude-usage
-
Test it works:
~/.local/bin/claude-usage # Should output something like: # #[fg=white,bold]5h:14(3h)#[default] #[fg=colour136]7d:75(19h)#[default]
-
Add to tmux status bar (in
~/.tmux.confor per-session):set-option -g status-right-length 60 set-option -g status-right '#(~/.local/bin/claude-usage) │ %H:%M %d-%b' -
Reload tmux:
tmux source-file ~/.tmux.conf # Or press: prefix + r (if you have reload bound)
All settings can be customized via environment variables (or edit the script directly):
# In ~/.bashrc or ~/.zshrc:
# Cache TTL in seconds (default: 300 = 5 minutes)
export CLAUDE_USAGE_CACHE_TTL=300
# Color thresholds (percentages)
export CLAUDE_USAGE_THRESHOLD_LOW=50 # Below = low (good)
export CLAUDE_USAGE_THRESHOLD_MED=80 # Below = medium (warning)
# Above = high (critical)
# Tmux style strings (customize for your status bar background)
export CLAUDE_USAGE_STYLE_LOW="fg=white,bold" # Low utilization
export CLAUDE_USAGE_STYLE_MED="fg=colour136" # Medium (goldenrod)
export CLAUDE_USAGE_STYLE_HIGH="fg=colour160" # High (dark red)
export CLAUDE_USAGE_STYLE_ERROR="fg=white,dim" # Error/stale state
# Custom credentials path (if not default)
export CLAUDE_USAGE_CREDENTIALS="$HOME/.claude/.credentials.json"Common tmux colors that work well:
white,black,red,green,yellow,blue,magenta,cyancolour0-colour255(256-color palette)brightred,brightyellow, etc. (bright variants)- Add
,boldor,dimfor emphasis
- Reads OAuth token from Claude Code's credentials file
- Calls
https://api.anthropic.com/api/oauth/usage(same API Claude Code uses) - Caches the formatted result to
~/.cache/claude-usage/status - Returns cached value if fresh, fetches new data if stale
- Shows
~suffix if using stale cache after API failure
The script uses this undocumented(?) endpoint:
curl -s "https://api.anthropic.com/api/oauth/usage" \
-H "Authorization: Bearer $TOKEN" \
-H "anthropic-beta: oauth-2025-04-20"Returns:
{
"five_hour": {"utilization": 14.0, "resets_at": "2026-01-29T10:00:00+00:00"},
"seven_day": {"utilization": 75.0, "resets_at": "2026-01-30T08:00:00+00:00"},
"extra_usage": {"utilization": 96.4, "monthly_limit": 60000, "used_credits": 57845}
}Shows 5h:--(?) 7d:--(?):
- Check credentials exist:
ls -la ~/.claude/.credentials.json - Test manually:
~/.local/bin/claude-usageand check for errors
Colors not showing:
- Ensure your terminal supports 256 colors
- Check
echo $TERMshows something likexterm-256colorortmux-256color
Wrong reset times:
- The script requires GNU date. Check:
date --versionshould show GNU coreutils
Token visible in ps:
- Shouldn't happen with this version. The token is passed via
--configwith process substitution.
MIT - Use it, modify it, share it.
- Built with Claude Code (naturally)
- Code reviewed by OpenAI Codex (grade: A)
- Inspired by wanting to know "why is Claude slow right now?"
If this helped you, consider starring the gist!
