Skip to content
Skills Library
AI & agents · Review & audit

token-audit

/token-audit

Measure and cut what an AI session costs in tokens: what it loads before its first tool call (CLAUDE.md, the AGENTS.md it imports, skill listings), which sections are large, stale or repeated in every repository, and, for a finished session, where its tokens actually went (the context of the first request, the tools called most, the largest results). Use it whenever agent files are written, reviewed or refactored (AGENTS.md, CLAUDE.md, CONTEXT.md, a skill), when someone says a session was expensive, slow to start or ran out of context, before attaching many repositories to one session, when de

Repository
skills ↗
Licence
LGPL
Last repository change
13.11.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
29
Scripts
10
HTML comments
0
URLs in SKILL.md
1
Deprecation

No signals detected. Repository changed on 13.11.2026, without references to retired models or APIs.

Licence

LGPL, otwarta.

What to check before installing
  • 10 scripts in this package. Review them before installing, as Claude may execute them.

Scripts: evals/heavy-agents-file/graders/01.sh, evals/heavy-agents-file/graders/02.sh, evals/heavy-agents-file/graders/03.sh, evals/heavy-agents-file/graders/04.sh, evals/heavy-agents-file/graders/05.sh, evals/heavy-agents-file/place-files.sh, evals/where-tokens-went/graders/01.sh, evals/where-tokens-went/graders/02.sh, evals/where-tokens-went/graders/03.sh, evals/where-tokens-went/place-files.sh

What it does and when to use it

Measure and cut what an AI session costs in tokens: what it loads before its first tool call (CLAUDE.md, the AGENTS.md it imports, skill listings), which sections are large, stale or repeated in every repository, and, for a finished session, where its tokens actually went (the context of the first request, the tools called most, the largest results). Use it whenever agent files are written, reviewed or refactored (AGENTS.md, CLAUDE.md, CONTEXT.md, a skill), when someone says a session was expensive, slow to start or ran out of context, before attaching many repositories to one session, when de

Original author description

Measure and cut what an AI session costs in tokens: what it loads before its first tool call (CLAUDE.md, the AGENTS.md it imports, skill listings), which sections are large, stale or repeated in every repository, and, for a finished session, where its tokens actually went (the context of the first request, the tools called most, the largest results). Use it whenever agent files are written, reviewed or refactored (AGENTS.md, CLAUDE.md, CONTEXT.md, a skill), when someone says a session was expensive, slow to start or ran out of context, before attaching many repositories to one session, when de

How it works

  1. 1. Measure what a session loads
  2. 2. Decide what each section is
  3. 3. Read where a session's tokens went
  4. 4. Turn findings into changes
  5. 5. Report
  6. What not to do
Original SKILL.md headings · 135 lines, 1,268 words
SKILL.md preview
---
name: token-audit
description: "Measure and cut what an AI session costs in tokens: what it loads before its first tool call (CLAUDE.md, the AGENTS.md it imports, skill listings), which sections are large, stale or repeated in every repository, and, for a finished session, where its tokens actually went (the context of the first request, the tools called most, the largest results). Use it whenever agent files are written, reviewed or refactored (AGENTS.md, CLAUDE.md, CONTEXT.md, a skill), when someone says a session was expensive, slow to start or ran out of context, before attaching many repositories to one session, when deciding what belongs in an always-loaded file and what in a document read on demand, and when work a model repeats by hand should become a script. Use it even if the user only says the agent files feel long or asks why a chat used so many tokens. Script first: token_audit.py prints sizes and counts, so no transcript or file content enters the context."
license: MIT OR GPL-2.0-only
compatibility: Needs python3. Reads local files only and sends nothing anywhere. With skills.sh (npx skills add) the wrapper clones swarm-routing/skills to find tools/token-audit/token_audit.py (git and network access to github.com the first time; later runs refresh the clone and fall back to it when offline); SKILLS_TOOLS_DIR=<checkout> avoids it.
metadata:
  author: swarm-routing
  repository: https://github.com/swarm-routing/skills
---

# token-audit

Everything a session loads at its start is sent again with every request it
makes. A file that costs 7,000 tokens once costs 700,000 over a hundred
requests, in every session, for everyone. So the cheapest token is the one
that is not in an always-loaded file, and the second cheapest is the one a
script reads instead of the model. This skill finds both.

```bash
SKILL="$CLAUDE_PLUGIN_ROOT/skills/token-audit"   # as the Claude Code plugin
# installed with skills.sh (npx skills add): SKILL=<the directory this SKILL.md is in>
"$SKILL"/scripts/token-audit files .                      # what a session in this repository loads
"$SKILL"/scripts/token-audit files ../ARA ../Termite .    # several repositories attached to one session
"$SKILL"/scripts/token-audit files . --budget AGENTS.md=12000 --budget-loaded 16000   # as a gate: exit 1 when over
"$SKILL"/scripts/token-audit transcript <session>.jsonl   # where a finished session's tokens went
```

Inside a `swarm-routing/skills` checkout, `python3 -I
tools/token-audit/token_audit.py` is the same. Both commands take `--json`.

Two kinds of number come out, and a report must keep them apart:

- **`files` gives estimates.** Bytes are exact; tokens are bytes divided by
  3.5. A token count is specific to a model, and only that model's token
  counter gives the exact figure. The estimate is good for comparing files
  and for budgets, not for a bill. Do not send files to any service to count
  them: this skill works offline on purpose.
- **`transcript` gives measurements.** They are the usage the API reported
  for each request of the session.

## 1. Measure what a session loads

Run `files` on the repository, or on every repository the session will have
attached. Read, in this order:

1. **The total loaded at session start.** This is the fixed cost of every
   request. With several repositories it adds up: each one's files are loaded
   whether the task needs that repository or not.
2. **The largest sections.** A section is a `## ` heading and what follows it.
3. **The notes on each section.** `managed <block>` is text between
   `org-sync:begin/end` markers: the same in every repository, owned by a
   template. Dates and issue numbers mark status, the text that goes stale.
4. **Read on demand.** Markdown files the loaded ones link to. They cost
   nothing until a session opens them, which is where long material belongs.
5. **Sections identical in more than one repository** (with several
   repositories). That text is paid for once per repository attached.

## 2. Decide what each section is

For every large section, ask what a session loses if the text is not in front
of it from the first request. That gives four kinds:

| Kind | Test | Where it goes |
|---|---|---|
| Always needed | it changes how the agent behaves on any task here: an invariant, a rule that is easy to break, where the build and the checks are | stays, as short as it can be said |
| Needed for some tasks | a tool catalogue, a long how-to, a table of where things are, background and history | a document under `docs/`, with one line left behind that says **when** to read it |
| Status | dated sentences, "merged in #N", what is planned or in progress | out of the agent files: an issue, an epic, or a generated page. Status in prose is wrong within days, and a wrong line costs more than a missing one |
| Org-managed | between `org-sync` markers | not edited here. Change the template in `swarm-routing/.github` `templates/`; a per-repository edit is undone by the next sync and fails its check |

The line left behind is what makes the split work. "See docs/tools.md" tells
a session nothing; "Before changing a workflow or a release script, read
docs/tools.md (every tool, its commands and its self-test)" tells it when the
cost is worth paying. A pointer with no condition is either always followed,
which saves nothing, or never, which loses the content.

Nothing is deleted on size alone. A rule that moves keeps its words and gets
a pointer; a rule that goes is named in the summary with the reason.

## 3. Read where a session's tokens went

For a session that felt expensive, slow or that ran out of room, run
`transcript` on its JSONL file (Claude Code keeps one per session under
`~/.claude/projects/<project>/`; a subagent's transcript is its own file, and
several files can be given at once; the script reads a `.jsonl` file under the
current directory or `~/.claude`, and `--root DIR` names another place). Never open the transcript itself: it is
the whole session, and reading it costs what the session cost. The script
prints sizes, counts and a 60-character summary of each call's input.

- **Context of the first request**: the cost of starting, before any work. If
  it is large, section 1 says why.
- **Largest context, and requests**: a session's input cost is roughly its
  context times its requests, so a long session with a large context is the
  expensive shape. Splitting the work, or handing a narrow task to a subagent
  that reports a summary, changes it.
- **Per tool: calls and bytes of results.** A tool called dozens of times
  with small variations is a loop the model is running by hand. The script
  lists these as candidates for a script or a data file.
- **Largest results**: whole files read where a range or a search would do,
  or a command printing more than was needed.
- **Calls repeated with identical input**: something read twice.

## 4. Turn findings into changes

- **Agent files**: one PR per repository for its own sections. Run `files`
  before and after and put both totals in the PR.
- **Org-managed text**: one PR to the template, with the before and after of
  one repository and the number of repositories it applies to.
- **A loop the model ran by hand**: an issue for a script, with the tool, the
  number of calls and the bytes from the transcript audit as its evidence. A
  script that prints a summary replaces the calls for every later session
  (AntHocNet ADR-0014: raw data stays out of the context; the model reads a
  verdict).
- **A budget**: once a file is the size it should be, `--budget` keeps it
  there. Propose the number from the measurement; whether it becomes a gate
  is the maintainer's decision.

## 5. Report

Give the result in this shape, so two audits can be compared:

```
Loaded at session start: <bytes> bytes, about <tokens> tokens (estimate) -> <bytes> after
Largest sections: <section, bytes, kind> ...
Moved on demand: <what> -> <file>, read when <condition>
Status removed: <what>, now at <issue or page>
Not touched: <org-managed blocks>, to change through <template>
Session (measured): first request <tokens>, largest context <tokens>, <n> requests
Candidates for a script: <tool>, <calls> calls, <bytes> bytes
```

Leave out the lines that do not apply. Say "estimate" next to every token
figure that came from `files` and "measured" next to those from `transcript`.

## What not to do

- Do not shorten a rule until it stops being one. "Wire formats are
  versioned" is shorter than the rule and does not say what to do.
- Do not move an invariant out of the always-loaded file to meet a budget:
  raise the question instead. The budget serves the rules, not the reverse.
- Do not treat a smaller file as proof of a better one. If the repository has
  an onboarding eval (questions a fresh session must answer from the agent
  files), run it before and after; if it has none, say that the cut was not
  checked that way.
Files in this package (29)
  • SKILL.md 9 KB
  • evals/heavy-agents-file/case.yaml 1 KB
  • evals/heavy-agents-file/place-files.sh 1 KB
  • evals/heavy-agents-file/prompt.md 1 KB
  • evals/heavy-agents-file/files/AGENTS.md 7 KB
  • evals/heavy-agents-file/files/CLAUDE.md 1 KB
  • evals/heavy-agents-file/files/Makefile 1 KB
  • evals/heavy-agents-file/files/docs/README.md 1 KB
  • evals/heavy-agents-file/files/docs/wire.md 1 KB
  • evals/heavy-agents-file/graders/01.sh 1 KB
  • evals/heavy-agents-file/graders/02.sh 1 KB
  • evals/heavy-agents-file/graders/03.sh 1 KB
  • evals/heavy-agents-file/graders/04.sh 1 KB
  • evals/heavy-agents-file/graders/05.sh 1 KB
  • evals/heavy-agents-file/graders/06.md 1 KB
  • evals/heavy-agents-file/graders/07.md 1 KB
  • evals/where-tokens-went/case.yaml 1 KB
  • evals/where-tokens-went/place-files.sh 1 KB
  • evals/where-tokens-went/prompt.md 1 KB
  • evals/where-tokens-went/files/session.jsonl 125 KB
  • evals/where-tokens-went/graders/01.sh 1 KB
  • evals/where-tokens-went/graders/02.sh 1 KB
  • evals/where-tokens-went/graders/03.sh 1 KB
  • evals/where-tokens-went/graders/04.md 1 KB
  • evals/where-tokens-went/graders/05.md 1 KB
  • evals/where-tokens-went/graders/06.md 1 KB
  • evals/where-tokens-went/graders/07.md 1 KB
  • evals/where-tokens-went/graders/08.md 1 KB
  • scripts/token-audit 5 KB

Versions

RepositoryScoreLicence
This page · swarm-routing/skills100LGPL
FlorianBruniaux/claude-code-ultimate-guide100CC-BY-SA-4.0
dreamlab-ai/agentbox100AGPL-3.0
BooneAndrewsLab/claude-plugins100MIT
kreht1/anchor100MIT
Er2oneousbit/claude-code-game-kit86MIT
estebanmr99/lean-agents86MIT

Database snapshot: 13.11.2026 · package version d5e81017845d (SHA-256 digest of the entire package)

Downloads in the last 30 days: 1 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100context-cost
    Measure how many tokens your coding agent reads before you type anything (CLAUDE.md and AGENTS.md chains, imports, memory files, always-on Cursor rules, skills and MCP servers), find what is stale, duplicated or only needed in one folder, and show how much each cut saves. Use…
  • 100context-audit
    Audit and clean up what Claude Code loads into every session — CLAUDE.md/memory files, skills, agents, slash commands, plugins, MCP servers, hooks — and show how much context each costs per request and how often it was actually used. Use when the user wants to tidy, slim down,…
  • 100tokens
    Measure and cut what Claude Code spends. Finds session-start context, CLAUDE.md and memory size, skill and MCP listings, per-prompt hook text, cache misses, big tool outputs and unused plugins. Use when asked about token use, context bloat, cost, running out of context, Claude…
  • 100claude-token-audit
    Show where Claude Code tokens and usage limits go, from the local session logs in ~/.claude/projects. Breaks usage down by project, session, day, model and tool, finds the biggest tool outputs flooding the context, measures cache hit rate and peak context per session, sizes what…
  • 100context-rent
    Find out what is eating the context window and token budget of Claude Code and Codex CLI sessions, and fix it. Use when the user asks why they hit usage limits, why sessions get slow or expensive, where their tokens go, how to save tokens, whether their CLAUDE.md, AGENTS.md or…
  • 84audit
    When the bundled explain-usage skill resolves in this session, prefer it for where this session's tokens went; this skill for startup cost before any work, per-tool attribution, and whether a settings change saved anything. Use when: 'what is eating my context window at…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.