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:
# default root is ~/.codex/sessions
cxstat
# customise the tokenizer and row limits
cxstat --top 10
# inspect usage grouped by project paths
cxstat list-project
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).--model NAME- model hint used to resolve the tokenizer (e.g.gpt-4o-mini).--encoding NAME- explicit tiktoken encoding such ascl100k_base.--top N- limit table rows; combine with--show-fullto disable truncation.
Roadmap Status
- Additional groupings (agents, approval policy, latency buckets).
- Optional CSV/JSON export for dashboards.
- Snapshot comparisons between two time ranges.
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 cxstat-0.1.0.tar.gz.
File metadata
- Download URL: cxstat-0.1.0.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55e2182547040bf0543c82d1c3b7003fd4e71829dbcacea1e86f00ccae3cdefb
|
|
| MD5 |
e439d7a1bdfbb4dc3c777bc601922676
|
|
| BLAKE2b-256 |
6e99f487cc502273562dbbf96060834be2c00d8e9df31b0dd0eb9afe0b8dd05b
|
File details
Details for the file cxstat-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cxstat-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b2108b7cab49118970a52aafed821e478dfd982776aa01f2e5656a25e00524b
|
|
| MD5 |
d4d2db28c68810c20a171c8b4ec3ac24
|
|
| BLAKE2b-256 |
207995c630acb60aed6203212fbb0248472ea83d81e05eb5ae66835c916f0898
|