claude-usage-plz
Check your Claude Max/Pro usage limits from Linux. No browser, no macOS, no scraping.
$ claude-usage
Session (5h): 59% used (resets 11pm (UTC))
Week (all): 33% used (resets Apr 7, 3pm (UTC))
Week (Sonnet): 12% used (resets Apr 7, 5pm (UTC))
Why
There is no API to check Claude usage programmatically (anthropics/claude-code#9617). The /usage slash command only works inside interactive sessions. Every existing tool is either macOS-only (menu bar apps) or uses private APIs that break.
This tool runs /usage inside a virtual terminal, reads the screen, and parses the output. It works anywhere Claude Code runs.
Install
pip install claude-usage-plz
Requires Claude Code to be installed via npm and logged in:
# Install Node.js if needed, then:
npm install -g @anthropic-ai/claude-code
Note: On Linux, you must install Claude Code via npm (
npm install -g @anthropic-ai/claude-code). The VS Code extension bundles its own binary, but it is not on PATH and cannot be relied upon for programmatic use.
CLI
# Default (~/.claude)
claude-usage
# Specific profile
claude-usage --claude-dir ~/.claude-work
# JSON output (for scripts)
claude-usage --json
{
"five_hour_pct": 59.0,
"five_hour_resets": "11pm (UTC)",
"seven_day_pct": 33.0,
"seven_day_resets": "Apr 7, 3pm (UTC)",
"sonnet_week_pct": 12.0,
"sonnet_week_resets": "Apr 7, 5pm (UTC)"
}
Python API
from claude_usage import get_usage
# Default account
usage = get_usage()
print(f"5h: {usage.five_hour_pct}%, 7d: {usage.seven_day_pct}%")
# Specific account
usage = get_usage("/home/me/.claude-work")
# All fields
usage.five_hour_pct # float | None
usage.five_hour_resets # str | None (e.g. "11pm (UTC)")
usage.seven_day_pct # float | None
usage.seven_day_resets # str | None
usage.sonnet_week_pct # float | None
usage.sonnet_week_resets # str | None
# As dict/JSON
usage.to_dict()
How it works
- Spawns
claude --dangerously-skip-permissionsin a virtual PTY (pexpect) - Accepts the bypass-permissions prompt
- Sends
/usage+ Enter - Reads the rendered TUI screen via pyte (terminal emulator)
- Parses percentages with regex
- Exits the session
Takes ~15-20 seconds per call. The claude process is closed after each probe.
Multi-account usage
Pass --claude-dir (CLI) or the claude_dir argument (Python) to check different accounts:
from claude_usage import get_usage
work = get_usage("/home/me/.claude-profiles/work/.claude")
personal = get_usage("/home/me/.claude-profiles/personal/.claude")
print(f"Work: {work.five_hour_pct}% | Personal: {personal.five_hour_pct}%")
Limitations
- Linux only (uses PTY via pexpect; macOS may work but untested)
- ~15-20s per call (spawns a full claude session)
- Depends on TUI layout (may break if Anthropic changes
/usageoutput) - Requires
--dangerously-skip-permissions(only runs/usageand/exit)
License
MIT
Metadata
Release files for claude-usage-plz 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 | |
|---|---|---|---|---|
| claude_usage_plz-0.3.0.tar.gz | 13.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| claude_usage_plz-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.3 kB
Release files / claude_usage_plz-0.3.0.tar.gz
| Download URL | claude_usage_plz-0.3.0.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
30506d5b02ed446fb284e0608ac85481ad6b87c5c916f2c06764544097ccc8a5
|
|
BLAKE2b-256 checksum How to use checksums |
cd4ff096d0c9cb28929e5af8785e04364d59874cf6d882706a73b26a501dbf2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Release files / claude_usage_plz-0.3.0-py3-none-any.whl
| Download URL | claude_usage_plz-0.3.0-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
edc8b312a1f43e18f5322666e3b8b1a7f3c7ff6998ef1b94bf2fbf12936e6ae6
|
|
BLAKE2b-256 checksum How to use checksums |
99075ca5302241029bf8d05ead6c14b96517ab19afeacae8933770880df61fdf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Security for claude-usage-plz 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.