Expose API rate-limit response headers to hooks and status line scripts

Resolved 💬 2 comments Opened Mar 13, 2026 by jeszyman Closed Mar 13, 2026

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:

  1. PostToolUse hook input — add a rate_limits object with the header values
  2. 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.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗