claude-code - 💡(How to fix) Fix Add context_breakdown to statusline hook JSON input [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#49022Fetched 2026-04-17 08:53:01
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Timeline (top)
labeled ×3commented ×1

The statusline hook currently receives context_window.used_percentage and total_input_tokens/total_output_tokens, but not the per-category breakdown that /context displays (system prompt, system tools, memory files, skills, messages, autocompact buffer, free space).

Exposing this breakdown in the statusline JSON would let external monitoring tools (menu bar widgets, dashboards, IDE plugins) show actionable context health, e.g. warning a user that their messages are dominating context vs. their tools/skills budget.

Root Cause

The statusline hook currently receives context_window.used_percentage and total_input_tokens/total_output_tokens, but not the per-category breakdown that /context displays (system prompt, system tools, memory files, skills, messages, autocompact buffer, free space).

Exposing this breakdown in the statusline JSON would let external monitoring tools (menu bar widgets, dashboards, IDE plugins) show actionable context health, e.g. warning a user that their messages are dominating context vs. their tools/skills budget.

Code Example

{
  "session_id": "...",
  "context_window": {
    "used_percentage": 13,
    "total_input_tokens": 133200,
    "context_window_size": 1000000,
    "breakdown": {
      "system_prompt_tokens": 6000,
      "system_tools_tokens": 10500,
      "memory_files_tokens": 354,
      "skills_tokens": 761,
      "messages_tokens": 115600,
      "autocompact_buffer_tokens": 33000,
      "free_tokens": 833800
    }
  }
}
RAW_BUFFERClick to expand / collapse

Summary

The statusline hook currently receives context_window.used_percentage and total_input_tokens/total_output_tokens, but not the per-category breakdown that /context displays (system prompt, system tools, memory files, skills, messages, autocompact buffer, free space).

Exposing this breakdown in the statusline JSON would let external monitoring tools (menu bar widgets, dashboards, IDE plugins) show actionable context health, e.g. warning a user that their messages are dominating context vs. their tools/skills budget.

Proposed JSON addition

{
  "session_id": "...",
  "context_window": {
    "used_percentage": 13,
    "total_input_tokens": 133200,
    "context_window_size": 1000000,
    "breakdown": {
      "system_prompt_tokens": 6000,
      "system_tools_tokens": 10500,
      "memory_files_tokens": 354,
      "skills_tokens": 761,
      "messages_tokens": 115600,
      "autocompact_buffer_tokens": 33000,
      "free_tokens": 833800
    }
  }
}

Why

  • /context already computes this. Cost of also emitting it to the statusline is near-zero.
  • Without it, third-party tools can only show a single % bar, not show where context is going (which is what actually helps users decide to compact, trim memory, or prune skills).

Use case

Building a macOS menu bar widget (https://github.com/sudomakeit25/claude-usage-widget) that monitors Claude Code usage. Would let the widget show a stacked context bar per active session.

extent analysis

TL;DR

Exposing the per-category breakdown of context window usage in the statusline JSON would allow external monitoring tools to display actionable context health metrics.

Guidance

  • Add a breakdown object to the context_window JSON object, containing the per-category token counts, as proposed in the issue.
  • Update the statusline hook to include this new breakdown object in its output.
  • Verify that the updated statusline JSON contains the expected breakdown data by checking the output of the statusline hook.
  • Use the new breakdown data in external monitoring tools, such as the proposed macOS menu bar widget, to display stacked context bars per active session.

Example

{
  "session_id": "...",
  "context_window": {
    "used_percentage": 13,
    "total_input_tokens": 133200,
    "context_window_size": 1000000,
    "breakdown": {
      "system_prompt_tokens": 6000,
      "system_tools_tokens": 10500,
      "memory_files_tokens": 354,
      "skills_tokens": 761,
      "messages_tokens": 115600,
      "autocompact_buffer_tokens": 33000,
      "free_tokens": 833800
    }
  }
}

Notes

The proposed solution assumes that the /context endpoint already computes the per-category breakdown, and that the cost of emitting this data to the statusline is near-zero.

Recommendation

Apply the proposed workaround by adding the breakdown object to the statusline JSON, as it would provide valuable context health metrics to external monitoring tools without incurring significant additional costs.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Add context_breakdown to statusline hook JSON input [1 comments, 2 participants]