record-usage

A command that records Claude Code usage percentages and reset times from the status line, instead of fetching them through OAuth.

In plain words
What is it for?
Use it to feed weekly and five-hour usage data into cctally, especially when you want to avoid OAuth API calls.
Why use it?
It avoids OAuth requests and uses information Claude Code already provides. It can run in the background so updating the status line is not delayed.

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/record-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 922 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.00922
Opus 5 $0.00000 $0.00461
Sonnet 5 $0.00000 $0.00184
Haiku 4.5 $0.00000 $0.00092

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

Security

Grade A, and why

record-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/record-usage.md · 102 lines

How it starts

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

Optional: status-line integration (no OAuth API calls)

record-usage is now an opt-in alternative to the default hook-based integration installed by cctally setup. Use it if you specifically want to avoid OAuth API roundtrips and prefer your usage data to come from the status-line stdin Claude Code already provides.

To wire it up, add this snippet to your ~/.claude/statusline-command.sh (after parsing week_pct/week_resets/five_pct/five_resets from the status-line JSON):

if [ -n "$week_pct" ] && [ -n "$week_resets" ]; then
    record_args="--percent $week_pct --resets-at ${week_resets%.*}"
    if [ -n "$five_pct" ] && [ -n "$five_resets" ]; then
        record_args="$record_args --five-hour-percent $five_pct --five-hour-resets-at ${five_resets%.*}"
    fi
    cctally record-usage $record_args &
fi

Trailing & matters — record-usage runs in the background so it never blocks the status-line render.

Both paths (status-line snippet and the default hook integration) can run simultaneously; the record-usage funnel dedupes correctly.


record-usage

Record a usage-percent snapshot from the Claude Code status-line rate_limits data. Writes to weekly_usage_snapshots and, if the snapshot crosses a new integer percent, also to percent_milestones.

Cost coverage: Cumulative Claude costs stored on percent and five-hour milestones are transcript-derived lower bounds, not exact /usage billing totals.

Synopsis

cctally record-usage
    --percent PERCENT
    --resets-at RESETS_AT
    [--five-hour-percent FIVE_HOUR_PERCENT]
    [--five-hour-resets-at FIVE_HOUR_RESETS_AT]

Purpose

This is the ingestion end of the data pipeline. It is not meant to be called interactively — your status-line script calls it after every status render so the SQLite snapshot history stays fresh.

When to use it

  • Wired into ~/.claude/statusline-command.sh. See installation.md.
  • Manually replaying a missed snapshot if your status-line script crashed (rare; the cost is one missing data point).

Read the full file on GitHub · 102 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 · 102 lines · 0 tokens per session scan A a14f056b88b1

Subscribe to this mod's changes

record-usage is a command published in the GitHub repository omrikais/cctally (5 stars, last pushed 4d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 922 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.