Skip to main content

Contributing and license

The Token Usage Dashboard is open source. The source code is on GitHub: Flexible-Universe/Token-Usage-Dashboard.

Development environment for the Token Usage Dashboard​

To develop the Token Usage Dashboard, all you need is Python 3.11 or newer. No pip install, no venv, no third-party packages. What the standard library does not have is either written or left out. This is how you start the dashboard and run the tests:

python3 app.py # start
python3 -m unittest discover -s tests -t . # tests, from the root directory

Token Usage Dashboard repository layout​

The following table lists the main files and directories in the Token Usage Dashboard repository and their purpose:

FilePurpose
install.pysets up the data directory, export scripts, config.toml and jobs
install.sh, install.cmdstarters for macOS/Linux and Windows: find Python 3.11+, call install.py
app.pyentry point, HTTP server, routing
loader.pyconfiguration, reading monthly files, plausibility
metrics.pymetrics from the daily data
sources.pyreads the extra sources projects/, blocks/, sessions/, rtk/, status/
insights.pymetrics of the extra sources
static/interface, language catalogues under static/i18n/, Chart.js under static/vendor/
export/export chain
tools/make-sample-data.pygenerates sample data
docs/detailed documentation in English
tests/tests using unittest

Token Usage Dashboard tests​

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. The interface tests run with node --test through tests/test_frontend.py.

Some reference tests compute against real export files. Without a data directory they skip themselves; the run is then green but covers less. To have them run, name the directory through the environment variable TOKEN_DASHBOARD_REAL_DATA, not through config.toml:

TOKEN_DASHBOARD_REAL_DATA="$HOME/Library/Application Support/Claude-Code-Usage" \
python3 -m unittest discover -s tests -t .

The test of the Windows starter runs on Windows only. On Linux and Windows a few installer tests that need launchd or a POSIX shell skip as well. The installer tests never change a real scheduler.

Conventions for Token Usage Dashboard contributions​

A contribution to the Token Usage Dashboard has to follow these rules:

  • One task, one commit. After every commit the full test run has to pass. Commit messages are in English.
  • No umlauts in source code, comments and Markdown of the repository. Use ue, ae, oe, ss instead.
  • Visible texts only through the language catalogues. static/i18n/de.js and static/i18n/en.js must stay complete and in sync. A new backend message needs a key in its module and a sentence in both catalogues.
  • Missing calendar days are gaps, not zeros.
  • No invented numbers. Estimates are marked visibly.
  • Ratios from sums, not as a mean of ratios.
  • No silent fallback. Broken files are rejected and reported, and so is a skipped check.
  • Timestamps stay ISO-8601 UTC in the backend. Conversion to local time happens in the interface.
  • Foreign text never through innerHTML. Model names, project names, session IDs and message texts are set via createElement and textContent.
  • Comments give reasons; they do not describe what the line already says.

For new features this order has proven itself: first a design (What does the source really deliver? Which number would be tempting but unfounded?), then a plan, then the test, then the implementation.

Adding a new data source to the Token Usage Dashboard​

This is how you add a new data source to the Token Usage Dashboard:

  1. sources.py: write the loader, normalize rows, report broken rows, add it to the list of extra sources.
  2. sources.py: add the checks for the source.
  3. insights.py: metrics, time series and coverage. If the source does not support a model filter, return modelFilterSupported: false.
  4. app.py: add the endpoint and add the source to DataStore.SUBDIRS. Without this entry the dashboard does not notice changed files of the source.
  5. static/: tab, panel, load and draw function.
  6. Add tests and documentation.

What the Token Usage Dashboard deliberately does not do​

The following table lists ideas the Token Usage Dashboard deliberately does not implement, and why:

IdeaWhy not
A monetary value for the RTK savingsThere is no list price, only an empirical usage ratio
An RTK breakdown per commandOnly available as an ASCII table; a parser would break silently as soon as the layout changes
Reconstructing project paths from the keyA hyphen inside a folder name cannot be told apart from the path separator
Trend forecast instead of the daily meanThe projection is meant to stay comprehensible
Third-party packages for charts or the serverThe dashboard should start on any machine with Python

Reporting security vulnerabilities in the Token Usage Dashboard​

Report security vulnerabilities in the Token Usage Dashboard through GitHub Private Vulnerability Reporting: on the repository's Security tab, choose Report a vulnerability. Do not open a public issue for this, because everyone can read it before a fix is available.

Token Usage Dashboard license​

The Token Usage Dashboard is licensed under the AGPL-3.0. The full text is in the LICENSE file in the repository, and the running server serves it at /LICENSE. There is no contributor license agreement; contributions are made under the AGPL-3.0 as well.

Section 13 of the license implies: anyone who runs the application, modified or not, for third parties over a network must offer those users the source code of their version. Anyone running it only for themselves is not affected.

Chart.js 4.4.1 is bundled under static/vendor/ under the MIT license.

Token Usage Dashboard trademark notice​

The Token Usage Dashboard project is not affiliated with Anthropic or OpenAI, and is neither endorsed nor reviewed by them. Claude, Claude Code, OpenAI and Codex are trademarks of their respective owners. ccusage and rtk are independent third-party tools; the project merely reads their output.