tokenusage (tu)
Fast Rust CLI/TUI/GUI token usage tracker for Codex usage and Claude Code usage.
tu scans local session logs, merges multiple sources, estimates cost, and shows results in:
- CLI table (responsive columns)
- TUI (sticky header + scroll)
- GUI (
iced+tiny-skia) - Live session monitor with progress bars
Why tu
- Real-world speedup vs
ccusage: about 34.5x (cold) and 131.1x (warm) on local Codex logs - Why it is faster: native Rust startup, parallel file discovery/parsing, and incremental cache reuse
- One report for both Codex + Claude (merged totals and merged model view)
- Also supports source-specific modes:
tu codex,tu claude,tu live codex,tu live claude
This project is built for people searching for: Claude Code usage tracker, Codex usage monitor, LLM token cost dashboard, Rust TUI/GUI token analytics.
Screenshots
Install
cargo (crates.io)
cargo-binstall (prebuilt binary)
Homebrew
npm
From source
Quick Start
# Run daily report (default command)
# Only Codex / only Claude
# Date filter
# Weekly / monthly
# Live block monitor
# GUI dashboard
Benchmark Details (Real Local Data, Codex-Only)
Benchmark setup:
- Machine: Apple M3 Max, macOS 15.6.1
- Dataset:
~/.codex/sessions(71 JSONL files, ~537 MB), date range2025-09-01to2026-02-28 tuversion:1.1.2@ccusage/codexversion:18.0.8- Both in default mode (online pricing behavior, network enabled)
Results:
| Tool | Command | Time |
|---|---|---|
tu (cold, rebuild cache) |
tu codex --rebuild-cache -s 2025-09-01 -u 2026-02-28 |
0.19s |
@ccusage/codex (single run) |
ccusage-codex daily -s 2025-09-01 -u 2026-02-28 |
6.56s |
tu (warm, avg of 10 runs) |
tu codex -s 2025-09-01 -u 2026-02-28 |
0.052s |
@ccusage/codex (warm, avg of 10 runs) |
ccusage-codex daily -s 2025-09-01 -u 2026-02-28 |
6.819s |
- Cold-run speedup: about 34.5x
- Warm-run speedup: about 131.1x
Notes: results vary by hardware, filesystem cache state, and log volume.
Demo Dataset (No Real Data)
Use the bundled mock dataset when you want screenshots/demos without exposing local usage logs.
# regenerate demo logs
# run reports with demo-only config
What tu Tracks
- Input tokens
- Output tokens
- Cache create tokens
- Cache read tokens
- Total tokens
- Estimated cost (USD)
- Per-model merged view (
claude-haiku-...,gpt-5.3-codex, etc.)
Data Sources
By default, tu checks these directories and merges all valid logs:
- Claude:
~/.config/claude/projects~/.claude/projects
- Codex:
~/.codex/sessions~/.config/codex/sessions
You can override with:
--claude-projects-dir <PATH>(repeatable)--codex-sessions-dir <PATH>(repeatable)
This merged mode is the key difference from single-source tools: one timeline/table can include both providers, while still allowing per-source commands when needed.
Command Overview
tu [daily|codex|claude|monthly|weekly|session|blocks|live|statusline|gui]
Useful commands:
tu daily --tui: terminal table UI with sticky headertu daily --jsontu daily --jq '.rows[0]'tu blocks --activetu blocks --livetu live: same intent as live block monitortu statusline: statusline output (cache-aware)
Config File
Config search order:
./.tu/tu.json~/.config/tu/tu.json~/.config/tokenusage/tokenusage.json
You can also pass explicit config:
Example:
Pricing
- Uses OpenRouter model pricing when available.
- Pricing cache TTL: 6 hours.
- Falls back to built-in offline rate table if network data is unavailable.
- Optional override file:
Use offline-only mode:
Performance Notes
- Parallel file discovery via
ignorecrate - Parallel parsing with
rayon+ worker threads + channels - Incremental parse cache for repeated runs
Built-in heavy directory ignores include: .git, node_modules, target, dist, build, .cache, venv...
Troubleshooting
- If no data appears, pass explicit roots:
--claude-projects-dir ...--codex-sessions-dir ...
- If your terminal is narrow,
tuauto-switches to compact columns. - Use
--debugto print parser stats.
Development
Release (Maintainers)
Tag-based release is enabled in GitHub Actions (.github/workflows/release.yml).
On tag push (vX.Y.Z), the pipeline:
- builds and uploads release assets (Linux/macOS/Windows)
- publishes GitHub Release
- publishes to crates.io and npm (release fails if tokens are missing)
- optionally updates Homebrew tap formula (if configured)
Required repository secrets for full multi-channel publish:
CRATES_IO_TOKENNPM_TOKENHOMEBREW_TAP_PAT
If CRATES_IO_TOKEN or NPM_TOKEN is missing, the tagged release job fails to prevent partial publish.
Homebrew tap target repo defaults to:
hanbu97/homebrew-tap(tap name:hanbu97/tap)
Version sync requirement before tagging:
Cargo.tomlpackage.versionmust equal tag withoutv- npm package version is auto-synced from
Cargo.tomlduring release workflow
License
MIT. See LICENSE.