Skip to content

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Claude Code Usage

Claude Code Usage

A macOS menu bar app that shows how much Claude Code you have left. The menu bar reads 5h 62% · 7d 41%, the percentages left in the 5-hour and weekly windows, and refreshes at the configured interval. Opening the menu shows those same remaining percentages with how long until each window resets, and from there you can open the window, force a refresh, or quit.

The Tokens page in light mode, showing 703M tokens over 30 days with a daily chart and a breakdown by model

The Limits page in light mode, showing 62% left in the 5-hour window and 41% left in the weekly window

Team-signed builds also include a small macOS widget for the desktop and Notification Center. It follows the menu dropdown's selected 5-hour and weekly windows and its left/used percentage setting. Reset countdowns keep moving between refreshes, and clicking the widget opens the main window.

The unified toolbar switches between Limits and Tokens. Limits shows the 5-hour and weekly subscription windows, how long until each resets, and whether the current pace runs out before then. Tokens shows totals, a chart, and breakdowns by model, day, and project, summed from the JSONL transcripts in ~/.claude/projects. Choose Past 24h, 7 days, 30 days, or 90 days in the toolbar. The range picker is disabled on Limits.

The Dock icon follows the usage and Settings windows. While either is open, the app has a Dock tile, a Cmd-Tab entry, and standard App, Edit, View, Window, and Help menus. Closing the usage window parks it for reopening. When both windows are closed, the menu bar item stays running as an accessory app.

Built with SwiftUI and AppKit, with no third-party dependencies. Unofficial, and not affiliated with Anthropic.

The limits come from Anthropic's OAuth usage endpoint. The app sends the token Claude Code already keeps in your login keychain, so there is no second login here. If there is no token, or the usage API rejects it with a 401, the window says "Not logged in" and drops any numbers it had been showing. Whether you are logged in is decided by the token, not by claude auth status, which can report a login after the token is dead.

Claude Code's access tokens last eight hours, and only Claude Code refreshes them. When the stored token is past its expiresAt, the app skips the request and says the session has expired rather than that you are logged out. The Tokens page stays available, and the limits come back on the first poll after Claude Code has run and stored a fresh token. The app never refreshes the token itself.

The window subtitle names your plan (Max 20x plan, Team Standard plan), read from the subscriptionType and rateLimitTier stored with the token, plus the seat tier in ~/.claude.json for Team and Enterprise.

The 5-hour and weekly limits belong to a subscription. If Claude Code is billed per token instead, through an API key, an ANTHROPIC_AUTH_TOKEN gateway, or Bedrock, Vertex, or Foundry, there are no limits to show. The app asks claude auth status --json how Claude Code is being billed, because an API key in the environment outranks a claude.ai login that is still in the keychain. In that case the Tokens page shows local usage and Limits explains API billing, and the menu bar reads Claude: API billing. A plan that reports no windows at all reads Claude: no limits.

A Finder-launched app gets launchd's PATH, and zsh -l does not read .zshrc, which is where the native installer, nvm, bun, pnpm, and mise add their directories. So the app reads PATH once from an interactive login shell ($SHELL -ilc), falls back to launchctl getenv PATH, and then checks the usual install directories (~/.local/bin, ~/.claude/local, nvm, bun, volta, pnpm, mise, asdf, Homebrew). The same shell read also picks up the variables that decide how Claude Code authenticates (ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, CLAUDE_CODE_OAUTH_TOKEN, CLAUDE_CODE_USE_BEDROCK/_VERTEX/_FOUNDRY, CLAUDE_CONFIG_DIR). They are passed only to claude auth status, so its answer matches what a terminal would get. The lookup is in native/Sources/ClaudeUsageCore/CLIService.swift.

That token is sent only to https://api.anthropic.com/api/oauth/usage. Transcripts stay on disk. There is no extra account, no telemetry, and no other server. The endpoint is not a public API, so a Claude Code update can change the shape of the response or stop accepting the request.

Requirements

  • macOS 13 or newer
  • Xcode command line tools with Swift 5.9 or newer; full Xcode to build the widget
  • Claude Code, installed any way, and logged in

Build and run

swift build --package-path native
swift run --package-path native ClaudeUsage
swift test --package-path native

Closing the window leaves the status item running. Reopen it from the status menu. Settings opens in its own window through Command-comma, the app menu, the status menu, or --settings. Command-W and Escape close Settings. Use Command-1 and Command-2 to switch pages, Option-Command-1 through Option-Command-4 to select a token range, and Command-R to refresh. The toolbar can be customized from the View menu. Help opens the Claude Code documentation.

The limits are polled every minute while the window is open and at the Settings interval while it is closed. The user agent needs claude --version, which can cost a shell start and a Node start, so it is read once per run rather than once per poll. When Claude Code is billed per token there is nothing to poll, so each tick only reruns claude auth status and does a full reload once billing has switched back to a subscription.

Settings live in ~/Library/Application Support/<bundle id>/settings.json, in the same format earlier releases wrote, so an upgrade keeps them. The Appearance choice (System, Light, or Dark) is kept in the app's user defaults.

Demo mode

For a deterministic visual preview that does not read credentials, make network requests, save preferences, update the widget, or register a login item:

swift run --package-path native ClaudeUsage --demo
swift run --package-path native ClaudeUsage --demo --screenshot-dir "$PWD/artifacts"

Demo quota figures and token totals are fixtures covering 90 days, with about 700M tokens over the last 30 calendar days. The screenshot command captures six full windows, including the titlebar and toolbar: demo-limits-light.png, demo-limits-dark.png, demo-tokens-light.png, demo-tokens-dark.png, demo-settings-light.png, and demo-settings-dark.png.

Widget

The widget does not fetch from Anthropic. The menu bar process writes the selected limits to widget-snapshot.json in a shared macOS App Group, then asks WidgetKit to reload when a visible value changes. The snapshot contains percentages, reset dates, display preferences, and the last successful fetch time. It contains no OAuth token and no transcript data.

WidgetKit schedules the actual render, so a tile can lag behind the menu bar. It also asks for a fresh snapshot every 30 minutes and renders reset dates as live SwiftUI date text. Keep Claude Code Usage running in the menu bar if you want the widget to receive new quota figures.

The extension needs a real Apple team identity for its App Group. An ad-hoc bundle works, but scripts/bundle.sh leaves the widget out rather than shipping a tile that cannot read its data.

The widget has its own tests:

xcodebuild \
  -project widget/ClaudeUsageWidget.xcodeproj \
  -scheme ClaudeUsageWidget \
  -derivedDataPath target/widget-test \
  CODE_SIGNING_ALLOWED=NO \
  HOST_BUNDLE_ID=com.example.claude-usage \
  APP_GROUP_ID=EXAMPLETEAM.com.example.claude-usage \
  test

Distribution

scripts/bundle.sh builds Claude Code Usage.app in release mode, signs it, and writes a zip and a disk image with an Applications link to target/native/. The version comes from native/VERSION. Set your own identifiers first:

cp scripts/release.env.example scripts/release.env

Fill in a bundle id you own. release.env is ignored by git, and the script reads your signing certificate from your keychain, so nothing about your developer account is ever committed. Then:

sh scripts/bundle.sh

The script signs with the first Developer ID Application: Name (TEAMID) identity in your keychain, reads the team id from its name, and uses <TEAMID>.<BUNDLE_ID> for the widget's App Group. Set SIGN_IDENTITY or TEAM_ID in release.env only to override that. Without a Developer ID certificate the app is signed ad-hoc and the widget is left out. PACK_DMG=0 skips the disk image.

To notarize as well, create a notarytool profile once. It stores your app-specific password in your login keychain rather than in the repo:

xcrun notarytool store-credentials <profile> \
  --apple-id you@example.com --team-id <TEAM_ID> --password <app-specific>

Put that profile name in release.env as NOTARY_PROFILE and run the script again. The script notarizes and staples the app first, then puts that stapled copy in the disk image and notarizes the finished image.

The disk image opens with the app beside the Applications link. Finder writes that layout, so the terminal running the script needs permission to control Finder (System Settings, Privacy & Security, Automation). Without it the script prints a warning and the image opens in Finder's default view.

Cutting a release

Bump native/VERSION and commit it with the change it ships. Then bundle, tag, and publish:

sh scripts/bundle.sh
V=$(cat native/VERSION)

git push origin master
git tag -a "v$V" -m "v$V"
git push origin "v$V"

gh release create "v$V" --title "v$V" --notes "..." \
  "target/native/claude-usage-$V.dmg" \
  "target/native/claude-usage-$V.zip"

Bundle before tagging, so what ships is built from the commit the tag names. xcrun stapler validate target/native/claude-usage-$V.dmg confirms the notarization ticket made it into the disk image before you upload it.

The app is signed with the hardened runtime, which notarization requires. It stays outside App Sandbox because it runs the user's shell and the claude CLI and reads Claude Code's keychain item. Widget builds give the host only an App Group entitlement. The extension is sandboxed and can read only that shared group.

Icon

The Claude Code mark is from thesvg.org (MIT) and lives in assets/app-icon.svg. To regenerate the bundle icon after editing the mark:

python3 scripts/make_icon.py

That renders the mark onto the macOS icon grid, an 824x824 rounded body inside a 1024x1024 canvas, and writes assets/dock-icon.png, the 1024 master the app hands AppKit for the Dock and the app switcher, plus assets/AppIcon.icns, which is what Finder shows on the bundle. Nothing rounds or insets the artwork on the way, so the padding, corner curve, and shadow have to be baked in or the icon sits larger than its neighbours. The corner and shadow constants in the script are fitted to the silhouette macOS applies to its own app icons, within 3px at 1024.

License

This project's source is ISC.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages