pbtop is a terminal dashboard for people who use Claude Code. It shows token use, estimated cost and your usage limits by day, model, project and session.
- You want to see what your sessions cost, and which models and projects cost most.
- You want to know how far along you are against a Claude plan limit or a budget you set.
- You want a number for a script:
--jsonand--summaryprint the same data.
pbtop
playbook usageBoth run the same code. playbook usage comes with Playbook. pbtop is the same dashboard as its own program: the Homebrew formula of playbook links it, and the install guide shows how to install it alone.
The terminal view opens on this month compared with last month, unless --range or a saved range says otherwise. Without a terminal, or with --summary, it prints a text summary instead.
| Flag | What it does |
|---|---|
--range <name> |
Picks the range: today, week, last-week, month, last-month, 30d, 60d, 90d or all. |
--summary |
Prints the text summary and exits. It covers every recorded session unless you give --range. It masks the account when the header does (o or usage.maskAccount). |
--json |
Prints the totals, the groups and the live view as JSON. The default range is 30d. |
--utc, --local |
Group days and show times in UTC or in your local zone. Local is the default. |
The screen needs at least 80 columns and 24 rows. Below that it says so and draws nothing else. The pictures here use 150 columns and 44 rows, and show sample data.
Every tab has a header with the range, the cost, the tokens and the messages. For today, this week and this month it compares them with the previous period. The header also carries the budget, beside the comparison on a wide screen and under it on a narrow one. When it stacks, the comparison takes one row. The tab bar sits under the header. F1 to F3 pick a tab, and the default layout has three.
Charts. Every chart, two to a row. The Hourly chart shows the cost of each of the last 24 hours with the total in its title. It has no data in the sample, because the sample sets no limit.
Numbers. The models table, the live sessions and the sessions per day. Live sessions have a message in the last 15 minutes. Each limit in the header also says when it reaches the limit at the current pace, so a separate Projection panel is gone.
Breakdown. Skills first, then agents and tools, then health and projects.
Help. ? opens a window that lists every key. It scrolls when the screen is short.
Layout editor. e opens a window to add, move and remove tabs and panels. Each change applies and saves at once. The usage.ui.layout key holds the result.
Adding a panel takes one action: press a, choose the panel and press Enter. The panel lands in the next free place, and the tab arranges itself. A tab holds up to 8 panels, and the editor refuses a ninth with a message. The budget is not a panel: it is part of the header, which every tab shows, so the editor does not offer it. A saved layout that lists budget loads and skips the word; a tab left empty is dropped.
A tab with no row layout of its own draws this grid, which the editor edits as it is:
| Panels | Rows | Why |
|---|---|---|
| 1 | one full panel | The whole body for one panel. |
| 2 | two stacked, each full width | Live and Sessions are tables that want the width. |
| 3 | a pair, then one full width | Two small panels over one that gets the width. |
| 4 | 2 by 2 | Four equal panels. |
| 5 | 2, 2, then one full width | Rows of two, and the odd last one takes the row. |
| 6 | 2, 2, 2 | Three rows of two. |
| 7 | 2, 2, 2, then one full width | Four rows. |
| 8 | 2, 2, 2, 2 | Four rows of two. |
A tab keeps its own rows only when you set them with f (split or join a row) or when the stored value has a |. Then adding fills the last row that has room, opens a new row while the tab has fewer than 4, and otherwise fills the first row with room. Old stored layouts load and save as written.
A short screen keeps every row at 5 lines or more. When the rows do not fit, the tab draws the rows that do and hides the panels of the others. The footer then says how many panels are hidden and how many screen rows show all of them, for example 2 panels hidden, 28 rows show all. The header is never left out, so the panels give way to it. At 150 by 44 every count from 1 to 8 fits.
Budget window. b asks for a manual monthly budget in dollars. Enter saves it to usage.budget.monthlyUsd, and 0 clears it.
Full screen Sessions list. p opens a table of recent sessions with their state, repo, branch, worktree, pull request link, last activity and cost. It uses the same records as playbook sessions. It only reads: nothing here changes a session. It asks gh for each branch, so it re-reads every 30 seconds instead of every 5.
The table comes from the same list as the help window, so it lists every key.
Navigation
| Key | What it does | Where |
|---|---|---|
1 to 6 |
Focus a panel by its number | all panels |
Tab |
Show the next tab | all panels |
Shift-Tab |
Show the previous tab | all panels |
F1 to F12 |
Show a tab by its number | all panels |
] |
Focus the next panel of the tab | all panels |
[ |
Focus the previous panel of the tab | all panels |
Down, j |
Select the next row | tables |
Up, k |
Select the previous row | tables |
PgDn |
Move five rows down | tables |
PgUp |
Move five rows up | tables |
Home, g |
First row, or first day of a chart | tables, charts |
End, G |
Last row, or last day of a chart | tables, charts |
Left, h |
Move the chart cursor one bar back | charts |
Right, l |
Move the chart cursor one bar forward | charts |
Periods
| Key | What it does | Where |
|---|---|---|
W |
Show last week | all panels |
M |
Show last month | all panels |
r |
Cycle today, this week, this month, all | all panels |
z |
Switch between local time and UTC | all panels |
Views
| Key | What it does | Where |
|---|---|---|
v |
Next view of the focused panel | Spend, Projects |
t |
Next color theme (off with NO_COLOR) | all panels |
o |
Mask the account email, and save it | all panels |
p |
Open the full screen Sessions list | all panels |
e |
Edit the tabs and the panels on each | all panels |
? |
Show this help | all panels |
i |
Toggle every limit's figures and notes | header |
Sorting
| Key | What it does | Where |
|---|---|---|
s |
Sort by the next column | tables |
S |
Reverse the sort order | tables |
Filtering
| Key | What it does | Where |
|---|---|---|
u, U |
Next account; U shows all, or the newest | all panels |
x |
Next machine, then all machines | all panels |
/ |
Type a filter on any field | all panels |
Enter |
Filter to selected row; again to undo | tables 3-6 |
c |
Clear the filter | all panels |
Refresh
| Key | What it does | Where |
|---|---|---|
R, B |
Read usage and budget limits now | all panels |
b |
Set the manual monthly budget | all panels |
X |
Delete usage history, asks to confirm | all panels |
Quit
| Key | What it does | Where |
|---|---|---|
q, Esc |
Quit | all panels |
Ctrl-C |
Quit, also while typing a filter | all panels |
Marks
| Key | What it does | Where |
|---|---|---|
~ |
Tools: count only, from transcripts |
From any other range, r goes to the stop after the closest one. --range takes every range.
- Claude Code transcripts. The session files under
~/.claude/projects, or under$CLAUDE_CONFIG_DIR/projectswhen that variable is set. Every total comes from these. - Codex rollouts. The files under
~/.codex/sessions, read the same way. - The OpenTelemetry receiver.
playbook usage collectlistens on127.0.0.1only, on port 47318 by default. If another program holds that port on the first run, it picks a free one and keeps it. It feeds the cost per agent and per skill, tool timings and the health view. pbtop reads a session that sends nothing to it from transcripts. Totals ignore the receiver's rows.
Unless you turn on usage sync, nothing leaves your machine. The receiver stores no prompts, tool content, paths, emails or user ids.
Claude Code hides the names of skills from non-official plugins ("plugin skills (names hidden)"). Setup asks whether to show them (usage.toolDetails). See what it sends.
Both tools keep their data in one file: ~/.config/playbook/data/usage.db. It holds the events read from transcripts, one row per assistant message, with the model, the effort, the repo, the branch, the account, the token counts and the cost. It also holds tool calls, the telemetry tables, the machine row and the tables that usage sync fills.
The file has a schema version, stamped when it opens. SCHEMA_VERSION in crates/telemetry/src/db.rs is the current one, and an older build refuses a database that a newer one stamped. Events stay after Claude Code prunes its old sessions. To wipe the history, press X. It asks first, and the next read starts over from the transcripts.
Each row carries the id of the computer that wrote it. The id is a random version 4 UUID, made from 16 random bytes on first use and kept in the one-row machine table of usage.db. It does not come from a path or a hostname, so renaming the machine keeps it. The name defaults to the hostname and shows as the machine name in the dashboard.
playbook usage machine
playbook usage machine --name laptopThe first line shows the id and the name. The second sets a name, and an empty name restores the hostname.
pbtop uses the cost Claude Code reports through telemetry, matched by request id, and adds requests only telemetry saw. Transcripts carry no cost, so it estimates every other message from a copy of the LiteLLM price list that ships with pbtop. For an estimated message:
cost = (input x in + output x out
+ cache write 5 min x in x 1.25 + cache write 1 hour x in x 2
+ cache read x in x read share) / 1,000,000
Here in and out are the model's dollars per million input and output tokens, and read share is its cache read price as a share of in. The table also has the higher price some models charge for a long prompt.
An estimate is at API prices, not what a plan bills. For a model the table lacks, pbtop learns a rate from three telemetry requests. Without them the model shows as unpriced in the header border, --summary and --json. The header marks estimates: ~$451 (estimated), or ~$451 (12% estimated) when telemetry covers the rest.
The budget part of the header compares your use with a limit. It has up to four rows, three on a narrow screen, and only the rows with data are drawn. i shows all of them. The N notes, i border hint shows only when i reveals them.
Monthly c ████│█████████░░░░░░░░░░░░░░░░░░░ 24% $120 of $500 ▲ hits it in 6d 13h resets in 27d (Thu 10-01)
Monthly left $380 pace +17pt allow $0.57/h $13.61/d proj $1,736 resets Thu 10-01 00:00 UTC cached 10m ago
Spend h this week $3.05 █████░░░░░ last week $6.21 ██████████ -51% avg $0.04/h $0.99/d
Each limit is one row: its name, a letter for its source, a bar that grows with the screen, the percent used, the amount, a verdict and the time left. The bar reddens as it fills. The │ mark on the bar (| without UTF-8) is where you should be by now, the share of the period that has passed. A bar that runs past the mark is ahead of pace and a bar that stops short of it is behind. When the screen is narrow, pieces drop in this order: the date, the amount, the countdown, the time to the limit. The bar, the percent and the verdict stay.
The verdict is a mark and a word, colored by state. The marks are ▲, ◆, ● and ○, and !, ~, + and ? without UTF-8, so the state reads without color.
| Verdict | Meaning |
|---|---|
reached |
The limit is used up. |
hits it |
At the average pace the limit is reached before the period ends. The time follows, as in hits it in 2d 4h. |
close |
The projected total lands between 80 percent and the limit. |
ok |
The projected total stays under 80 percent. |
too early |
Under one hour of the period has passed, so there is no projection. |
After the verdict, safe means neither pace reaches the limit before it resets. hits it in 7d (24h) means the pace of the last 24 hours reaches it even though the average does not. stale 7h says the reading is old.
The line under the worst limit holds the figures that need a table, in columns: left, pace (the points ahead or behind the mark), allow per hour and per day, proj (the projected total), avg per hour and per day, the full reset time with its time zone, and where the number comes from. Press i to show that line for every limit, with the full text of any notes where the spend line was.
The spend line compares the spend of the period with the previous one over the same elapsed span, as two bars on one scale, the change in percent and the average rate.
The letter after the name says where the limit comes from:
m, measured: the 5 hour and weekly windows of a Pro or Max plan, from therate_limitsdata that Claude Code passes to the Playbook statusline. Behind a Claude apps gateway it can also hold a dollar limit.c, cached: usage numbers that Claude Code keeps in its own config file, with how old they are. Only a few plan and usage fields are read.u, manual: the dollars you set inusage.budget.monthlyUsdorusage.budget.weeklyUsd.h, local history: the spend line, estimated from your session transcripts.
The figures line spells the source out, for example manual, local or cached 1d 22h ago, plus this machine since.
A limit that Claude Code reports wins over a manual budget. A manual monthly budget covers the calendar month in your chosen time zone, and the spend is the estimated cost from your history. A weekly budget starts on the day in usage.weekStart. With no limit at all, the header shows an empty bar and says to press b.
Notes about the numbers go in one dim line, or in the bottom border of the header as a count when there is no room for the line. They are a missing 5 hour or weekly window, a manual budget beside a detected one, and the figure Claude Code last reported. Press i to read each in full. --json carries the same text.
The time to the limit needs at least one hour of elapsed time in the period. The internals page has the math, and playbook usage doctor lists which limit sources exist on this machine.
A background thread owns the database. It reads new transcript lines and re-reads the store every 5 seconds. It also reads at once when you change the range or the filter, and when you press R or B. A refresh keeps your cursor, focus, sorts and selected rows. The footer shows when the last read happened. A first read of a large history runs in small batches, and the screen shows the store as it grows.
Live means a session whose last message is no older than 15 minutes.
| Key | Default | What it does |
|---|---|---|
usage.theme |
default |
The color theme. Choices are default, spectrum, dark, light and mono. t cycles them. |
usage.weekStart |
monday |
The first day of the week. |
usage.timeZone |
local |
local or utc. |
usage.telemetry |
auto |
off stops Playbook from pointing sessions at the receiver. |
usage.priceRefresh |
auto |
off stops the daily price download. |
usage.budget.monthlyUsd |
0 |
A manual monthly budget. 0 means none. |
usage.budget.weeklyUsd |
0 |
The same for the week. |
usage.ui.layout |
empty | The tabs and panels, up to 8 panels per tab. Empty means the three default tabs. |
Set one with playbook config set --global usage.theme dark. The config keys page has the rest. Three environment variables matter too:
PLAYBOOK_TELEMETRY_TZsets the zone,localorutc. A flag beats it, and it beatsusage.timeZone.NO_COLORforces themonotheme.CLAUDE_CONFIG_DIRmoves where transcripts are read from.
The standalone program reads the same usage.db and settings. It starts no collector and has no session records, so the Sessions list is empty. Run pbtop collect to collect telemetry.
Usage sync is an opt-in preview that copies usage rows between your own machines through a database you own. See the sync guide. Once machines have synced, the dashboard reads a merged view. Spend, tokens, models, budget, projection and burn-up count every machine. The live view, agents, skills, tools, health, sessions and projects follow the machine you pick. x picks the next machine and then all machines.
- The numbers look low or stale. Run
playbook usage statusto see whether the receiver runs and how many telemetry rows exist. - A limit looks wrong. Run
playbook usage doctor. Its output has no email, name or token, so you can share it. - The screen is blank or too small. Use at least 80 columns by 24 rows.
- A model shows no price. The table lacks it.
--summarynames it.