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

Published

Track local coding agent usage and share global AGENTS.md changes with friends.

Readme

token-rats

Track local agent usage and share your evolving global instructions with friends on Token Rats.

Install

npx token-rats login   # one-time auth
npx token-rats sync    # upload your usage

Or install globally:

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 | Read local Claude Code, Codex, OpenCode, and Cursor usage and upload counts to your leaderboard. | | token-rats setup-track [path] | Preview global instructions and enable automatic friends-only history. | | 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] [--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. | | --api-url <url> | Override the API base URL (useful for local dev or staging). |

What data is collected

Usage collection reads usage metadata. It reads:

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

Usage parsers discard prompt and completion content. The separate, opt-in setup-track feature uploads the instruction text you choose to track; it is off by default.

The collector source is in packages/parsers/ and packages/cli/src/lib/. You can inspect which fields are extracted before running sync.

Data sources

Claude Code

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

Cursor

Reads the Cursor sqlite cache:

  • macOS: ~/Library/Application Support/Cursor/User/globalStorage/state.vscdb
  • Linux: ~/.config/Cursor/User/globalStorage/state.vscdb
  • Windows: %APPDATA%\Cursor\User\globalStorage\state.vscdb

If the Cursor database is not found or cannot be read, the CLI skips it silently and continues with Claude Code data.

Codex

Reads ${CODEX_HOME:-~/.codex}/sessions/**/*.jsonl and archived sessions.

OpenCode

Reads the message table in ${XDG_DATA_HOME:-~/.local/share}/opencode/opencode*.db. OPENCODE_DATA_DIR overrides the directory; OPENCODE_DB adds a custom database path. The reader selects only assistant usage fields and groups them by session, provider, and model. It includes current SQLite WAL changes. Older JSON storage is not imported.

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

  • Node.js ≥ 22.13 (for the built-in SQLite reader without a flag)
  • A Token Rats account (sign up at tokenrats.com)

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.

Data boundaries: Usage collection uploads metadata. setup-track additionally uploads selected instruction files after an explicit preview and opt-in. Common credential patterns and marked private sections are omitted; review the preview for other private details. Automatic versions are shared only with current friends (common private board or mutual follows), even if your profile is private.

Automatic tracking

token-rats login installs the background tracker. It reads Claude Code, Codex, OpenCode, and Cursor records on startup, then checks for changes every 30 seconds. Failed uploads are retried. Use login --no-daemon to use manual sync only. Use daemon-status and uninstall-daemon to manage automatic tracking. After an upgrade, run install-daemon to copy the new runtime into place. Custom --api-url settings are passed to the installed tracker.

Open /app/compare on your Token Rats server to enter a subscription amount for a month. Cursor counts are estimates. API estimates are not provider bills. See the counting method.

The CLI and its documentation are MIT licensed. The npm package includes LICENSE.

Automatic global AGENTS.md history (0.5.0)

npx token-rats@latest setup-track             # preview, confirm, install background tracker
npx token-rats@latest setup-track --dry-run   # preview only; no login, uploads, or installation
npx token-rats@latest setup-track /path/to/AGENTS.md
npx token-rats@latest setup-track --stop      # pause all captures on this machine
npx token-rats@latest setup-track --status    # list local sources; web shows live status

Default discovery checks ${CODEX_HOME:-~/.codex}/AGENTS.override.md (preferred when present), otherwise AGENTS.md, and ${XDG_CONFIG_HOME:-~/.config}/opencode/AGENTS.md. Supply a path for another global instructions file. Each file gets a separate history. Changing the global file location requires running setup-track again for the new path.

Review the preview and confirm. --yes skips the interactive question when you have already reviewed the preview; --no-daemon skips background installation, so run token-rats watch yourself. The installed tracker also syncs token usage.

Two stable scans coalesce rapid edits; changes usually appear within a minute while the tracker is online. Atomic file saves work. Failed uploads retry the latest saved content; edits made and replaced between scans or while offline are not a keystroke-level history. Duplicate sanitized content does not add a version. Missing files and files over 20,000 characters show an error in My setups.

To exclude a private section, use markers on separate lines (without nesting):

<!-- token-rats:private -->
Instructions that must stay on this computer.
<!-- /token-rats:private -->

Open My setups to pause or resume a source and view its history. Pausing retains existing versions and their audience. Hide a version with “Only me” or delete the setup to remove its history. Automatic captures cannot be made public directly; copy a reviewed excerpt to a separate manual setup for public sharing. Local file paths stay on your machine; instruction content can itself contain private information, so review it before enabling.