Local AI usage observability CLI for Codex sessions.
Project description
codex-stats
codex-stats is a local analytics CLI for Codex usage.
It reads your local Codex state from ~/.codex and surfaces:
- session summaries
- rolling usage totals across today, week, month, or the last
Ndays - model and project breakdowns
- project-specific drilldowns
- recent session history
- estimated token-based cost
- anomaly-aware usage insights and recommendations
- export and import for cross-device snapshots
- merged export snapshots for multi-device rollups
- shareable weekly and monthly reports
Install
pipx install codex-stats
Or with pip:
python3 -m pip install codex-stats
Command Reference
codex-statsShow the default usage summary for today.codex-stats todayShow today's usage summary explicitly.codex-stats weekShow usage totals for the last 7 days.codex-stats monthShow usage totals for the last 30 days.codex-stats --days 14Show a rolling summary for the lastNdays.codex-stats sessionShow the most recent session in detail.codex-stats session --id <session_id>Show one specific session by ID.codex-stats modelsBreak usage down by model.codex-stats projectBreak usage down by project.codex-stats project backend-apiShow a single project's summary across all available local data.codex-stats project backend-api --days 30Show a single project's summary for a rolling time window.codex-stats dailyShow per-day usage with an ASCII trend graph.codex-stats compareCompare the last 7 days against the previous 7 days.codex-stats compare today yesterdayCompare named time windows directly.codex-stats historyShow recent session history.codex-stats topShow the largest sessions by token usage.codex-stats top --project backend-apiShow the largest sessions for one project.codex-stats costsShow estimated cost totals and monthly projection.codex-stats insightsShow anomaly-aware insights and recommended next steps.codex-stats doctorValidate local Codex data sources and config.codex-stats doctor --strictReturn a non-zero exit code if any doctor check fails.codex-stats initCreate a default config file under~/.config/codex-stats/.codex-stats config showShow the effective config, including pricing and display defaults.codex-stats report weeklyGenerate a weekly shareable report.codex-stats report weekly --format markdownGenerate a weekly report in Markdown.codex-stats report weekly --project backend-apiGenerate a weekly report for one project.codex-stats report weekly --format markdown --output weekly-report.mdWrite a formatted report to a file.codex-stats export codex-stats-export.jsonExport normalized local stats to JSON.codex-stats export codex-stats-export.json --since 30dExport only a rolling window of recent sessions.codex-stats import laptop.json desktop.jsonRead one or more exported snapshots and summarize them.codex-stats merge merged.json laptop.json desktop.jsonMerge multiple exported snapshots into one deduplicated file.codex-stats merge merged.json laptop.json desktop.json --jsonMerge snapshots and return a machine-readable merge summary.codex-stats completions zshPrint shell completion setup for your shell.codex-stats --color alwaysForce ANSI color output.codex-stats --jsonReturn machine-readable JSON output for supported commands.
How It Works
codex-stats does not proxy or intercept Codex API traffic.
It reads local Codex artifacts, including:
state_5.sqlitefor session metadata- rollout JSONL files for request and token snapshots
Notes
- Costs are estimates, not billing values.
- Output depends on local Codex file formats remaining compatible.
exportandimportlet you move normalized snapshots between machines.mergelets you deduplicate and combine exported snapshots into one file.export --since Ndlimits snapshots to a rolling window before sharing.doctor --strictis useful in scripts and CI because it returns a non-zero exit code on failed checks.--color auto|always|nevercontrols ANSI styling.
Pricing Config
Optional pricing config lives at ~/.config/codex-stats/config.toml.
[pricing]
default_usd_per_1k_tokens = 0.01
[pricing.model_usd_per_1k_tokens]
gpt-5.4 = 0.02
gpt-5-mini = 0.005
To create the config file automatically:
codex-stats init
To inspect the effective config:
codex-stats config show
codex-stats config show --json
JSON Schemas
Machine-readable output is intended to stay stable across patch releases.
summaryJSON: time-window totals such as sessions, requests, tokens, cost estimate, and top modelreportJSON: period, optional project scope, summary, comparison, projects, top sessions, costs, and insightsexportJSON:schema_version,exported_at, and normalizedsessionsdoctorJSON: a list of checks withname,ok,detail, andseverityconfigJSON: config path, whether the file exists, pricing defaults, overrides, and display defaultsimportandmergeJSON: import summary plus deduped session counts
Full field documentation lives in docs/json-schema.md.
Development
For local development from the repo:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -U pip setuptools
python -m pip install -e .
Run without installing:
PYTHONPATH=src python3 -m codex_stats
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 codex_stats-1.1.0.tar.gz.
File metadata
- Download URL: codex_stats-1.1.0.tar.gz
- Upload date:
- Size: 26.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3916165c5b34ffb25eac839577c5dc43cae433ed38d9efc40b280667d38c0d6
|
|
| MD5 |
088055928ea36860b58aeb21d8835fa9
|
|
| BLAKE2b-256 |
0ccb80ef40ceb6726d1717cc978d687c9f2766ebf6a37c9f1b443ad676b0fad9
|
Provenance
The following attestation bundles were made for codex_stats-1.1.0.tar.gz:
Publisher:
publish.yml on vivek378521/codex-stats
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_stats-1.1.0.tar.gz -
Subject digest:
f3916165c5b34ffb25eac839577c5dc43cae433ed38d9efc40b280667d38c0d6 - Sigstore transparency entry: 1227156708
- Sigstore integration time:
-
Permalink:
vivek378521/codex-stats@efa25a62a205dd3fa1f5a89b1be64908a5598b5b -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/vivek378521
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@efa25a62a205dd3fa1f5a89b1be64908a5598b5b -
Trigger Event:
release
-
Statement type:
File details
Details for the file codex_stats-1.1.0-py3-none-any.whl.
File metadata
- Download URL: codex_stats-1.1.0-py3-none-any.whl
- Upload date:
- Size: 24.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
109aea99bb7d73c0ec1b8a9c67dd8615b5e678dc64ea067b0b83ce1075ba4cec
|
|
| MD5 |
d610f63cbd24089e3bb89013a0062460
|
|
| BLAKE2b-256 |
16f1c5b684de79ee42b7535e065e66e3d527b2f6616958af957f185df45db366
|
Provenance
The following attestation bundles were made for codex_stats-1.1.0-py3-none-any.whl:
Publisher:
publish.yml on vivek378521/codex-stats
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_stats-1.1.0-py3-none-any.whl -
Subject digest:
109aea99bb7d73c0ec1b8a9c67dd8615b5e678dc64ea067b0b83ce1075ba4cec - Sigstore transparency entry: 1227156760
- Sigstore integration time:
-
Permalink:
vivek378521/codex-stats@efa25a62a205dd3fa1f5a89b1be64908a5598b5b -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/vivek378521
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@efa25a62a205dd3fa1f5a89b1be64908a5598b5b -
Trigger Event:
release
-
Statement type: