Parent
Part of #199 — port claude-usage into devtools/.
Depends on credential resolution (#199 child: OAuth credentials issue).
Problem
Need a small client for Anthropic’s OAuth usage endpoint that powers the 5-hour and 7-day windows, without importing claude-hud’s Node module.
API notes (as used by claude-hud)
- Endpoint:
GET https://api.anthropic.com/api/oauth/usage (confirm path/headers against current Claude Code behavior while implementing)
- Auth: OAuth bearer token from Claude Code credentials
- User-Agent used by claude-hud:
claude-code/2.1 (match or document divergence)
- Response includes roughly:
five_hour.utilization, five_hour.resets_at
seven_day.utilization, seven_day.resets_at
- Map utilization → percent fields
fiveHour / sevenDay
- Plan name from subscription type / fallback (claude-hud has
getUsagePlanNameFallback)
Scope
internal/usage HTTP client with injectable transport for tests
- Map API response → stable output struct used by the CLI
- Sensible timeouts (claude-hud default ~15s)
- Optional short-lived cache (nice-to-have; claude-hud uses ~5 min file cache for HUD — CLI may skip or use a simpler in-process/optional cache)
- Handle 401/403/429 and network errors with clear messages
- Respect “custom base URL ⇒ usage N/A” behavior if applicable
Acceptance criteria
Out of scope
- HUD rendering / statusline integration
- Mutating credentials or performing OAuth login
Parent
Part of #199 — port
claude-usageintodevtools/.Depends on credential resolution (#199 child: OAuth credentials issue).
Problem
Need a small client for Anthropic’s OAuth usage endpoint that powers the 5-hour and 7-day windows, without importing claude-hud’s Node module.
API notes (as used by claude-hud)
GET https://api.anthropic.com/api/oauth/usage(confirm path/headers against current Claude Code behavior while implementing)claude-code/2.1(match or document divergence)five_hour.utilization,five_hour.resets_atseven_day.utilization,seven_day.resets_atfiveHour/sevenDaygetUsagePlanNameFallback)Scope
internal/usageHTTP client with injectable transport for testsAcceptance criteria
~/.claude/plugins/cache/**/claude-hud/**Out of scope