toktrack logo

toktrack

Track AI CLI spending across Claude, Codex & Gemini in 40ms

2026-02-24

Product Introduction

  1. 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.
  2. 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

  1. Ultra-Fast SIMD JSON Parsing:

    • How it works: Leverages Rust’s simd-json crate 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.
  2. 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).
  3. 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 --json for scripting integration.

Problems Solved

  1. Pain Point: Irrecoverable cost history loss due to AI CLI retention policies (e.g., Claude Code’s 30-day auto-deletion).
  2. 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.
  3. 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-opus vs. gpt-4-turbo) via CLI scripts.

Unique Advantages

  1. 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.
  2. 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)

  1. 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.

  2. 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.

  3. Is Rust required to install toktrack?
    No. Use npx toktrack for automatic cross-platform binary downloads (macOS x64/ARM64, Linux x64/ARM64, Windows x64). Rust is only needed for source builds.

  4. How does toktrack achieve 40ms scan speeds?
    Through SIMD-accelerated JSON parsing (simd-json crate) and multithreaded file processing (Rayon), achieving ~3 GiB/s throughput on modern CPUs.

  5. Can I export data for custom cost reports?
    Yes. Use CLI commands like toktrack monthly --json to pipe structured cost data into external tools (e.g., Python scripts, BI dashboards).

Subscribe to Our Newsletter

Get weekly curated tool recommendations and stay updated with the latest product news