Skip to main content

Check your Claude Max/Pro usage limits from the command line

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

claude_usage_plz-0.3.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

claude_usage_plz-0.3.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file claude_usage_plz-0.3.0.tar.gz.

File metadata

  • Download URL: claude_usage_plz-0.3.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for claude_usage_plz-0.3.0.tar.gz
Algorithm Hash digest
SHA256 30506d5b02ed446fb284e0608ac85481ad6b87c5c916f2c06764544097ccc8a5
MD5 d41c51c84760868f57d930e359757ad7
BLAKE2b-256 cd4ff096d0c9cb28929e5af8785e04364d59874cf6d882706a73b26a501dbf2d

See more details on using hashes here.

File details

Details for the file claude_usage_plz-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for claude_usage_plz-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 edc8b312a1f43e18f5322666e3b8b1a7f3c7ff6998ef1b94bf2fbf12936e6ae6
MD5 a5386334ed07bfa807bce033282073b8
BLAKE2b-256 99075ca5302241029bf8d05ead6c14b96517ab19afeacae8933770880df61fdf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page