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 main → pytest + 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.

Metadata

Release files for token-oracle 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for token-oracle 0.1.3
File Size Uploaded Provenance Actions
token_oracle-0.1.3.tar.gz 5.0 MB With provenance Details for token_oracle-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for token-oracle 0.1.3
File Interpreter ABI Platform Actions
token_oracle-0.1.3-py3-none-any.whl Python 3 none any Details for token_oracle-0.1.3-py3-none-any.whl

Total release size: 5.1 MB

Release files / token_oracle-0.1.3.tar.gz

Download URL token_oracle-0.1.3.tar.gz
Size 5.0 MB
Tags Source
SHA-256 checksum
How to use checksums
84ad7700eaf53d0e3b8812f14e1fea1b6a53a32f46aafb0975b8a72026b24556
BLAKE2b-256 checksum
How to use checksums
28388f46fd6df924f215a7a5c62f834f8488443fe9da0de6bc718076125de7a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.

Transparency log

Release files / token_oracle-0.1.3-py3-none-any.whl

Download URL token_oracle-0.1.3-py3-none-any.whl
Size 139.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae89e86eda9b742989bc72c7bac4f7675e958e462e8f0e62728734cc0139d231
BLAKE2b-256 checksum
How to use checksums
478dff7a82ff802d9ec2b1e9e3a54defde72759d79aa12b887f23522febc3bcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.

Transparency log

Security for token-oracle 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for token_oracle-0.1.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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