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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@mariozechner/cccost

v1.0.3

Published

Claude Code Cost Tracker - Track token usage and costs for Claude Code sessions

Readme

cccost - Claude Code Cost Tracker

Track token usage and costs for your Claude Code sessions in real-time.

Problem

Claude Code does not show cost for users of the Pro and Max plan when using the /cost command. API users enjoy that privilege. Except that /cost has a bug (CC 1.0.83). And if you wrote a fancy statusline script and think you can just parse the session transcript to get token usage and cost, think again. The transcript does not contain all requests Claude Code issues to the Anthropic servers.

What Claude Code Cost Tracker does

Claude Code cost track is a minimally invasive tool. Instead of running Claude Code directly, run your session via cccost. All arguments you pass will be forwarded to Claude Code verbatim:

cccost --dangerously-skip-permissions

cccost spawns Claude Code and injects this code. It hooks the NodeJS fetch() function and intercepts all API requests to Anthropic's servers. It then writes a file ~/.claude/projects//.usage.json and keeps updating it with every new request.

The file contains total input/output/cache read/cache write statistics per model, the usage stats for the last request made with each model, and the total cost. E.g.:

{
  "requests": 7,
  "totalCost": 0.10331005,
  "models": {
    "claude-3-5-haiku-20241022": {
      "requests": 6,
      "input_tokens": 731,
      "output_tokens": 99,
      "cache_creation_input_tokens": 0,
      "cache_read_input_tokens": 0,
      "cost": 0.0009808,
      "last": {
        "utcTimestamp": 1755475841151,
        "input_tokens": 335,
        "output_tokens": 9,
        "cache_creation_input_tokens": 0,
        "cache_read_input_tokens": 0,
        "cost": 0.000304
      }
    },
    "claude-opus-4-1-20250805": {
      "requests": 1,
      "input_tokens": 3,
      "output_tokens": 12,
      "cache_creation_input_tokens": 4761,
      "cache_read_input_tokens": 8077,
      "cost": 0.10232925,
      "last": {
        "utcTimestamp": 1755475842778,
        "input_tokens": 3,
        "output_tokens": 12,
        "cache_creation_input_tokens": 4761,
        "cache_read_input_tokens": 8077,
        "cost": 0.10232925
      }
    }
  }
}

You can use that to write accurate statusline scripts that display e.g. context usage or cost for the current session. Simply read the .usage.json file for the current session to get the statistics.

The GitHub repository includes an example statusline.js.

Installation

npm install -g @mariozechner/cccost

Usage

Simply start Claude Code via cccost instead of claude:

# Track a Claude Code session
cccost --dangerously-skip-permissions --model sonnet

Options

  • --ccc-verbose: cccost will output debug logging during the session

Development

# Clone the repository
git clone https://github.com/badlogic/cccost.git
cd cccost

# Install dependencies
npm install

# Debugging, e.g. via VS Code JavaScript Debug Terminal
# Do this once to disable anti-debug in your Claude Code
# install, otherwise you won't be able to debug cccost
npx @mariozechner/cc-antidebug patch

npx tsx src/cli.ts

# Build
npm run build

License

MIT

Author

Mario Zechner