refresh-usage

A command that fetches Claude’s seven-day and five-hour usage limits from Anthropic’s OAuth usage service and saves the results.

In plain words
What is it for?
Use it to force-refresh rate-limit information outside the normal automatic hook process.
Why use it?
It provides a manual refresh when automatic updates are stale or when you are debugging usage data. It also refreshes the status-line cache after a successful fetch.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/omrikais/cctally/refresh-usage
Clone the repo
git clone --depth 1 https://github.com/omrikais/cctally
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,868 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01868
Opus 5 $0.00000 $0.00934
Sonnet 5 $0.00000 $0.00374
Haiku 4.5 $0.00000 $0.00187

Measured 2d ago against content hash 18be0b300195, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

refresh-usage scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

docs/commands/refresh-usage.md · 178 lines

How it starts

The opening of the file, as written. The whole thing — 178 lines — stays where its author put it; the contents beside it link to each section on GitHub.

cctally refresh-usage

Force-fetch 7-day and 5-hour rate-limits from the Anthropic OAuth usage API and persist them via the same path record-usage uses.

Normally not needed because cctally hook-tick calls the same OAuth-fetch path automatically. Manual invocation is mostly for force-refresh / debugging.

Difference from hook-tick

refresh-usage busts the status-line cache file (/tmp/claude-statusline-usage-cache.json) on success, so the next status-line tick re-fetches. hook-tick calls a non-busting variant of the same fetch path to avoid interfering with the status-line cache.

User-Agent

cctally refresh-usage sends User-Agent: claude-code/<discovered-version> by default. Anthropic gates the OAuth /usage endpoint behind a per-User-Agent rate-limit; presenting the official Claude Code UA bypasses that gate so the fetch returns 200 instead of 429 during active sessions.

The discovery chain (first hit wins):

  1. Active executable. claude --version 2>/dev/null (5 s timeout), parsed against \d+\.\d+\.\d+(?:-[A-Za-z0-9.]+)?.
  2. Versions directory glob. ~/.local/share/claude/versions/ filtered to semver-shaped entries; highest semver wins.
  3. Frozen sentinel. A pinned fallback version baked into the script.

The default can be overridden via the oauth_usage.user_agent config field — see Honesty mode below.

Flags

  • --quiet — suppress text output
  • --json — emit structured envelope
  • --color {auto,always,never} — color discipline
  • --timeout N — HTTP timeout (default 5s)

Exit codes

Code Meaning
0 Success or rate-limited (graceful fallback emitted)
2 No OAuth token (run claude once to authenticate)
3 Network / HTTP failure (non-429)
4 Malformed response
5 record-usage failure

A 429 response from the OAuth usage API is not an error from the user's perspective — there is no actionable retry without changing UA. The command serves last-known data from weekly_usage_snapshots, prints a freshness indicator, and exits 0. See the next section for the exact output shape.

Read the full file on GitHub · 178 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 178 lines · 0 tokens per session scan A 18be0b300195

Subscribe to this mod's changes

refresh-usage is a command published in the GitHub repository omrikais/cctally (5 stars, last pushed 3d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 1,868 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.