A visual context window usage indicator for Claude Code terminal statusline.
- 📊 Progress Bar: Visual representation of context usage
- 🎨 Color-coded: Green → Yellow → Red based on usage
- 📈 Real-time Updates: Shows current context percentage and remaining tokens
- 🔄 Auto-reset: Resets to 0% after
/clearcommand - 💾 Compression Alert: Shows "(Compressed)" when exceeding 100%
Color indicators:
- 🟢 Green: < 60% usage
- 🟡 Yellow: 60-85% usage
- 🔴 Red: > 85% usage
Using curl:
bash <(curl -fsSL https://raw.githubusercontent.com/yangs1202/claude-code-context/main/install.sh)Using wget:
bash <(wget -qO- https://raw.githubusercontent.com/yangs1202/claude-code-context/main/install.sh)# Clone the repository
git clone git@github.com:yangs1202/claude-code-context.git
cd claude-code-context
# Run installation script
./install.sh- Claude Code v2.0+
jq(JSON processor)awk(text processor)
Install dependencies:
# macOS
brew install jq
# Ubuntu/Debian
sudo apt-get install jq
# RHEL/CentOS
sudo yum install jqThe installer will:
- ✅ Check dependencies (jq, awk)
- ✅ Install
statusline.shto~/.claude/ - ✅ Update
~/.claude/settings.json - ✅ Create backup of existing settings
- ✅ Set proper permissions
If you prefer manual installation:
-
Copy
statusline.shto~/.claude/:cp statusline.sh ~/.claude/ chmod +x ~/.claude/statusline.sh
-
Add to
~/.claude/settings.json:{ "statusLine": { "type": "command", "command": "~/.claude/statusline.sh" } } -
Restart Claude Code
bash <(curl -fsSL https://raw.githubusercontent.com/yangs1202/claude-code-context/main/uninstall.sh)# If you cloned the repository
cd claude-code-context
./uninstall.shOr manually remove:
rm ~/.claude/statusline.sh
rm /tmp/claude-statusline-state
# Remove "statusLine" from ~/.claude/settings.jsonThe script:
- Receives JSON data from Claude Code via stdin
- Tracks
session_idto detect/clearcommands - Calculates context usage by comparing current tokens with baseline
- Displays a color-coded progress bar with percentage and remaining tokens
When you run /clear, the session ID changes and the counter resets to 0%.
Status bar not showing?
- Make sure you've restarted Claude Code after installation
- Check that
~/.claude/statusline.shexists and is executable - Verify
statusLineis in your~/.claude/settings.json
Status bar not updating after /clear?
- The script automatically tracks session changes
- Try restarting Claude Code
Dependencies missing?
- Install
jq: See Requirements section above
Colors not showing?
- Make sure your terminal supports ANSI colors
- Try a different terminal emulator
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE file for details
Created for the Claude Code community to help monitor context usage more effectively.
