feat: zero-config Claude quota discovery - #3
Conversation
cruzanstx
left a comment
There was a problem hiding this comment.
First: we genuinely love seeing cclimits being used on Windows. The real Windows/MSIX validation and read-only DPAPI approach are exactly the kind of cross-platform contribution we hoped for. Thank you for building and testing this.
The implementation is thoughtful, and the PR suite passes locally (271 passed). I found two issues that should be fixed before merge:
-
Stale local usage is rendered as healthy in compact output (
lib/cclimits.py:769-807,lib/cclimits.py:2557-2560).A two-hour-old
cachedUsageUtilizationsnapshot produces:Claude: 10.0% (5h) ✅Detailed/JSON output carries
source_stale, but--onelineignores it. A snapshot with no validfetchedAtMsis also returned asstatus: "ok"with no age or stale marker at all. That makes old/undated data indistinguishable from live quota in the format most likely to be embedded in status lines.Please either reject stale/undated local snapshots as the automatic fallback, or propagate an explicit stale/unknown marker into
--oneline. Add coverage for both an old timestamp and a missing timestamp. -
The copied MIT implementation needs its upstream license notice preserved (
lib/cclimits.py:394-395,_win_dpapi_unprotect, and_win_gcm_decrypt).The attribution comment is good, but the upstream MIT license requires its copyright and permission notice to accompany copies or substantial portions. Please add the
Copyright (c) 2026 claude-usage-assistant contributorsMIT notice to the distributed license/third-party notices. If using a separate notice file, include it inpackage.json.filesso it is present in the npm tarball.
Two non-blocking cleanups worth including:
source_pathexposes and caches the full Windows profile path, including the username (lib/cclimits.py:695,:772,:856). The source label is sufficient for normal JSON; reserve paths for explicit debug output.TestGetClaudeUsage.test_no_credentialsonly patchesget_claude_credentials, so it fails on machines that actually have a Claude Desktop session orcachedUsageUtilization. Patch the new Desktop/cache discovery functions so the test remains hermetic.
Also, the PR title currently ends with the duplicated text Feature/claude zero config.
|
One additional cross-platform issue from the final review pass: macOS Desktop detection currently promises a recovery path that cannot work ( On macOS,
Retrying cannot succeed because Desktop OAuth extraction is implemented only for Windows. Please either implement the macOS safeStorage/Keychain path or restrict Desktop detection and that hint to Windows. The help text should also state explicitly that Desktop OAuth discovery is currently Windows-only. This does not diminish the Windows work—we’re especially glad to see cclimits being used and validated there—but the other-platform guidance needs to remain accurate. |
cruzanstx
left a comment
There was a problem hiding this comment.
Re-reviewed at 26a7c035dfe5080020d854c70ce516dabe0d51df. All requested code changes are resolved:
- stale and undated Claude Code snapshots now fail closed instead of appearing live in compact output;
- Windows profile paths are no longer returned or cached;
- macOS/Linux guidance now accurately states that Claude Desktop OAuth discovery is Windows-only;
- the no-credentials test is isolated from real local Claude state;
- the upstream MIT notice is preserved and verified in the npm tarball.
Local verification passed: 274 passed, focused Claude tests 17 passed, stale-cache reproduction now reports Claude: 🔑, and npm pack --dry-run includes THIRD_PARTY_NOTICES.md.
Approved. Thank you again for the careful Windows implementation and quick follow-up.
One non-blocking housekeeping item remains: please clean the duplicated Feature/claude zero config suffix from the PR title before merge.
Summary
Adds zero-config Claude quota discovery, reusing authentication that already exists on the machine.
What it supports
%APPDATA%\Claude%LOCALAPPDATA%\Packages\...\LocalCache\Roaming\Claude~/.claude.json -> cachedUsageUtilizationas a no-auth fallbackSafety / behavior
Validation
Manual Windows validation passed on a machine where:
cclimits --claudediscovered the existing Desktop OAuth session automatically and returned live 5-hour / 7-day quota dataSource: Claude Desktop OAuth (read-only)Focused tests cover source precedence, cache parsing/staleness, Desktop token-cache parsing, expired-token rejection, and Windows/MSIX profile discovery.
The Windows safeStorage implementation is adapted from the MIT-licensed
huanchong-99/claude-usage-assistantproject, with attribution in code.