📊 cursor-usage
Your Cursor usage, spend, and cycle limits — right from your terminal.
Cursor shows your usage only on its web dashboard. cursor-usage gives you
usage, spend, and cycle limits from the shell — for scripts, hooks, and AI agents
deciding when to back off, plus per-day reports and CSV exports. It uses the Cursor
session already on your machine.
$ cursor-usage --format short
composer 37% · other 12%
✨ Features
- 📊 Usage and spend — per-model tokens and compute value for the current billing month or a custom time window.
- 📈 Cycle limits — percentages used and remaining for Composer / Auto and Other models, plus included spend and the reset date when reported.
- 🚦 Thresholds for scripts —
--warn [N]exits 1 when either cycle bucket reaches N%. - 📅 Per-day breakdown —
--by-daygroups usage events by local calendar day. - 💾 CSV export —
--csvsaves individual events with timestamps, models, tokens, and cost. - 🧾 Plain, JSON, or short — readable reports, raw data, and a one-line status.
- 🌍 Cross-platform — macOS, Linux, and Windows; Python 3.8+.
- 🔋 Zero dependencies — pure Python standard library.
- 🔒 Local & private — reads your existing Cursor session and sends it only to Cursor.
🚀 Quickstart
pip install cursor-usage
cursor-usage
Run cursor-agent login, sign in at cursor.com in Firefox, or use an existing
Cursor app session on this machine.
🧑💻 Usage
| Command | What it does |
|---|---|
cursor-usage |
Usage summary for the current billing month and cycle limits when available |
cursor-usage --by-day |
Add a per-day breakdown in plain format |
cursor-usage --csv FILE |
Export usage events in the selected window to CSV in plain format |
cursor-usage --days N |
Show usage from the last N days |
cursor-usage --month YYYY-MM |
Show usage from a specific UTC calendar month, up to the current time |
cursor-usage --start YYYY-MM-DD |
Set the inclusive start date in UTC |
cursor-usage --end YYYY-MM-DD |
Set the inclusive end date in UTC |
cursor-usage --page-size N |
Set events per API page for --by-day and --csv (default 1000) |
cursor-usage --warn [N] |
Exit 1 when either cycle bucket reaches N% (default 70) |
cursor-usage --format {plain,json,short} |
Choose output format (default plain) |
cursor-usage --json |
Print raw aggregated-usage JSON (alias for --format json) |
cursor-usage --limits-json |
Print raw current cycle-limits JSON, overriding --format |
cursor-usage -v, --verbose |
Log the credential source, expiry, rejections, and optional limits failures to stderr |
cursor-usage -V, --version |
Print the version |
cursor-usage -h, --help |
Show help |
Combine flags with a command such as cursor-usage --by-day --csv june.csv --month 2026-06.
When both --json and --format appear, the last one wins. The usage start
comes from --start, then --days (counting back from now), then --month,
then the current billing month. --end overrides the end boundary. After
validating the session, short format and --limits-json fetch cycle limits.
Cycle limits and warnings always use the current billing cycle.
📊 Example: cursor-usage
==============================================================================
CURSOR USAGE | you@example.com | 2026-06-04 -> 2026-06-09
==============================================================================
Included value used : $875.81 (compute consumed; included in plan)
Tokens in=126,033,860 out=18,989,068
cacheRead=2,492,781,450 cacheWrite=8,322,520
------------------------------------------------------------------------------
model $ value in tok out tok
------------------------------------------------------------------------------
composer-2.5 460.14 95,638,983 13,315,470
claude-4.6-opus-high 233.71 786,434 1,059,451
gemini-3.5-flash 45.77 16,097,065 1,075,904
gpt-5.4-high 43.65 4,069,043 1,041,967
...
==============================================================================
CURSOR CYCLE LIMITS | resets 2026-07-04
==============================================================================
Composer / Auto [###########...................] 36.7% used, 63.3% left
Other models [####..........................] 12.4% used, 87.6% left
Included usage $146.80 of $400.00 used ($253.20 left)
📅 Example: --by-day
==============================================================================
CURSOR USAGE BY DAY | you@example.com | 2026-06-04 -> 2026-06-09
==============================================================================
date events $ value in tok out tok
------------------------------------------------------------------------------
2026-06-04 433 324.46 38,602,275 6,080,617
2026-06-05 368 252.58 40,616,543 6,469,309
2026-06-06 416 121.06 29,686,247 4,497,010
2026-06-07 444 177.71 17,128,795 1,942,132
------------------------------------------------------------------------------
TOTAL 1,661 875.81 126,033,860 18,989,068
💾 Example: --csv usage.csv
The CSV has one row per usage event, sorted by timestamp.
datetime_local,timestamp_ms,date,model,kind,input_tokens,output_tokens,cache_read_tokens,cache_write_tokens,value_cents,charged_cents,requests_costs,is_headless,owning_user
🤖 Using it from scripts and agents
cursor-usage --warn 70 || echo "back off"
cursor-usage --format short
cursor-usage --json
The threshold check uses the reported percentages before rounding. An exact
match triggers the warning. One reported percentage is enough to check the
threshold. If both endpoints lack usable percentages, --warn reports an
error unless the plan reports unlimited usage. Short format rounds to whole
percentages and displays unlimited for an unlimited plan.
The command exits 0 on success, 1 when the threshold is reached or an API or data error occurs, and 2 for invalid arguments or when no session can be authenticated. A threshold match leaves the requested output on stdout. Diagnostics go to stderr.
🤔 How it works
The CLI finds your local Cursor web session and asks Cursor's dashboard API for usage. The aggregated endpoint provides per-model totals. Cycle limits come from the current-period endpoint, with the usage-summary endpoint as a fallback. Per-day and CSV reports fetch the per-event log in pages.
The CLI collects sessions from all available sources and tries them in this priority order. Within each group, it tries the latest expiry first.
- Overrides from
CURSOR_SESSION_TOKENand the session file. SetCURSOR_USAGE_SESSION_FILEto choose the file path. The default is~/.config/cursor-usage/sessionon macOS and Linux or%APPDATA%/cursor-usage/sessionon Windows. On macOS and Linux, usechmod 600on the file. The CLI skips files readable by group or others. - Saved sign-ins from macOS Keychain, the
cursor-agent loginfile, and the optional OS keyring. On Linux, the login file is$XDG_CONFIG_HOME/cursor/auth.jsonor~/.config/cursor/auth.jsonby default. On Windows, the CLI tries%APPDATA%/cursor/auth.jsonwhen available. OS keyring lookup waits up to five seconds. - Firefox dashboard cookies across profiles, including Snap on Linux.
- Cursor or Cursor Nightly sessions from the app's SQLite state database.
The CLI skips Agent API tokens, encrypted or invalid credentials, and sessions
that expire within 60 seconds. It checks each distinct candidate once against
Cursor's identity endpoint and falls through if Cursor rejects it. With -v,
the CLI reports rejections and the source and UTC expiry of the accepted
session. If no session works, it lists each source's status and suggests
cursor-agent login.
For manual setup, open the Cursor dashboard in your browser and look under
Application or Storage in developer tools for the WorkosCursorSessionToken
cookie. The environment override and session file accept the cookie value
(id::jwt, including its URL-encoded form) or a raw session JWT. Put just the
value in the file. In Bash, you can set the environment override without
displaying the value or adding it to shell history.
read -rs CURSOR_SESSION_TOKEN
export CURSOR_SESSION_TOKEN
cursor-usage
unset CURSOR_SESSION_TOKEN
For the protocol and a recipe to rebuild the tool, see docs/HOW_THIS_WAS_BUILT.md.
🔒 Privacy & security
- Reads your existing local session. The Firefox lookup uses a private temporary copy of the cookie database and its write-ahead log, then removes the copy.
- Sends the session cookie only to
cursor.com. HTTP redirects are blocked. - Keeps the session out of output and errors, including with
-v. - CSV exports contain your usage data. Git ignores
*.csvin this repo. - No telemetry. No third-party calls.
⚠️ Good to know
$ valuemeasures compute consumed. With usage-based pricing off, the flat subscription covers those figures.- The dashboard API is undocumented and Cursor may change it.
- Personal Cursor API keys authenticate the Agent API. Usage requires a Cursor web session.
- If your session expires, sign back in at
cursor.com. Refresh any session value you supplied manually before running the command again.
🛠️ Install options
pip install cursor-usage # from PyPI
pipx install cursor-usage # isolated command installation
pip install . # from a local clone
pip install "cursor-usage[keyring]" # optional OS keyring lookup
Requires Python 3.8+.
🤝 Contributing
Issues and PRs are welcome. After installing the local project with pip install -e .,
run the tests with:
pip install pytest && pytest -q
Tests use temporary files and mocked HTTP; they never contact the endpoint or read your real credentials.
Regenerate the demo with python3 docs/record_demo.py after installing
agg and the DejaVu Sans Mono font.
The recorder runs the CLI against illustrative responses with HTTP disabled.
Set CURSOR_USAGE_DEMO_FONT_DIR if the font is outside agg's font search path.
The README embeds the resulting docs/demo.gif.
📄 License
MIT — do whatever you like.
Metadata
Release files for cursor-usage 0.3.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 | Provenance | Actions |
|---|---|---|---|---|
| cursor_usage-0.3.0.tar.gz | 31.3 kB | Without provenance | Details for cursor_usage-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cursor_usage-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for cursor_usage-0.3.0-py3-none-any.whl |
Total release size: 51.2 kB
Release files / cursor_usage-0.3.0.tar.gz
| Download URL | cursor_usage-0.3.0.tar.gz |
|---|---|
| Size | 31.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7e3d40caf3090c598ea376316884a4a186f4229c2814f4d6dcf918854e056fcb
|
|
BLAKE2b-256 checksum How to use checksums |
61376c23bb4b66c23e5ababf7faa510f39c1ee3b880c820837b39a1894525adc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / cursor_usage-0.3.0-py3-none-any.whl
| Download URL | cursor_usage-0.3.0-py3-none-any.whl |
|---|---|
| Size | 19.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4159d5cffd370a143dfcfe0c6343aad44e253e8e424d507f4ea98900e4e6ae6a
|
|
BLAKE2b-256 checksum How to use checksums |
62a5db20fc799fd47af787e94cb539136872ba5a7f0c184c4adbfadfe4076187
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for cursor-usage 0.3.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.