npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

token-rats

v0.1.0

Published

Sync your Claude Code + Cursor + Codex token usage to your Token Rats leaderboard. Auto-refreshes via a background watcher.

Downloads

519

Readme

token-rats

Strava for AI token burn — sync your Claude Code + Cursor + Codex usage to your Token Rats leaderboard. Run once, watches forever.

Install

npx token-rats login   # one-time auth
npx token-rats sync    # uploads usage, then asks to install a background watcher

After your first successful sync, the CLI asks:

Install background sync? [Y/n]

Say yes once and you’re done. A native OS service (launchd on macOS, systemd --user on Linux) keeps watching your Claude Code, Cursor, and Codex logs and uploads new sessions automatically. No more sync runs, no cron jobs to babysit.

For a stable install across reboots, install globally rather than via npx:

npm install -g token-rats
token-rats sync

Commands

| Command | Description | |---|---| | token-rats login | Open your browser to authenticate (device-code flow). Saves a token to ~/.config/token-rats/token. | | token-rats sync | Discover Claude Code, Cursor, and Codex logs, parse them, upload counts. On first success, prompts to install the background watcher. | | token-rats watch | Run the watcher in your terminal (Ctrl-C to stop). Useful for debugging. | | token-rats watch --install | Install the background watcher (launchd / systemd --user). | | token-rats watch --uninstall | Remove the background watcher. | | token-rats watch --status | Show whether the watcher is installed and running. | | token-rats whoami | Show the currently signed-in account handle. | | token-rats logout | Delete your stored credentials. | | token-rats --version | Print the CLI version. | | token-rats help | Print this help. |

Sync flags

token-rats sync [--dry-run] [--verbose] [--no-daemon] [--api-url <url>]

| Flag | Description | |---|---| | --dry-run | Parse files but do not upload. Prints what would be sent. | | --verbose | Print which files were discovered and how many records each contains. | | --no-daemon | Skip the post-sync prompt to install the background watcher. (TOKEN_RATS_NO_DAEMON=1 does the same globally.) | | --api-url <url> | Override the API base URL (useful for local dev or staging). |

Watch flags

token-rats watch [--install | --uninstall | --status]
token-rats watch [--interval <ms>] [--verbose]

| Flag | Description | |---|---| | --install | Install the background watcher. Idempotent. | | --uninstall | Remove the background watcher. | | --status | Print install + running state and the log path. | | --interval <ms> | Debounce window for file-change uploads. Default: 2000. | | --verbose | Print per-file change events and uploads. |

Background watcher details

  • Sources watched: Claude Code (~/.claude/projects/**/*.jsonl), Codex rollouts, and Cursor's per-workspace SQLite cache.
  • Cursor polling: every 90s, stat()-first, capped to the 10 most-recently-modified workspaces. Idle CPU is near zero.
  • macOS: ~/Library/LaunchAgents/com.tokenrats.watch.plist. Auto-restarts on crash and runs at login.
  • Linux: ~/.config/systemd/user/token-rats-watch.service. Auto-restarts on crash. For the watcher to survive logout, run once: sudo loginctl enable-linger $USER. Without it, the watcher resumes at your next login.
  • Windows: not yet supported. Use token-rats sync for now.
  • Logs: ~/.config/token-rats/logs/watch.log (or ~/Library/Application Support/token-rats/logs/ on macOS).
  • Auth expiry: if your session expires, the watcher backs off 10 minutes instead of crashing. Run token-rats login to recover; the watcher picks up on its own.
  • Upgrades: when you npm update -g token-rats, just run token-rats sync once — the daemon re-installs against the new binary path automatically.

What data is collected

Token Rats reads usage counts only. It reads:

  • Input token count
  • Output token count
  • Model name
  • Session start/end timestamps

It does not read, store, or transmit any prompt or completion content.

The parser source code is in packages/parsers/. You can audit exactly what is extracted before running sync. We literally can't read what you typed.

Data sources

Claude Code

Reads ~/.claude/projects/**/*.jsonl (macOS/Linux) or %USERPROFILE%\.claude\projects\**\*.jsonl (Windows).

Cursor

Reads per-workspace SQLite caches under Cursor/User/workspaceStorage/*/state.vscdb:

  • macOS: ~/Library/Application Support/
  • Linux: ~/.config/
  • Windows: %APPDATA%\

Cursor doesn't store token counts on disk for most sessions, so per-request tokens are estimated from request type. Numbers are comparable across Token Rats users but won't match cursor.com to the token. If the Cursor database isn't found or can't be read, the CLI skips it silently.

Codex

Reads rollout JSONL files under <codex-home>/sessions/YYYY/MM/DD/. <codex-home> defaults to ~/.codex; Snap and Flatpak distros are also probed.

Auth

Authentication uses a device-code flow:

  1. token-rats login calls the Token Rats API to get a one-time code and URL.
  2. Your browser opens the URL automatically (or you can copy-paste it).
  3. You sign in with GitHub on the web.
  4. The CLI polls until approved, then saves your token to ~/.config/token-rats/token (mode 0600 — readable only by you).

Requirements

Privacy

Token Rats is open source. The CLI source is in packages/cli/ and the parsers are in packages/parsers/. You can inspect exactly what is read from your disk and what is sent to the server.

Privacy posture: Token Rats reads usage counts only — never prompts or completions. The parser source is in packages/parsers/. We literally can't read what you typed. The background watcher follows the same rule — it's the same parser code on a timer.