tokens

Count all historical Claude Code token usage across all local projects, broken down by model, project, date, and week. Includes cost estimation based on official Anthropic pricing.

Token Stats

Step 1 — Detect Python

python --version 2>/dev/null || python3 --version 2>/dev/null || echo "PYTHON_NOT_FOUND"

If the output is PYTHON_NOT_FOUND, Python is not installed. Tell the user:

Python is required but not found on your system. Please install it:

After installing Python, run /tokens:tokens again.

Then stop — do not continue.

Step 2 — Locate and run the bundled script

SCRIPT=$(find "$HOME/.claude/plugins/cache" -name "token_stats.py" 2>/dev/null | head -1)
if [ -z "$SCRIPT" ]; then
  echo "ERROR: token_stats.py not found. Try: claude plugin update tokens@claude-tokens-plugin"
  exit 1
fi
python "$SCRIPT" 2>/dev/null || python3 "$SCRIPT"

Display the output directly without additional explanation.