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 and logged in.

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.1.0.tar.gz (8.4 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.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for claude_usage_plz-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9e9c9bbb5acccdbd8f1cca35ccaeac990122269691f2e00c5990797d90405e59
MD5 edfe392ca4805f09b0c497802a81b8dc
BLAKE2b-256 4bbe436e34ef5280e1693837ffe9617489f1e16a8a2e25dc242e603bef2fbd02

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for claude_usage_plz-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db2cc19ef5da3aa80cd2940596b4288c96cf4e2711f7fa48fe1ee22caeed5a1c
MD5 83bafdbef7221697956030512b08339c
BLAKE2b-256 737f9c61fd983e36d82efaf6c6bba0336f289c752d33ab360b08b793b653c6e9

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