How to Check Claude Code Token Usage and Cost
Quick answer
| Goal | What to run or open |
|---|---|
| Check token usage and cost for this session | /usage in Claude Code (/cost and /stats are the same command) |
| See plan limits (Pro, Max, Team, Enterprise) | /usage — usage bars, d/w for 24h vs 7d breakdown |
| Keep usage visible while you work | Configure a status line (/statusline or statusLine in settings) |
| See why tokens exist before your first prompt | /context — system prompt, CLAUDE.md, skills, MCP listings |
| History across sessions on this machine | ccusage, or PromptConduit reading ~/.claude/projects/ (transcript layout) |
| Authoritative billing (API / Console) | Claude Console Usage page |
To see Claude Code token usage in the active session, run /usage: the Session block lists input, output, cache read, and cache write tokens per model with an estimated dollar total. For history across sessions, use a tool that reads the local JSONL transcripts in ~/.claude/projects/, such as ccusage (terminal reports) or PromptConduit (per-prompt cost in your editor, tagged with repo and branch). For the invoice itself, the Claude Console Usage page is the source of truth.
The rest of this guide compares those options, walks through a local setup, and explains how to read the numbers, especially the cache columns, which usually account for most of the tokens in a long session.
The options compared
| Tool | Where the data comes from | Granularity | Cost shown? | Repo / branch attribution | Local only? |
|---|---|---|---|---|---|
/usage in Claude Code (/cost and /stats are aliases) | The running session’s API responses | Current session, per model | Yes, estimated at list price (or your org’s configured rates) | No | Yes |
| ccusage | Local Claude Code JSONL files | Daily, weekly, monthly, per session, 5-hour blocks | Yes, USD | Per project with --instances | Yes |
| Claude Console | Anthropic billing | Organization and workspace; daily per-user metrics via the Claude Code dashboard and Analytics API | Yes, billed usage | No (per user, not per repo) | No, hosted by Anthropic |
| PromptConduit CLI + editor extension | Local transcripts and hook events | Per request, per prompt, per session, per model | Yes, API-equivalent USD | Yes: repo, branch, commit, open PR | Yes on the Free tier; cloud history is opt-in |
Notes on each:
/usage. Anthropic’s cost docs say the Session block shows API token usage for the current session and is “intended for API users”; on Pro and Max the session cost figure “isn’t relevant for billing purposes.” Totals reset when/clearstarts a new session (before v2.1.211 they kept accumulating across/clearfor the life of the process). On v2.1.251 or later the Session block also has aPrompt cache (main)line: request count, share of input tokens served from cache, misses, expected rebuilds after compaction, and whether the cache is warm. From v2.1.260 it can name a likely cause for the last miss, such as changed tool definitions. It covers the main conversation only, not subagents.- ccusage. A CLI you run with
bunx ccusage,pnpm dlx ccusage, ornpx ccusage@latest. It reportsdaily,weekly,monthly,session, andblocks, tracks cache creation and cache read tokens separately, and also reads other agents’ local data (Codex, Gemini CLI, and more). It is a strong choice if you want reports in the shell. - Claude Console. If you authenticate Claude Code with a Console account, a “Claude Code” workspace is created automatically, and you can set workspace spend limits. This is where you reconcile invoices. It is not designed to tell you which git repo or prompt produced a spike.
- PromptConduit. Prices every API request locally against a bundled rate card and shows it in the editor status bar, so you see the cost before you send the next prompt. It also works for Cursor and several other agents (see supported tools).
Check plan limits, not just dollars
If you sign in with a Pro, Max, Team, or Enterprise plan, the number you usually care about is how much of your limit is left, not a dollar total. /usage shows that on the same screen as the Session block: plan usage bars, activity stats, and a breakdown that attributes recent usage to skills, subagents, plugins, and individual MCP servers, with recommendations such as trimming a large CLAUDE.md. Per Anthropic’s cost docs, the figures are approximate and computed from session history on the current machine, so usage from other devices or claude.ai is not included.
On Team and Enterprise plans, usage draws from a per-seat allowance that resets on a rolling five-hour window and a weekly window, shared with Claude chat and Cowork. Messages such as “You’ve hit your session limit” or “You’ve hit your weekly limit” mean one of those seat windows is exhausted; Anthropic treats them as shared across models, so /model does not restore access until the window resets. A separate model-family cap (for example Opus-only) can sometimes be cleared by switching models, which is a different limit. To continue past the allowance where usage credits are enabled, run /usage-credits — Pro and Max subscribers land in Settings → Usage on claude.ai; Team admins manage credits in the org console.
When /usage says it is rate limited
Plan limits come from a separate request, and it can fail when the usage endpoint is rate limited. /usage then shows the last bars it loaded on this machine within the past 60 minutes, labelled Showing last-known usage. A message like rate limited until 3:14am means Claude Code cannot fetch your limits again until then, not that your work with Claude is limited. Press r after that time to retry.
Act on the breakdown
On a subscription plan, each recommendation row in /usage starts with the share of your recent usage it applies to (at least 10%), for example 25% Trim ~/code/api/CLAUDE.md · 49k tokens per request. That share says how much of your usage the row touches, not how much the change saves, and one request can count toward several rows, so shares can add up to more than 100%. When the footer shows a hint like f to fix 2 of 3 (v2.1.305 or later), pressing f runs any /effort command shown and asks Claude to propose the other changes it can make, showing each before it edits. Rows that say run /compact need you to run the command yourself. Recent versions also add a Loops row for the heaviest /loop or other session-scoped scheduled tasks (v2.1.242 or later), which matters because a loop fires on its interval even while the session is idle and resends your full context each time.
The /usage usage-credits row, when usage credits are on, shows your spend for the current month against any spend limit you or your organization set. Manage credits with /usage-credits.
See usage across sessions and over time
/usage is scoped to one session plus a 24-hour or 7-day plan window. For longer history, three things work, and they answer different questions:
| Question | Where to look |
|---|---|
| What did I do and where did it go wrong? | /insights writes an HTML report of up to 200 recent sessions to ~/.claude/usage-data/report.html. It is a report on how you work, not a token total, and it spends tokens from your plan or API usage. Reports are deleted on the cleanupPeriodDays schedule (30 days by default) |
| How many tokens per day, month, or project on this machine? | Read the local transcripts: ccusage (daily, monthly, session, blocks) or PromptConduit |
| How do I stream token and cost numbers into my own dashboard? | Claude Code’s OpenTelemetry export, below |
/stats is another alias for /usage that opens on the Stats tab, so it is the quickest place to look at activity stats.
Export token and cost metrics with OpenTelemetry
Claude Code can emit metrics through OpenTelemetry on any setup (subscription, Console, or a cloud provider). To print them to the terminal first, as a check before you point them at a collector:
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_METRICS_EXPORTER=console
export OTEL_METRIC_EXPORT_INTERVAL=1000 # 1 second, for debugging
claude
Token counts arrive as claude_code.token.usage, with a type attribute of input, output, cacheRead, or cacheCreation (input excludes cache tokens), and dollars as claude_code.cost.usage in USD. Both carry attributes such as model, session.id, and user.id. Switch OTEL_METRICS_EXPORTER to otlp and set OTEL_EXPORTER_OTLP_ENDPOINT to send them to a collector. The OpenTelemetry cost export post covers that setup, and Anthropic’s monitoring docs list every metric.
Team and organization usage
If you are the admin rather than the developer, where you look depends on how your team signs in. This is summarized from Anthropic’s cost docs:
| Your setup | See spend | Per-user reporting |
|---|---|---|
| Claude for Teams or Enterprise | Spend report in org analytics (estimated spend per user and per model, updated daily; covers usage-credit spend, not usage inside the seat allowance) | Spend report CSV; Enterprise Analytics API on Enterprise |
| Claude Console (API) | Console Cost page | Claude Code dashboard and the Claude Code Analytics API |
| Bedrock, Google Cloud, or Foundry | Your cloud billing console | OpenTelemetry or an LLM gateway; Anthropic’s analytics dashboards do not cover this usage |
For budgeting, Anthropic reports an average of about $13 per developer per active day and $150-250 per developer per month across enterprise deployments, with costs below $30 per active day for 90% of users. Those are API-rate figures for planning, not a forecast for your team; start with a pilot group. If your organization pays contracted rates, an admin can set the modelPricing managed setting (v2.1.242 or later) so /usage, the status line, and OpenTelemetry report at those rates instead of list price. None of the above attributes spend to a git repo or pull request, which is the gap the spend attribution post covers.
Show usage continuously with a status line
/usage is a snapshot. To keep numbers on screen, add a status line. Claude Code runs the command you configure and pipes session JSON to it on stdin. This inline version prints the model and context percentage:
{
"statusLine": {
"type": "command",
"command": "jq -r '\"[\\(.model.display_name)] \\(.context_window.used_percentage // 0)% context\"'"
}
}
Put it in ~/.claude/settings.json, or run /statusline and describe what you want. Fields from the status line docs worth knowing:
| Field | Meaning |
|---|---|
cost.total_cost_usd | Estimated session cost, at list price unless an admin configured rates. Resets on /clear |
context_window.used_percentage | Share of the context window used, from input tokens only (output tokens excluded) |
context_window.current_usage | Token counts from the last API call: input, output, cache creation, cache read |
rate_limits.five_hour.used_percentage, rate_limits.seven_day.used_percentage | Plan limit consumed, 0 to 100. Present only for Pro and Max subscribers, after the first API response |
Handle absent fields with a fallback such as // empty in jq, since each can be missing early in a session.
While Claude works, the spinner line can also show a live output token count for the current turn (for example ↓ 5.5k tokens). That number grows as the model streams and resets each turn; it does not include your prompt or cached context. Session totals still come from /usage.
Why tokens are used before you type anything (base context)
Claude Code sends your whole conversation with every request, and each tool call triggers another request carrying its results. The base context loaded before your first message includes the system prompt, tool definitions, CLAUDE.md, and skill and MCP listings — not a fixed token count you can look up (Anthropic does not publish one number; it changes with version and model). Run /context to see what fills the window today. Anthropic’s cost guidance is to keep CLAUDE.md short (aim for under 200 lines), move workflow-specific instructions into skills, which load only when invoked, and disable MCP servers you are not using. /clear between unrelated tasks, because stale context is paid for on every later request.
A small amount of usage also happens in the background: Anthropic says conversation summarization for claude --resume and some commands use typically under $0.04 per session.
How to track Claude Code cost per prompt with PromptConduit
No account is needed for any of these steps.
1. Install the CLI and wire the Claude Code hooks.
curl -fsSL https://promptconduit.dev/install | bash
promptconduit install claude-code
This adds hooks to ~/.claude/settings.json. In Free mode every event is written to ~/.promptconduit/events.jsonl and nothing is sent anywhere. The quick start covers the same steps in more detail.
2. Use Claude Code as usual, then check the session cost from the same directory.
promptconduit cost # current session, human-readable
promptconduit cost --json # same summary as JSON
promptconduit cost --cwd ~/code/api # scope to another workspace
Illustrative output (the format matches the CLI; the numbers are made up):
AI session cost — claude-code (exact)
Total: $0.5526 USD
claude-sonnet-4-6 $0.5526 in 1200 · out 5300 · cache-read 940000 · cache-write 50000
Tools: 31 call(s) (Read ×14, Bash ×9, Edit ×8)
Signals: cache-hit 95% · input-share 0% · tier standard
cache-miss cost share 35%
(exact) means the token counts were read verbatim from the transcript’s usage block, not estimated. The tool line lists tool names and counts only; tool inputs are never read.
3. Install the editor extension for live cost. In Cursor, search the Extensions pane for “PromptConduit” (it installs from Open VSX). The status bar then shows ⚡ <request cost> · 🕘 <session cost>. Click it, or run PromptConduit: Show Cost Breakdown from the command palette, to open a per-prompt ledger with Session, This branch, and This PR scopes. PromptConduit: Show All Sessions Cost gives a multi-session overview. Details are in the extension docs.
4. Inspect the raw events if you want to build your own report.
promptconduit events -n 5 # last five captured events
promptconduit events --raw # include the full JSON envelope
promptconduit events --path # print the log file location
End-of-turn Stop events carry a cost enrichment with a list of priced requests (request_id, model, tokens, usd, signals) and a vcs enrichment with repo, branch, and commit. The Cursor post has a jq recipe that rolls this up by repo and model.
How to read the numbers
Anthropic’s API reports four token counts on every response, and Claude Code writes them into the transcript. PromptConduit keeps the same four columns.
- Input (
input_tokens): fresh prompt content that was neither read from nor written to the cache. Billed at the model’s base input rate. - Cache write (
cache_creation_input_tokens): content written into the prompt cache. Per Anthropic’s prompt caching docs, 5-minute cache writes cost 1.25x the base input price and 1-hour writes cost 2x. When the transcript records the TTL split, PromptConduit prices each part at its own rate; otherwise it uses the 5-minute rate. - Cache read (
cache_read_input_tokens): content served from an existing cache entry. Billed at 0.1x the base input price for most models; Anthropic lists lower multipliers for some newer models, so check the docs for yours. - Output (
output_tokens): everything the model generates. Thinking tokens are billed as output.
Total input for a request is cache_read + cache_creation + input. In a long agent session the cache read column is usually the biggest by far, because Claude Code resends the conversation on every request and the cache serves most of it. That is expected and cheap per token. What deserves attention:
- Cache hit rate. PromptConduit computes
cache_read / (cache_read + cache_write + input). A low value on a long session means context is being rebuilt instead of reused. The cache hit rate guide covers the usual causes. - Cache-miss cost share. The share of dollars spent on fresh input plus cache writes. High share with a low hit rate points at context being resent uncached.
- Tier. A coarse bucket (premium, standard, economy) from the model name. Opus-class work on routine edits shows up here.
- Tool calls. Many small tool calls mean many requests, each carrying the full context. See batching tool calls.
The dollar figures are what the same tokens would cost at pay-as-you-go API rates. On a subscription that is an “API-equivalent” number, useful for comparing sessions and models, not what you are charged.
Common pitfalls
- Treating the session total as your bill. Both
/usageand PromptConduit estimate from token counts. Contracted rates, data residency multipliers, and cloud provider pricing (Bedrock, Vertex, Foundry) are not applied by PromptConduit. Reconcile against the Console or your cloud billing. - Missing subagent spend. Subagents send their own requests. Claude Code’s
Prompt cache (main)line covers the main conversation only. If a session looks cheap but your plan usage climbed, check subagent activity; the subagent guide explains when delegation saves tokens and when it costs more. - Comparing across
/clear./usageresets on/clear. Session-level numbers in any tool are only comparable if you know where the session boundaries are. - Idle gaps. The first request after the cache lifetime expires re-caches the full context, which shows up as a burst of cache write tokens. Per Claude Code’s docs, that lifetime is five minutes by default on an API key or cloud provider and an hour on a subscription unless you are drawing on usage credits.
- Unpriced models. If a model is not in PromptConduit’s rate table, tokens are still exact but the cost shows as
unpricedrather than $0. Runpromptconduit cost refresh-cardto fetch the latest card from /model-rates, orpromptconduit cost refresh-pricingto fill gaps from LiteLLM’s public price table. Neither sends any of your data. - Paying twice for a wrong approach. Stopping a turn halfway through edits discards work you have already paid for, and the redo is billed again. Planning first and front-loading context cut most of that waste.
- MCP and CLAUDE.md overhead. Large tool definitions and instruction files ride along on every request. Run
/contextin Claude Code to see what fills the window, and read right-sizing MCP servers.
Privacy
The cost feature reads transcripts and hook payloads on your machine and stores numbers and identifiers only: token counts, dollar amounts, model names, tool names, and the basename of the working directory. Prompt text, tool inputs, and file contents are not part of cost records. Events stay in ~/.promptconduit/events.jsonl (30-day retention by default; see promptconduit prune) unless you run promptconduit login or set an API key. The security page covers the details.
When cloud history helps
Local tracking answers “what did this session cost?” If you want shared rollups for a team, by member, model, repo, and pull request, see pricing. Teams of up to 3 are free; Team is $99 per month flat for up to 15 members.
Related reading
- Claude Code transcripts: location and format — where
~/.claude/projects/JSONL files live and how usage blocks are stored - Claude Code OpenTelemetry cost export — stream per-request
cost_usdinto your observability stack - Attribute AI coding spend to teams and repos — chargeback patterns when several developers share a codebase
- Cursor AI spend by repo and model — same PromptConduit log when you use both agents
Frequently asked questions
How do I check token usage in Claude Code?
Run /usage (or /cost or /stats). The Session block lists input, output, cache read, and cache write tokens per model for the current session, plus an estimated dollar total. On Pro, Max, Team, or Enterprise, the same screen shows plan usage bars and what counted against your limits.
How do I see Claude Code token usage?
Run /usage inside Claude Code. Its Session block shows input, output, cache read, and cache write tokens per model for the current session, plus an estimated dollar total. /cost and /stats are aliases for /usage. While a turn runs, the spinner line can also show live output tokens for that turn only.
Does the /usage cost figure match my bill?
Not exactly. Claude Code computes it locally from token counts at list price unless an admin sets contracted rates, and Anthropic describes it as an estimate. For authoritative billing, use the Usage page in the Claude Console. On a Pro or Max subscription the dollar figure is not what you pay.
Where does Claude Code store token usage data?
Each session is a JSONL transcript under ~/.claude/projects/. Every assistant line carries a usage object with input_tokens, output_tokens, cache_read_input_tokens, and cache_creation_input_tokens. Tools like ccusage and PromptConduit read these files locally.
What is the difference between cache read and cache write tokens?
Cache write (cache creation) tokens are prompt content written into the prompt cache, billed above the base input rate: 1.25x for the 5-minute TTL and 2x for the 1-hour TTL. Cache read tokens are content served from an existing cache entry, billed at a fraction of the base input rate (0.1x for most models, lower for some newer ones).
How do I see Claude Code cost per prompt or per repository?
PromptConduit's editor extension shows a per-prompt cost ledger with branch and PR scopes, and the CLI tags each captured event with git context (repo, branch, commit). ccusage can group Claude Code usage by project with its --instances flag.
How do I check my Claude Code plan usage limits?
On a Pro, Max, Team, or Enterprise plan, run /usage. It shows plan usage bars and activity stats alongside the Session block, plus a breakdown of what counts against your limits (skills, subagents, plugins, MCP servers). Press d or w to switch between the last 24 hours and 7 days. The breakdown is computed from local history, so usage from other devices or claude.ai is not included.
How do I show Claude Code token usage all the time?
Configure a status line. Add a statusLine entry to ~/.claude/settings.json that runs a command, which receives session JSON on stdin including cost.total_cost_usd, context_window.used_percentage (input tokens only), and, for Pro and Max subscribers after the first API response, rate_limits.five_hour and rate_limits.seven_day used_percentage. Run /statusline to have Claude Code set one up for you.
Why does my session already have tokens before I type anything?
Every request carries the system prompt, tool definitions, CLAUDE.md, and loaded skill and MCP listings before your first message. Run /context to see what fills the window, and trim CLAUDE.md or disable unused MCP servers to shrink that base.
How do I see my total or lifetime Claude Code token usage?
Run /stats, which is an alias for /usage that opens on the Stats tab with your activity stats. /usage plan bars and breakdowns only cover the last 24 hours or 7 days of local history. For per-day, per-month, and per-project totals across all sessions on a machine, read the local transcripts with ccusage or PromptConduit. Neither includes usage from other devices or claude.ai.
Is there a Claude token counter or tracker that keeps a history?
Claude Code itself keeps no running history of dollar totals; /usage resets with /clear. Tools that read ~/.claude/projects/ (ccusage, PromptConduit) build a history from the usage block in each transcript line. To stream token and cost metrics into your own stack, enable Claude Code's OpenTelemetry export, which emits claude_code.token.usage and claude_code.cost.usage.
How do I get a Claude Code usage report for my team?
It depends on how your team signs in. On Team or Enterprise plans, the spend report in claude.ai org analytics shows estimated spend per user and per model with CSV export, and Enterprise adds an Analytics API. On the Claude Console, use the Claude Code dashboard or the Claude Code Analytics API. On Bedrock, Vertex, or Foundry, use OpenTelemetry or an LLM gateway. None of these attribute spend to a repo or pull request.
What does the /insights command do, and does it show token usage?
/insights writes an HTML report about how you work (projects, friction points, suggestions) from up to 200 recent sessions on this machine, saved to ~/.claude/usage-data/report.html. It does not report token totals, and running it uses tokens from your plan or API usage.
Why does /usage say it is rate limited or show last-known usage?
The request for plan limits can fail when the usage endpoint is rate limited. /usage then shows the last bars it loaded in the past 60 minutes with a Showing last-known usage note, and you press r to retry after the time it names. It does not mean your work with Claude is limited.
Does tracking Claude Code cost send my code anywhere?
/usage and ccusage are local. PromptConduit's Free tier is also local: events go to ~/.promptconduit/events.jsonl and nothing is sent unless you set an API key or sign in. The cost data itself is numbers and identifiers only, never prompt text.