|
| 1 | +# ClaudeWatch — Mac Menu Bar Usage Monitor |
| 2 | + |
| 3 | +A lightweight Mac menu bar app that shows your Claude.ai usage percentages in real time, using the Claude desktop app's session cookies for authentication. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## What It Shows |
| 8 | + |
| 9 | +``` |
| 10 | +[Claude icon] 34% | 64% |
| 11 | +``` |
| 12 | + |
| 13 | +- **34%** — 5-hour session usage (resets every 5 hours) |
| 14 | +- **64%** — 7-day weekly usage |
| 15 | + |
| 16 | +Click the icon to see reset times, extra credit usage, and a link to the full usage page. |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +## Requirements |
| 21 | + |
| 22 | +- macOS (Apple Silicon or Intel) |
| 23 | +- Python 3.9+ |
| 24 | +- **Claude desktop app** must be installed and you must be logged in (the app reads its session cookies) |
| 25 | + |
| 26 | +--- |
| 27 | + |
| 28 | +## Setup |
| 29 | + |
| 30 | +```bash |
| 31 | +chmod +x setup.sh |
| 32 | +./setup.sh |
| 33 | +``` |
| 34 | + |
| 35 | +The setup script will: |
| 36 | +1. Create `~/.claude_monitor/` with a virtual environment |
| 37 | +2. Install dependencies (`rumps`, `requests`, `pycryptodome`) |
| 38 | +3. Copy the Claude tray icon from the desktop app |
| 39 | +4. Optionally install a Launch Agent so it starts at login |
| 40 | + |
| 41 | +--- |
| 42 | + |
| 43 | +## How It Works |
| 44 | + |
| 45 | +The Claude desktop app is an Electron app that stores session cookies in a Chromium SQLite database: |
| 46 | + |
| 47 | +``` |
| 48 | +~/Library/Application Support/Claude/Cookies |
| 49 | +``` |
| 50 | + |
| 51 | +Cookies are encrypted with AES-128-CBC. The key is derived via PBKDF2-SHA1 from a password stored in Keychain under **"Claude Safe Storage"** / account **"Claude Key"**. |
| 52 | + |
| 53 | +**Decryption notes (Chromium v10 format on macOS):** |
| 54 | +- Strip the `v10` prefix (3 bytes) |
| 55 | +- Derive AES key: `PBKDF2(password, salt=b"saltysalt", iterations=1003, dklen=16, hash=SHA1)` |
| 56 | +- Decrypt with `IV = b" " * 16` (16 space chars) |
| 57 | +- The plaintext has a **32-byte internal Chromium header** prepended — skip it: `plaintext[32:-pkcs7_pad]` |
| 58 | + |
| 59 | +**Usage endpoint:** |
| 60 | +``` |
| 61 | +GET https://claude.ai/api/organizations/{org_id}/usage |
| 62 | +Cookie: sessionKey=...; lastActiveOrg=...; anthropic-device-id=... |
| 63 | +``` |
| 64 | + |
| 65 | +Response: |
| 66 | +```json |
| 67 | +{ |
| 68 | + "five_hour": { "utilization": 34.0, "resets_at": "..." }, |
| 69 | + "seven_day": { "utilization": 64.0, "resets_at": "..." }, |
| 70 | + "extra_usage": { "used_credits": 194, "monthly_limit": 3300 } |
| 71 | +} |
| 72 | +``` |
| 73 | + |
| 74 | +--- |
| 75 | + |
| 76 | +## Management |
| 77 | + |
| 78 | +```bash |
| 79 | +# Stop |
| 80 | +launchctl unload ~/Library/LaunchAgents/com.katespurr.claudemonitor.plist |
| 81 | + |
| 82 | +# Start |
| 83 | +launchctl load ~/Library/LaunchAgents/com.katespurr.claudemonitor.plist |
| 84 | + |
| 85 | +# Logs |
| 86 | +tail -f ~/.claude_monitor/monitor.log |
| 87 | +``` |
| 88 | + |
| 89 | +--- |
| 90 | + |
| 91 | +## Files |
| 92 | + |
| 93 | +| File | Purpose | |
| 94 | +|------|---------| |
| 95 | +| `claude_monitor.py` | Main app — copy to `~/.claude_monitor/` | |
| 96 | +| `setup.sh` | One-time setup script | |
| 97 | +| `~/.claude_monitor/config.json` | Refresh interval (default: 5 min) | |
0 commit comments