Product Introduction
- Definition: Toktrack is a Rust-based command-line interface (CLI) tool designed for monitoring token consumption and costs across multiple AI coding assistants (Claude Code, Codex CLI, Gemini CLI, OpenCode). It scans session files generated by these tools.
- Core Value Proposition: It provides real-time cost visibility per model and per day, solves data loss risks from automatic session deletion (e.g., Claude Code’s 30-day retention), and offers unified cost analytics via a high-performance TUI or JSON-output CLI.
Main Features
Ultra-Fast SIMD JSON Parsing:
- How it works: Leverages Rust’s
simd-jsoncrate for Single Instruction Multiple Data (SIMD) acceleration, parsing JSONL session files at ~3 GiB/s throughput. Combined with Rayon-based parallel processing, it scans 3,500+ files in ~40ms. - Technology: Rust’s memory safety + SIMD instructions for near-hardware-level speed.
- How it works: Leverages Rust’s
Persistent Cost Cache:
- How it works: Independently stores daily token/cost summaries in
~/.toktrack/cache/(e.g.,claude-code_daily.json). Once saved, summaries are immutable. Survives CLI data deletion (e.g., Claude’s 30-day purge). - Technology: Local JSON-based cache with TTL for pricing data (
pricing.json).
- How it works: Independently stores daily token/cost summaries in
Multi-CLI Dashboard (TUI & CLI):
- How it works: Aggregates data from
~/.claude/projects/,~/.codex/sessions/,~/.gemini/tmp/, and~/.local/share/opencode/. - Interfaces:
- TUI: 3-tab view (Overview, Stats, Models) with daily/weekly/monthly breakdowns.
- CLI: Commands like
toktrack daily --jsonfor scripting integration.
- How it works: Aggregates data from
Problems Solved
- Pain Point: Irrecoverable cost history loss due to AI CLI retention policies (e.g., Claude Code’s 30-day auto-deletion).
- Target Audience:
- Developers using AI coding tools daily (Claude/Codex/Gemini).
- Engineering Managers tracking team-wide AI spending.
- FinOps teams auditing cloud-based AI expenses.
- Use Cases:
- Audit monthly spending across Claude, Codex, and Gemini in one view.
- Preserve historical costs after Claude automatically deletes sessions.
- Compare cost-per-model (e.g.,
claude-3-opusvs.gpt-4-turbo) via CLI scripts.
Unique Advantages
- Differentiation:
- Speed: 1000x faster than alternatives (40ms vs. 40s for 3,500 files).
- Persistence: Only tool caching data independently of volatile CLI sessions.
- Unified View: Supports 4+ AI coding tools in a single dashboard.
- Key Innovation:
- Hybrid Caching Strategy: Cold scans use SIMD+Rayon; warm scans parse only new files via mtime filtering.
- Immutable Daily Summaries: Guarantees historical data integrity even after source files vanish.
Frequently Asked Questions (FAQ)
How does toktrack prevent Claude Code data loss?
Toktrack caches immutable daily cost summaries in~/.toktrack/cache/. Even if Claude deletes sessions after 30 days, your summarized cost history remains intact.Which AI coding tools does toktrack support?
It supports Claude Code, Codex CLI (including gpt-5.3-codex), Gemini CLI, and OpenCode, parsing session files from their default storage paths.Is Rust required to install toktrack?
No. Usenpx toktrackfor automatic cross-platform binary downloads (macOS x64/ARM64, Linux x64/ARM64, Windows x64). Rust is only needed for source builds.How does toktrack achieve 40ms scan speeds?
Through SIMD-accelerated JSON parsing (simd-jsoncrate) and multithreaded file processing (Rayon), achieving ~3 GiB/s throughput on modern CPUs.Can I export data for custom cost reports?
Yes. Use CLI commands liketoktrack monthly --jsonto pipe structured cost data into external tools (e.g., Python scripts, BI dashboards).
