token-finops-cli
A small, read-only CLI to keep an eye on your GitHub Copilot CLI token usage and estimate a "runway" — how many days your monthly AI-unit budget will last at your current burn rate.
It reads directly from the Copilot CLI's own local telemetry database
(~/.copilot/session-store.db, table assistant_usage_events) — no
external API calls, no scraping, nothing leaves your machine. The database
is opened in immutable/read-only mode so it can never interfere with a
live Copilot CLI session.
Why
GitHub's Copilot usage-metrics REST API is enterprise-admin-only (requires
manage_billing:copilot / read:enterprise scopes) — there's no
individual-seat endpoint to query your own quota. This tool works around
that by reading the CLI's own local usage log and letting you supply your
own monthly budget number (from the Copilot billing page) so it can project
a runway estimate.
Install
With uv (recommended):
uv tool install token-finops-cli
token-finops --since 7d
Or from source, editable, in a venv:
uv venv
uv pip install -e ".[dev]"
.venv/bin/token-finops --since 7d
Or plain pip:
pip install token-finops-cli
Usage
token-finops # full report, last 7 days (same as "report")
token-finops --since 30d # last 30 days
token-finops --since all # all-time
token-finops --session <id> # filter to one session
# Budget / runway
token-finops --budget 50000 --cycle-day 1
token-finops --compact # 2-line minimal output
token-finops --watch 5 # live-refreshing view every 5s
Session history & break/gap reports
The sessions subcommand gives per-session archival/historical reporting
— useful for looking back at past sessions rather than just current
budget status:
token-finops sessions # list all past sessions
token-finops sessions --since 30d --limit 10
token-finops sessions --session <id> # detailed break/gap report
token-finops sessions --session <id> --gap-minutes 60
token-finops sessions --totals # ONE combined report across ALL sessions
The detailed per-session view detects "breaks" — gaps between requests
longer than --gap-minutes (default 30) — and reports active time (time
actually spent working) vs. idle/paused time (e.g. you closed the
terminal and came back the next day), alongside total elapsed wall-clock
time and a list of each pause with its start/end/duration.
Try it without your own data (synthetic demo)
A small script generates a throwaway SQLite DB with fake usage events (same
columns the tool reads, nothing from your real ~/.copilot/session-store.db
is ever touched):
python3 examples/generate_synthetic_db.py /tmp/demo.db --days 20
token-finops --db-path /tmp/demo.db --since 7d
token-finops --db-path /tmp/demo.db --compact
Or point the tool at any DB via the TOKEN_FINOPS_DB env var instead of
--db-path.
Options
| Flag | Description |
|---|---|
--since {1d,7d,30d,all} |
Time window for the usage summary |
--session ID |
Filter to a single session |
--budget N |
Monthly AI-unit budget (default 50000) — get this from your Copilot billing page |
--cycle-day N |
Day of month your billing cycle resets on (default 1) |
--watch SECONDS |
Live-refreshing view, redraws every N seconds |
--compact / -c |
2-line minimal output (budget bar + runway status) |
--verbose / -vv |
Full report (overrides --compact) |
sessions subcommand options:
| Flag | Description |
|---|---|
--since {1d,7d,30d,all} |
Time window for the session list (default all) |
--limit N |
Max sessions to list (default 20) |
--session ID |
Show a detailed break/gap report for one session instead of the list |
--gap-minutes N |
Idle-gap threshold in minutes to count as a "break" (default 30) |
--totals |
Print one combined report aggregated across ALL sessions matching --since (total requests/tokens/AI units, plus summed active/idle time and break count across every session) |
What it measures
The "AI unit" is GitHub's own cost/usage unit for a mixed
included-quota + pay-per-use Copilot plan, taken from the
total_nano_aiu column (divided by 1e9) — this matches what's shown on
the Copilot billing page. It is not raw token counts.
Requirements
- Python 3 (standard library only — no dependencies)
- GitHub Copilot CLI installed and used at least once (so
~/.copilot/session-store.dbexists)
Optional: use as a Copilot CLI skill
You can drop a SKILL.md into ~/.copilot/skills/token-finops-cli/ so any
Copilot CLI session can answer "what's my usage/runway?" on demand by
invoking this script. See the CLI's skills documentation for the expected
format.
Roadmap
- Support reading local usage/session logs from other coding agents (e.g. Claude Code), so this becomes a general "agentic coding tool finops" CLI rather than Copilot-only.
License
AGPL-3.0 — see LICENSE.
Metadata
Release files for token-finops-cli 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| token_finops_cli-0.2.0.tar.gz | 24.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| token_finops_cli-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 47.9 kB
Release files / token_finops_cli-0.2.0.tar.gz
| Download URL | token_finops_cli-0.2.0.tar.gz |
|---|---|
| Size | 24.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a1ee5422c3a828d9fe8b3763621fa21bc29f1423449e01d94d3c8732d20ebc22
|
|
BLAKE2b-256 checksum How to use checksums |
aca4ff078907ad34c0b09b7597e394be8692f8eed430d080a02a9cd8ed1dfd90
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 7, 2026.
Transparency logRelease files / token_finops_cli-0.2.0-py3-none-any.whl
| Download URL | token_finops_cli-0.2.0-py3-none-any.whl |
|---|---|
| Size | 24.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
608fe13f0d2533c402432d7f4c034f8fbf6baf6c5511994374762789a6d6f182
|
|
BLAKE2b-256 checksum How to use checksums |
c206bf060e6f4010febbcc686e6dfd0ff21a6cee00d86d169d86a0c9ac86962e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 7, 2026.
Transparency log