ccstats

ccstats is a fast CLI for token and cost usage analytics for Claude Code, OpenAI Codex, and Cursor logs.
Search keywords: claude code usage stats, codex usage stats, cursor usage stats, token usage cli, ai token cost tracker.
Highlights
- Fast local analysis of usage JSONL logs
- Claude Code support (
~/.claude/projects/) - OpenAI Codex support (
~/.codex/sessions/) - Experimental Cursor support (
Cursor/User/globalStorage/state.vscdb) - Daily/weekly/monthly/project/session views
- Optional model-level token and cost breakdown
Installation
Homebrew (macOS/Linux)
Cargo binstall (prebuilt binary)
Cargo install (from source)
Shell script
|
# Install a specific version
| VERSION=v0.2.61
Manual download
Download from GitHub Releases.
Quick Start (Codex)
# Install
# Today
# Daily trend
# Same result via unified source flag
Quick Start (Cursor)
Cursor support is experimental because Cursor's local database schema is not a public API. ccstats reads local SQLite tokenCount fields only and does not estimate missing usage.
# Install
# Today
# Daily trend
# Same source via alias
Crate Documentation
- docs.rs: https://docs.rs/ccstats/latest/ccstats/
- crates.io: https://crates.io/crates/ccstats
- The crate-level Rustdoc in
src/lib.rsexplains the SDK entry points and CLI runtime.
Rust SDK
ccstats can be used as a Rust library when another app needs structured local usage and cost data without spawning the CLI.
use ;
let summary = summarize_cost?;
println!;
The SDK uses the same source registry, parsers, aggregation logic, pricing cache, and fallback pricing as the CLI. Returned summaries include total tokens, cache read/create tokens, reasoning tokens, per-model breakdowns, cost_usd, and an optional converted cost when SummaryOptions::currency is set.
Usage
Claude Code
# Today's usage
# Daily breakdown
# Weekly summary
# Monthly summary
# By project
# By session
# 5-hour billing blocks
# With model breakdown
# JSON output
# Debug mode (timing info)
OpenAI Codex
# Codex subcommand mode
# Or use unified source flag
# Today's Codex usage
# Daily Codex breakdown
# Weekly Codex summary
# By session
# With model breakdown
Cursor (Experimental)
Cursor uses the unified source flag rather than a dedicated subcommand.
# Today's Cursor usage
# Daily Cursor breakdown
# Weekly Cursor summary
# By session/conversation
# Cursor alias
By default, ccstats checks these local Cursor databases:
- macOS:
~/Library/Application Support/Cursor/User/globalStorage/state.vscdb - Linux:
~/.config/Cursor/User/globalStorage/state.vscdb workspaceStorage/*/state.vscdbunder the same Cursor user directory
You can override the Cursor user directory with CURSOR_HOME:
CURSOR_HOME="/path/to/Cursor/User"
Current limitations:
- Only explicit
tokenCount/usage fields are counted. - Project aggregation and 5-hour billing blocks are not supported for Cursor.
- Cache creation, cache read, and reasoning token fields are reported as zero unless Cursor exposes them directly in a supported local record.
Common Options
# Bucket by timezone
# Locale-aware number formatting
# Filter by date
# Monthly budget forecast (uses --until as the as-of date when present)
# Select data source explicitly (supports aliases)
# Combine all supported data sources
# Experimental Cursor source (reads local SQLite tokenCount fields)
# Cursor alias
# Offline mode (use cached pricing)
# Compact output
# Hide cost column
Session CSV Columns
ccstats session --csv now includes:
reasoning_tokenscache_creation_tokenscache_read_tokens
Parsing Warnings
When malformed JSONL records are encountered, ccstats reports them in stderr:
Warning: ignored <N> malformed records
Supported Data Sources
| Source | Directory | Features |
|---|---|---|
| Claude Code | ~/.claude/projects/ |
Projects, Billing Blocks, Deduplication |
| OpenAI Codex | ~/.codex/sessions/ |
Reasoning Tokens |
| All Sources | Multiple | Combined daily/weekly/monthly/today/statusline summaries |
| Cursor (experimental) | Cursor User/globalStorage/state.vscdb |
Local SQLite tokenCount fields only |
Architecture
See docs/ARCHITECTURE.md for:
- Adding new data sources
- Data flow and processing pipeline
- Caching mechanism
- Architecture and module boundaries
See docs/algorithm/authoritative-token-accounting.md for:
- Token accounting rules
- Source-specific normalization
- Deduplication semantics
License
MIT. See LICENSE.