Skip to main content

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 N days
  • 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-stats Show the default usage summary for today.
  • codex-stats today Show today's usage summary explicitly.
  • codex-stats week Show usage totals for the last 7 days.
  • codex-stats month Show usage totals for the last 30 days.
  • codex-stats --days 14 Show a rolling summary for the last N days.
  • codex-stats session Show the most recent session in detail.
  • codex-stats session --id <session_id> Show one specific session by ID.
  • codex-stats models Break usage down by model.
  • codex-stats project Break usage down by project.
  • codex-stats project backend-api Show a single project's summary across all available local data.
  • codex-stats project backend-api --days 30 Show a single project's summary for a rolling time window.
  • codex-stats daily Show per-day usage with an ASCII trend graph.
  • codex-stats compare Compare the last 7 days against the previous 7 days.
  • codex-stats compare today yesterday Compare named time windows directly.
  • codex-stats history Show recent session history.
  • codex-stats top Show the largest sessions by token usage.
  • codex-stats top --project backend-api Show the largest sessions for one project.
  • codex-stats costs Show estimated cost totals and monthly projection.
  • codex-stats insights Show anomaly-aware insights and recommended next steps.
  • codex-stats doctor Validate local Codex data sources and config.
  • codex-stats doctor --strict Return a non-zero exit code if any doctor check fails.
  • codex-stats init Create a default config file under ~/.config/codex-stats/.
  • codex-stats report weekly Generate a weekly shareable report.
  • codex-stats report weekly --format markdown Generate a weekly report in Markdown.
  • codex-stats report weekly --project backend-api Generate a weekly report for one project.
  • codex-stats report weekly --format markdown --output weekly-report.md Write a formatted report to a file.
  • codex-stats export codex-stats-export.json Export normalized local stats to JSON.
  • codex-stats export codex-stats-export.json --since 30d Export only a rolling window of recent sessions.
  • codex-stats import laptop.json desktop.json Read one or more exported snapshots and summarize them.
  • codex-stats merge merged.json laptop.json desktop.json Merge multiple exported snapshots into one deduplicated file.
  • codex-stats completions zsh Print shell completion setup for your shell.
  • codex-stats --color always Force ANSI color output.
  • codex-stats --json Return 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.sqlite for 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.
  • export and import let you move normalized snapshots between machines.
  • merge lets you deduplicate and combine exported snapshots into one file.
  • export --since Nd limits snapshots to a rolling window before sharing.
  • doctor --strict is useful in scripts and CI because it returns a non-zero exit code on failed checks.
  • --color auto|always|never controls 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

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codex_stats-1.0.1.tar.gz (24.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codex_stats-1.0.1-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file codex_stats-1.0.1.tar.gz.

File metadata

  • Download URL: codex_stats-1.0.1.tar.gz
  • Upload date:
  • Size: 24.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for codex_stats-1.0.1.tar.gz
Algorithm Hash digest
SHA256 90d93ae473805bc379ef335b23b4022cfd5ba8980b199aa0ad35178fa88c8441
MD5 cd2878a65a90977ffc34b4cff792ec18
BLAKE2b-256 bc7d69c7192e1ce683be030ef168f0708d39adeeed2b9392a6a1f3c1e7e7beeb

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_stats-1.0.1.tar.gz:

Publisher: publish.yml on vivek378521/codex-stats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codex_stats-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: codex_stats-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for codex_stats-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c738ae612602adb8f07010661fc5577a1baedd3d0162c0f26964fa93260e7b88
MD5 e4ae8ceacefdf19e70bb56a030160fe0
BLAKE2b-256 06661d9685240d65a17f6e2254f78a441c87c308dae131d4de85957817b2fcbb

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_stats-1.0.1-py3-none-any.whl:

Publisher: publish.yml on vivek378521/codex-stats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page