-
Notifications
You must be signed in to change notification settings - Fork 2
Dashboard
An interactive Streamlit view over your extracted data: cost breakdowns, the
session-depth meta-analysis, per-model and per-category charts, and quota
trends. Charts are Apache ECharts (via streamlit-echarts) on a dark theme,
and most charts cross-filter the whole board on click (and the time trend on
a date brush).
It is an optional extra (it pulls in Streamlit, Apache ECharts, pandas and NumPy), so it is not installed by the core tool.
Want to see it first? The public live demo runs this exact dashboard on a synthetic dataset — no install, no real data.
# editable checkout (uv)
uv sync --extra dashboard
prompt-analytics dashboard # reads ./output by default
# straight from PyPI, no install
uvx --with "prompt-analytics-for-claude-code[dashboard]" prompt-analytics dashboard
# or pip
pip install "prompt-analytics-for-claude-code[dashboard]"
prompt-analytics dashboard(Use double quotes around the [dashboard] extra — single quotes are passed
through literally by cmd.exe and break the install.)
The dashboard command runs streamlit run on the bundled app and serves on
http://localhost:8501 by default; if the port is taken it picks the next
free one and prints the URL. Any extra flags are forwarded straight to Streamlit,
so prompt-analytics dashboard --server.port 8599 changes the port; you can also
set defaults in a .streamlit/config.toml — see the
Streamlit docs.
By default dashboard refreshes the data first — it runs extract + snapshot
- local (heuristic) categorize on your
~/.claudehistory, then opens the board, so a fresh launch never shows stale numbers. Pass--no-refreshto skip that and render the existing CSVs as-is. The refresh is skipped on the demo dataset (CCA_DEMO=1). If you start anextractwhile the dashboard is open, the cache keys on the CSV mtimes — a browser refresh (or the sidebar Refresh data button) shows the new data.
Resolution order:
-
CCA_DEMO=1— the bundled syntheticdemo_data/dataset, with a "Demo data" banner. This is what the public live demo runs. -
CCA_DATA_DIR— an explicit directory of CSVs. -
--output-dir DIRon thedashboardcommand (exported to the app asPROMPT_ANALYTICS_OUTPUT_DIR). - Default:
./output.
# Linux / macOS
CCA_DEMO=1 prompt-analytics dashboard # synthetic demo data
CCA_DATA_DIR=/path/to/csvs prompt-analytics dashboard
prompt-analytics dashboard --output-dir ./out # a specific extract# Windows (PowerShell) — the `VAR=x cmd` prefix syntax does not exist there
$env:CCA_DEMO = "1"; prompt-analytics dashboard
$env:CCA_DATA_DIR = "C:\path\to\csvs"; prompt-analytics dashboard
prompt-analytics dashboard --output-dir .\out
Remove-Item Env:CCA_DEMO # unset when doneAll charts share one visual identity: color semantics live in
dashboard/theme.py (stable colors per token type, per model family, per
category) and the ECharts render layer in dashboard/echarts.py. Pages price
everything on the primary provider (the first in pricing.yml, anthropic by
default); the multi-provider grid stays available in the CLI.
Most categorical charts emit a cross-filter on click (project / model / category) and the time trend filters a date range by brush. Two aggregate clicks join them — a prompts-per-session bar (Sessions) and a prompt-length bucket (Composition / Input) — so any of them narrows the whole board. When a click filter is active a badge appears with two drill-through buttons, "Explore prompts →" and "Explore files →", opening the two detail pages on the current selection, plus a Reset. (The persistent sidebar filters — date / model / project / category — are separate; Reset clears only the click drill.)
The Compare tab (after Optimize) is the before/after view: pick a pivot date
(or one of the auto-detected config-change dates) and a comparison window (1
week / 1 month / full history — the windowed modes keep N days immediately on each
side for a fair like-for-like read), then read the five workload-normalized ratios
as Before | After bands. Below them a Composition shift section makes the
output/context move concrete — the code, test and context-rent shares plus the
per-line efficiency (tokens and cost to write a line of code), with prose-vs-code
and loading-vs-rent donuts before vs after — followed by two average-based
charts (cost/prompt by token type, output language mix). On the full-history
window it is built from the same report the impact command prints, so the bands
and the CLI table never drift — and it is averages and ratios only, never sums.
| Page | Shows |
|---|---|
| Home | KPI cards + cost-split donut, then cost over time stacked by model (click a model → filter) with a Day/Week/Month toggle. |
| Usage | Cost by token type per day/week (date brush + click → date filter), cache-read headline + non-cache volume bars, subagent cost, and the spend punchcard (weekday × hour). |
| Models | Two donuts (token volume / cost by model), per-prompt cost distribution by model (box plot), and cost by model over time (Day/Week/Month toggle). Every chart emits the model filter on click. |
| Sessions | Horizontal cost pareto by project (click → project filter), a cost treemap (click a tile → Prompt Explorer), prompts/session (click a bar → filter the board to that session size), and a box plot of cost/session by model. |
| Session depth | KPI deep-vs-opener cost multiplier, a box plot of one prompt's cost by depth band, and small-multiples of the input-side token mix plus output — the differentiating analysis. |
| Composition |
"Where your cost goes, by content" — four sections, each a band of 4 KPIs + 2 charts: Input (cost by category + prompt-length histogram, both click-to-filter), Output (prose-vs-code donut + code language mix), Context (loading-vs-rent donut + a tokens Pareto), and Files — a force-layout file cost-graph (files sized by reconciled context cost, coloured by language; edit-prompt satellites; project picker + drill on a file). Mirrors by-output / by-context / by-file. (The old Prompts tab folded in here and into the Prompt Explorer; the category charts need categorize — see Prompt Categories.) |
| Prompt Explorer | The prompt detail page: drill session → prompt with a cumulative-cost timeline and the full prompt text; a selected prompt links its edited files straight to the File Explorer. Respects the global cross-filters; reached from the "Explore prompts →" button and treemap tiles. |
| File Explorer | The per-file footprint table (project / language / kind / scope filters + search) and a per-file drill: who edited it (with the task), which sessions kept it in context, and the load + rent it cost. Reached from "Explore files →", a prompt's edited-file links, and the Composition file graph. |
| Optimize | The prescriptive story: an avoidable-$ headline and three cards (long-pause cache rewrites, compact-earlier lever, compaction-is-cheap reassurance). |
| Compare | Before/after a pivot date with a comparison window (1 week / 1 month / full history): the five workload-normalized ratios as Before | After bands, a Composition shift section (output/context shares + per-line efficiency + prose-vs-code and loading-vs-rent donuts before vs after), and two average-based charts (cost/prompt by token type, output language mix). Reuses the impact numbers on full history; averages/ratios only. |
| Quotas |
Quota windows first (utilization gauges, trend with reset windows, countdowns — need snapshot), then the cost story: plan break-even and Cost via GitHub Copilot (AI credits: subscription + overage beyond the allowance). |
| How it works | The trust argument displayed: dedup, ccusage reconciliation, pricing-at-read-time, categorization — and the cost inputs (per-token rate grid, Claude plans, Copilot credit allowances). |
The dashboard reads config.yml from the active data directory. Create the
default with prompt-analytics config init. One section so far:
features:
categorization: true # gate the category charts (Composition / Input) + filter
prompt_text: true # whether extract stored full prompt text
quota_snapshot: true # gate the Quotas pageMissing keys fall back to these defaults. A features flag set to false hides
the corresponding page; it does not delete any data.
See CLI Commands for the same data in the terminal, and Codebase Guide for how the dashboard layer is wired.