Skip to content

Commit d04058d

Browse files
Initial release — Claude usage monitor for Mac menu bar
Reads session cookies from the Claude desktop app to show 5-hour session % and 7-day weekly % directly in the menu bar. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
0 parents  commit d04058d

8 files changed

Lines changed: 580 additions & 0 deletions

File tree

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# py2app build artifacts
2+
build/
3+
dist/
4+
5+
# Virtual environment
6+
venv/
7+
8+
# macOS
9+
.DS_Store
10+
11+
# Logs
12+
*.log

ClaudeWatch.icns

1.06 MB
Binary file not shown.

README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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) |

TrayIconTemplate.png

2.06 KB
Loading

TrayIconTemplate@2x.png

2.78 KB
Loading

0 commit comments

Comments
 (0)