Documentation
TokenBuild is a plugin for Claude Code. It handles the work that shouldn't cost tokens, such as reading logs, finding files and re-sending long chats, with plain code on your machine. It comes as three products: Token Saver cuts the tokens each task uses, Team Build plans the work and coordinates every Claude on a team, and ML Validation and Economics learns from your repo's history to check the work and prove what each saving is worth.
This page is the overview. The Help manual covers everything in depth.
Download the full manual (PDF)129 pages · 2.7 MB
Quick start
You need Claude Code with a Claude Pro, Max, Team or Enterprise plan, or an Anthropic API key. TokenBuild never asks for your Claude login.
- See your waste (free, no account). In a terminal, run
npx tokenbuild audit. It prices the avoidable waste in the session logs Claude Code already keeps on your machine. Nothing is uploaded. - Start your trial. Create an account and choose Solo or Team. The 30-day trial costs $5, credited to your first payment. See Pricing.
- Install. Open your CLI key page, create a key and copy the one line shown for your system:
- Windows: paste it into PowerShell.
- Mac or Linux: paste it into Terminal.
npx tokenbuild install <key>does the same. - Restart Claude Code. The plugin's hooks, tools and skills load when Claude Code starts.
- Check it. In Claude Code, type
/tokenbuild:setup, or runnpx tokenbuild doctorin your repo. Either one shows your plan, what's on in this repo and the one thing to do next. - Work as usual. There's nothing new to learn: TokenBuild works through Claude Code's hooks. Your dashboard updates every 30 minutes while a session is open, and again when it ends.
Updating. Run npx tokenbuild release update, or in Claude Code's terminal claude plugin marketplace update tokenbuild then claude plugin update tokenbuild@tokenbuild. Restart Claude Code afterwards.
What happens in a session
TokenBuild runs one small process per Claude Code event. Hooks finish in milliseconds and never wait on the network.
| When | What TokenBuild does |
|---|---|
| Session starts | Refreshes the repo index in the background. Injects the project state (decisions, recent work, what's open) after /clear, or the handoff note if one is waiting. Runs the weekly setup check. |
| You send a prompt | Adds a short brief: likely files with line numbers, the tests to check and past fixes there. Adds the budget forecast with an 80% range, saved answers that are still valid, and a learned tip. Offers a fresh start first if the prompt cache expired on a huge conversation. When you ask to push or ship, it adds the change's risk. |
| Claude reads or searches | Waste Guard blocks lockfiles, build output and huge whole-file reads. The Context Ledger answers repeat reads of unchanged lines with "already in your context", or with only the lines that changed. Next-Read offers the outlines of the files that usually come next. |
| Claude edits | Edit Preflight syntax-checks the edit before it lands. The Verify Loop runs the tests that edit can affect, in the background, and reports one line. |
| Claude runs a command | Noisy test, build and lint output is condensed to the errors and a summary; the full log stays in .tokenbuild/logs. A command that fails the same way three times triggers the Loop Breaker. |
| Claude finishes a reply | Formats edited files with your own formatter. Records decisions. Warns once if a task is heading for trouble (early warning), runs far past its budget, or the conversation has grown big enough that a fresh start is cheaper. |
| Session ends | Closes the last task so it is measured, then sends the session's counts to your dashboard. |
The three products
Every TokenBuild feature belongs to one of three products, and each product has its own command group: tokenbuild save, tokenbuild team and tokenbuild learn. The older single-word commands still work. Most features run by themselves through Claude Code's hooks with nothing to type. See the command reference for every command.
| Product | What it does | Commands |
|---|---|---|
| Token Saver | Keeps what wouldn't help out of Claude's context, cuts what Claude writes, avoids wasted turns, and counts every token saved. | save |
| Team Build | Keeps the goal, plan and decisions outside the conversation, plans projects, and coordinates every Claude on a team. | team |
| ML Validation and Economics | Models trained on your repo's own history check the work and decide where tokens pay off, and prove it. | learn |
1. Token Saver
Commands: tokenbuild save (run, index, map, find, pack, docs, boost, ask, handoff, profile, tune, stats, meter, sync, autosync).
Read less
- Waste Guard: stops reads of lockfiles, generated and vendored files, and oversized whole files before they enter context.
- Output Shrinker: Claude sees the errors, code frames and summary of noisy commands; the full log stays on disk (
save run). - Context Ledger: tracks what Claude has already read this session and never sends unchanged lines twice.
- Repo Index and context packs: a local map of symbols and imports. Claude asks for exact files and lines with
tb_find,tb_mapandtb_packinstead of searching. - Task Brief: likely files, related files, the check to run and past failures fixed there, on every prompt. A vague request gets one clarifying question first.
- Next-Read: when Claude opens a file, the outlines of the files usually opened next are already there.
- Exploration Memo: answers about your repo are reused while the files behind them are unchanged.
- Docs Oracle: library docs at the version you installed (
save docs <symbol>,tb_docs). - Fingerprints: every error is remembered with the files that fixed it; when it comes back, Claude starts at the fix.
- Local Boost (optional): a model on your own machine (Ollama) reads big files and logs for Claude (
save boost,save ask). - Model routing: helper agents, including TokenBuild's scout, run on a lighter model so your chosen model does the hard thinking.
Write less, waste fewer turns
- Anchor Edits and Codemod Mode: change lines by number without writing the old code out again; one call for the same change across many files.
- Edit Preflight: every edit is syntax-checked before it lands, so a broken edit comes straight back with the error.
- Loop Breaker: stops repeated identical failures and edits that keep undoing each other.
- Fresh Start and Context GC: past about 100K tokens, or when most of a conversation is dead weight, a short handoff note lets you
/clearand continue from about 2K tokens (save handoff,save profile). - Adaptive Fresh Start (0.20.1): every 5 prompts (any interval from 1 to 10000,
save fresh --every N), a learned model recommends/clearor continuing normally and says why. It learns from the measured tokens per reply after each decision and from whether you followed it. - Cache Keeper: after a long break, offers a small fresh start before a huge conversation is re-cached.
- Tool Diet, CLAUDE.md Compiler, Permission Learner: unused MCP servers, folder-only instructions and commands you always approve, found and fixed (
save tune diet|claudemd|permissions; add--apply).
Measure
- Savings ledger: every token kept out of context, counted tool by tool (
save stats). - Real Meter: exact tokens and cost per task from Claude Code's own usage records (
save meter). - Dashboard sync: every 30 minutes during a session and when it ends (
save sync);save autosync onkeeps the dashboard current with no session open.
2. Team Build
Commands: tokenbuild team (task, state, preflight, autopilot, plan, relay).
For every developer
- Task State and Project State: goal, plan, verified facts and decisions, so a new session or subagent resumes in seconds, and parallel agents claim plan items so they never overlap (
team task,team state,tb_task). - Project Preflight: plans a project before you start: files, tests, estimate, dependencies and stages for each step (
team preflight "<goal>",tb_preflight). - Autopilot budgets: a token budget split across planning, coding, testing and correction, learned from the most efficient similar tasks here (
team autopilot "<task>").
On Team plans
Team plans add Team Relay and the Team dashboard. Each teammate installs TokenBuild as in the quick start.
- Create the team. Choose the Team plan at signup, or open the Team dashboard on a Solo plan and upgrade. Your existing subscription is prorated.
- Invite people. In People, choose Invite people and send the link or code. Teammates can also ask to join with the owner's email. Every request waits for an admin, who approves it as coder or viewer.
- Set roles. Admins approve requests, change roles, invite people, set the Team Relay level and manage billing. Coders add, assign and finish plan items, set dependencies, specs and stages, hand off tasks and add projects. Viewers see the board, plans, people, handoffs and savings. The owner is always an admin, and whoever adds a project is its admin.
- Turn on level 2 (Overview → Team Relay). It shares task goals, the plan, saved answers and handoff notes. The board, plans and handoffs need it. Level 1 shares only names, branches, edited file paths and error hashes.
- Add projects. New project takes a name, the code repo link and a link to project files. It lines up with teammates' sessions in that repo automatically.
- Plan the work. Add items to a project's plan. Set after # for dependencies, assign people, and write a spec for each item (done when, constraints, files to start with). Items group into stages by their dependencies.
- Deploy stages. Deploy stage sends each ready, assigned item to its person's next Claude prompt as a staged task, with its spec. Turn on auto to send the next stage once everything in the current one is done and verified. Each teammate can also run
tokenbuild team plan runto work through their ready items with Claude Code. - Hand off. Pass a task from the dashboard (Handoffs) or a session (
tokenbuild team relay send <name>). The teammate's next Claude prompt in that repo starts from your state, and they're emailed from tasks@tokenbuild.ai. - Connect GitHub (Admin, optional). A repository or organization webhook adds pull requests, review blockers and CI states, linked to plan items and sessions. Metadata only, no token, no code access.
- Watch the Conflict Radar and the brief. The Overview lists prioritized actions, each with its evidence and owner. The radar flags overlapping changes, shared high-risk modules, conflicting ownership and out-of-order work. Act on an alert, or dismiss it with a reason.
- Keep team knowledge. Decisions a Claude session states arrive as drafts. Once an admin approves them, they reach every session in that repo (Team Knowledge).
- Hand off with a contract.
team relay send <name> --contractdrafts the nine-field handoff from local state. Review it in Agents & Sessions, and it's sent verified only with fresh passing tests. - Run experiments, carefully (0.20.3). Admins propose a workflow change, approve it and let it run for half the team. An independent Judge decides with a 95% interval, and a kill switch stops everything. The Engineering graph, evidence grades and a research delivery forecast are in Work & Planning.
- Use the insights. The dashboard flags likely collisions before the first edit, teammates on coupled code who never coordinate, at-risk tasks and who could help. It suggests dependencies and assignees (accepting or dismissing a suggestion teaches it) and shows pooled estimate accuracy, who knows what, and which parts of a handoff note save the most.
Team Memory. Everyone's Claude learns from the whole team's history on the same repo: which files tasks change and which errors they fixed. Only file paths, counts and one-way hashes are shared.
Two Claudes can't claim the same plan item: the second claim is refused, and the work it didn't repeat is credited as a coordination saving, as is a picked-up handoff.
3. ML Validation and Economics
Commands: tokenbuild learn (verify, risk, proof, replay, recipes, shape; learn alone shows what it learned).
Code validation: tests
The Verify Loop runs only the tests an edit can affect, picked from your import graph, in the background, with one line back (learn verify, tb_verify). It supports Vitest, Jest, node --test, pytest and go test. Any other runner works with "verify": "your command {files}" in the config.
- Predictive test selection: from this repo's test history, how likely each test is to fail for the files just changed. Skipping is token-aware: a test is skipped only when its risk times the rework it could cause costs less than running it, so in practice everything runs. To skip low-risk tests and save time instead, set
"testSelect": "time"(combined risk under 2%; the report says how many were skipped). - Learned check order: the riskiest tests per second run first; if they fail, the rest wait.
- Flaky tests: a failure is rerun once. A test that then passes with no change is reported as flaky, so Claude doesn't spend a fix cycle on it.
- Risk-expanded checks (0.20.4): when the whole pending change is high risk, nothing is skipped and the run covers the tests of every changed file.
"riskExpand": falseturns it off. - Turn these off with
"testSelect": falseand"flakyRerun": false.
Code validation: before you ship
- Change risk:
tokenbuild learn risk, or ask Claude to push, merge or ship. It shows how likely the change is to need a revert or follow-up fix, learned from what happened after past changes here, with the reasons and what to run first.learn risk --install-hookprints it before everygit push(it never blocks the push). - Learned pre-deploy checks: the checks that caught failures in these folders before.
- Production incidents:
learn risk --incident "<error message>"shows the files that fixed this error before and the recent work there. - Drift:
tokenbuild learnflags areas of the codebase that have become more expensive to work in.
Project economics
- Proof, with a control group: about 10% of sessions run with one feature held off, so each feature's effect is measured, not claimed (
learn proof). Each effect has a 95% interval; only one that excludes no effect is credited, at the interval's low end. Otherwise it reads "insufficient evidence". Opt out with"holdout": 0. - Three tiers, never added together:
save statsshows measured use (Real Meter), estimated avoided text (the parts can overlap, and it isn't a bill saving) and proven savings, plus TokenBuild's own overhead and break-even against your plan fee. - Overhead budget:
save overheadmeasures each hook's latency against the 50 ms rule and the context hooks add. At most"nudgeBudget"messages per session (default 5) are shown to you. - Budget forecasts: what similar tasks cost, with an 80% range, and an early warning at 30% of the budget when a task looks headed for trouble.
- Replay: compares ways of working (plan first, scout, impacted tests and more) on this repo's history, ranked by tokens to a verified result (
learn replay). The cheapest is a recommendation only when its interval against the next excludes no difference; otherwise "insufficient evidence". - Recipe Compiler: verified work you repeat becomes a versioned skill for your repo: 3+ verified tasks at 60%+ confidence. It is retired when it doesn't save, verifies less, is reopened, goes unused for 90 days or its source tasks age out (
learn recipes). - Repo Shape Optimizer: which files cost Claude the most to read, and a plan to split or co-locate them (
learn shape). Guardrails hold back security-sensitive, generated, lock, migration and config files; untested hotspots get tests first; plans move code only and revert on failure.
How TokenBuild learns
All learning runs on your machine, from this repo's own measured tasks. Run tokenbuild learn to see what it has learned; tokenbuild learn --reset clears it (measured tasks are kept).
- What it optimizes. Tokens to a verified result. A task that ends on a failing check, edits without ever passing a check, or gets reopened within 48 hours pays a rework penalty. Saving tokens by giving up early never counts as a win.
- Which help to give. For each kind of task, it learns whether the brief and next-read are worth their tokens, and how many likely files the brief should list. It uses Thompson sampling, first per kind of task, then on the task's context once that approach has proven better. Every decision is logged with its probability.
- Unbiased comparisons. Doubly robust off-policy evaluation estimates what "always on" or "always off" would have scored, without the bias of comparing tasks that happened to differ.
tokenbuild replaycompares strategies the same way and ranks them by tokens to a verified result. - Task kinds. A classifier learns, from what tasks actually turned out to be, whether a request is a question, fix, feature, refactor or test.
- File ranking. The brief's file list is re-ranked by a model trained on which files tasks here really opened or edited.
- Budgets. Forecasts and Autopilot budgets (
tokenbuild autopilot "<task>") come with an 80% conformal range. At 30% of its forecast, a learned early warning judges whether a task is heading for trouble and tells you once. - It checks itself. Every learned policy runs in shadow until it beats the default off-policy with 95% confidence. The brief is held back when this repo's briefs at that confidence are usually wrong. A feature whose "off" tasks verify clearly less often is never turned off again in that repo. When forecasts start missing (a new codebase area, teammate or Claude model), exploration widens until the models catch up. Verify Loop, Edit Preflight and the Context Ledger are never turned off by learning.
- Starting points from everyone. A new repo starts from statistics pooled across TokenBuild users (task counts and how tasks did against their forecasts), the main evidence for the learner. Each machine sends only its own figures, with random noise added before sending (differential privacy, ε = 1 per release, at most one release a week), plus each feature's estimated effect, also noised and rounded; nothing else is shared. Turn this off with
"shareLearning": false. - Field measures (0.20). Whether finished work held up: V-op (tests linked to the edited files passed after the last edit), V-dur (changed lines that no later fix touched, at 48 hours and 7 days) and task counts per kind and arm, computed locally from a per-edit log that never leaves your machine. Only the counts sync (
"shareField": false= off). - Evolved flags on trial (0.20). Candidate behavior changes that passed the benchmark gate run in a share of sessions (
"trial", default 10%) and are compared on vs off before a person promotes or retires them. None ship in 0.20.0, so it behaves like 0.19.1.
Configuration
Settings live in .tokenbuild/config.json at the root of each repo. They're all optional.
| Setting | Default | What it does |
|---|---|---|
holdout | 10 | Percent of sessions that hold one feature off for the savings proof. 0 = off. |
learn | true | The learning layer (policies, tips, brief size). false = fixed behavior. |
briefSize | learned | Pin the number of likely files in the brief. |
brief, memory | true | false turns off the Task Brief, or Repo Memory and the brief. |
autopilot, earlyWarn | true | Budget split and its warnings; the early warning. |
verify | auto | A test command with {files}, or false to turn off the Verify Loop. |
verifyFull | auto | The full-suite command for tb_verify scope "full". |
testSelect, flakyRerun | "tokens", true | Predictive test selection (learned order; token-aware skipping, "time" to skip for speed, false off); rerun-on-failure for flaky tests. |
briefGate | 0.75 | Hold the brief back when its calibrated chance of naming the right file is below this; false = always show. |
risk | true | The change-risk line when you ask to push or ship. |
handoff, handoffAt | true, 100000 | Fresh Start, and the conversation size (tokens) at which it's offered. |
shareDecisions, experiments | false, true | Share this machine's stated decisions as Team Knowledge drafts (consent); take part in team workflow experiments. |
adaptiveFresh, freshEvery, freshMin | true, 5, 20000 | Adaptive Fresh Start; how often it decides (1–10000 prompts); the smallest conversation it advises on (tokens). |
cacheKeeper | true | Offer a fresh start before re-caching a huge conversation after a break. |
syncEvery, syncOnEnd | 30, true | Minutes between dashboard syncs during a session (0 = off); sync at session end. |
shareLearning, shareFingerprints | true | Cross-user priors (noised counts); global fingerprints (hashes and config file names). |
shareField, trial | true, 10 | Send field measure counts (V-op, V-dur, turnover); percent of sessions that trial an evolved flag (none ship in 0.20.0). |
teamMemory, relay | true | Team plans: shared Repo Memory; Team Relay for this repo. |
autoTune | false | true applies the weekly setup check's findings instead of only suggesting them. |
boost | false | Local Boost (set with tokenbuild boost on). |
Privacy in short
Your code, file contents, prompts and Claude conversations never leave your machine. Sync sends counts: per-tool daily totals, per-task token totals for the savings proof, noised learning counts, and one-way error hashes with the names of well-known config files that fixed them. On Team plans, teammates also see file paths, branches and, at level 2, task goals and plan titles. Full details are in the Privacy Policy and on the Security page.
Help and troubleshooting
- The tb_ tools or skills don't show up.
- Restart Claude Code after installing or updating. Then run
/tokenbuild:setup; it names what's missing. - "No active plan".
- Check Billing. Then run
npx tokenbuild login <key>with the key from your CLI key page. Without a plan, every hook steps aside and Claude Code works as normal. - The Verify Loop never reports.
- It needs a supported runner (see Testing) and test files it can link to your code through imports or matching names. Set
"verify"for anything else. - The dashboard looks out of date.
- It syncs every 30 minutes during a session and when a session ends. Run
npx tokenbuild syncto send now. - A learned behavior doesn't suit you.
- See it with
tokenbuild learn, clear it withtokenbuild learn --reset, or pin it with the settings above. - Uninstall.
- In Claude Code's terminal, run
claude plugin uninstall tokenbuild@tokenbuild. Delete the.tokenbuildfolder in a repo to remove its local data.
More: the command reference, the FAQ, and contact (support@tokenbuild.ai). Toki, the assistant in the corner of every page, answers common questions instantly.