Running from source
When you run the Token Usage Dashboard from a clone of the repository, there are two levels:
- Level A: the dashboard only. You display an existing data directory or sample data. All you need is Python.
- Level B: the full chain. You additionally set up the exports so that the data directory fills itself. You need Node.js and
ccusagefor this.
The requirements are listed under Installation. There is no pip install, no venv and no requirements.txt.
Token Usage Dashboard quick start with sample data
This is how you clone the Token Usage Dashboard repository, generate sample data and start the server:
git clone https://github.com/Flexible-Universe/Token-Usage-Dashboard.git token-usage-dashboard
cd token-usage-dashboard
python3 tools/make-sample-data.py --out sample-data
python3 app.py
The first start writes a config.toml next to app.py that points at the usual data directory of your system. To make the dashboard show the sample data you just generated, set directory = "sample-data" there and start app.py again.
The sample data is invented. It deliberately contains the cases the dashboard has to decide about: missing calendar days, uneven coverage across the extra sources and idle blocks.
Level A: the Token Usage Dashboard only
1. Get the Token Usage Dashboard repository
This is how you get the Token Usage Dashboard repository onto your machine:
git clone https://github.com/Flexible-Universe/Token-Usage-Dashboard.git token-usage-dashboard
cd token-usage-dashboard
For level A, the clone may live anywhere. For level B, the rules under Where the data directory may live apply.
2. Provide a data directory for the dashboard
The Token Usage Dashboard produces no data. It needs a directory with at least one file matching YYYY-MM.json. You have these options:
- Copy an existing directory from another machine.
- Set up the export chain (level B).
- Generate sample data:
python3 tools/make-sample-data.py --out sample-data - Write a single file by hand (macOS path shown):
mkdir -p ~/Library/Application\ Support/Claude-Code-Usage
cat > ~/Library/Application\ Support/Claude-Code-Usage/2026-09.json <<'JSON'
{
"daily": [
{ "date": "2026-09-01",
"inputTokens": 1000, "outputTokens": 5000,
"cacheCreationTokens": 2000, "cacheReadTokens": 40000,
"totalTokens": 48000, "totalCost": 1.23,
"modelsUsed": ["claude-opus-5"],
"modelBreakdowns": [
{ "modelName": "claude-opus-5", "cost": 1.23,
"inputTokens": 1000, "outputTokens": 5000,
"cacheCreationTokens": 2000, "cacheReadTokens": 40000 }
] }
],
"totals": { "inputTokens": 1000, "outputTokens": 5000,
"cacheCreationTokens": 2000, "cacheReadTokens": 40000,
"totalTokens": 48000, "totalCost": 1.23 }
}
JSON
The subdirectories projects/, blocks/, sessions/, rtk/ and status/ are optional. Without them the dashboard still starts, and the corresponding tabs show a coverage note.
3. Adjust the dashboard configuration
Set the path of the Token Usage Dashboard's data directory in config.toml next to app.py. All settings are described under Configuration.
4. Start the Token Usage Dashboard
This is how you start the Token Usage Dashboard from the clone:
python3 app.py
The output looks like this (the start messages are German):
Datenverzeichnis: /…/Claude-Code-Usage
Gefundene Monatsdateien: 5
Dashboard laeuft auf http://127.0.0.1:8000/
Beenden mit Strg+C
With open_browser = true, the browser opens by itself after a short delay.
5. Run the Token Usage Dashboard tests (recommended)
This is how you run the Token Usage Dashboard tests:
python3 -m unittest discover -s tests -t .
Always run the tests from the root directory. Some test classes compute against real data and skip themselves without it. More under Contributing and license.
Level B: set up the export chain
Setting up the export chain the short way with the installer
One call of the installer handles the data directory, export scripts, config.toml and jobs:
./install.sh --with-jobs # macOS, Linux
install.cmd --with-jobs # Windows
From a clone the application stays where it is: config.toml goes next to app.py, and no start script is created. Without --with-jobs the installer does everything except the jobs. --dry-run shows beforehand what would happen.
What the installer does not overwrite from a clone: an existing config.toml, and scripts in <data>/bin that differ from the repository. It reports both and leaves them alone. --force brings the scripts up to the repository's state.
The installer does not install ccusage and rtk. You do that beforehand in steps 1 and 2. The following sections describe the manual route. They also explain what the installer does.
Earlier versions installed shell scripts (ccusage-export.sh, rtk-export.sh) and launchd templates. Run ./install.sh --with-jobs --force once, with the same --label-prefix as back then if you gave one. The jobs then call the Python scripts. The installer reports the old .sh copies in <data>/bin as obsolete; you can delete them by hand.
1. Install ccusage
This is how you install ccusage for the Token Usage Dashboard export chain and check its version:
npm install -g ccusage
ccusage --version
2. Install rtk (optional)
rtk is only needed if the RTK tab in the Token Usage Dashboard should show data. This is how you check the rtk installation:
rtk --version # must print "rtk X.Y.Z"
rtk gain # must work
rtkThere is a second tool called rtk (reachingforthejack/rtk, Rust Type Kit). If rtk gain fails, the wrong one is installed. which rtk (where rtk on Windows) shows which one is meant.
3. Create the data directory for the export chain
This is how you create the data directory for the Token Usage Dashboard and copy the export scripts into it:
DATA="$HOME/Library/Application Support/Claude-Code-Usage"
mkdir -p "$DATA"/{bin,logs,projects,blocks,sessions}
cp export/*.py "$DATA/bin/"
rtk-export.py creates rtk/ itself as soon as it has found a working rtk.
The repository is the source, <data>/bin is where the scripts run. The jobs call the copies, not the files in the repository. That way a work in progress cannot drag the nightly export down with it. If you change a script, change it in the repository and bring it over with ./install.sh --force.
4. Test the export runs by hand
Before automating, run each Token Usage Dashboard export once on its own:
DATA="$HOME/Library/Application Support/Claude-Code-Usage"
python3 "$DATA/bin/ccusage-export.py" daily --data-dir "$DATA"
python3 "$DATA/bin/ccusage-export.py" weekly --data-dir "$DATA"
python3 "$DATA/bin/rtk-export.py" --data-dir "$DATA"
tail -20 "$DATA/logs/daily.log"
On Windows in PowerShell:
$DATA = "$env:LOCALAPPDATA\Claude-Code-Usage"
py -3 "$DATA\bin\ccusage-export.py" daily --data-dir "$DATA"
Get-Content "$DATA\logs\daily.log" -Tail 20
A line OK names file, size and balance. A line ABBRUCH (“aborted”) always means: the target file was left unchanged.
If a script cannot find its binary, pass the path:
python3 "$DATA/bin/ccusage-export.py" daily --data-dir "$DATA" \
--ccusage-bin "$HOME/.nvm/versions/node/v22.0.0/bin/ccusage"
python3 "$DATA/bin/rtk-export.py" --data-dir "$DATA" --rtk-bin /opt/homebrew/bin/rtk
5. Set up the export jobs
The installer generates the Token Usage Dashboard export jobs; there are no templates to fill in any more. To see what it would write without writing it:
./install.sh --with-jobs --dry-run
The dry run prints every file or task together with the complete call. Every call uses absolute paths, because neither a plist nor a systemd unit nor a scheduled task expands ~.
If you move the data directory later, the paths in the jobs point nowhere. ./install.sh --with-jobs --data-dir <new path> rewrites them.
6. Make sure no export data is lost
The weekly run is the critical part of the Token Usage Dashboard export chain. The reason is explained under Export chain. The dashboard monitors it and warns in time when a gap is about to open.