Check usage limits for Claude Code and Antigravity CLI from terminal
Project description
AI Limit Checker
✨ Features
- Claude Code — 5h & 7d usage windows with Sonnet/Opus breakdown
- Antigravity CLI — Per-group (Gemini / Claude+GPT) weekly + five-hour limits
- Watch mode — Automatically detect when a 5h limit resets and notify you
- JSON output — Structured output for AI agents (Hermes, Claude Code, etc.)
- Zero dependencies — Pure Python stdlib, no pip conflicts
- Cross-platform — Windows, macOS, and Linux
- No credential leakage — Tokens never printed; only official API endpoints are called
Install
pip install ai-limit-checker
Requires Python 3.10+. No external dependencies.
Quick Start
# Show all limits (default)
aichecker
# JSON output for AI agents / scripts
aichecker --json
# Compact one-liner (great for shell prompts / tmux status bars)
aichecker --oneline
# Check only one tool
aichecker --claude
aichecker --antigravity
# Ignore the 60s cache (force fresh API call)
aichecker --no-cache
Two command names are available — aichecker and ailimits — both invoke the same entry point.
Watch Mode
Watch mode polls usage every 5 minutes and automatically sends a ping to the CLI when a 5h limit window resets — triggering a fresh usage window so you can resume work immediately.
CLI
# Run continuously (polls every 5 min, pings on reset)
aichecker --watch
# Single check — perfect for cron jobs
aichecker --watch --once
# Customise poll interval and post-reset delay
aichecker --watch --interval 60 --delay 30
# Dry-run — log what would happen without calling the CLIs
aichecker --watch --once --dry-run
How it works:
- Every poll, the tool records each 5h window's
resets_attimestamp andused_pct - When
now >= resets_at + delay(default 120s) and the window had usage > 0% before, a reset is detected - A trivial prompt (
"hi") is sent toclaude -poragy -pto trigger a new 5h usage window - State is persisted to
~/.cache/ai-limit-checker/watch_state.jsonacross restarts
The 2-minute delay ensures the server has fully refreshed before triggering.
Deduplication: if both Gemini and Claude/GPT groups on Antigravity reset at the same time, only one ping is sent to
agy(they share the same 5h window on the same CLI).
Cron setup
For scheduled use, run a single check with --once:
# crontab — every 5 minutes
*/5 * * * * /usr/local/bin/aichecker --watch --once
The tool stays silent when no reset has occurred (empty stdout = nothing to report).
Programmatic API
from ai_limit_checker.watch import watch_5h_resets
# Built-in: pings the CLI and prints to stdout on reset
watch_5h_resets(once=True)
# Custom callback — send to Discord, Telegram, Slack, etc.
# (the CLI ping still happens automatically; this is for extra notifications)
def on_reset(reset_labels: list[str]) -> None:
msg = f"🔄 Limits reset: {', '.join(reset_labels)}"
send_to_discord(msg) # your notification function
watch_5h_resets(on_reset=on_reset, interval=300, delay=120, once=True)
# Dry-run mode — log without calling the CLIs (for testing)
watch_5h_resets(once=True, dry_run=True)
| Parameter | Type | Default | Description |
|---|---|---|---|
on_reset |
Callable | None |
None |
Callback receiving a list of reset window labels. If None, prints to stdout. The CLI ping happens regardless. |
interval |
int |
300 |
Seconds between polls (when not --once). |
delay |
int |
120 |
Seconds to wait after resets_at before triggering. |
once |
bool |
False |
Run a single check and exit (for cron/scheduled use). |
dry_run |
bool |
False |
Log what would happen without calling the CLIs. |
JSON Output
aichecker --json
Returns structured JSON with all limits, remaining percentages, and reset timestamps. AI agents can parse this to plan task delegation based on remaining quota.
Example JSON structure
{
"claude": {
"status": "ok",
"plan": "max",
"five_hour": {
"used_pct": 1.0,
"remaining_pct": 99.0,
"resets_at": "2026-06-29T16:31:00Z"
},
"seven_day": {
"used_pct": 56.0,
"remaining_pct": 44.0,
"resets_at": "2026-07-02T05:00:00Z"
}
},
"antigravity": {
"status": "ok",
"tier": "Google AI Ultra",
"is_paid": true,
"project_id": "my-project-12345",
"groups": [
{
"name": "Gemini Models",
"buckets": [
{
"window": "weekly",
"label": "Weekly Limit",
"used_pct": 0.0,
"remaining_pct": 100.0,
"remaining_fraction": 1.0,
"resets_at": "2026-07-06T12:00:00Z"
},
{
"window": "5h",
"label": "Five Hour Limit",
"used_pct": 0.0,
"remaining_pct": 100.0,
"remaining_fraction": 1.0,
"resets_at": "2026-06-29T18:31:00Z"
}
]
},
{
"name": "Claude and GPT models",
"buckets": [
{
"window": "weekly",
"label": "Weekly Limit",
"used_pct": 93.0,
"remaining_pct": 7.0,
"remaining_fraction": 0.07,
"resets_at": "2026-07-02T12:00:00Z"
},
{
"window": "5h",
"label": "Five Hour Limit",
"used_pct": 95.0,
"remaining_pct": 5.0,
"remaining_fraction": 0.05,
"resets_at": "2026-06-29T12:50:00Z"
}
]
}
],
"highest_used_pct": 95.0
}
}
Example Output
🔍 AI CLI Usage Checker
2026-06-29 12:00:00
════════════════════════════════════════
Claude Code (Max Plan)
════════════════════════════════════════
✅ Connected
5h Window: 1.0% used (99.0% left) → resets in 4h 56m
7d Window: 56.0% used (44.0% left) → resets in 2d 17h
════════════════════════════════════════
Antigravity CLI
════════════════════════════════════════
✅ Connected
Tier: Google AI Ultra
Project: my-project-12345
Gemini Models
Weekly Limit: 0.0% used → resets in 6d 23h
Five Hour Limit: 0.0% used → resets in 4h 59m
Claude and GPT models
Weekly Limit: 93.0% used → resets in 2d 20h
Five Hour Limit: 95.0% used → resets in 19m
One-liner mode (--oneline):
Claude: 1.0% (5h) 🟢 | 56.0% (7d) 🟡 | Antigravity: 95.0% used 🔴
How It Works
Claude Code
- Reads OAuth credentials from
~/.claude/.credentials.json(Windows/Linux) or macOS Keychain - Calls the official Anthropic usage API to get 5h and 7d window data
Antigravity CLI
- Reads OAuth credentials from Windows Credential Manager (
gemini:antigravity) or~/.gemini/oauth_creds.json - Calls
daily-cloudcode-pa.googleapis.com— the same endpoint the Antigravity desktop app uses - Fetches tier info via
loadCodeAssist, then per-model-group quota buckets
Why
daily-prefix? The base endpointcloudcode-pa.googleapis.comalways returnsremainingFraction: 1(100% remaining) regardless of actual usage. Thedaily-prefixed host returns real-time usage data that matches the desktop app's "Weekly Limit" / "Five Hour Limit" readouts.
Antigravity usage readouts
Usage is reported as % used, matching the Antigravity desktop app. Models are grouped (Gemini vs. Claude/GPT); within a group the weekly and five-hour windows are shared.
Tier note: loadCodeAssist returns two tiers. currentTier is the Cloud Code Assist API tier — always free-tier for consumer (non-GCP) accounts, regardless of any Google One AI subscription. paidTier carries the real subscription (e.g. Google AI Ultra) and only appears when one exists, so the tool prefers it. The raw API tier is still available as api_tier_id in --json output. Accounts with no Google One AI plan correctly show Antigravity (free-tier).
Why "Gemini Models" can sit at 0.0%: on a Google AI Ultra account the Gemini group is effectively unmetered — the server reports remainingFraction of exactly 1 no matter how much you use Gemini (verified against a run that consumed millions of Gemini tokens). Only the third-party group (Claude and GPT) is metered and moves. So a Gemini group stuck at 0.0% used after heavy Antigravity use is expected, not a bug. Genuinely tiny usage (under 0.1%) is shown as <0.1% used to distinguish it from an untouched 0.0% limit, and the raw remaining_fraction (0–1, full precision) is included per bucket in --json output.
Supported Tools
| Tool | Metrics |
|---|---|
| Claude Code | 5h window, 7d window, Sonnet/Opus breakdown |
| Antigravity CLI | Per-group weekly + five-hour limits, % used, reset time |
Programmatic API
All functions are importable from ai_limit_checker:
from ai_limit_checker import check_claude, check_antigravity
# Check Claude Code usage
claude_result = check_claude()
print(claude_result["five_hour"]["used_pct"])
# Check Antigravity usage
agy_result = check_antigravity()
for group in agy_result.get("groups", []):
print(group["name"])
for bucket in group["buckets"]:
print(f" {bucket['label']}: {bucket['used_pct']}% used")
from ai_limit_checker.cli import gather, format_json, format_oneline
# Gather both tools at once (with 60s caching)
result = gather(do_claude=True, do_antigravity=True)
print(format_json(result))
CLI Reference
aichecker [OPTIONS]
Options:
--json Output structured JSON
--oneline Output a compact one-liner
--claude Check only Claude Code
--antigravity Check only Antigravity CLI
--no-cache Ignore the 60s result cache
--watch Watch mode: poll and ping CLI on 5h limit reset
--once Watch mode: single check (for cron)
--interval SECONDS Watch mode: poll interval (default 300)
--delay SECONDS Watch mode: delay after reset before triggering (default 120)
--dry-run Watch mode: log without calling the CLIs
--version Show version
-h, --help Show help
Development
git clone https://github.com/peetwan/ai-limit-checker.git
cd ai-limit-checker
# Install in editable mode with test dependencies
pip install -e ".[test]"
# or: pip install -e . && pip install pytest ruff
# Run tests
pytest
# Lint
ruff check src/ tests/
# Run locally
python -m ai_limit_checker --json
Testing
The test suite uses pytest with 86 tests covering:
- Credential parsing (Claude & Antigravity)
- API response parsing and normalization
- Output formatting (human, JSON, one-liner)
- Watch mode: reset detection, state persistence, CLI ping triggering, deduplication, dry-run
- Edge cases: missing credentials, API errors, unmetered groups, zero-usage rounding
pytest # run all tests
pytest -q # quiet mode
pytest -k watch # run only watch-mode tests
License
MIT © Peet Chanut
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ai_limit_checker-0.7.0.tar.gz.
File metadata
- Download URL: ai_limit_checker-0.7.0.tar.gz
- Upload date:
- Size: 22.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40b5f823c036ebdab47050c2a14226a50f42dd14f9112aed9e8d05be8d333bb9
|
|
| MD5 |
dc7c953b4cd9a1d6ff403f8c2b646353
|
|
| BLAKE2b-256 |
93d13fd9709265c3157c857ce9b42bfb5c6eae3888c8bc7eafa8c7e19e89f202
|
File details
Details for the file ai_limit_checker-0.7.0-py3-none-any.whl.
File metadata
- Download URL: ai_limit_checker-0.7.0-py3-none-any.whl
- Upload date:
- Size: 24.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2eb858bc4fc50cbf7ce3114f41125a73e8896e8c7bb81d890de07ccecfd21d60
|
|
| MD5 |
db4aec3bd6aeda29b28ba300fa5d9f73
|
|
| BLAKE2b-256 |
33f68a679e5699c987cc368ee958f41ef1610ba4dc1648f90c8a4dfe1df51481
|