Custom Claude Code status line to restore context window visibility for AWS Bedrock users by displaying token usage. Specifically designed for AWS Bedrock users who have lost access to the /context
command in Claude Code and need to restore visibility into their context window usage.
Problem Statement: AWS Bedrock users in Claude Code lost access to the built-in /context
command, making it impossible to see how much of the context window is being used during conversations.
Solution: This tool restores that visibility by parsing Claude Code's transcript files and displaying token usage directly in the status line.
How It Works: The tool reads JSONL transcript files generated by Claude Code, extracts token usage data (input + cache read + cache creation tokens), and formats it for display in the status line.
Normal Operation:
Opus (125k)
- 125,000 total tokens with Claude 3.5 OpusSonnet 4 (1.2M)
- 1.2 million tokens with Claude 3.5 SonnetClaude (50.5k)
- 50,500 tokens with default model name
Error States:
- (-)
- Error reading transcript or no data available
Choose Method 1 if: You want automatic updates and minimal maintenance Choose Method 2 if: You need offline access or want to modify the script
Add this to your Claude Code settings (~/.claude/settings.json
):
{
"statusLine": {
"type": "command",
"command": "npx -y @this-dot/claude-code-context-status-line"
}
}
Verification:
# Test the installation
echo '{"transcript_path":"/tmp/test.jsonl","model":{"display_name":"Test"}}' | npx @this-dot/claude-code-context-status-line
# Expected output: Test (-)
- Download the script:
curl -o context-status.js https://raw.githubusercontent.com/thisdot/claude-code-context-status-line/main/src/context-status.js
chmod +x context-status.js
- Add to your
~/.claude/settings.json
:
{
"statusLine": {
"type": "command",
"command": "node /absolute/path/to/context-status.js"
}
}
Finding your Claude Code settings:
- macOS:
~/.claude/settings.json
- Linux:
~/.claude/settings.json
- Windows:
%USERPROFILE%\.claude\settings.json
Status line shows "- (-)" constantly:
- Check Claude Code version:
claude --version
- Verify settings.json syntax with a JSON validator
- Test the script manually:
echo '{"transcript_path":"/path/to/transcript.jsonl"}' | npx -p @this-dot/claude-code-context-status-line claude-code-context-status-line
Node.js not found errors:
- Ensure Node.js 18+ is installed:
node --version
- Check PATH includes Node.js installation
- On macOS: Try
brew install node
if using Homebrew
Permission denied errors:
- Check Claude Code has access to the script location
- Use absolute paths in Claude Code configuration
Status line doesn't update:
- Claude Code caches status line output - restart Claude Code to see changes
- Verify your conversation is generating token usage data
- Check that transcript files are being created in the expected location
- Check the Issues page for similar problems
Local Operation Only:
- All processing happens locally on your machine
- No data is sent to external servers
- Transcript files are read with restricted access
File Access:
- Script only reads transcript files provided by Claude Code
- Path traversal protection prevents access outside project directories
- No modification of transcript files - read-only access
Data Handling:
- Token counts extracted from conversation metadata only
- No conversation content is processed or stored
- Minimal memory footprint with automatic cleanup
Designed for Efficiency:
- Processes 10,000+ conversation entries in <100ms
- Memory usage stays under 10MB during processing
- Optimized for frequent status line updates
Scaling Characteristics:
- Small conversations (< 50 entries): >10 updates/second
- Large conversations (10,000+ entries): >1 update/second
- No performance degradation over time
Resource Usage:
- CPU: Minimal - optimized for quick parsing
- Memory: < 10MB peak usage
- Disk: Read-only access to transcript files
Node.js:
- Minimum: Node.js 18.0.0
- Recommended: Node.js 20+ for optimal performance
- Tested on: 18.x, 20.x, 22.x
Claude Code:
- Minimum: Any version with status line support
- Tested with: Claude Code 1.0.80+
- Status line API: Stable across versions
Operating Systems:
- ✅ macOS (Intel & Apple Silicon)
- ✅ Linux (Ubuntu 20.04+, other distributions)
- ✅ Windows 10/11 with WSL or native Node.js
Dependencies:
- Zero runtime dependencies
- Built-in Node.js modules only
What tokens are counted:
- Input tokens: Your messages and conversation context
- Cache read tokens: Previously cached content being reused
- Cache creation tokens: New content being cached for future use
- Total: Sum of all three token types
Status Line Behavior:
- Updates when Claude Code processes new messages
- Shows cumulative token count for entire conversation
- Reflects the most recent conversation state
MIT License - see LICENSE file for details.