Summary
The Anthropic API returns detailed rate-limit headers on every response (anthropic-ratelimit-tokens-remaining, anthropic-ratelimit-requests-remaining, anthropic-ratelimit-input-tokens-remaining, etc.), but Claude Code does not expose these to hooks or status line scripts.
Problem
Users who want to monitor their usage and implement warnings (e.g., at 50%/75% thresholds) have no way to access this data programmatically within Claude Code. The hook JSON input and status line JSON both lack any rate-limit fields.
Proposed solution
Include the API response rate-limit headers in:
- PostToolUse hook input — add a
rate_limits object with the header values
- Status line JSON — add a
rate_limits object so status line scripts can display remaining capacity
Example fields:
{
"rate_limits": {
"requests_limit": 50,
"requests_remaining": 48,
"requests_reset": "2026-03-12T10:00:00Z",
"input_tokens_limit": 30000,
"input_tokens_remaining": 25000,
"output_tokens_limit": 8000,
"output_tokens_remaining": 7000
}
}
Use case
Building a status line warning system that alerts when approaching per-minute rate limits, or a hook that suggests switching to a lighter model when limits are close.
Summary
The Anthropic API returns detailed rate-limit headers on every response (
anthropic-ratelimit-tokens-remaining,anthropic-ratelimit-requests-remaining,anthropic-ratelimit-input-tokens-remaining, etc.), but Claude Code does not expose these to hooks or status line scripts.Problem
Users who want to monitor their usage and implement warnings (e.g., at 50%/75% thresholds) have no way to access this data programmatically within Claude Code. The hook JSON input and status line JSON both lack any rate-limit fields.
Proposed solution
Include the API response rate-limit headers in:
rate_limitsobject with the header valuesrate_limitsobject so status line scripts can display remaining capacityExample fields:
{ "rate_limits": { "requests_limit": 50, "requests_remaining": 48, "requests_reset": "2026-03-12T10:00:00Z", "input_tokens_limit": 30000, "input_tokens_remaining": 25000, "output_tokens_limit": 8000, "output_tokens_remaining": 7000 } }Use case
Building a status line warning system that alerts when approaching per-minute rate limits, or a hook that suggests switching to a lighter model when limits are close.