[FEATURE] Include session compact count in 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
The statusline JSON input provides session metadata and context_window data, but there's no way to know how many times the current session has been compacted. Users building custom statuslines must resort to file-based workarounds using SessionStart hooks with "matcher": "compact", which creates a race condition: the statusline renders before the hook writes, so the compact count is always stale until the next render.
Proposed Solution
Include compact count in the statusline JSON input:
{
"session_id": "...",
"session_compact_count": 2,
"context_window": { ... }
}
This would be consistent with how context_window.current_usage is already provided, and eliminates the race condition since data comes from the same source.
Alternative Solutions
_No response_
Priority
Medium - Would be very helpful
Feature Category
CLI commands and flags
Use Case Example
Displaying compact count in the statusline (e.g., ⚡⚡ for 2 compacts) helps users understand:
- How long/complex their session has been
- When they're working in a heavily-compacted session where older context may be summarized
- Session health at a glance alongside context usage
Additional Context
Related to https://github.com/anthropics/claude-code/issues/15184 which requests autocompact settings. This request is for compact count - complementary but distinct data.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗