codex-stats
Local analytics for coding agents. codex-stats reads the session data already on
your machine from Codex, OpenCode, Claude Code, Hermes, and DeepSeek Harness, then
writes a standalone browser dashboard.
What you get
- An Overview tab plus one tab per tool, each with day, week, month, and all-time windows
- A Graphs / Stats toggle: charts first, or numbers and tables first
- Token, cost, model, project, branch, and provider breakdowns
- Session outcomes, context hygiene, tool behavior, and MCP/skill/subagent attribution
- Efficiency (cost per 1k lines), waste ledger with the Context Tax flow diagram to show where spend goes, leaks, runway/burn, and regression detection
- Animated donuts, columns, treemaps, gauges, scatter plots, calendars, stacked areas, and heatmaps
- Shareable JPG cards and browser PDF export
Install
pipx install codex-stats
Or with pip:
python3 -m pip install codex-stats
Run
codex-stats
It writes ~/.cache/codex-stats/dashboard.html and opens it in your browser. Set
XDG_CACHE_HOME to move it. Inside the dashboard, use the tab row to switch tools and
windows, the Graphs / Stats toggle to switch views, the search box to filter rows,
Data sources to inspect ingest health, and the export menu for PDF and JPG cards.
Press G or S anywhere outside a text field to switch between Graphs and Stats.
Data sources
| Tool | Location | Notes |
|---|---|---|
| Codex | ~/.codex |
state_5.sqlite + rollout JSONL, including git branch |
| OpenCode | ~/.local/share/opencode/opencode.db |
recorded cost + tokens per session |
| Claude Code | ~/.claude/projects/**/*.jsonl |
per-project transcripts, including git branch |
| Hermes | ~/.hermes/state.db |
recorded cost + tokens per session |
| DeepSeek Harness | ~/.dsh/sessions |
zstd JSONL event logs: tokens, tool calls, file edits |
Override locations with CODEX_HOME, CODEX_STATS_OPENCODE_HOME,
CODEX_STATS_CLAUDE_PROJECTS_DIR, CODEX_STATS_HERMES_HOME, and
CODEX_STATS_DSH_HOME.
Each source reads its 2,000 most recent sessions by default. Set
CODEX_STATS_MAX_SESSIONS=N to change the cap, or 0 to read everything. Parsed
sessions are cached under the dashboard cache directory and re-read when a source
changes.
Cost
Cost is estimated per token component (fresh input, cache reads, cache writes, output)
from a dated rate snapshot. OpenCode and Hermes recorded costs win when present. Update
rates or set a monthly budget in ~/.config/codex-stats/config.toml:
[pricing.model_usd_per_1k_tokens.gpt-5.4]
input = 0.0025
cached_read = 0.00025
cache_write = 0.0
output = 0.015
[budget]
monthly_limit_usd = 120.0
warn_at_ratio = 0.9
Unidentified models use a labeled mid-tier fallback rather than a flat rate.
Leaderboard
The leaderboard is opt-in. With CODEX_STATS_ENABLE_LEADERBOARD=1, the tool can submit
your all-time totals (tokens, requests, sessions, estimated cost, and per-CLI token
share) under a username you choose. Prompts, file names, project names, models, and
timestamps are never sent. Use CODEX_STATS_DISABLE_LEADERBOARD=1 to hard-disable it,
or CODEX_STATS_LEADERBOARD_URL to point at your own server.
Notes
- Projects are identified by working directory, not folder name alone.
- Branches are grouped per repository; a branch idle for 14 days is flagged as quiet.
- Outcomes are conservative: "verified" requires a successful test, lint, typecheck, or build after the final edit. Unsupported signals stay unclassified.
- Waste and per-line costs are labeled estimates, not invoices.
- When history is truncated, the dashboard says so rather than reporting a partial history as complete.
Development
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -e .
PYTHONPATH=src python3 -m codex_stats
PYTHONPATH=src python3 -m unittest discover -s tests -v
ruff check src tests
mypy src/codex_stats
The roadmap lives in docs/roadmap.md.
Metadata
Release files for codex-stats 1.21.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| codex_stats-1.21.0.tar.gz | 173.2 kB | With provenance | Details for codex_stats-1.21.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| codex_stats-1.21.0-py3-none-any.whl | Python 3 | none | any | Details for codex_stats-1.21.0-py3-none-any.whl |
Total release size: 300.7 kB
Release files / codex_stats-1.21.0.tar.gz
| Download URL | codex_stats-1.21.0.tar.gz |
|---|---|
| Size | 173.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
78e97802a221244b8c8266e3e456f5f67fc26cd4b83e492335c84be4d783e680
|
|
BLAKE2b-256 checksum How to use checksums |
dd5504a3d1a0da1256dbb58fef149d5aa675049a6eebc7744056d9205fcbd0ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.
Transparency logRelease files / codex_stats-1.21.0-py3-none-any.whl
| Download URL | codex_stats-1.21.0-py3-none-any.whl |
|---|---|
| Size | 127.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
786da4aa22520926391c9c241bb91ed92667d06a637e62eafe1696804ab377c5
|
|
BLAKE2b-256 checksum How to use checksums |
48e3fcff88c55050587ec805401a51696dbc6dc444c4dcb7d9ed683b924499ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.
Transparency logSecurity for codex-stats 1.21.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for codex_stats-1.21.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.