Skip to main content

token-oracle — know when you'll hit the limit

Website

Site: oracle.muslewski.com

PyPI version CI Python versions MIT license Discussions

oracle dash demo

Live dashboard — staged multi-subscription forecast for Claude Code and Grok, with time left before each cap. No API keys; reads local logs, optionally verifies against the sites.

Live usage in your status bar

Wire it once:

oracle statusline --install

Claude Code (and tmux) then shows a live headline such as:

◔ 5h 26% · wk 60% · $8 today

(The 5h/wk numbers come from the rate-limit header self-ingest; cost uses local ledger.)


Install

Run it instantly — no install, using a runner you probably already have:

npx token-oracle dash         # Node
bunx token-oracle dash        # Bun
uvx token-oracle dash         # uv

Or install the token-oracle / oracle command onto your PATH:

npm install -g token-oracle    # Node shim → runs uvx/pipx/python under the hood
curl -fsSL https://raw.githubusercontent.com/muslewski/token-oracle/main/install.sh | sh
uv tool install token-oracle   # uv (isolated, fast)
pipx install token-oracle      # pipx (isolated)
pip install token-oracle       # pip

npx/bunx/uvx fetch and run the latest release on demand; the installers put it on your PATH. The npm package is a thin launcher over the PyPI tool. All routes are the same offline-first CLI — see SETUP.md for live web data and configuration.

Quickstart

token-oracle init         # guided setup (or --preset max20 for non-interactive)
token-oracle forecast     # live forecast — time left before your cap
token-oracle report       # what you spent, day by day (tokens + cost + % of weekly cap)
token-oracle dash         # full-screen TUI — Past ledger / Present live / Future prophecy
token-oracle doctor       # check configuration + data sources

oracle forecast demo

▶ demo

oracle doctor demo

Config can live globally (~/.config/token-oracle/config.json) or per-project (.token-oracle.json walking up from the cwd). Run token-oracle --help for all subcommands.

How it works

token-oracle reads your agent's local usage logs, computes an observed token-consumption rate over a configurable sliding window, and estimates how long you have before you exhaust your current allowance or hit your plan cap. No provider API calls — purely offline inference from log files already on your machine. Ships with pro/max5/max20 plan presets and an offline USD pricing snapshot for cost estimates, both user-overridable via plan, cost_mode, and pricing config keys.

Supported sources (first-class agent harnesses):

Source source value Log location
Claude Code claude_code ~/.claude/projects/*/*.jsonl
Grok Build grok ~/.grok/sessions/*/*/updates.jsonl + signals.json (contextTokensUsed for live)
Generic (file) generic JSON file of [timestamp, tokens] pairs via source_opts.events_path

Multi-subscription: put "profiles": {"claude": {...}, "grok": {...}} in config.json to track both Claude Code (Max20 etc) and Grok/SuperGrok Heavy simultaneously. oracle dash shows side-by-side with reset alarms.

Future tab (in oracle dash): per-window prophecy lines, observational cap ETA warnings, and a next-24h expected-burn sparkline from the hour-of-week profile — the projection math rendered, not just a single %.

Parts & options

All subcommands accept --config FILE. Without it, resolution is $TOKEN_ORACLE_CONFIG.token-oracle.json (cwd walk-up) → XDG global.

Subcommand Extra flags Description
init --preset, --force Starter config (TTY wizard if no flags; non-clobbering)
forecast --json Print forecast (default: statusline format)
snapshot --out FILE Write snapshot JSON to a file, print the path
statusline Emit plain-text/ANSI statusline fragment
tmux Emit tmux status-right fragment
doctor Check configuration and data sources
report --days, --by, --json, --since/--until Daily (or week/model) token + cost ledger
dash Full-screen TUI: Past ledger, Present live, Future prophecy + 24h sparkline
clean --yes Remove config, cache, and snapshot files

Grok Build users: {"source": "grok"} (or with source_opts.sessions_dir) in config; then oracle tmux / statusline / forecast surface usage. Hooks in ~/.grok/hooks/ can drive oracle snapshot.

Full reference: token-oracle <subcommand> --help

CLI reference

token-oracle {forecast,report,snapshot,statusline,tmux,doctor,dash,init,clean} [OPTIONS]

token-oracle init       [--config FILE] [--preset NAME] [--force]
token-oracle forecast   [--config FILE] [--json]
token-oracle report     [--config FILE] [--days N] [--by day|week|model] [--json]
token-oracle snapshot   [--config FILE] [--out FILE]
token-oracle statusline [--config FILE]
token-oracle tmux       [--config FILE]
token-oracle doctor     [--config FILE]
token-oracle dash       [--config FILE]
token-oracle clean      [--config FILE] [--yes]

Adapters

Output adapters let token-oracle feed your status bar or terminal multiplexer (works for Grok, Claude, etc.):

  • tmux — writes a tmux-formatted status-right fragment (e.g. set -g status-right '#(oracle tmux)')
  • statusline — writes a plain-text/ANSI fragment for any status line

See ADAPTERS.md for setup and configuration. Grok users in tmux get token status in bottom bar directly.

Colors

The forecast bar uses colour thresholds on projected usage at window end (as a % of cap) to signal urgency:

Colour Projected % of cap
🟢 Green < 85 %
🟡 Lime 85 – 100 %
🟠 Orange 100 – 120 %
🔴 Red ≥ 120 %

Works with agentic-sage

agentic-sage is a companion JS tool. Division of labor: oracle owns tokens, cost, and forecasts; sage owns sessions, fleet coordination, and guidance. Point sage at oracle's snapshot:

{
  "tokenForecastPath": "~/.local/share/token-oracle/forecast.json"
}

oracle doctor detects sage and prints the exact link hint (or flags a stale snapshot). Enable "snapshot_writethrough": true so forecast/statusline/tmux keep the file fresh automatically.

Contributing

See CONTRIBUTING.md. In brief: fork → branch from mainpytest + ruff check + mypy → pull request.

Community

If you're not sure whether something is a bug, start a Discussion — maintainers can promote it to an issue when it is.

License

MIT — Copyright (c) 2026 Mateusz Muślewski.

Download files

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

Source Distribution

token_oracle-0.1.3.tar.gz (5.0 MB view details)

Uploaded Source

Built Distribution

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

token_oracle-0.1.3-py3-none-any.whl (139.8 kB view details)

Uploaded Python 3

File details

Details for the file token_oracle-0.1.3.tar.gz.

File metadata

  • Download URL: token_oracle-0.1.3.tar.gz
  • Upload date:
  • Size: 5.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for token_oracle-0.1.3.tar.gz
Algorithm Hash digest
SHA256 84ad7700eaf53d0e3b8812f14e1fea1b6a53a32f46aafb0975b8a72026b24556
MD5 558eaaf9efbf35e0dc53b259adaff235
BLAKE2b-256 28388f46fd6df924f215a7a5c62f834f8488443fe9da0de6bc718076125de7a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for token_oracle-0.1.3.tar.gz:

Publisher: publish.yml on muslewski/token-oracle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file token_oracle-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: token_oracle-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 139.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for token_oracle-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ae89e86eda9b742989bc72c7bac4f7675e958e462e8f0e62728734cc0139d231
MD5 0831e99a5d11efcff93ea5075be6cd76
BLAKE2b-256 478dff7a82ff802d9ec2b1e9e3a54defde72759d79aa12b887f23522febc3bcc

See more details on using hashes here.

Provenance

The following attestation bundles were made for token_oracle-0.1.3-py3-none-any.whl:

Publisher: publish.yml on muslewski/token-oracle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 files

0.1.2

2 files

0.1.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page