Add context usage information to statusline JSON input
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
Summary
The statusline script currently receives JSON input from Claude Code but doesn't include information about the current context window usage. This makes it impossible to accurately display context percentage in custom statuslines.
## Current Behavior
The JSON passed to statusline scripts includes:
session_idtranscript_pathexceeds_200k_tokens(boolean)costinformation
However, it doesn't include:
- Current total tokens in context
- Maximum context window size for the model
The /context command shows accurate context usage (e.g., "94k/200k tokens (47%)"), but this information isn't available to statusline scripts.
Proposed Solution
Please add the following fields to the statusline JSON input:
```json
{
"context": {
"current_tokens": 94000,
"max_tokens": 200000,
"percentage": 47
}
}
Alternative Solutions
Currently, there's no reliable workaround since the transcript only stores per-message usage, not cumulative context size.
Priority
Medium - Would be very helpful
Feature Category
CLI commands and flags
Use Case Example
This would enable custom statuslines to display real-time context usage, helping users:
- Monitor conversation length at a glance
- Know when they're approaching context limits
- Match the information shown in /context in their terminal prompt
Additional Context
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗