Feature Request: Enhanced Status Line with Context Information Integration
Summary
Request to integrate or improve status line functionality similar to the community-developed context enhancement script that provides additional contextual information in the Claude Code status line.
Background
A community member has created a comprehensive status line enhancement script (reference) that adds valuable context information to Claude Code's status line.
Current Community Solution
The existing script provides the following features:
- Model name display: Shows current model being used
- Current folder name: Displays active project directory
- Git branch information: Shows current branch when in a git repository
- Context usage metrics: Real-time context usage percentage and token counts (out of 200,000 limit)
Implementation Details
The community solution consists of a Python script that:
#\!/usr/bin/env python3
import json
import sys
import os
# Constant
CONTEXT_LIMIT = 200000
# Read JSON from stdin
data = json.load(sys.stdin)
# Extract values
model = data['model']['display_name']
current_dir = os.path.basename(data['workspace']['current_dir'])
# Check for git branch
git_branch = ""
if os.path.exists('.git'):
try:
with open('.git/HEAD', 'r') as f:
ref = f.read().strip()
if ref.startswith('ref: refs/heads/'):
git_branch = f" |⚡️ {ref.replace('ref: refs/heads/', '')}"
except:
pass
transcript_path = data['transcript_path']
# Parse transcript file to calculate context usage
context_used_token = 0
try:
with open(transcript_path, 'r') as f:
lines = f.readlines()
# Iterate from last line to first line
for line in reversed(lines):
line = line.strip()
if not line:
continue
try:
obj = json.loads(line)
# Check if this line contains token usage information
if (obj.get('type') == 'assistant' and 'message' in obj and 'usage' in obj['message']):
usage = obj['message']['usage']
input_tokens = usage.get('input_tokens', 0)
cache_creation_input_tokens = usage.get('cache_creation_input_tokens', 0)
cache_read_input_tokens = usage.get('cache_read_input_tokens', 0)
output_tokens = usage.get('output_tokens', 0)
context_used_token = input_tokens + cache_creation_input_tokens + cache_read_input_tokens + output_tokens
break
except json.JSONDecodeError:
continue
except Exception:
pass
# Calculate percentage
context_percentage = (context_used_token / CONTEXT_LIMIT) * 100
# Print status line
print(f"[{model}] 📁 {current_dir}{git_branch} | Context used: {context_percentage:.1f}% ({context_used_token:,}/{CONTEXT_LIMIT:,} tokens)")
Current Setup Process
Users currently need to:
- Download the Python script
- Add execution permissions:
chmod +x /path/to/claude-code-status-line.py - Update
~/.claude/settings.json:
``json``
{
"statusLine": {
"type": "command",
"command": "/path/to/claude-code-status-line.py"
}
}
Current Output Format
[Model Name] 📁 <folder> |⚡️ <branch> | Context used: XX.X% (XXX,XXX/200,000 tokens)
Proposed Enhancement
Consider integrating similar functionality natively into Claude Code to eliminate the need for external scripts:
- Built-in Status Elements: Native support for model, folder, git branch, and context usage display
- Configurable Status Line: Allow users to customize which elements appear
- Real-time Updates: Automatic context usage tracking without file parsing
- Cross-platform Compatibility: Remove dependency on external Python scripts
- Enhanced Git Integration: Better git repository detection and branch display
Benefits
- Improved User Experience: No external script setup required
- Better Context Awareness: Real-time visibility into context usage and limits
- Enhanced Productivity: Quick project and session status at a glance
- Reduced Friction: Native integration eliminates manual configuration
- Reliability: Built-in functionality more stable than external scripts
Technical Considerations
The community solution demonstrates that the following data is already available:
- Model information via
data['model']['display_name'] - Workspace directory via
data['workspace']['current_dir'] - Transcript path via
data['transcript_path'] - Token usage via transcript file parsing
This suggests native integration would be straightforward since the underlying data is already accessible.
Suggested Implementation
- Add native status line configuration options in Claude Code settings
- Provide template-based status line customization
- Include optional display elements (model, folder, git, context usage)
- Implement real-time context tracking without external file parsing
- Support user-defined status line formats and icons
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗