Feature: Add cache hit rate fields to statusline input JSON

Status Fixed / completed
Maintainer reply None cached
Activity 1 comment · opened Aug 21, 2026 · closed Aug 21, 2026

Summary

The statusline command receives a JSON input containing token usage info, but it doesn't include prompt caching data. Users building custom statuslines (via statusLine.command) would benefit from displaying cache hit rate.

Current Statusline Input Schema

The JSON passed to the statusline command currently includes:

{
  "cwd": "path",
  "model": { "id": "...", "display_name": "..." },
  "context_window": {
    "context_window_size": 200000,
    "total_input_tokens": 80000,
    "total_output_tokens": 20000,
    "current_usage": { "input_tokens": 0, "output_tokens": 0 }
  }
}

Requested Addition

Add prompt cache fields to the statusline input JSON:

{
  "context_window": {
    "cache_read_input_tokens": 50000,
    "cache_creation_input_tokens": 30000
  }
}

Use Case

Custom statusline scripts could calculate and display cache hit rate:

myproject · glm-5 · cache: 63% · ████░░░░░░ 40% · 80k/200k

This helps users understand prompt caching effectiveness during long sessions.

Notes

  • The API response already includes cache_read_input_tokens and cache_creation_input_tokens in the usage object
  • These fields should be readily available in Claude Code's internal state
  • Even when v2.1.8+ zeroes out current_usage, the cache fields would remain useful for monitoring caching behavior

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗