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

ccgh-stats

v0.2.0

Published

Track and display your Claude Code usage stats on GitHub

Readme

ccgh-stats

npm version License: MIT

Track and display your Claude Code usage stats on GitHub with a beautiful heatmap widget.

Claude Stats Widget

Yes, this is a real widget generated live from actual backend data! ✨

Installation

npm install -g ccgh-stats

Setup

  1. Register and sync your data:
ccgh-stats setup

This will:

  • Register you with the API
  • Sync your Claude Code usage history
  • Give you a widget URL
  1. Add the widget to your GitHub README:
![Claude Stats](https://ccgh-stats.vercel.app/api/w/YOUR_PUBLIC_ID.svg)

Auto-sync with Claude Code Hooks

Add this to your ~/.claude/settings.json:

{
  "hooks": {
    "UserPromptSubmit": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "ccgh-stats --sync"
          }
        ]
      }
    ]
  }
}

Each entry in the event array is a group that holds its own hooks array. UserPromptSubmit runs on every prompt, so the matcher stays empty.

This will automatically sync your stats every 10 minutes while using Claude Code. The sync reads only the session files that changed since the last run, so it stays out of your way.

Commands

| Command | Description | |---------|-------------| | ccgh-stats setup | Register and do initial sync | | ccgh-stats link | Add this machine to an account you already have | | ccgh-stats status | Show registration status, including the device ID | | ccgh-stats sync | Sync now | | ccgh-stats sync --full | Read every session file again and resend every day | | ccgh-stats --sync | Incremental sync (used by hook) |

Several machines

Every machine keeps its own device ID in ~/.claude-stats/config.json. The backend stores one row per day, per model, per device, and the widget adds them up. Your laptop and your desktop both feed the same widget and neither one overwrites the other.

To add a second machine, install the package there and run:

ccgh-stats link

It asks for the public ID and the write token of the account you already have. Both are in ~/.claude-stats/config.json on the first machine. The token is not shown while you type it, so it never lands in your shell history.

You can pass them as environment variables instead:

CCGH_PUBLIC_ID=pub_xxx CCGH_WRITE_TOKEN=tok_xxx ccgh-stats link

If that machine already has a config, link stops. Pass --force to point it at another account.

A machine that was set up before device IDs existed keeps sending under the name default, so its history stays exactly where it is.

How it works

  1. Parses your Claude Code session files from ~/.claude/projects/
  2. Caches what each file counted for, in ~/.claude-stats/cache.json, so a file is read again only when it changes
  3. Syncs aggregated stats to the API (only token counts, no conversation content). A day is always sent as its full total across every session file, not just the files that changed
  4. Generates an SVG widget showing your usage heatmap

If your numbers ever look wrong, ccgh-stats sync --full reads everything again and resends every day.

Development

The tests need no install and no network. They run the parser and the CLI against a stub of the API inside a throwaway home directory.

npm test

Privacy

  • Only token counts are sent (input/output tokens per day per model)
  • A random device ID is sent too, so several machines can feed one widget
  • No conversation content is ever transmitted
  • Your data is tied to a random public ID, not your identity

License

MIT