agentleFS
Aarf101Aarf101/budgetloop/skills/report-token-budget/SKILL.md

report-token-budget

Skill0 starsChanged 46 days agoMITView on GitHub

Report how a run's token budget was spent from a trace file. Use when a run finished and you need to explain peak versus final tokens, which steps or tools cost the most, or what compaction reclaimed.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    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:

    Read the trace, never invent it: Every number in the report comes from the trace file.

    line 23
  2. Very specific:

    Prefer --json when another tool consumes the answer.

    line 52
  3. Distinctive:

    Start from the template: status, peak versus usable, the biggest step and tool, compaction net, and the one budget change you recommend.

    line 71

≈ “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

Report a token budget

A trace is the evidence a run left behind. This skill turns that evidence into a one-page answer to "where did the budget go", so the next run spends deliberately instead of by accident.

Token counts are a 4-characters-per-token estimate, never a vendor invoice. Compare runs to each other, never to a bill.

Non-negotiables

  1. Read the trace, never invent it. Every number in the report comes from the trace file. An absent field is reported as absent.
  2. Peak decides, final merely remains. Size budgets against peak, not final: compaction can make the final window look cheap.
  3. Name the most expensive step and tool. A report without a biggest spender is a summary, not a diagnosis.
  4. Say what compaction cost and saved. Dropped messages, reclaimed tokens, and the summary's own cost, or the state "no compaction".

Steps

1. Locate the trace

ls -1t .budgetloop/traces | head -5

Traces are generated evidence. Never edit one; copy it first if you must annotate. If there is no trace, re-run with a trace directory instead of guessing.

2. Run the reporter, not your eyes

python skills/report-token-budget/scripts/report_budget.py <trace> [--json]

The script reads one trace and prints the whole breakdown: budget and headroom, per-step growth, per-tool observation cost, and compactions. Prefer --json when another tool consumes the answer.

3. Read the four sections in order

  1. Budget — budget, usable_budget, peak, final, headroom, and utilisation. Over 85% peak utilisation means the next similar run needs a bigger budget or a smaller task.
  2. Steps — which step grew the window most. A single huge jump points at one observation; steady growth points at the task size.
  3. Tools — which tool's observations cost the most characters and which ones failed. Failures still occupy the window.
  4. Compactions — what was summarised away and the net reclaimed. Zero compactions on a tight budget is a finding, not an omission.

Field meanings live in budget fields.

4. Write the verdict in one paragraph

Start from the template: status, peak versus usable, the biggest step and tool, compaction net, and the one budget change you recommend. One paragraph, numbers included.

Output shape

A short report (terminal text or JSON with --json): header, budget, steps, tools, compactions, verdict. No required schema beyond naming the biggest spender and the compaction net.

Edge cases

  • No compactions — say so explicitly; do not leave the section out.
  • Budget-exceeded runs — the overflow step is the finding. Report the fixed cost versus the observation that could not fit.
  • Failed observations — they cost window space too. List them under tools, not as a footnote.
  • Hand-written or partial traces — report which fields are absent rather than filling them with zeros.

Reference

  • Budget fields — where each number comes from in the trace, and what the ledger actions mean.
  • Report template — the verdict skeleton.
  • Script: scripts/report_budget.py — the only reader you need.

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.