An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# cc-statusline

**A beautiful, informative statusline for Claude Code**

cc-statusline in action

*Real-time directory, git branch, model info, costs, and session time tracking*

[![npm version](https://badge.fury.io/js/@chongdashu%2Fcc-statusline.svg)](https://www.npmjs.com/package/@chongdashu/cc-statusline)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Node.js](https://img.shields.io/badge/Node.js-16%2B-green.svg)](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

Demo of cc-statusline 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

![GitHub stars](https://img.shields.io/github/stars/chongdashu/cc-statusline?style=social)
![GitHub forks](https://img.shields.io/github/forks/chongdashu/cc-statusline?style=social)
![npm downloads](https://img.shields.io/npm/dm/@chongdashu/cc-statusline)

## ๐Ÿ”— 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)**