npx claude-count-tokens login
npx claude-count-tokens sync
npx claude-count-tokens sync --install
<script src="https://unpkg.com/claude-count-tokens/widget/claude-token-heatmap.js"></script>
<claude-token-heatmap user="YOUR_GITHUB_USERNAME" palette="spring"></claude-token-heatmap>
Works with any site — plain HTML, Next.js, Astro, Hugo, Jekyll, WordPress. No build step, no dependencies.
The widget automatically follows your site's theme. It detects dark mode from:
prefers-color-scheme (system preference)class="dark" on <html> or <body>data-theme="dark" on <html> or <body>To force a specific theme:
<claude-token-heatmap user="you" theme="dark"></claude-token-heatmap>
The default palette is spring. Pick a different one with the palette attribute:
<claude-token-heatmap user="you" palette="mint"></claude-token-heatmap>
Or define your own with CSS custom properties:
claude-token-heatmap {
--cth-cell-l1: #d4e4c8;
--cth-cell-l2: #b5cda3;
--cth-cell-l3: #94b47e;
--cth-cell-l4: #6e9a56;
}
The widget fills its container by default. Customize with CSS:
claude-token-heatmap {
max-width: 600px; /* constrain width */
--cth-cell-s: 10px; /* cell size (default 13px) */
--cth-cell-g: 2px; /* gap (default 3px) */
--cth-cell-r: 2px; /* border radius (default 3px) */
}
Automatically shrinks on screens narrower than 700px.
# dashboard
npx claude-count-tokens # live dashboard on port 7890
npx claude-count-tokens --port 3000 # custom port
npx claude-count-tokens --days 90 # last 90 days only
# auth
npx claude-count-tokens login # log in with GitHub
npx claude-count-tokens logout # log out, clear credentials
# sync
npx claude-count-tokens sync # upload token data to cloud
npx claude-count-tokens sync --install # auto-sync every hour (macOS)
npx claude-count-tokens sync --uninstall # remove auto-sync
npx claude-count-tokens sync --status # check if auto-sync is running
# export
npx claude-count-tokens export # export to ./claude-token-data.json
npx claude-count-tokens export -o out.json # custom output path
The widget reads local JSONL logs that Claude Code writes at ~/.claude/projects/. For each AI response, it sums:
| Type | What it is |
|---|---|
| Input | tokens in your prompt |
| Output | tokens Claude generated |
| Cache write | tokens written to context cache |
| Cache read | tokens read from context cache |
This only counts Claude Code CLI usage from your machine's local logs.
~/.claude/projects/)