AI coding tool token analytics powered by DuckDB
Project description
clanker-analytics
Token usage analytics for AI coding tools. Reads local session logs and shows per-project breakdowns using DuckDB.
Supports Claude Code, Codex, and Gemini CLI.
Install
uv tool install clanker-analytics
Or run without installing:
uvx clanker-analytics
Usage
clanker-analytics # 7-day chart (default)
clanker-analytics --since 24h # last 24 hours (also: 7d, 2w, 2026-03-01)
clanker-analytics --share # chart + copy to clipboard + open X
clanker-analytics --table # tabular view
clanker-analytics --table --by date # table grouped by date (also: model, session)
clanker-analytics --tool claude # Claude Code only (also: codex, gemini)
clanker-analytics --refresh # force cache rebuild
clanker-analytics --sql "SELECT ..." # custom SQL against 'tokens' table
How it works
DuckDB reads session logs directly from ~/.claude/projects/, ~/.codex/sessions/, and ~/.gemini/tmp/ — no Python JSON parsing. Results are cached to ~/.cache/clanker-analytics/tokens.parquet (ZSTD compressed) and auto-invalidated when source files change.
Columns
- total — all tokens processed (input + output + cache write + cache read)
- billable — total minus the 90% cache read discount
- output — output tokens only
- cache — cache read hits as % of input tokens
- api_cost — estimated cost at API rates
API cost calculation
The api_cost and billable columns use published API pricing. Cache reads are 0.1x the input token price for all three providers:
| Input | Cache read | Cache write | Output | |
|---|---|---|---|---|
| Claude Sonnet | $3/MTok | $0.30/MTok | $3.75/MTok | $15/MTok |
| Claude Opus | $5/MTok | $0.50/MTok | $6.25/MTok | $25/MTok |
| GPT-5 | $1.25/MTok | $0.125/MTok | (auto) | $10/MTok |
| Gemini Flash | $0.15/MTok | $0.0375/MTok | (auto) | $0.60/MTok |
| Gemini 2.5 Pro | $1.25/MTok | $0.125/MTok | (auto) | $10/MTok |
| Gemini 3.1 Pro | $2/MTok | $0.50/MTok | (auto) | $12/MTok |
Sources: Anthropic pricing, OpenAI pricing, Google AI pricing
Environmental impact estimates
The --chart / --share output shows estimated environmental impact per million tokens:
| Metric | Per 1M tokens | Source |
|---|---|---|
| Electricity | 0.6 kWh | Epoch AI, arxiv:2505.09598 |
| Water | 1 liter | Li & Ren (2023), adjusted for modern models |
| CO2 | 90 g | Ritchie (2025) |
These are rough estimates — actual impact varies 10-100x depending on model, hardware, and data center location. No provider publishes official per-token figures.
Chart colors
Brand colors used in --chart / --share output:
| Tool | Color | Source |
|---|---|---|
| Claude Code | #d97757 |
Anthropic brand guidelines |
| Codex | #10a37f |
OpenAI brand |
| Gemini | #4285f4 |
Google brand |
Requirements
Python 3.13+, DuckDB 1.5+, matplotlib 3.9+.
Tested on Linux, macOS, and Windows (including WSL data auto-discovery).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clanker_analytics-0.2.2.tar.gz.
File metadata
- Download URL: clanker_analytics-0.2.2.tar.gz
- Upload date:
- Size: 2.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d019c93af0fcea4175397029823acb32bb3ae4da00d79faf8dabd92da4d48a4
|
|
| MD5 |
c1494176a1ac0b62d406ded814197563
|
|
| BLAKE2b-256 |
b9accb82877dc1a4df71ec5b62dddfea3c881b546266d0ce4bec7aeeebd819c8
|
Provenance
The following attestation bundles were made for clanker_analytics-0.2.2.tar.gz:
Publisher:
publish.yml on wakamex/clanker-analytics
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clanker_analytics-0.2.2.tar.gz -
Subject digest:
4d019c93af0fcea4175397029823acb32bb3ae4da00d79faf8dabd92da4d48a4 - Sigstore transparency entry: 1114511732
- Sigstore integration time:
-
Permalink:
wakamex/clanker-analytics@dfb2800430f85996ad633a982e270263e85c594d -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/wakamex
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@dfb2800430f85996ad633a982e270263e85c594d -
Trigger Event:
push
-
Statement type:
File details
Details for the file clanker_analytics-0.2.2-py3-none-any.whl.
File metadata
- Download URL: clanker_analytics-0.2.2-py3-none-any.whl
- Upload date:
- Size: 2.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
277526e4d1e62156634b4955e5b5c9be1714077e35054385bc428a5f5fe97d4a
|
|
| MD5 |
e2d24063fee3a53832d41da66c711c0d
|
|
| BLAKE2b-256 |
900cbca5e64aec77efeff4275697ae4f040627b08b809ecad0c3a2e1fb990a05
|
Provenance
The following attestation bundles were made for clanker_analytics-0.2.2-py3-none-any.whl:
Publisher:
publish.yml on wakamex/clanker-analytics
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clanker_analytics-0.2.2-py3-none-any.whl -
Subject digest:
277526e4d1e62156634b4955e5b5c9be1714077e35054385bc428a5f5fe97d4a - Sigstore transparency entry: 1114511739
- Sigstore integration time:
-
Permalink:
wakamex/clanker-analytics@dfb2800430f85996ad633a982e270263e85c594d -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/wakamex
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@dfb2800430f85996ad633a982e270263e85c594d -
Trigger Event:
push
-
Statement type: