claude-code-statusline
Version:
A cute pet-themed status line plugin for Claude Code that displays your token usage through adorable emoji pets!
207 lines (146 loc) β’ 5.3 kB
Markdown
# πΎ Claude Code Statusline
A cute pet-themed status line plugin for Claude Code that displays your token usage through adorable emoji pets!
## β¨ Features
- π± **Dynamic Pet States**: Different pet behaviors based on your actual token usage percentage
- π **5-Hour Window Monitoring**: Real-time display of current billing window usage
- β±οΈ **Time Remaining**: Clear indication of remaining time in the current session
- π° **Cost Tracking**: Live cost updates for your current session
- π¨ **Visual Progress Bar**: Intuitive usage visualization with color coding
- β‘ **High Performance**: Direct ccusage module integration for faster response
## π± Pet States
Your pet reacts to your actual token usage percentage (not burn rate):
| Usage | Pet | State | Description |
|-------|-----|-------|-------------|
| 0-10% | πΈππ± | Just Started | Taking it easy, just getting warmed up |
| 10-30% | π±π½π» | Light Work | Working leisurely, nice and steady |
| 30-60% | ππΊπ» | Getting Busy | Picking up the pace, getting focused |
| 60-80% | πΊπΌπ» | Very Active | Working hard, high concentration |
| 80-95% | π€ͺπΌπΎ | Intense Mode | Full sprint mode, maximum effort |
| 95-100% | π΅πΏπ° | Nearly Exhausted | Almost at the limit, hang in there! |
Plus random special states: π½ Stretching, π» Grooming, π₯± Yawning, and more!
## π¦ Installation
### Recommended: Global npm Installation
Install directly from npm registry:
```bash
# Install globally
npm install -g claude-code-statusline
# Verify installation
claude-code-statusline --version
```
### Alternative: Local Development
For development or custom modifications:
```bash
# Clone the project
git clone https://github.com/xpzouying/claude-code-statusline.git
cd claude-code-statusline
# Install dependencies
npm install
# Link locally for testing
npm link
```
## βοΈ Configuration
### Setup Claude Code
Create or edit `.claude/settings.json` in your project directory:
```json
{
"statusLine": {
"type": "command",
"command": "claude-code-statusline",
"padding": 0
}
}
```
For local development installation:
```json
{
"statusLine": {
"type": "command",
"command": "node /path/to/claude-code-statusline/index.js",
"padding": 0
}
}
```
### Restart Claude Code
After configuration, restart your Claude Code session to see the pet status line.
## π― Examples
Low usage:
```
π Taking it easy~ | 5h: 8% ββββββββββ | 4h 36m left | π° $0.15 | Pro
```
Medium usage:
```
π Getting busy! | 5h: 45% ββββββββββ | 2h 45m left | π° $0.89 | Pro
```
High usage:
```
πΎ Super focused! | 5h: 85% ββββββββββ | 45m left | π° $1.70 | API
```
Almost exhausted:
```
π° Hang in there! | 5h: 97% ββββββββββ | 9m left | π° $1.94 | Pro
```
## π§ͺ Testing
Run the test suite to verify functionality:
```bash
npm test
```
## π§ Troubleshooting
### Status line not showing
1. Check `.claude/settings.json` format is correct
2. Ensure script path exists and has execute permissions
3. Restart Claude Code session
### Configuration errors
If you see "Expected object, but received string":
β **Wrong format**:
```json
{
"statusLine": "cc-pet-statusline"
}
```
β
**Correct format**:
```json
{
"statusLine": {
"type": "command",
"command": "cc-pet-statusline",
"padding": 0
}
}
```
### Inaccurate data
- Plugin depends on ccusage reading local log files
- Ensure Claude Code is generating usage logs properly
- First usage may need some activity before showing accurate data
## π οΈ Technical Details
### Architecture
- **Node.js 18+**: Runtime environment
- **ccusage modules**: Direct import for data loading (`ccusage/data-loader`, `ccusage/calculate-cost`)
- **ANSI Colors**: Terminal color support
- **Performance**: ~300ms response time with direct module imports
### How it works
1. Claude Code calls the status line script every 300ms
2. Script receives current session JSON data via stdin
3. Directly imports ccusage modules to analyze local usage logs
4. Calculates pet state based on token usage percentage vs historical maximum
5. Outputs formatted status line to stdout
### Data Sources
- **Primary**: Direct ccusage module calls for active session blocks
- **Fallback**: Claude Code provided cost data when ccusage unavailable
- **Test Mode**: Mock data when session_id starts with 'test-'
## π Roadmap
- [ ] More pet themes (dogs, birds, etc.)
- [ ] Customizable usage thresholds
- [ ] Historical usage trends
- [ ] Sound notifications
- [ ] tmux plugin version
- [ ] Pixel art animations
## π€ Contributing
Issues and Pull Requests are welcome!
## π License
MIT License
## π Acknowledgments
Special thanks to:
- **[ccusage](https://github.com/ryoppippi/ccusage)** by [@ryoppippi](https://github.com/ryoppippi) - Provides the core token usage analysis and session block functionality that powers this plugin. Without ccusage's excellent data loading and cost calculation modules, this pet status line wouldn't be possible.
- **Claude Code Team** - For providing the status line API and extensibility support
Made with β€οΈ for the Claude Code community