Problem
The status line shows - for both the 5h and 7d usage metrics when the OAuth token cannot be retrieved (expired token, Keychain issues, missing credentials file, etc.).
Root Cause
Claude Code already provides rate_limits data directly in the JSON payload it sends to the status line command via stdin:
{
"rate_limits": {
"five_hour": {
"used_percentage": 42.5,
"resets_at": 1750000000
},
"seven_day": {
"used_percentage": 15.2,
"resets_at": 1750500000
}
}
}
However, statusline.sh ignores this data entirely and always makes a separate OAuth API call to https://api.anthropic.com/api/oauth/usage. When the OAuth token is unavailable or expired, the API call silently fails and the script falls through to showing - placeholders.
Expected Behavior
The script should read rate_limits from the JSON input as the primary data source, only falling back to the OAuth API call when the builtin data is absent (e.g., before the first API response in a new session).
Additional Notes
- The builtin
resets_at values are Unix epoch integers, not ISO 8601 strings like the API response
- This approach is also faster since it avoids the
curl call and OAuth token resolution entirely
- The OAuth API fallback is still valuable for cases where Claude Code hasn't populated
rate_limits yet
Problem
The status line shows
-for both the 5h and 7d usage metrics when the OAuth token cannot be retrieved (expired token, Keychain issues, missing credentials file, etc.).Root Cause
Claude Code already provides
rate_limitsdata directly in the JSON payload it sends to the status line command via stdin:{ "rate_limits": { "five_hour": { "used_percentage": 42.5, "resets_at": 1750000000 }, "seven_day": { "used_percentage": 15.2, "resets_at": 1750500000 } } }However,
statusline.shignores this data entirely and always makes a separate OAuth API call tohttps://api.anthropic.com/api/oauth/usage. When the OAuth token is unavailable or expired, the API call silently fails and the script falls through to showing-placeholders.Expected Behavior
The script should read
rate_limitsfrom the JSON input as the primary data source, only falling back to the OAuth API call when the builtin data is absent (e.g., before the first API response in a new session).Additional Notes
resets_atvalues are Unix epoch integers, not ISO 8601 strings like the API responsecurlcall and OAuth token resolution entirelyrate_limitsyet