Show HN: 用于查看 Claude Code 配额的 macOS 菜单栏仪表盘
Show HN: macOS menu bar gauges for your Claude Code quota

原始链接: https://github.com/grzegorz-raczek-unit8/claude-quota

这款 macOS 的 SwiftBar 插件可在菜单栏中实时监控您的 Claude Code 使用配额。 **主要功能:** * **可视化进度条:** 根据 5 小时窗口的使用情况,为每个账户显示颜色编码进度条(绿/橙/红)。 * **状态指示器:** 当使用窗口耗尽或达到每周上限时,显示重置倒计时。 * **详细视图:** 下拉菜单提供全面的使用统计信息,包括各模型的限制和重置时间。 * **自动发现:** 自动检测 Claude Code 账户,并提供置顶、重命名或隐藏选项。 * **安全轻量:** 直接从 macOS 钥匙串读取 OAuth 令牌(只读);不使用任何第三方服务、密码或网页抓取。 **安装:** 在终端运行以下命令(需要 Homebrew): `curl -fsSL https://raw.githubusercontent.com/grzegorz-raczek-unit8/claude-quota/main/install.sh | bash` **注意事项:** * 每 5 分钟更新一次。 * 首次使用时需要授予钥匙串访问权限。 * 由于它利用了未公开的内部 API,功能可能会受到 Claude Code 未来更新的影响。 * 如果账户显示警告图标,只需运行一次 `claude` CLI 命令即可刷新令牌。

一个名为“Show HN”的新项目提供了一个 macOS 菜单栏小组件,用于追踪 Claude Code 的配额使用情况。该工具解决了开发者普遍面临的一个困扰:Claude Code 本身不显示剩余使用限额,导致任务进行到一半时服务会意外中断。 讨论反映了两个主要观点: * **用户体验:** 开发者希望能够直观地查看配额限制,以避免提示词被意外截断。此外,关于“自动压缩”上下文功能也存在争议——一些用户认为 100 万 token 的窗口既不必要也存在问题,他们更倾向于手动管理上下文,以优化性能和成本。 * **提供商视角:** 评论者推测 Anthropic 可能是有意模糊这些指标,以防止用户“钻空子”利用剩余额度,或以此促使用户升级到更高层级的服务。 总的来说,该讨论突显出开发者对 AI 编程工具中更高透明度及自主上下文管理需求的日益增长。
相关文章

原文

Menu bar gauges for your Claude Code quota — one bar per account, like this:

menu bar screenshot

(drawn for dark menu bars — white outlines)

  • Each bar shows the 5-hour-window utilization for one account, colored green / orange (≥70%) / red (≥90%).
  • When the 5-hour window is fully used, the bar shows a countdown until reset (4:28) instead of the percentage.
  • When the weekly limit is hit, the bar turns black with a countdown to the weekly reset (2D) — that's the harder cap, whatever the 5-hour window says.
  • The dropdown lists full detail for every account inline: 5-hour and weekly windows, per-model windows where your plan reports them, extra-usage credits, and reset times.
  • Refreshes every 5 minutes (SwiftBar filename convention) plus a manual "Refresh now" entry.
curl -fsSL https://raw.githubusercontent.com/grzegorz-raczek-unit8/claude-quota/main/install.sh | bash

Requires macOS and Homebrew. When macOS shows a Keychain permission dialog on the first refresh, click Always Allow.

The plugin reads your Claude Code OAuth token from the macOS Keychain (read-only — it never refreshes or rewrites tokens, so it can't log you out) and queries the same usage endpoint that Claude Code's /usage screen uses. No passwords, no scraping, no third-party services.

Note: that endpoint is internal to Claude Code and undocumented, so a future Claude Code change may require a small fix here.

git clone https://github.com/grzegorz-raczek-unit8/claude-quota.git
cd claude-quota
./install.sh

Either install path sets up SwiftBar via Homebrew if you don't have it. If an account shows ⚠, its token went stale from disuse — run that claude CLI once and the widget recovers on the next cycle.

By default the plugin auto-discovers accounts: every ~/.claude / ~/.claude-* config directory that has a Claude Code Keychain entry gets a bar, labeled by the directory suffix (~/.claude-workW). A single auto-discovered account shows no letter label — just the bar.

To pin or rename accounts (e.g. you use multiple CLAUDE_CONFIG_DIRs), create ~/.config/claude-quota/accounts with one path [label] per line (single-word labels):

~/.claude-work Work
~/.claude-priv Priv

To hide an account's menu bar gauge (its dropdown detail stays), use Hide from menu bar under that account's row in the dropdown — or edit ~/.config/claude-quota/hidden (one label per line).

Multiple accounts via CLAUDE_CONFIG_DIR look like this in your shell rc:

claude()      { CLAUDE_CONFIG_DIR="$HOME/.claude-work" command claude "$@"; }
claude-priv() { CLAUDE_CONFIG_DIR="$HOME/.claude-priv" command claude "$@"; }

Delete claude-quota.5m.py from your SwiftBar plugin folder (~/.swiftbar by default).

联系我们 contact @ memedata.com