← Token Rats

Track local usage

The Token Rats CLI reads usage fields from files already written by your coding tools. It uploads token counts, model and provider names, session times, and opaque IDs.

npx token-rats sync --dry-run
npx token-rats login
npx token-rats sync

Supported sources

  • Claude Code: local project JSONL files; reported token counts.
  • Codex: local rollout JSONL files; reported token counts.
  • OpenCode: local SQLite database, including current WAL data; reported token counts grouped by model.
  • Cursor: local generation records; token counts are estimates.

OpenCode uses ~/.local/share/opencode/opencode.db by default. The collector also checks OPENCODE_DB, OPENCODE_DATA_DIR, and XDG_DATA_HOME. It reads only usage fields from assistant message records. Your prompts, responses, and AGENTS.md files are not uploaded by sync.

The collector source and counting limits are public: OpenCode reader · counting method.