Feature Request: Add context data to statusline JSON input

Resolved 💬 3 comments Opened Nov 26, 2025 by Milofax Closed Nov 30, 2025

Summary

Currently, statusline scripts receive JSON input with limited information. To enable accurate context window display, statusline tools need access to the actual context usage data that Claude Code already tracks internally.

Problem

Statusline tools like cc-statusline and ccstatusline try to calculate context usage by parsing session transcript files. However, this approach is inherently inaccurate because:

  1. System prompt tokens are not recorded in session files
  2. MCP tool definitions (~30-50k tokens for typical setups) are not included
  3. CLAUDE.md and other context files are loaded but not tracked in session transcripts

As a result, statuslines may show "36% context remaining" while Claude Code reports "8% until auto-compact" - a significant discrepancy that confuses users.

Proposed Solution

Add context information to the JSON that Claude Code passes to statusline commands:

{
  "workspace": { "current_dir": "/path/to/project" },
  "model": { "display_name": "Opus 4.5", "id": "claude-opus-4-5-20251101" },
  "session_id": "...",
  "context": {
    "used_tokens": 176000,
    "max_tokens": 200000,
    "used_percent": 88,
    "remaining_percent": 12,
    "auto_compact_threshold_percent": 80
  }
}

Alternative: /context --json command

Alternatively, expose a /context --json command or API that returns the accurate context data, which statusline scripts could query.

Current Workaround

Both cc-statusline and ccstatusline calculate context from session files using:

contextLength = input_tokens + cache_read_input_tokens + cache_creation_input_tokens

But this fundamentally cannot include:

  • System prompt overhead
  • MCP tool definitions (for users with many MCP servers, this can be 30-50k+ tokens)
  • Environment/configuration context

Impact

Users who rely on statusline context displays to manage their context window are misled by the inaccurate numbers. This makes it harder to know when to use /compact or start a new conversation.

Additional Context

  • Claude Code version: 2.0.53
  • Tested with cc-statusline and ccstatusline
  • Both tools show the same discrepancy because they use the same calculation method
  • The /context command already displays accurate data internally - this request is to expose it to external tools

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗