agentleFS
getpapigetpapi/papi/skills/usage-reporter/SKILL.md

usage-reporter

Skill11 starsChanged 3 months agoMITView on GitHub

Report the token usage of a build to PAPI from your AI client's own local transcript. Optional. Use when completing a build and you want tokens recorded, or when asked what a task or stage cost in tokens. Reads only numeric usage, never prompts or responses.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run the script with that window (optionally with the stage windows):

    line 23
  2. Very specific:

    If the result has "notRecorded": false, pass its buildExecute object into the completing build_execute call as input_tokens, output_tokens …

    line 30

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

usage-reporter

PAPI cannot see how many tokens a build used: the MCP call only sees its own request, and a model cannot read its own usage. The numbers exist in your AI client's local transcript. This skill sums them for a window and hands you the three numbers build_execute already accepts.

It is optional. If it cannot run, complete the build normally: tokens are recorded as Not recorded, never as 0 and never estimated.

What it supports today

ClientSourceStatus
Claude Code~/.claude/projects/<project path with dashes>/*.jsonlVerified. Every assistant message carries input, output, cache read and cache creation tokens, a timestamp and the model.
OpenCode~/.local/share/opencode/opencode.db, table messageVerified (task-4842). Each assistant row has input, output, reasoning, cache read and cache write tokens, a millisecond timestamp and the model id. Run node .claude/skills/usage-reporter/scripts/opencode-usage-report.mjs --from <iso> --to <iso>. It covers every OpenCode session on the machine, not only this project. Needs Node 22+ (node:sqlite).
Codexnot verifiedCodex was not installed on the machine checked, so no real transcript was available. No reader is shipped for it; it reports Not recorded until one is confirmed.

How to use it

  1. Note the build window: started_at when you called build_execute to start, and the time you complete it.
  2. Run the script with that window (optionally with the stage windows):
node .claude/skills/usage-reporter/scripts/usage-report.mjs \
  --from 2026-10-14T09:00:00Z --to 2026-10-14T11:30:00Z
  1. If the result has "notRecorded": false, pass its buildExecute object into the completing build_execute call as input_tokens, output_tokens and cache_read_tokens. If "notRecorded": true, pass nothing.

Stage calls (plan, review_submit, release, strategy_review): each of these tool responses ends with a line naming the time the next window opened. On your next stage call, run the script with --from <that time> --to <now> and pass its buildExecute object, your model and window_started_at as the optional stage_usage argument. The server stores it on that call, so no one runs anything by hand and nothing is estimated.

Per-stage totals: pass --stages '{"plan":["<iso>","<iso>"],"build":[...],"review":[...],"release":[...]}' using the plan, build, review and release tool-call timestamps. Stages are assigned in order without overlap; whatever falls outside every stage is reported as unassigned, so the stages plus unassigned always equal the window total.

What input_tokens means

input_tokens is every prompt token that was not read from cache: the model's input_tokens plus cache_creation_input_tokens. cache_read_tokens is the cached part, kept apart because it is billed very differently. Totals are session windows: any other turns inside the window are counted too, and this is not a per-call figure.

Privacy: exactly what is read and what leaves the machine

  • Read, locally: for each assistant record only the numeric usage fields, the timestamp, the message id and the model name. Prompts, responses, file contents and tool output are never read into the result or printed.
  • Printed: one JSON object with token counts and the model name.
  • Leaves the machine: nothing, unless you copy input_tokens, output_tokens and cache_read_tokens into the build_execute call yourself. Those three integers are the whole payload, validated and capped by the server.
  • The script makes no network call.

Caveats

  • The transcript format is not a public contract. The script checks every record and degrades to Not recorded on anything unfamiliar.
  • Claude Code writes a streamed message several times with the same message.id. The script keeps the last record per id; summing every line would roughly double the output tokens.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.