Skip to content

robbedoo/claude-token-tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Claude Token Tracker

npm version License: MIT

A Claude Code plugin that tracks token usage and dollar costs across sessions.

What It Does

  • Automatically records token usage (input, output, cache) per session
  • Calculates costs using bundled model pricing
  • Tracks per-project usage
  • Aggregates by day and week

Install

claude plugin add robbedoo/claude-token-tracker

Usage

/token-tracker:token

Displays a summary like:

╭────────────────────────────────────────────────╮
│            Claude Token Tracker                 │
├────────────────────────────────────────────────┤
│  Today        42,300 tokens    $1.85  (2 sess) │
│  Week        318,000 tokens   $12.40  (9 sess) │
├────────────────────────────────────────────────┤
│  By model (week):                               │
│    opus-4-6                $11.20  (90%)        │
│    sonnet-4-6               $1.20  (10%)        │
├────────────────────────────────────────────────┤
│  Project: cresly                                │
│    Today $1.85  •  Week $8.60                   │
╰────────────────────────────────────────────────╯

How It Works

  1. SessionStart hook snapshots ~/.claude/stats-cache.json
  2. SessionEnd hook diffs the snapshot against the current state
  3. Cost is calculated per model using bundled pricing
  4. Session record is appended to ~/.claude/token-usage.json
  5. /token-tracker:token reads the store and prints a formatted summary

Data Storage

All data is stored locally in ~/.claude/token-usage.json. Nothing is sent externally.

Updating Pricing

Model pricing is bundled in config/pricing.json. When Anthropic updates prices, install the latest plugin version:

claude plugin update token-tracker

Or manually edit the pricing file in the plugin cache.

Uninstall

claude plugin remove token-tracker

The data file (~/.claude/token-usage.json) is preserved after uninstall. Delete it manually if you want to remove all data.

Requirements

  • Claude Code CLI
  • Node.js (already required by Claude Code)

License

MIT

About

Claude Code plugin to track token usage and costs across sessions

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors