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

tokendiet

v1.16.0

Published

Token optimization gateway CLI for Claude Code

Readme

tokendiet

Token optimization gateway CLI for Claude Code. Runs as a local proxy between Claude Code and the Anthropic API, automatically stripping unnecessary tokens before each request — saving you money without changing how you work.

Install

npm install -g tokendiet

Or run directly with npx:

npx tokendiet@latest start

Usage

# Start the gateway
tokendiet start --org-token <token>

# Start with custom options
tokendiet start --org-token <token> --port 3200 --verbose

# Dry-run mode (no stripping — measure baseline)
tokendiet start --org-token <token> --dry-run

# Stop the gateway and restore Claude settings
tokendiet stop

If you don't pass --org-token, the CLI will check for a saved token or prompt you interactively.

Commands

| Command | Description | |---------|-------------| | start | Start the local TokenDiet gateway | | stop | Stop the running gateway and restore Claude settings |

Start options

| Flag | Default | Description | |------|---------|-------------| | --org-token <token> | — | Your organization API token | | --cloud-url <url> | https://tokendiet-production.up.railway.app | Cloud API URL | | --port <port> | 10741 | Port to listen on | | --verbose | off | Show full NestJS logs | | --dry-run | off | Disable all stripping (baseline measurement) |

Stop options

| Flag | Default | Description | |------|---------|-------------| | --port <port> | 10741 | Port the gateway is running on |

How it works

  1. Starts a local proxy on localhost:10741
  2. Patches ~/.claude/settings.json to route Claude Code traffic through it
  3. Applies stripping strategies to each request before forwarding to Anthropic
  4. Reports token savings to the cloud API
  5. Displays live savings feedback in the terminal
  6. Restores original Claude settings on exit (Ctrl+C) or tokendiet stop

Token resolution order

  1. --org-token CLI flag (highest priority)
  2. Saved token from ~/.tokendiet/.env
  3. Interactive prompt

If a token is rejected (401), the saved token is cleared and you're prompted again.

Stripping strategies

| Strategy | What it removes | |----------|----------------| | Whitespace normalization | Unnecessary whitespace from message content and tool results | | Schema metadata stripping | JSON Schema metadata (descriptions, titles, examples) from the tools array |

Both strategies are deterministic and idempotent — they never change the semantic meaning of your requests.

Data & Privacy

TokenDiet is designed so that your prompts, code, and conversation content never leave your machine via TokenDiet.

What stays on your machine

  • Your Anthropic API key — passed directly to Anthropic, never sent to TokenDiet servers
  • All prompt and message content — the full request body goes straight to the Anthropic API
  • Your code and file contents — TokenDiet strips tokens locally but never reads or stores your code

What is sent to the TokenDiet cloud API

Only usage metadata is reported, so we can calculate your savings:

  • Token counts (original, stripped, and actual from the API response)
  • Model name (e.g. claude-opus-4-6)
  • Cache usage statistics (read/write token counts)
  • Which stripping strategies were applied and how many tokens they reduced
  • Gateway version and request timestamp
  • A session identifier (random UUID) to group requests within the same Claude Code conversation for accurate savings tracking — this ID contains no personal information

What is never sent

  • Message content, prompts, or system instructions
  • Code, file contents, or tool results
  • Your Anthropic API key

Local storage

  • Your org token is saved to ~/.tokendiet/.env (file permissions: owner-only read/write)
  • Claude Code settings are temporarily patched while the gateway runs and restored on exit

Development

# Build and run the CLI with dev defaults (localhost:3001 cloud API)
npm run start

License

MIT