A beautiful, informative statusline for Claude Code
Real-time directory, git branch, model info, costs, and session time tracking
One command. Three questions. Custom statusline.
npx @chongdashu/cc-statusline@latest init
That's it! Answer a few simple questions, restart Claude Code, and enjoy your new statusline.
- Node.js 16+ - Required for the CLI tool
- Claude Code - The tool you're already using
- jq - JSON processor for advanced features (see installation guide below)
- Required for: context tracking, token stats, session timer
- Without jq: basic features still work with fallback parser
Without jq, your statusline will have LIMITED functionality:
- β No context remaining percentage
- β No token statistics from ccusage
- β No session timer
β οΈ Basic fallback parser is used (less reliable)
brew install jq
# Ubuntu/Debian
sudo apt-get install jq
# CentOS/RHEL/Fedora
sudo yum install jq
# Arch Linux
sudo pacman -S jq
Option 1: Package Manager (Recommended)
# Chocolatey
choco install jq
# Scoop
scoop install jq
# Winget
winget install jqlang.jq
Option 2: Manual Download
- Go to https://github.com/jqlang/jq/releases/latest
- Download:
- 64-bit:
jq-windows-amd64.exe
- 32-bit:
jq-windows-i386.exe
- 64-bit:
- Rename to
jq.exe
- Place in
C:\Windows\System32\
(requires admin) or add to PATH - Test:
jq --version
jq --version
# Should output: jq-1.6 or higher
- git - For branch display (you probably have this)
- ccusage - For usage stats (works via
npx
- no install needed)
Enhance your Claude Code terminal with useful information:
- π Directory Display - Current folder with
~
abbreviation - πΏ Git Integration - Current branch name
- π€ Model Info - Shows which Claude model you're using plus Claude Code version
- π§ Context Usage - Real-time context window usage with progress bars (requires jq)
- π° Cost Tracking - Live cost monitoring with burn rates via ccusage (partial without jq)
- β Session Timer - Time remaining until usage limit resets (requires jq)
- π Token Analytics - Token consumption and burn rate metrics (requires jq)
- π¨ Color Support - 256-color palette for Claude Code terminals
- β‘ Fast Execution - Optimized bash script with <100ms execution time
- π Global Installation (
~/.claude/
) - Use across all your projects - π Project Installation (
./.claude/
) - Keep settings project-specific
Feature | Description | Example |
---|---|---|
π Directory | Current working directory | ~/my-project |
πΏ Git Branch | Active git branch | feature/statusline |
π€ Model | Claude model name & version | Sonnet 4 |
π Claude Code | Claude Code version | v1.0.85 |
π¨ Output Style | Current output style setting | default |
π§ Context | Remaining context with progress bar | 83% [========--] |
π° Cost | Live costs with highlighted burn rate | $49.00 ($16.55/h) |
β Session | Time until reset with progress | 3h 7m until reset at 01:00 (37%) [===-------] |
Feature | Description | Example |
---|---|---|
π Tokens | Token consumption with burn rate | 14638846 tok (279900 tpm) |
New 3-Line Modern Layout (v1.2.2+):
π ~/Projects/cc-statusline πΏ feature/context-usage-output-styles π€ Sonnet 4 π v1.0.85 π¨ default
π§ Context Remaining: 83% [========--] β 3h 7m until reset at 01:00 (37%) [===-------]
π° $49.00 ($16.55/h) π 14638846 tok (279900 tpm)
Compact Mode:
π ~/my-app πΏ main π€ Claude Sonnet π v1.0.85
π§ Context Remaining: 95% [=========-]
π° $2.48 ($12.50/h)
Test your statusline before restarting Claude Code:
cc-statusline preview .claude/statusline.sh
What preview does:
- π Loads your actual statusline script
- π§ͺ Runs it with realistic mock data
- π Shows exactly what the output will look like
- β‘ Reports performance metrics and functionality
- π Safe Updates - Never overwrites existing statuslines without confirmation
- π‘οΈ Settings Protection - Preserves your existing settings.json configurations
β οΈ Conflict Detection - Warns when other statuslines are configured- β Smart Defaults - Project-level installation by default for safety
# Generate to custom location
cc-statusline init --output ./my-statusline.sh
# Skip auto-installation (manual setup)
cc-statusline init --no-install
# Global installation for convenience
npm install -g @chongdashu/cc-statusline
- π― Configuration - Two questions configure your preferences
- ποΈ Generation - Creates optimized bash script tailored to your needs
- βοΈ Installation - Integrates with Claude Code settings
- π Updates - Connects to ccusage for live usage statistics
- β‘ Bash-First - Native shell execution for maximum speed
- π¨ Claude Code Optimized - Forces colors for Claude Code terminals (respects NO_COLOR)
- π Environment Respect - Honors
NO_COLOR
and other terminal conventions - π¦ Zero Dependencies - Self-contained script with graceful fallbacks
- π Secure - No network requests except ccusage integration
After installation, you'll have a clean setup:
.claude/
βββ statusline.sh # π― Your generated statusline script
βββ settings.json # βοΈ Auto-updated Claude Code configuration
If auto-configuration fails, simply add this to .claude/settings.json
:
{
"statusLine": {
"type": "command",
"command": ".claude/statusline.sh",
"padding": 0
}
}
- Restart Claude Code after installation
- Verify settings - Check
.claude/settings.json
contains the configuration above - Check permissions - Ensure script is executable:
chmod +x .claude/statusline.sh
- Test performance:
cc-statusline preview .claude/statusline.sh
- Optimize features: Disable heavy features if execution > 500ms
- Disable ccusage: Remove usage tracking if not needed
- Install jq: See the jq installation guide below
- ccusage setup: Works automatically via
npx ccusage@latest
- Git not found: Install git for branch display
- Context not showing: Ensure you're in an active Claude Code session with context usage
- Colors not working: Check that NO_COLOR environment variable is not set
Metric | Target | Typical |
---|---|---|
Execution Time | <100ms | 45-80ms |
Memory Usage | <5MB | ~2MB |
CPU Impact | Negligible | <1% |
Dependencies | Minimal | jq only |
Benchmarked on macOS with all features enabled
Contributions are welcome!
Quick Start:
git clone https://github.com/chongdashu/cc-statusline
cd cc-statusline
npm install && npm run build
Contribution Areas:
- π Bug Fixes - Help make it more robust
- β¨ New Features - Add support for more runtimes/features
- π Documentation - Improve guides and examples
- π§ͺ Testing - Add test coverage and edge cases
See our Contributing Guide for detailed information.
The ccusage integration includes a robust file-based locking mechanism to prevent concurrent process spawning. Test this functionality:
Single Test:
echo '{}' | ./test/test-statusline-with-lock.sh
Concurrent Test:
./test/test-concurrent-locking.sh
Manual Concurrent Test:
# Spawn 10 concurrent processes
for i in {1..10}; do
echo '{}' | ./test/test-statusline-with-lock.sh &
done
Expected Behavior:
- β Only 1 process runs ccusage at a time
- β Other processes skip gracefully (no pile-up)
- β Lock files are properly cleaned up
- β No hanging processes remain
Verification Commands:
# Check for stale locks
ls /tmp/ccusage_statusline.* 2>/dev/null || echo "β
No locks remain"
# Monitor running processes
ps aux | grep ccusage | grep -v grep
- ccusage - Claude Code usage analytics (would not be possible with it!)
- Claude Code - Official documentation
We're grateful for all contributions that make cc-statusline better!
- Jonathan Borgwing (@DevVig) - Critical performance fix for infinite ccusage process spawning (#4)
Want to see your name here? Check out our Contributing Guide and help make cc-statusline even better!
We welcome:
- π Bug fixes and performance improvements
- β¨ New features and enhancements
- π Documentation improvements
- π§ͺ Test coverage and quality assurance
See CHANGELOG.md for detailed release history.
MIT License - see LICENSE file for details.
Made by Chong-U @ AIOriented