# TokenMetrics: making AI agent token spend visible per project

> A desktop app that reads Claude Code, Codex CLI and Gemini CLI logs locally and shows token usage by project, model and session.

- What it does today: Collects AI agent token usage from local logs and shows it by project, model, session and time, with estimated cost and subscription limit tracking. A developer who uses Claude Code, Codex CLI or Gemini CLI heavily and wants to see the spend can install it.
- Form: Open-Source, Desktop
- Maturity: Beta
- State: In development
- Focus: AI and AI-assisted development
- Started: 2026-11-08
- Technologies: Go, Wails, Svelte, TypeScript, SQLite
- Tags: #ai, #tokens, #cost, #visualization
- Source code: https://github.com/muhammetsafak/TokenMetrics
- Source: https://muhammetsafak.com/labs/tokenmetrics-lab/
- Language: en-US
- Author: Muhammet Şafak

---
Trying to fit inside my subscription limits, I realized I didn't know how many tokens I'd spent on which project; I was only guessing. TokenMetrics is the Go app I wrote to turn that guess into a measurement. The personal side of the story is in the [blog post](https://muhammetsafak.com/blog/which-project-burned-how-many-tokens-tokenmetrics/).

## Reading from logs that already exist

My first decision in this experiment was not to build a wrapper or a proxy. I read the local records agents already leave behind: Claude Code, Codex CLI and Gemini CLI. For API accounts you can add the Anthropic and OpenAI Admin APIs; for services that leave no logs I added manual entry and CSV import.

I made scanning incremental. The app stores how far it read in each file, writes records under their own identifiers and never counts the same message twice. I keep records in the database even after the log file is deleted. The cost is that totals recomputed from the raw logs can come out lower than the stored ones; the verification tools I wrote report that case as inconclusive rather than as a mismatch.

## Making the measurement readable

What mattered to me was not knowing the total but being able to see the usage. The overview screen shows today, the last 7 and 30 days; the chart shows token flow split by service or model. The comparison screen gives input, output and cache tokens, request count and estimated cost per model and service. The projects screen breaks usage down by the directory the agent worked in. The limits screen tracks the 5-hour and weekly windows; when a threshold is crossed, an OS notification and the tray icon raise the alert.

## Cost and limits

I take cost from a built-in price table and limit percentages from values you enter, because providers don't publish subscription limits. That's why I labeled all of it "estimated" in the interface.

I kept the privacy scope narrow: my parsers read token counts and metadata (model, time, project directory, session ID) and not prompts or answers. I keep the data in a single local SQLite file, and Admin API keys go to the operating system's keychain.

## Today's limits and what's next

Version 0.1.0, beta. It has gaps too: usage that leaves no logs is visible only through manual entry; I haven't yet separated which subscription records were charged to; and I haven't code signed the binaries or notarized the macOS app. The interface is Turkish only for now.

Next is collecting a few weeks of real usage data. As it builds up, I'll share here how far each project's share drifted from my guess.
