Skip to main content

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

  1. Spawns claude --dangerously-skip-permissions in a virtual PTY (pexpect)
  2. Accepts the bypass-permissions prompt
  3. Sends /usage + Enter
  4. Reads the rendered TUI screen via pyte (terminal emulator)
  5. Parses percentages with regex
  6. 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 /usage output)
  • Requires --dangerously-skip-permissions (only runs /usage and /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)

Source distribution for claude-usage-plz 0.3.0
File Size Uploaded Provenance
claude_usage_plz-0.3.0.tar.gz 13.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for claude-usage-plz 0.3.0
File Interpreter ABI Platform
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.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files No provenance

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