Overview
cc-statusline integrates with ccusage to provide advanced session tracking features. The integration is optional and only required for specific features.What Requires ccusage?
Only one feature requires ccusage:- Session Timer - Shows time remaining until usage limit reset with progress bars
- Cost tracking (from Claude Code native data)
- Token statistics (from Claude Code native data)
- Burn rate calculations (computed from native data)
- Directory, git, model info (local sources)
How It Works
Data Sources
cc-statusline uses two data sources:-
Claude Code Native JSON (stdin)
- Cost data (
cost.total_cost_usd,cost.total_duration_ms) - Token data (
context_window.total_input_tokens,context_window.total_output_tokens) - Model, version, output style info
- No external dependencies needed
- Cost data (
-
ccusage CLI (optional)
- Session reset time (
usageLimitResetTime) - Active block detection
- Required only for session timer feature
- Session reset time (
Integration Implementation
Fromusage.ts:89-123:
Usage Without Installation
ccusage doesn’t need to be installed globally. The statusline uses:- Global install:
npm install -g ccusage - npx execution:
npx ccusage@latest - Local PATH availability
Safety Features
Timeout Protection
Fromusage.ts:95-100, ccusage calls have 5-second timeouts:
- Uses GNU
timeout(Linux) orgtimeout(macOS with coreutils) - Falls back to no timeout if neither available
- Prevents hanging if ccusage is slow or unresponsive
Graceful Degradation
Fromusage.ts:32-33:
- If ccusage isn’t available → session timer doesn’t show
- If jq isn’t available → ccusage won’t be called
- If ccusage fails → no error, just no session timer
- All other features continue working normally
Cost and Token Data
Native Data Extraction (No ccusage needed)
Fromusage.ts:40-88, cost and token data comes from Claude Code’s stdin:
With jq (usage.ts:42-64):
usage.ts:66-88):
Dependencies
Required
- bash - Script execution
- awk - Burn rate calculations
Optional
- jq - JSON parsing (has bash fallback)
- ccusage - Session timer only
- timeout/gtimeout - Safety timeouts for ccusage
Performance Impact
From testing (tester.ts:186-231):
- Without ccusage: 45-80ms execution time
- With ccusage: 100-200ms execution time
- ccusage timeout: Maximum 5 seconds (rare)
Example Output
With ccusage Available
Without ccusage (Still Fully Functional)
Troubleshooting
Session Timer Not Showing
-
Check ccusage availability:
-
Check jq availability (required for ccusage integration):
-
Test ccusage manually:
Cost/Token Data Not Showing
This is NOT a ccusage issue! Cost and tokens use Claude Code native data.-
Check jq (preferred, has fallback):
-
Verify Claude Code input (testing):
-
Check fallback parser (if jq missing):
- Bash grep/sed patterns should extract basic data
- May be less reliable than jq
Related Documentation
- Claude Code JSON Format - Input data structure
- Manual Setup - Manual configuration without installer
- ccusage project - External dependency