克劳德用法
跟踪Claude使用窗口、费率限制和API运行状况。固定到shell提示符、tmux和Claude Code状态栏上。
显示促销乘数(2倍非高峰时段等)、5小时和7天费率限制使用情况,包括重置倒计时、上下文窗口填充、每日/每周代币总额、会话成本和Anthropic API状态,以及每个组件的健康和事件详细信息。
配置驱动。 新的促销活动开始了 ~/.claude/usage-windows.json。无需更改代码。
它是什么样子的
克劳德代码状态栏(低使用率-紧凑型):
⚡ 2x OFF-PEAK ends in 7h 59m
Opus 4.6 (1M context) │ ctx 6% │ d 123k │ w 890k │ ~$4.51 ($6.00/h) │ 5h 9% │ 7d 1%Claude Code状态栏(使用率高——带有节奏标记的栏):
⚡ 2x OFF-PEAK ends in 7h 59m
Opus 4.6 (1M context) │ ctx ███████░ 85% │ d 123k │ w 890k │ ~$19.09 ($8.33/h) │ 5h ██▊████░ 92% ↻23m │ 7d ████░┊░░ 45%这 ▊ 和 ┊ 标记显示了均匀使用的位置。如果填充超过标记,则燃烧速度比平均速度快。
状态检查:
$ claude-usage
🟢 API: All Systems Operational (just now)
🟢 Off-peak (standard) (1x usage)
Ends in: 1d 16h
Promo: Peak Hours Session Limit Adjustment (ongoing)跨时区日程安排:
$ claude-usage schedule
Peak Hours Session Limit Adjustment
Peak: mon, tue, wed, thu, fri UTC 13:00 – 19:00
City Peak start Peak end
──────────────── ────────── ──────────
San Francisco 6:00 AM 12:00 PM
New York 9:00 AM 3:00 PM
London 1:00 PM 7:00 PM
Tokyo 10:00 PM 4:00 AMAPI降级(带有事件详细信息):
$ claude-usage api-status
🟠 API: Partially Degraded Service (just now)
⚡ Elevated error rates on Claude API [major]
↳ Claude API: partial_outageAPI降级(通过直接探测检测到5xx):
$ claude-usage api-status
🟠 API overloaded (529)推迟决定:
$ claude-usage defer large
✅ PROCEED: large at 2x (already in favorable window)安装
自制:
brew tap abhay/tap
brew install claude-usage外壳安装程序(macOS/Linux):
curl -fsSL https://raw.githubusercontent.com/abhay/claude-usage-rs/main/install.sh | sh来源:
cargo install --path .设置
claude-usage init写入 usage-windows.json,注册状态行,并设置MCP服务器。如果你有多个 ~/.claude* 目录, init 自动查找并配置所有这些。
要使用最新的嵌入式默认值更新现有配置,请执行以下操作:
claude-usage init --force要针对特定实例:
CLAUDE_CONFIG_DIR=~/.claude-work claude-usage init命令
claude-usage # human-readable status (includes API health)
claude-usage schedule # peak/off-peak times across timezones
claude-usage watch # monitor status changes with desktop notifications
claude-usage api-status # check Anthropic API status (status page + direct probe)
claude-usage label # compact PS1/Starship token: ⚡2x
claude-usage tmux # tmux status bar segment
claude-usage statusline # Claude Code status bar (reads JSON from stdin)
claude-usage json # machine-readable JSON
claude-usage windows # list all configured windows
claude-usage defer large # should I defer this task? (small|medium|large|xl)
claude-usage wait # block until a favorable window opensShell 集成
Zsh/Bash (.zshrc / .bashrc):
PROMPT='$(claude-usage label 2>/dev/null) %n@%m %~ %# '星舰 (starship.toml):
[custom.claude_usage]
command = "claude-usage label"
when = true
format = "[$output]($style) "
style = "bold green"终端复用器 (~/.tmux.conf):
set -g status-right '#(claude-usage tmux) | %H:%M'
set -g status-interval 60阻挡,直到2x开始:
claude-usage wait && claude "refactor the auth module"MCP服务器(克劳德代码集成)
Claude可以通过MCP在任务中期检查使用窗口:
{
"mcpServers": {
"claude-usage": {
"command": "claude-usage",
"args": ["mcp"]
}
}
}或者跑 claude-usage init 自动注册。
可用工具:
should_defer_task:返回给定任务大小的推迟/继续建议
添加促销
编辑 ~/.claude/usage-windows.json 并输入一个条目:
{
"id": "anthropic-summer-2026",
"label": "Summer 2026 Promo",
"description": "2x usage on weekends",
"source": "https://support.claude.com/...",
"active_range": {
"start": "2026-06-01T00:00:00Z",
"end": "2026-06-30T23:59:59Z"
},
"tiers": [
{
"id": "weekend",
"label": "Weekend (2x)",
"multiplier": 2.0,
"favorable": true,
"schedule": {
"type": "recurring",
"days": ["sat", "sun"],
"utc_start": "00:00",
"utc_end": "23:59"
}
},
{
"id": "weekday",
"label": "Weekday (1x)",
"multiplier": 1.0,
"favorable": false,
"schedule": {
"type": "recurring",
"days": ["mon", "tue", "wed", "thu", "fri"],
"utc_start": "00:00",
"utc_end": "23:59"
}
}
],
"plans": ["pro", "max", "team"]
}计划类型
| 类型 | 它做什么 |
|---|---|
recurring | 匹配特定工作日+UTC时间窗口 |
inverse_recurring | 匹配一切 *外面* 循环窗口 |
always | 始终匹配(整个促销活动的扁平倍数) |
平台支持
macOS和Linux。目前还不支持Windows。
许可证
麻省理工学院
