tu — agent usage bundle
tu is a command-line tool that reports AI coding-assistant token cost and usage
on the machine it runs on. It reads local usage data (via a vendored ccusage)
and, in multi mode, aggregates across machines through a shared git repo.
This is a usage briefing for an agent operating an installed tu: when to reach
for it, what each command does, how it composes, and how to read its output.
When to use
Reach for tu to answer cost/usage questions about AI coding assistants on
this machine:
- “How much did Claude Code / Codex / OpenCode / Gemini / Copilot / Kimi cost today?”
- Daily, weekly, or monthly spend, as a snapshot or as history.
- Per-machine breakdowns (multi mode) and per-user views.
Do NOT reach for tu for:
- Billing management or payment — it only reports usage, it changes nothing.
- Tools it does not track (only the six sources below).
- Per-request granularity beyond what
ccusageemits —tuaggregates by day.
Capabilities map
Data grammar: tu [source] [period] [display]
- source —
cc(Claude Code),codex/co(Codex),oc(OpenCode),gemini/gem(Gemini),copilot/cop(Copilot),kimi/ki(Kimi); omit forall(default). - period —
d/daily(default),w/weekly,m/monthly. - display — bare = snapshot (current period);
h/history= time series;lb= leaderboard (users ranked by cost/tokens, multi mode);lbh= leaderboard history (period rows x user columns, multi mode). - combined shorthands —
dh(daily history),wh(weekly history),mh(monthly history).
Examples: tu (today, all), tu cc (today, Claude Code), tu h (daily history
pivot), tu cc mh (Claude Code monthly history), tu wh (weekly history),
tu m lb (this month’s leaderboard), tu lbh (daily leaderboard history).
Non-data commands
tu init-conf— scaffold~/.config/tu/tu.conf.tu init-metrics [url]— clone the metrics repo (multi mode); withurl, also writesmetrics_repointo~/.config/tu/tu.conffirst.tu sync— push/pull metrics manually (multi mode).tu status— show config and sync state (reports single vs multi mode).tu update— updatetuvia Homebrew.tu shell-init <bash|zsh|fish>— emit a shell completion script foreval.tu help(or-h/--help) — full help text.tu help-dump— emit a machine-readable help contract (JSON) for tooling.tu skill— print this bundle (agent usage briefing) to stdout.
Composition patterns
- Shells out to
ccusage(vendored) to read local usage data — no separate install needed; a singleccusagebinary serves all six sources. - Shells out to
gitin multi mode to sync per-machine metrics through a shared repo, so cost aggregates across machines. - Shells out to
brewfortu update(Homebrew-installed builds only). - Is shelled out to by shll.ai’s pull cron, which runs
tu help-dumpagainst the installed binary to render tu’s command reference on shll.ai. tu skill(this bundle) also renders at/tu/skillon shll.ai and is the surface a futureshll agent-setupwill aggregate into agent context.
Output & exit-code contract
- stdout is data; stderr is diagnostics. Parse stdout; treat stderr as warnings/errors. Success writes results to stdout with nothing on stderr.
- Exit codes:
0on success;1on operational failure (network, git, Homebrew, missing/misconfigured metrics repo — retry or fix the environment);2on usage error (bad grammar, unknown tool/shell, incompatible flags, bad flag values — fix the command line). - Graceful degradation: when a data source is unavailable,
tuwarns on stderr and falls back to the best available data (cached, local-only, or zero) rather than crashing — so a non-empty stderr can accompany exit 0. - Machine-readable formats (data commands only, mutually exclusive):
--json/-j— JSON.--csv— CSV.--md— Markdown table. Prefer--jsonfor programmatic parsing. Bare output is a formatted table.
Gotchas
- Cached data. Fetches are cached (~60s TTL). Pass
--fresh/-fto bypass the cache and refetch. - Single vs multi mode. Behavior depends on
~/.config/tu/tu.conf(legacy~/.tu.confis read as a fallback with a stderr deprecation warning; an optional~/.config/tu/org.confsupplies org-wide defaults under it): single mode reads only local data; multi mode aggregates across machines via the metrics repo. Runtu statusto see which mode is active.--user/-u(including-u all, which sums every user in the metrics repo from synced data) and multi-machine views apply in multi mode only (warned-and-ignored in single mode). --watch/-wis an interactive TUI (live-refreshing display). Do not invoke it from an agent — it does not terminate on its own and produces no parseable single-shot output.- Use
--no-colorfor clean, parseable output (disables ANSI color codes). - Implicit 3-month cap. Daily and weekly history default to the last ~3
calendar months. Pass
--fullfor the complete history. Monthly history (mh) is never capped. - History-only flags.
--since/-sand--untilbound a history window (YYYY-MM-DDorYYYYMMDD); on a snapshot display they warn and are ignored. Onlbthey replace the period window silently (the Δ column then compares against the equal-length preceding window). - Token mode.
--metric tokens/-trenders history and pivot tables in tokens instead of cost (all displays); the snapshot table keeps its Cost column in dollars — only the watch delta indicator follows the metric. - Leaderboard (
lb/lbh). Multi mode only (exits 1 in single mode) — reads the metrics repo, so today lags untiltu sync(the table footer says so).--top <n>keeps the top N rows (lb, rest collapse into… +k others) or the top N user columns (lbh, rest fold into oneotherscolumn);-u <name>pins/highlights a user rather than filtering;-u allis a no-op;--by-machineranksuser/machinepairs (lbonly — onlbhit warns and is ignored).