Skip to main content

Token usage analytics for Codex CLI sessions

Project description

cxstat

Token usage analytics for Codex CLI sessions

What cxstat?

  • Visualize token usage for MCP and shell and more other tool call.
  • Highlight the most expensive tools, prompts, and projects so you can tune workflows fast.

Key Features

  • Rich-powered reports - colourful tables for top tools, providers, and individual function calls.
  • Project breakdown - aggregate counts per workspace, including the latest invocation timestamp.
  • Zero-noise defaults - ignores empty invocations while keeping total call counts for context.

Installation

cxstat targets Python 3.12+. Install from source with your preferred workflow:

# using uvx
uvx cxstat

# using uv
uv tool install cxstat

# or pip
pip install cxstat

Quick Start

Analyse your Codex CLI history in seconds:

  1. Summarise every project collected under the default sessions root (~/.codex/sessions):

    cxstat
    

    Use flags such as --detail or --top 10 when you want deeper tool or prompt rankings.

  2. Focus on a single project by passing its path (absolute or relative) as the positional argument:

    cxstat /path/to/project
    

    The summary switches to that project only and reuses your chosen options (e.g. --detail).

  3. Review the project catalogue with their aggregated totals:

    cxstat list-project --top 10
    

    The listing displays each project path, total/input/output token counts, call volume, and the most recent invocation timestamp. Combine it with --sessions-root when your logs live outside the default directory.

Sample summary output:

Analysed 128 tool invocations (96 with tokens).
Total tokens: 68,421 (input 41,230 / output 27,191).

Token Usage by Tool
#  Label                                 Total Tokens  Input   Output  Calls
1  mcp.tavily-search                             18432  12321     6111     28
2  shell                                         14220   9000     5220     35
3  mcp.context7:get-library-docs                  8230   5110     3120     12

The project listing offers similar insight per workspace:

Token Usage by Project
#  Project                               Total Tokens  Input   Output  Calls  Last Invocation
1  /home/user/work/acme-app                     19876   12980     6896     42  2025-07-18T14:02:33
2  /home/user/work/internal-tools               15220    9210     6010     31  2025-07-17T09:11:02

Options

All commands share these flags:

  • --sessions-root PATH - directory containing Codex CLI JSONL logs (defaults to ~/.codex/sessions).
  • --detail / -d - include provider-level and top-call breakdown tables.
  • --top N - limit table rows for each summary table.
  • --theme NAME / -t NAME - select the colour theme for table output (available: default, contrast, mono, monokai, dracura, ayu; default is dracura).
  • --version / -v - show the installed cxstat version and exit.

Roadmap Status

  • Additional groupings (agents, approval policy, latency buckets).
  • Optional CSV/JSON export for dashboards.
  • Snapshot comparisons between two time ranges.

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

cxstat-0.1.1.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

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

cxstat-0.1.1-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file cxstat-0.1.1.tar.gz.

File metadata

  • Download URL: cxstat-0.1.1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.14

File hashes

Hashes for cxstat-0.1.1.tar.gz
Algorithm Hash digest
SHA256 436e09c38782dc4b67a4c0cc6b939a64df774d505c85afe7bb7c3ad614ad6a81
MD5 b2706510aa454c6035d2db9e993a8caa
BLAKE2b-256 e90b20c89d42f528b986d7986d85d31f03f5d849c13d42089eade567efa32f4e

See more details on using hashes here.

File details

Details for the file cxstat-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cxstat-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.14

File hashes

Hashes for cxstat-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b2dd710b5da08a1381eed70464a9900d1f0e0c259c67eeb6eaf9a4682d231dbf
MD5 8fae7a7760c5d5f337636f7aa98e0a9a
BLAKE2b-256 c54e26ca56beefb090e214ffb2bdae1c3b6f9e2f3df26e3eef34f0e32aa8f571

See more details on using hashes here.

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