Skip to main content

Analyze Claude AI usage logs and calculate costs

Project description

Claude Usage Analyzer

Analyze your Claude AI usage logs and calculate costs from ~/.claude or Docker containers.

Quick Start

Option 1: Run directly with uvx (recommended)

uvx claude-usage-analyzer

Option 2: Clone and run

git clone https://github.com/heswithme/claude-usage-analyzer.git
cd claude-usage-analyzer
uv run .

Usage

# Analyze local ~/.claude directory (default)
uvx claude-usage-analyzer

# Analyze Docker containers
uvx claude-usage-analyzer --docker

# Export results to JSON
uvx claude-usage-analyzer --output results.json

# Show only summary
uvx claude-usage-analyzer --summary-only

# Show tool usage statistics
uvx claude-usage-analyzer --tools

# Show cache efficiency analytics
uvx claude-usage-analyzer --cache

# Show response time analysis
uvx claude-usage-analyzer --response-times

# Show all enhanced analytics
uvx claude-usage-analyzer --full

# Limit items shown in tables
uvx claude-usage-analyzer --limit 5

Features

  • Zero Installation: Just clone and run with uv
  • Comprehensive Stats: Token usage, costs, sessions, daily trends
  • Docker Support: Analyze usage from devcontainers (auto-analyzes all containers)
  • Session Deduplication: Automatically detects and merges duplicate sessions across sources
  • Rich Terminal UI: Beautiful tables and formatting
  • Cost Tracking: Automatic calculation based on current Claude API pricing
  • Cache Analytics: Track cache efficiency, ROI, and savings
  • Response Time Analysis: Monitor performance by model and percentiles
  • Enhanced Tool Analytics: Cost per tool, usage patterns, and combinations

Example Output

╭──────────────────────────────────────────╮
│     Claude Usage Analyzer                │
│ Analyzing your Claude AI usage and costs │
╰──────────────────────────────────────────╯

      Overall Usage Statistics      
 Total Messages               1,213 
 Input Tokens                 2,661 
 Output Tokens               68,265 
 Cache Creation Tokens    3,257,802 
 Cache Read Tokens       98,725,473 
 Total Tokens           102,054,201 
                                    
 Total Cost                 $251.35 

Model Usage Breakdown
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━┓
┃ Model                  ┃ Messages  ┃ Input  ┃ Output ┃      Cache ┃    Cost ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━┩
│ claude-opus-4-20250514 │     1,204 │  2,661 │ 68,265 │ 101,983,275 │ $251.35 │
└────────────────────────┴───────────┴────────┴────────┴─────────────┴─────────┘

Daily Usage
┏━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━┓
┃ Date       ┃ Messages ┃ Sessions ┃      Tokens ┃    Cost ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━┩
│ 2025-06-12 │       82 │        1 │   3,602,253 │  $11.10 │
│ 2025-06-11 │    1,209 │        2 │ 101,998,767 │ $251.10 │
└────────────┴──────────┴──────────┴─────────────┴─────────┘

Session Breakdown
┏━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┓
┃ Session ID  ┃ Messages ┃ Duration ┃ Models            ┃    Cost ┃
┡━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━┩
│ 3885ab53... │      768 │    3h 1m │ opus, <synthetic> │ $159.41 │
│ 7701daad... │      441 │   2h 34m │ opus, <synthetic> │  $91.69 │
│ ca45556d... │       82 │      34m │ opus              │  $11.10 │
└─────────────┴──────────┴──────────┴───────────────────┴─────────┘

Requirements

  • Python 3.8+
  • uv (install with curl -LsSf https://astral.sh/uv/install.sh | sh)
  • Docker (optional, for container support)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

claude_usage_analyzer-0.2.2.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

claude_usage_analyzer-0.2.2-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file claude_usage_analyzer-0.2.2.tar.gz.

File metadata

File hashes

Hashes for claude_usage_analyzer-0.2.2.tar.gz
Algorithm Hash digest
SHA256 e7b7ae212cedb1c66a919430abc07a8c4dfff42c4365a333f8779b4ba4f43a5d
MD5 a913ae2a3826e82e2e9f16afe316c69d
BLAKE2b-256 af657f62fc212bda2bf7042500c01e8956c6e78027b8963c6f95c209a2be27a2

See more details on using hashes here.

File details

Details for the file claude_usage_analyzer-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for claude_usage_analyzer-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3a78b6dd992c7b2a0407852e7f404140ccc309670be5c71abe9ce3df8ed1bc15
MD5 34dd60819682de631726821a0ee79da6
BLAKE2b-256 2220775f7bdde4dcea3fda2b3d3eb27e2fb89fd00b53992376b0f67dfd69e746

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page