SpendLens
See what your Claude Code sessions would cost at list prices, and set how long
Claude Code keeps its transcripts, without leaving Visual Studio Code.
SpendLens is an independent, unofficial extension. It is not made, endorsed or
supported by Anthropic.
Features
- Dashboard in an editor tab: tokens per day by model, cost by model and by
project, hour-of-day rhythm and recent sessions, in your editor's theme.
- Sidebar: today's list-price cost, a daily trend, transcript retention and
cost by model.
- Status bar: today's cost or tokens; click it to open the dashboard.
- Transcript retention: set Claude Code's
cleanupPeriodDays from the
Settings editor or with SpendLens: Set Transcript Retention…. The value is
written to Claude Code's own settings.json, so Claude Code in the terminal
uses the same number. If a lower value would delete transcripts, SpendLens
tells you how many and asks first.
Costs are notional: what the same traffic would cost on the metered API at
Anthropic's list prices. A Pro or Max subscription is not billed per token.
Requirements
Python 3.11 or newer. SpendLens carries its own indexer and needs nothing
installed with pip. If spendLens.python.path is set, SpendLens uses only that
interpreter. Otherwise it uses the one selected in the Python extension, and
then the first suitable one on PATH: py -3, python or python3 on
Windows, and python3 or python on macOS and Linux.
Settings
| Setting |
Default |
What it does |
spendLens.retention.days |
Claude Code's default |
Days Claude Code keeps a transcript after its last use (cleanupPeriodDays) |
spendLens.retention.presets |
30, 90, 365, 3600 |
Choices offered by SpendLens: Set Transcript Retention… |
spendLens.index.projectsDir |
Claude Code's projects folder¹ |
Transcripts to read |
spendLens.index.databasePath |
usage.db in Claude Code's folder¹ |
Where the index is kept |
spendLens.index.inBackground |
on |
Keep indexing while VS Code is open |
spendLens.dashboard.refreshSeconds |
30 |
How often the index and views refresh |
spendLens.dashboard.port |
0 (any free port) |
Port for the local server |
spendLens.sidebar.days |
30 |
Days the sidebar's trend and models cover |
spendLens.statusBar.show |
cost |
cost, tokens or off |
spendLens.python.path |
(search) |
Interpreter to run the indexer with |
Claude Code's configuration folder is ~/.claude, or CLAUDE_CONFIG_DIR when
that is set.
¹ When the setting is empty and you have saved a projects-dir or db with
the claude-usage command-line tool, which keeps it in claude-usage.json,
SpendLens uses that instead.
Commands
- SpendLens: Open Dashboard
- SpendLens: Set Transcript Retention…
- SpendLens: Index Transcripts Now
- SpendLens: Restart Engine
- SpendLens: Open Settings
- SpendLens: Show Log
How it works
For each window, SpendLens starts its bundled indexer with your Python. The
indexer reads Claude Code's transcripts incrementally into a local SQLite
index and serves the dashboard, plus a summary the sidebar and status bar read,
on the loopback address and a free port. The server stops with the window, and
on its own if VS Code goes away without stopping it.
Turns already indexed stay in the index after Claude Code deletes their
transcript, so keeping SpendLens running preserves your usage history even
under a short retention window.
Privacy
SpendLens works entirely on your machine. It sends nothing anywhere: no
telemetry, no analytics, and no network requests beyond its own local server.
That server listens only on the loopback address and answers only requests
that carry a secret path created for each run. The address stays inside VS
Code, never on a command line or in the log, so web pages and other accounts
on the machine cannot read your usage.
It reads and writes only these files. By default all of them are in Claude
Code's configuration folder; the two Index settings, or values saved in
claude-usage.json, can point the transcripts and the index elsewhere.
- the session transcripts in
projects/, read only;
- Claude Code's
settings.json, read for cleanupPeriodDays, and written only
when you change retention, and then only that one key;
- the usage index,
usage.db (with SQLite's usage.db-wal and usage.db-shm
beside it), which it creates and keeps up to date;
claude-usage.json, the indexer's own settings file, read only and only if
it exists. The CLAUDE_USAGE_CONFIG environment variable can name another
path for it.
Trademarks
Claude and Claude Code are trademarks of Anthropic, PBC. SpendLens is not
affiliated with Anthropic. Visual Studio Code is a trademark of Microsoft.