Compact usage stats in your Claude Code statusline — shows 5h/7d rate-limit utilization, reset countdowns, and context window usage.
Based on claude-watch with a fix for macOS Keychain credential storage.
Opus 4.6 | my-project • main
5h 6% (2h 30m) • 7d 12% (5d 4h) | ctx 45% (90k/200k)
curl -o ~/.claude/statusline-command.sh \
https://gist.githubusercontent.com/<THIS_GIST>/raw/statusline-command.sh
curl -o ~/.claude/fetch-usage.sh \
https://gist.githubusercontent.com/<THIS_GIST>/raw/fetch-usage.sh
chmod +x ~/.claude/statusline-command.sh ~/.claude/fetch-usage.sh{
"statusLine": {
"type": "command",
"command": "bash ~/.claude/statusline-command.sh"
},
"hooks": {
"PreToolUse": [{"matcher": "", "hooks": [{"type": "command", "command": "bash ~/.claude/fetch-usage.sh > /dev/null 2>&1 &"}]}],
"Stop": [{"matcher": "", "hooks": [{"type": "command", "command": "bash ~/.claude/fetch-usage.sh > /dev/null 2>&1 &"}]}]
}
}bash ~/.claude/fetch-usage.sh
cat /tmp/.claude_usage_cache # should show 4 linesThe fetch-usage.sh script needs your Claude OAuth access token to call the usage API. Where it's stored depends on your Claude Code version:
| Version | Storage | Path |
|---|---|---|
| v2.1+ (current) | macOS Keychain | security find-generic-password -s "Claude Code-credentials" -w |
| Older versions | JSON file | ~/.claude/.credentials.json |
This fork checks the macOS Keychain first, then falls back to the credentials file. The upstream claude-watch only checks the file, which silently fails on Claude Code v2.1+ on macOS.
If you're on Linux, credentials are likely still in ~/.claude/.credentials.json. If neither source works, try running /login in Claude Code to regenerate credentials.
The fetch-usage.sh script caches your OAuth token in /tmp/.claude_token_cache for 15 minutes to avoid repeated keychain/file reads. This file is created with default permissions — on shared systems you may want to add umask 077 or chmod 600 after the write.
jq(for JSON parsing)curl(for API calls)- macOS (uses
date -jfor timestamp parsing andsecurityfor Keychain access)
Based on claude-watch by @xleddyl.