Skip to content

lazureykis/claude-code-usage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Claude Code Usage

Reads Claude Code session JSONL files to compute real-time daily token consumption. Available as both Python and Rust. Designed to feed an ESP32-based device that displays usage on screen.

Usage

# Python
python3 get_usage.py            # today's usage
python3 get_usage.py 2026-03-11 # specific date

# Rust
cargo build --release
./target/release/claude-code-usage            # today's usage
./target/release/claude-code-usage 2026-03-11 # specific date

Output

{
  "date": "2026-03-12",
  "total_output_tokens": 78283,
  "total_input_tokens": 38987,
  "total_cache_read_tokens": 36482745,
  "total_cache_creation_tokens": 2516519,
  "output_by_model": {
    "opus": 66710,
    "haiku": 11573
  },
  "total_cost_usd": 12.34,
  "cost_by_model_usd": {
    "opus": 11.50,
    "haiku": 0.84
  },
  "messages": 481,
  "sessions": 3
}

Pricing

Cost is estimated using Anthropic's published pricing. Cache read tokens are 0.1x and cache write tokens are 1.25x the base input price.

How It Works

Scans all ~/.claude/projects/**/*.jsonl session files for assistant messages matching the target date. Each message contains a usage object with token counts and model info. Unlike ~/.claude/stats-cache.json (which can lag days behind), this gives real-time results.

Requirements

  • Python: 3.10+ (stdlib only, no dependencies)
  • Rust: 1.70+ (cargo build --release)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors