missuo/tokens
About
Track, visualize, and compete on your AI coding-assistant token usage — CLI + web leaderboard. A fork of junhoyeo/tokscale.
Developer ToolsMeasured star growth
- in 24h
- +2
- in 7 days
- +22
- in 15 days
- +50
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalYou already burn tokens all day. tokens.ci turns that into a public standing: how much you ran through today, how it splits across clients and models, and where you rank against everyone else doing the same thing.
bunx tokens-cli@latest login
iOS app
Your rank and usage on your phone, without opening a browser — share cards rendered on device, plus Home screen and Lock screen widgets for the day's tokens, your running total and your rank.
There is no sign-in. You enter a GitHub username and the app reads that public profile, so enter your own or the widgets will show someone else's usage.
Languages
The site is available in English, Simplified Chinese and Japanese. English is
the default and carries no prefix, so every existing link keeps working; the
other languages live under /zh-CN/… and /ja/…, and the switcher in the
header moves you to the same page in the other language rather than to the
home page.
The prefix is not cosmetic. HTML is cached at Cloudflare's edge by URL, so a
scheme where one URL renders different bytes based on a cookie would let
whichever request arrived first decide the language for everyone behind it.
With a prefix in the URL, /zh-CN/leaderboard and /leaderboard are simply two
documents.
To add a language:
- Add the locale to
LOCALESandLOCALE_LABELSinweb/src/lib/i18n/config.ts. - Copy
web/src/lib/i18n/messages/*/en.tsto the new locale directory underweb/src/lib/i18n/messages/<namespace>/and translate the values. Keys you leave out fall back to English at runtime, so a partial catalogue is usable. - Add the two prefixed entries (
/<locale>and/<locale>/:path*) to the matcher inweb/src/middleware.ts.
Messages are ICU: {name} for values, {count, plural, one {…} other {…}} for
counts, and richText() from web/src/lib/i18n/rich.tsx when a sentence has to
contain a link. Numbers and relative times go through Intl — see
web/src/lib/format.ts.
The CLI is English unless you ask otherwise: --lang, then TOKENS_LANG, then
language in settings.json. The system locale (LANG, LC_ALL) is never
consulted, and --json output is always English. tokens --lang ja status
renders one run in Japanese without changing anything stored.
Share cards follow the same rule: /api/og?locale=ja draws the Japanese card
and the URL is the cache key, so each language is its own immutable entry. An
absent or unknown locale renders English, which is what every card minted
before this existed already asks for.
Why this repository is public
So you can check what we send.
The CLI reads the session files your AI clients already write to disk, totals them locally, and uploads only the totals — token counts, model names, client names, timestamps. Prompts, completions, file contents and paths never leave your machine.
You do not have to take that on faith. The whole pipeline is here:
cli/tokens-core/src/sessions/— one parser per client, showing exactly which fields are read out of each session filecli/tokens-core/src/aggregator.rs— how those reads become daily totalscli/tokens-cli/src/main.rs— the submit path;build_submit_payloadis the one function that assembles the payload, for both a real submit and a dry run
tokens submit --dry-run summarizes what would be uploaded without uploading
it; tokens submit --dry-run --json prints the exact JSON payload.
MCP server names are opt-in. By default no MCP information is sent. Run
tokens mcp-names enable (or pass --include-mcp to one submit) to include the
names — never commands, URLs, credentials or env values — of the MCP servers
configured for the clients that submission covers (Claude Code
~/.claude/.mcp.json, Cursor ~/.cursor/mcp.json, Kiro
~/.kiro/settings/mcp.json, OpenCode skills). They are shown publicly on your
profile. tokens mcp-names disable turns it off, and the next submit clears the
stored list; tokens mcp-names status shows the setting and the files read.
If your gateway adds routing prefixes to model IDs, list those prefixes in
~/.config/tokens/settings.json (or $TOKENS_CONFIG_DIR/settings.json):
{
"modelIdPrefixesToStrip": ["gateway-a/", "gateway-b/"]
}
This list is empty by default. Matching is case-insensitive; the longest matching
prefix is removed once before the existing model normalization. Empty prefixes
are ignored, and removal cannot produce an empty ID. Unlisted namespaces remain
distinct. The rule affects local grouping and uploaded model IDs, unlike the
presentation-only modelAliases setting. Pricing, token counts, costs, and raw
session files and caches are unchanged. Subsequent submissions apply the rule to
historical usage too. Use the same rules on devices that submit the same usage;
changing the rules changes uploaded model identity.
We are not asking anyone to run their own copy. This repo exists to be read.
Supported clients
All 45 are detected automatically — if it is installed and has written sessions, it is counted.
Where each one stores its data
| Client | Data location |
|---|---|
| Claude Code | ~/.claude/projects/, ~/.claude/transcripts/ |
| Codex CLI | ~/.codex/sessions/ |
| OpenCode | ~/.local/share/opencode/opencode.db (1.2+) or ~/.local/share/opencode/storage/message/ |
| Cursor CLI and IDE | Account usage cached at ~/.config/tokens/cursor-cache/usage*.json (legacy CSV also supported) |
| Copilot CLI | ~/.copilot/otel/*.jsonl |
| Gemini CLI | ~/.gemini/tmp/*/chats/*.json |
| Kimi CLI | ~/.kimi/sessions/ |
| Qoder / Qoder CN | ~/.qoder/projects/ and ~/.qoder-cn/projects/ (override with QODER_CONFIG_DIR / QODERCN_CONFIG_DIR), ~/.qoder{,-cn}/logs/sessions/**/segments/, plus the IDE's SharedClientCache/cache/db/local.db |
| Qwen CLI | ~/.qwen/projects/ |
| Reasonix | ~/.reasonix/stats/*.jsonl (override via REASONIX_STATE_HOME or REASONIX_HOME) |
| Amp | tokens amp sync → ~/.config/tokens/amp-cache/threads/ (current Amp keeps threads on ampcode.com); older releases' ~/.local/share/amp/threads/ |
| Droid | ~/.factory/sessions/ |
| Cline | VS Code globalStorage tasks, or ~/.cline/data/sessions/ for the Cline CLI / desktop |
| Roo Code | VS Code globalStorage tasks |
| Kilo | VS Code globalStorage tasks |
| Kilo CLI | ~/.local/share/kilo/kilo.db |
| Crush | $XDG_DATA_HOME/crush/projects.json |
| Goose | ~/.local/share/goose/sessions/sessions.db |
| Mux | ~/.mux/sessions/ |
| Pi | ~/.pi/agent/sessions/, ~/.omp/agent/sessions/ |
| kwwk | ~/.kwwk/sessions/. Programs embedding kwwk that keep a .kwwk-sessions/ directory per task: add the parent of those task directories to scanner.extraScanPaths.kwwk (or TOKENS_EXTRA_DIRS=kwwk:<dir>); only session directories are read, not the code next to them |
| Zed Agent | ~/.local/share/zed/threads/threads.db |
| Kiro | ~/.kiro/sessions/cli/, ~/.local/share/kiro-cli/data.sqlite3 |
| Warp / Oz | tokens warp sync → ~/.config/tokens/warp-cache/usage.json |
| Trae | tokens trae sync → ~/.config/tokens/trae-cache/sessions/ (international account usage API). The Trae / Trae CN desktop apps keep chat in an encrypted ModularData/ai-agent/database.db and write no readable token counts |
| TRAE CLI 2.0 | ~/.trae/cli/sessions/ and ~/.trae/cli/archived_sessions/ (override with TRAE_HOME / TRAECLI_HOME) |
| Antigravity | ~/.gemini/antigravity/conversations/*.db, ~/.gemini/antigravity-insiders/conversations/*.db (current builds); older builds via tokens antigravity sync → ~/.config/tokens/antigravity-cache/sessions/ |
| OpenClaw | ~/.openclaw/agents/ |
| Codebuff | ~/.config/manicode/ |
| Hermes | $HERMES_HOME/state.db |
| Synthetic | Re-attributed via hf: model prefix or synthetic provider |
| Fx | ~/.fx/sessions/<sessionId>/usage-v2.json (per-session aggregates) |
--client claude means Claude Code. Chats in the Claude web, desktop and mobile
apps, Projects included, are not counted: the apps keep no local per-message
token counts, and tokens does not read your claude.ai account. Claude Code on
the web is covered separately, see Cloud agent sessions.
Paseo
Paseo runs agents through their native providers. Usage is reported under the underlying supported client (for example, Claude Code or Codex CLI), including sessions launched from Paseo.
For Claude and Codex profiles with separate data directories, Tokens also reads
agents.providers in ~/.paseo/config.json (or $PASEO_HOME/config.json). It
finds absolute env.CLAUDE_CONFIG_DIR and env.CODEX_HOME paths on built-in
providers and profiles that extends them, including inherited base settings.
Claude projects, subagents and transcripts, plus active and archived Codex
sessions, use the existing parsers and file deduplication. Paseo's agent records
and timelines are not counted again.
Run Tokens on the daemon host, where the session files live. Relative provider
paths and paths set only in the daemon's launch environment cannot be discovered
from this config; use absolute provider paths or Tokens' existing
scanner.extraScanPaths setting for those installations.
Qoder
Qoder ships two separate editions — international (~/.qoder, QODER_CONFIG_DIR)
and China (~/.qoder-cn, QODERCN_CONFIG_DIR) — and both are reported under one
qoder client. Tokens reads three local sources:
- CLI/desktop transcripts under
<config>/projects/**/*.jsonl, includingsubagents/agent-*.jsonl; - structured segment logs under
<config>/logs/sessions/**/segments/*.jsonl, which are the only record ofqodercli --print --no-session-persistencecalls; - the desktop IDE database
<app data>/Qoder[CN]/SharedClientCache/cache/db/local.db(chat_message.token_info), opened read-only.
One model request is counted once: transcript fragments sharing message.id
collapse, and the three sources cross-deduplicate on Qoder's request_id, so a
request that appears in both a transcript and a segment log, or in a forked
session's replayed history, is not counted twice. turn.finished roll-ups are
ignored. Token buckets are only ever taken from numbers Qoder recorded; cache
reads are subtracted from the reported prompt so the cached subset is not added
twice. See docs/qoder.md for the field mapping and limits.
Qoder's managed (plan-billed) models are charged in credits, and the CLI zeroes every token field for them unless token exposure is enabled. Those rows are not estimated from reply length, credits, or context occupancy — they are simply absent from the token totals, which is why a Qoder user on managed models can legitimately show little or no token usage. To record real counters for future CLI requests, export the flag in the environment Qoder inherits:
export QODER_EXPOSE_TOKEN_USAGE=1 # international
export QODERCN_EXPOSE_TOKEN_USAGE=1 # Qoder CN
This does not backfill history, and Qoder versions differ in whether they honour it (the IDE ignores it entirely; its SQLite store always has real tokens). BYOK/custom-model requests carry real counters regardless.
Clients that expose usage only through an account API need a sync step first —
tokens cursor sync, tokens antigravity sync, tokens trae sync,
tokens warp sync, tokens amp sync — after which they submit like everything
else. Antigravity needs it only on older builds: current Antigravity and
Antigravity - Insiders conversation databases are read directly
(tokens antigravity status shows which ones were found).
Tokens detects Cursor Agent CLI sign-ins without requiring the desktop IDE.
It reads the CLI's cursor-access-token / cursor-user Keychain item on macOS,
or its auth.json file (~/.cursor/auth.json on macOS,
${XDG_CONFIG_HOME:-~/.config}/cursor/auth.json on Linux,
%APPDATA%/Cursor/auth.json on Windows). CURSOR_CONFIG_DIR/auth.json is also
checked; CURSOR_AUTH_FILE selects an explicit auth file.
Automatic detection preserves the existing desktop login preference and falls
back to the CLI. To select the CLI explicitly, including when the two clients
use different accounts, run:
tokens cursor login --source cli
tokens cursor sync
tokens submit -c cursor --dry-run
The local login is read only by tokens cursor login and tokens cursor sync;
tokens submit syncs Cursor only for accounts stored by tokens cursor login
and never reads the CLI or desktop login itself. The source selection is saved
for later tokens cursor sync runs. --source cli
never reads the desktop IDE login or falls back to a pasted browser cookie.
Use --source desktop or --source auto to change the preference.
API-key-only CLI sessions cannot authenticate the usage dashboard; use
agent login / cursor-agent login with an account session.
Usage remains an account-level total under cursor, including CLI and IDE usage
for that account; this integration does not claim to split the two. It uses the
same account cache so enabling CLI authentication does not double-count usage.
For accounts on unified billing, the first sync walks back through the billing
history and later syncs fetch incrementally. Older events already in the JSON
cache are kept. Once an account has synced from billing it stays on billing:
a failed billing request skips that sync instead of falling back to the legacy
usage endpoint, and legacy events from the period billing covers are dropped so
no usage is counted twice.
Amp keeps threads on ampcode.com, including threads that ran in the cloud, and
no longer writes them to disk. tokens amp sync uses the amp CLI you are
signed in to — tokens never reads Amp's credentials — to list your threads
(amp threads list and amp threads search author:me) and export each new or
changed one (amp threads export). Only the thread id, its creation time and
each message's role, id and usage are written to
~/.config/tokens/amp-cache/threads/; prompts, replies and titles are dropped
first. After the first sync, tokens submit (and so tokens serve) syncs
again before every scan. A thread that is also in
~/.local/share/amp/threads/ is read from the sync cache only, so it is not
counted twice. tokens amp status shows the CLI found and the cache.
An export holds only the requests of the thread's main agent. Subagent (Task)
and system-model requests (thread titles and the like), which Amp bills to the
same thread, are not in it and are not counted; in one account measured, they
were about 15% of the tokens amp usage reports. A first sync also misses old
threads that ran on Amp's servers, which amp threads list leaves out and
amp threads search finds only among the 100 most recently active.
Pricing comes from a combination of LiteLLM, OpenRouter and models.dev, with the best matching rate used per model. Built-in overrides handle tiered rates and cache discounts where the upstream feeds do not.
What makes it different
One number, across everything. Most usage tools are scoped to a single client. This one merges every client you run into one total, deduplicated per client-day, so switching from Claude Code to Codex mid-afternoon does not split your day into two half-stories.
Built to be gamed against. A public leaderboard attracts inflated numbers. Submissions are checked for cross-device duplicates and monotonic regressions, accounts caught faking totals are banned, and the bans are public in the Hall of Shame. Ranking is worth nothing if nobody polices it.
A profile worth linking. Your page carries a verified badge if your GitHub account has at least two social links, your split by client and model, your contribution graph, and embeddable SVG cards for a README — ten templates, both themes, rendered server-side.
Small on your machine. The CLI is one job: scan, total, submit. It runs as a background service and otherwise stays out of the way.
Differences from Tokscale
This project is a fork of Tokscale. The data-collection core is shared and we keep pulling upstream's parser, pricing and correctness fixes. Everything above that has diverged:
| Tokscale | Tokens | |
|---|---|---|
| CLI surface | Full TUI dashboard plus report commands (models, monthly, hourly, graph, wrapped, pricing, …) |
Submit only — login, submit, serve, status. The TUI and every report command are removed, ~11k lines and 15 dependencies with them |
| Reporting | In the terminal | On the web, where it can be linked and compared |
| Anti-cheat | — | Cross-device duplicate guard, resubmit monotonicity checks, account bans, public Hall of Shame |
| Identity | Username | Verified badge from GitHub social links, refreshed daily |
| Groups | Team/group leaderboards | Removed — one global ranking |
| Frontend | Upstream's components | Rebuilt on shadcn/ui with its own brand marks and per-page Open Graph cards |
Upstream sync policy: data capabilities and correctness fixes come in; UI implementations do not. The site keeps its own component set so the design stays consistent across updates.
Install
macOS
brew install owo-network/brew/tokens
tokens login
brew services start tokens # keeps submitting in the background
Linux
curl -fsSL https://tokens.ci/install.sh | sh
tokens login
The installer sets up a systemd user service, so submission keeps running after you close the terminal.
Windows, or a one-off anywhere (Bun or Node 18+)
bunx tokens-cli@latest login # or: npx tokens-cli@latest login
bunx tokens-cli@latest submit
To keep submitting in the background on Windows, install it globally and let Task Scheduler run it. The scheduled task runs without a console window:
npm i -g tokens-cli # or: bun add -g tokens-cli
tokens login
tokens autosubmit enable --interval 30m
The task runs tokensw.exe, a windowless launcher installed next to
tokens.exe. A task registered by an older version that still runs
tokens.exe is switched over automatically on its next run.
Private mode
tokens login --private
Keeps your usage off the leaderboard and makes your profile, devices, badges
and embeds answer as if the account did not exist. The command prints a read
token (tkr_…) once; send it as Authorization: Bearer tkr_… or append
?token=tkr_… to a badge or embed URL to read your own data. Running it on a
machine that is already logged in switches that account. Turn private mode off,
and create or revoke read tokens, in Settings.
On every public profile, device names are shown masked (jo****ro).
Cloud agent sessions
Claude Code on the web runs in a cloud VM that tokens serve never sees.
tokens cloud submit, run from the session's own end-of-turn hook, reports that
usage with the same totals-only payload. Each session is its own device, keyed
by a hash of the session id (never the id itself) and labelled by the server, so
a resumed session is merged rather than counted twice, and a cloud device may
only report its own agent's client. Codex cloud is not supported: its agent does
not run in the container. Setup, the full rules and what was tested are in
docs/cloud-sessions.md.
Who pays for this
Tokens is free to use and free to self-host, and the leaderboard reads each page from Postgres rather than from a cache of a cache. That is what keeps the numbers honest, and it is also the expensive way to do it. Neon cover that cost, so the board does not have to go behind a paywall or get thinner to fit a budget.
License
MIT — see LICENSE.
Built on Tokscale by Junho Yeo; credit for the original design and implementation goes to the upstream author and contributors.
Explore related projects
Loading…