Skip to content

asathinkeroops/ccstatusline

Repository files navigation

ccstatusline

High-performance Claude Code status line, support tokens usage statistics.

ccstatusline screenshot

Features

  • Session Info Display: Duration, model name, context usage percentage, project name, Git branch, current directory
  • Token Statistics:
    • Multi-dimensional: Day/week/month/total token usage
    • High Performance: Smart caching and concurrent processing, millisecond-level response
  • Beautiful Output: ANSI colors, progress bar, separator formatting

Installation

NPM Install (Recommended)

npm install -g @asathinkeroops/ccstatusline

Output Example

⏱ 2h15m30s | ◆ CLAUDE-SONNET-4-6 | ○ ████████░░ 85% | ◈ gateway | ⎇ main | • ~/projects/gateway
────────────────────────────────────────────────────────────────────────────────────────────────────
◇ Day 125.3K | ▸ Week 1.2M | ▪ Month 8.5M | ◉ Total 52.1M

Core Components

Go CLI (tokens-usage command)

Reads Claude Code session logs from ~/.claude/projects/ and outputs JSON statistics:

ccstatusline tokens-usage --period all

Output format:

{
  "day": { "total_tokens": 125300, ... },
  "week": { "total_tokens": 1200000, ... },
  "month": { "total_tokens": 8500000, ... },
  "total": { "total_tokens": 52100000, ... }
}

Status Line Script (statusline.js)

Receives Claude Code stdin JSON, calls Go CLI for statistics, formats and outputs two-line status line.

Go CLI Commands

# Today's usage (default)
ccstatusline tokens-usage

# This week's usage
ccstatusline tokens-usage --period week

# This month's usage
ccstatusline tokens-usage --period month

# This year's usage
ccstatusline tokens-usage --period year

# Total usage
ccstatusline tokens-usage --period total

# All periods at once
ccstatusline tokens-usage --period all

# Specific date range
ccstatusline tokens-usage --start 2026-01-01 --end 2026-03-31

# Filter by model
ccstatusline tokens-usage --model claude-sonnet-4-6

# Filter by project
ccstatusline tokens-usage --project gateway

# Disable cache
ccstatusline tokens-usage --no-cache

# Clear cache
ccstatusline tokens-usage --clear-cache

Technical Features

  • Concurrent Processing: Goroutine worker pool (max 8 concurrent)
  • Large File Support: 10MB buffer for handling large JSON lines
  • Smart Cache: Incremental cache, historical data persisted, only parse today's data each run
  • Multi-timestamp Compatibility: Supports multiple timestamp format parsing

Cache System

  • Location: ~/.ccstatusline/cache/tokens-usage/
  • Structure:
    • summary.json - Global aggregated statistics
    • metadata.json - Last updated date and cache version
    • daily/<month>.json - Daily stats per month
  • Incremental Update: Each run detects missing dates, only parses new data

Development

Build Go Binary

go build -o ccstatusline .

Build NPM Package

cd packages/npm
npm run build

Local Test NPM Package

cd packages/npm
npm link

License

MIT

About

ccstatusline / ccline is a high-performance claude code status line, support tokens usage statistics. ccstatusline ccstatusline ccstatusline

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors