You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(ccusage): support context_window field from Claude Code statusline hook (#749)
* feat(ccusage): support context_window field from Claude Code statusline hook
Claude Code now provides context_window data in its statusline hook JSON,
containing total_input_tokens, total_output_tokens, and context_window_size.
This change:
- Adds context_window field to statuslineHookJsonSchema in _types.ts
- Updates statusline command to prefer context_window data when available
- Falls back to existing transcript-based calculation when not provided
- Refactors context info formatting into reusable helper function
- Uses Result type pattern for consistent functional error handling
The context_window data from Claude Code is more accurate than parsing
the transcript file, as it reflects the actual token counts used by the API.
* docs: add context_window reference to statusline guide
Add note about Claude Code's context_window data being used for accurate
token counts, with link to official documentation.
* chore(ccusage): fix typo colour to color
Copy file name to clipboardExpand all lines: docs/guide/statusline.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -105,6 +105,7 @@ When using `--cost-source both`, the session cost shows both Claude Code and ccu
105
105
- Green text: Low usage (< 50% by default)
106
106
- Yellow text: Medium usage (50-80% by default)
107
107
- Red text: High usage (> 80% by default)
108
+
- Uses Claude Code's [`context_window` data](https://code.claude.com/docs/en/statusline) when available for accurate token counts
0 commit comments