context_window.used_percentage in status line JSON is significantly inaccurate
Preflight Checklist
- [x] I have searched existing requests and this bug hasn't been reported yet
- [x] This is a single bug report (not multiple bugs)
Bug Description
The context_window.used_percentage value provided to custom status line scripts is significantly lower than the actual context usage. This makes custom status lines unreliable.
Example: My custom status line showed 78% ctx while the built-in "Context left until auto-compact" warning simultaneously showed 7% remaining (meaning actual usage was ~93%). That's a ~15 percentage point discrepancy.
This appears to be because used_percentage only counts user/assistant message tokens but does not include system prompts, CLAUDE.md content, tool definitions, plugin metadata, and other overhead that counts toward the real context limit.
Expected Behavior
context_window.used_percentage should reflect the true context usage — the same number the auto-compact system uses internally. If the built-in warning says 7% left, the status line JSON should report ~93%, not 78%.
Additional Context
- This also relates to #28216 — even if a default status line is added, it will be misleading if the underlying data is wrong.
- Many users are building custom status lines (see community blog posts and tools like
ccstatusline) that all rely on this value being accurate.
Environment
- Claude Code CLI (latest)
- macOS
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗