Skip to main content

Local-first, read-only AI coding agent token and usage inspector.

Project description

TokenCat

PyPI Version Python Versions License

Supported Platform

TokenCat is a local-first, read-only CLI for understanding how AI coding agents are being used on your machine.

If you jump between Codex, Claude Code, Gemini CLI, and Copilot CLI, TokenCat gives you one terminal-native view for sessions, models, tokens, and API-equivalent cost estimates without proxying traffic, rewriting endpoints, or touching your prompts and responses.

TokenCat dashboard demo

Why TokenCat

  • One place to inspect Codex, Claude Code, Gemini CLI, VS Code Copilot Chat/Agent usage, and Copilot CLI session-state totals
  • A default 0-argument dashboard: just run tokencat
  • Read-only by design: no proxying, no interception, no auth-token handling
  • Local pricing estimates with clear coverage for unknown or unattributed usage
  • JSON output for scripts and terminal output for humans

Install

Python 3.9+ is required.

pipx install tokencat

Upgrade later with:

pipx upgrade tokencat

If you want to try the repo directly:

pipx install .

Quick Start

Open the dashboard:

tokencat

Force a specific dashboard theme:

tokencat --theme light
tokencat dashboard --theme dark

Look at a longer window:

tokencat --since 30d

Focus on one tool:

tokencat dashboard --provider codex

List recent sessions:

tokencat sessions --provider codex --limit 20

Inspect model totals:

tokencat models --provider gemini

Inspect daily totals:

tokencat daily --provider claude

Check local detection and health:

tokencat doctor

Inspect or refresh pricing data:

tokencat pricing show
tokencat pricing refresh

What You Get

  • A dense terminal dashboard with provider health, token totals, pricing coverage, daily usage, and recent sessions
  • Compact dashboard token counts such as 2M and 837K on narrow terminals
  • Dashboard theme switching with --theme auto|dark|light
  • Session-level views with anonymous IDs by default
  • Model-level aggregation across supported tools
  • Daily time-series aggregation across supported tools
  • A bundled pricing catalog, plus a local cache that can refresh itself on first use
  • Stable JSON envelopes for scripting and automation

Supported Tools

Tool Status Notes
Codex Supported Reads ~/.codex/sessions/**/*.jsonl and ~/.codex/archived_sessions/*.jsonl, then falls back to ~/.codex/state_*.sqlite when needed.
Claude Code Supported Reads projects/**/*.jsonl under CLAUDE_CONFIG_DIR when set, otherwise scans both ~/.config/claude and legacy ~/.claude. Preserves exact observed model names, including redirected non-Anthropic models and subagent sessions.
Gemini CLI Supported Reads ~/.gemini/tmp/**/chats/session-*.json and non-sensitive settings metadata.
GitHub Copilot Supported Reads VS Code `workspaceStorage//chatSessions/.json

Pricing

TokenCat can estimate API-equivalent cost for models with known pricing data.

  • Pricing works offline by default using the bundled catalog shipped with the package.
  • On first pricing use, TokenCat silently tries to refresh its own cache under ~/.tokencat/pricing/.
  • If that refresh fails, it quietly falls back to the bundled catalog.
  • tokencat pricing refresh manually refreshes the local cache.
  • The terminal dashboard also does a silent PyPI update check and only shows a notice when a newer TokenCat release exists.
  • Pricing resolution is source-aware: direct source price first, then official API price, then OpenRouter as the marketplace fallback.
  • JSON output includes pricing_source so you can see whether a session or model was priced from the direct source, an official vendor catalog, or OpenRouter.
  • Metadata-only rows in the upstream dataset are ignored; TokenCat only treats entries with explicit price fields as priced.
  • Unknown or historically renamed models are shown clearly instead of being guessed.

Maintainers can refresh the bundled package catalog explicitly before building:

make refresh-bundled-pricing
make build

Current pricing references:

Privacy

TokenCat is intentionally conservative.

  • It only reads local files that already exist on your machine.
  • It does not proxy traffic or intercept requests.
  • It does not rewrite provider endpoints or mutate provider sessions.
  • It does not read OAuth credentials for reporting.
  • It never prints raw prompt or response bodies.
  • It redacts sensitive local metadata by default.

To reveal more local metadata in session listings:

tokencat sessions --show-title --show-path

JSON Output

All JSON commands keep a stable top-level shape:

  • generated_at
  • filters
  • providers
  • summary or items
  • warnings

That makes TokenCat easy to pipe into scripts, local dashboards, or personal automation.

Common Flags

  • --provider codex|gemini|copilot
  • --provider codex|claude|gemini|copilot
  • --since / --until with values like 7d, 24h, or ISO dates
  • --theme auto|dark|light for dashboard rendering
  • --json
  • --no-price

--theme auto uses COLORFGBG when available to detect a light terminal background, and falls back to the dark palette when it cannot tell.

Dashboard token counts automatically switch to compact notation on terminals 120 columns wide or narrower.

Session listings also support:

  • --limit
  • --model
  • --show-title
  • --show-path

Limits

  • TokenCat is macOS-first today.
  • Linux path hooks are present, but Linux is not yet a polished target.
  • Windows is not yet supported.
  • Copilot support covers VS Code Chat/Agent sessions plus standalone CLI shutdown summaries under ~/.copilot/session-state/. Active CLI sessions without a shutdown summary are detected but not yet counted.
  • Cost is an estimate, not your actual bill.

License

TokenCat is licensed under GNU GPLv3. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tokencat-0.6.1.tar.gz (112.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tokencat-0.6.1-py3-none-any.whl (102.5 kB view details)

Uploaded Python 3

File details

Details for the file tokencat-0.6.1.tar.gz.

File metadata

  • Download URL: tokencat-0.6.1.tar.gz
  • Upload date:
  • Size: 112.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for tokencat-0.6.1.tar.gz
Algorithm Hash digest
SHA256 119cf5251fdce5ec266400969728e573e9920f1668bba231101d4c35bf76cb68
MD5 be77895cd64afd57aef13e12f9bd8cf3
BLAKE2b-256 72ecb2afde1134fe59a694e1a2aa3df0bcf18c04aeeb712cf7301e7b637099d1

See more details on using hashes here.

File details

Details for the file tokencat-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: tokencat-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 102.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for tokencat-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a8fddac5a05a172781bc927bcf8e274619d92f921bccd5be068ee1de3dcc5c02
MD5 b830d84dd0356668fe5b1ec92ab4a952
BLAKE2b-256 6a44fdbaf649a012388e17e033d6f9715ea80548114e4a5d81ad6e93bccd1017

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page