查询你的 Claude Code 使用额度

粘贴 Claude Code 状态栏看到的 JSON,或手动填写数字——以下计算全部在你的浏览器中完成,不会上传到任何地方。

1. 粘贴你的状态栏 JSON

整个状态栏对象,或者只粘贴其中的 rate_limits 部分——都可以。

2. 或者手动填写数字

会填补你上面没有粘贴的那个窗口;也可以额外输入最近的消耗速度估算。

5 小时窗口



7 天(每周)窗口



你的用量窗口

5 小时窗口

请粘贴 JSON,或在上方手动填写数字。

7 天(每周)窗口

请粘贴 JSON,或在上方手动填写数字。

如果你等的是 7 天窗口重置而不是全局重置?可以看看值不值得等重置,以及Banked Reset的已知信息。

一段可直接使用的状态栏脚本

在 Claude Code 状态栏中直接显示 5h: X% · 7d: Y% · reset odds 24h: Z%

读取 Claude Code 自身的 rate_limits JSON 获取前两个用量数字,第三个数字来自本站的预测 API——本地缓存 10 分钟,网络超时 2 秒,网速慢也不会卡住你的提示符。

#!/bin/bash
# claudereset.org example Claude Code status line script.
# Install: save this as ~/.claude/statusline.sh (chmod +x), then set it as your status line
# command per https://code.claude.com/docs/en/statusline — Claude Code pipes the status line's
# JSON into this script's stdin on every prompt render.
#
# Shows your own Claude Code usage (5-hour and 7-day windows, straight from the status line's own
# `rate_limits` object) plus this site's live 24h global-reset-odds forecast. The forecast fetch
# is cached locally for 10 minutes (by file mtime) and capped at a 2-second timeout, so a slow or
# unreachable network never blocks your prompt — it just falls back to showing only the usage
# figures.
set -u
input=$(cat)

# rate_limits is only present for Pro/Max subscribers (or a spend-limited gateway), and only
# after the session's first API response — `// empty` makes jq print nothing rather than "null"
# when it's absent, per code.claude.com/docs/en/statusline's own example.
FIVE_H=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // empty')
WEEK=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty')

LINE=""
[ -n "$FIVE_H" ] && LINE="5h: $(printf '%.0f' "$FIVE_H")%"
[ -n "$WEEK" ] && LINE="${LINE}${LINE:+ · }7d: $(printf '%.0f' "$WEEK")%"

CACHE="$HOME/.cache/claudereset-forecast.json"
mkdir -p "$(dirname "$CACHE")" 2>/dev/null

# 10-minute local cache, judged by the cache file's own mtime (works with either BSD or GNU stat).
CACHE_AGE=999999
if [ -f "$CACHE" ]; then
  MTIME=$(stat -f %m "$CACHE" 2>/dev/null || stat -c %Y "$CACHE" 2>/dev/null || echo "")
  if [ -n "$MTIME" ]; then
    CACHE_AGE=$(( $(date +%s) - MTIME ))
  fi
fi

if [ "$CACHE_AGE" -ge 600 ]; then
  if curl -s -m 2 https://claudereset.org/api/v1/forecast.json -o "$CACHE.tmp" 2>/dev/null; then
    mv "$CACHE.tmp" "$CACHE" 2>/dev/null
  else
    rm -f "$CACHE.tmp" 2>/dev/null
  fi
fi

P24=$(jq -r '.p24 // empty' "$CACHE" 2>/dev/null)
if [ -n "$P24" ]; then
  LINE="${LINE}${LINE:+ · }reset odds 24h: ${P24}%"
fi

echo "$LINE"

保存为 ~/.claude/statusline.sh,执行 chmod +x,然后将其设为你的状态栏命令——详见官方状态栏文档。也可在/developers/查看。

为什么某个窗口可能是空的

  • rate_limits 只对 Claude.ai Pro 和 Max 订阅用户(或使用有消费限额网关的用户)展示,且要在本次会话第一次收到 API 响应之后才会出现。
  • five_hourseven_day 这两个窗口可能各自独立地不出现在 JSON 中。
  • 一旦某个窗口自己的重置时间已过,Claude Code 就会把它从状态栏中移除。
  • 读取这项数据需要 Claude Code v2.1.251 或更高版本。

来源