https://github.com/chongdashu/cc-statusline
Transform your Claude Code experience with a beautiful, informative statusline
https://github.com/chongdashu/cc-statusline
Last synced: 3 months ago
JSON representation
Transform your Claude Code experience with a beautiful, informative statusline
- Host: GitHub
- URL: https://github.com/chongdashu/cc-statusline
- Owner: chongdashu
- License: mit
- Created: 2025-08-13T10:16:03.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-08-20T21:46:37.000Z (3 months ago)
- Last Synced: 2025-08-20T23:21:13.241Z (3 months ago)
- Language: TypeScript
- Homepage:
- Size: 50 MB
- Stars: 64
- Watchers: 2
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-claude-code - **cc-statusline**
README
# cc-statusline
**A beautiful, informative statusline for Claude Code**

*Real-time directory, git branch, model info, costs, and session time tracking*
[](https://www.npmjs.com/package/@chongdashu/cc-statusline)
[](https://opensource.org/licenses/MIT)
[](https://nodejs.org/)
## โก Quick Start
**One command. Two questions. Custom statusline.**
```bash
npx @chongdashu/cc-statusline@latest init
```
That's it! Answer 2 simple questions, restart Claude Code, and enjoy your new statusline.
## ๐ฏ Simple Setup

## โจ What You Get
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
- **๐ฐ Cost Tracking** - Live cost monitoring with burn rates via ccusage
- **โ Session Timer** - Time remaining until usage limit resets
- **๐ Token Analytics** - Token consumption and burn rate metrics
- **๐จ Color Support** - 256-color palette for Claude Code terminals
- **โก Fast Execution** - Optimized bash script with <100ms execution time
## ๐๏ธ Features Overview
### ๐ฅ Default Features (All Pre-selected in v1.2.2+)
| 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%) [===-------]` |
### ๐ Power Features (Also Pre-selected)
| Feature | Description | Example |
|---------|-------------|---------|
| ๐ **Tokens** | Token consumption with burn rate | `14638846 tok (279900 tpm)` |
### ๐จ Example Outputs
**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)
```
## ๐ ๏ธ Advanced Usage
### Preview Your Statusline
Test your statusline before restarting Claude Code:
```bash
cc-statusline preview .claude/statusline.sh
```
**What preview does:**
1. ๐ **Loads** your actual statusline script
2. ๐งช **Runs** it with realistic mock data
3. ๐ **Shows** exactly what the output will look like
4. โก **Reports** performance metrics and functionality
### Custom Installation
```bash
# 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
```
## ๐ง How It Works
### How It Works
1. **๐ฏ Configuration** - Two questions configure your preferences
2. **๐๏ธ Generation** - Creates optimized bash script tailored to your needs
3. **โ๏ธ Installation** - Integrates with Claude Code settings
4. **๐ Updates** - Connects to ccusage for live usage statistics
### Technical Architecture
- **โก 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
## ๐ Requirements
### โ
Required (You Already Have These!)
- **Claude Code** - The tool you're already using
- **jq** - JSON processing (pre-installed on most systems)
### ๐ Optional Enhancements
- **git** - For branch display (you probably have this)
- **ccusage** - For usage stats (works via `npx` - no install needed)
### Quick Compatibility Check
```bash
command -v jq && echo "โ
Ready to go!"
```
## ๐ File Structure
After installation, you'll have a clean setup:
```
.claude/
โโโ statusline.sh # ๐ฏ Your generated statusline script
โโโ settings.json # โ๏ธ Auto-updated Claude Code configuration
```
### Manual Configuration (Backup Plan)
If auto-configuration fails, simply add this to `.claude/settings.json`:
```json
{
"statusLine": {
"type": "command",
"command": ".claude/statusline.sh",
"padding": 0
}
}
```
## ๐ง Troubleshooting
### ๐ซ Statusline Not Showing
1. **Restart Claude Code** after installation
2. **Verify settings** - Check `.claude/settings.json` contains the configuration above
3. **Check permissions** - Ensure script is executable: `chmod +x .claude/statusline.sh`
### ๐ Performance Issues
- **Test performance**: `cc-statusline preview .claude/statusline.sh`
- **Optimize features**: Disable heavy features if execution > 500ms
- **Disable ccusage**: Remove usage tracking if not needed
### ๐งฉ Missing Features
- **Install jq**: `brew install jq` (macOS) or `apt install jq` (Ubuntu)
- **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
## ๐ Performance
| 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*
## ๐ค Contributing
Contributions are welcome!
**Quick Start:**
```bash
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](CONTRIBUTING.md) for detailed information.
## ๐งช Testing
### Locking Mechanism Tests
The ccusage integration includes a robust file-based locking mechanism to prevent concurrent process spawning. Test this functionality:
**Single Test:**
```bash
echo '{}' | ./test/test-statusline-with-lock.sh
```
**Concurrent Test:**
```bash
./test/test-concurrent-locking.sh
```
**Manual Concurrent Test:**
```bash
# 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:**
```bash
# 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
```
## ๐ Stats



## ๐ Related Projects
- **[ccusage](https://github.com/ryoppippi/ccusage)** - Claude Code usage analytics (would not be possible with it!)
- **[Claude Code](https://docs.anthropic.com/en/docs/claude-code)** - Official documentation
## ๐ฅ Contributors
We're grateful for all contributions that make cc-statusline better!
- **[Jonathan Borgwing (@DevVig)](https://github.com/DevVig)** - Critical performance fix for infinite ccusage process spawning ([#4](https://github.com/chongdashu/cc-statusline/pull/4))
### How to Contribute
Want to see your name here? Check out our [Contributing Guide](CONTRIBUTING.md) 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
## ๐ Changelog
See [CHANGELOG.md](CHANGELOG.md) for detailed release history.
## ๐ License
MIT License - see [LICENSE](LICENSE) file for details.
---
**Made by [Chong-U](https://github.com/chongdashu) @ [AIOriented](https://aioriented.dev)**