CLI Consumption
CLI Consumption is a local-first Python package for measuring how AI coding CLIs use models, tokens, tools, conversations, and turns. It can analyze one workstation, consolidate copied data from several machines, or send metadata-only snapshots to a central collector.
Codex, Pi, OpenCode, and the core Claude Code local transcript format are supported. Kilo Code is planned behind the same provider-neutral adapter contract.
The collector deliberately excludes prompts, responses, tool arguments, and credentials. See Privacy before sharing a database or export.
Quick start
The project requires Python 3.14 or newer and uses
uv for every development and execution workflow.
From a checkout:
uv sync
uv run cli-consumption collect
uv run cli-consumption export --output reports
Open reports/dashboard.html locally. The generated dashboard is self-contained and
makes no network requests. Detailed normalized CSV tables are opt-in with --csv.
The dashboard supports time, provider, machine, project, and model filters. It reports period-over-period activity, token composition, cache efficiency, turn latency and duration distributions, technical throughput, context pressure, content-free work-item duration and reliability, configuration cohorts, compactions, subagent delegation, and ingestion quality. Token events are local usage metadata rather than billing records, and a technically completed turn is not a measure of task quality or productivity.
For a dashboard that is safer to share, pseudonymize machine, project, model, and role labels, group tool names, round timestamps to days, and hide small rows in the cohort-comparison view:
uv run cli-consumption export --output shared-report --share-safe
Share-safe reports still disclose aggregate work patterns and must be treated as private operational data.
From PyPI, the CLI can run without a permanent installation:
uv tool run cli-consumption collect
uv tool run cli-consumption export --output reports
To run the latest unreleased GitHub source instead:
uv tool run --from git+https://github.com/Guillaume-Lombardo/cli-consumption \
cli-consumption providers
Collect from one or more machines
With no source option, collect reads ~/.codex and labels it with the local
hostname:
uv run cli-consumption collect --database usage.sqlite
Select Claude Code to read ~/.claude/projects/ instead:
uv run cli-consumption collect --provider claude --database usage.sqlite
Select OpenCode to read ~/.local/share/opencode/opencode.db instead:
uv run cli-consumption collect --provider opencode --database usage.sqlite
Select Pi to read ~/.pi/agent/sessions/ instead:
uv run cli-consumption collect --provider pi --database usage.sqlite
Use all to detect and collect every supported provider present on the machine:
uv run cli-consumption collect --provider all --database usage.sqlite
With explicit copied sources, each path is inspected for the provider-specific
sessions/ or projects/ directory. Sources that contain no supported provider data
are rejected instead of silently skipped.
For an offline multi-machine workflow, copy only each machine's Codex sessions/
directory into a trusted analysis location. Do not copy auth.json or other
credentials. Then repeat --source:
uv run cli-consumption collect \
--source desktop=/data/codex/desktop \
--source laptop=/data/codex/laptop \
--source server=/data/codex/server \
--database usage.sqlite
Globally identical conversation IDs are deduplicated. If copies differ, the most complete rollout wins. Explicit project mappings use the longest matching original working-directory prefix:
uv run cli-consumption collect \
--source desktop=/data/codex/desktop \
--project cli-consumption=/home/me/dev/cli-consumption
Copied Claude Code sources point to the configuration directory containing projects/:
uv run cli-consumption collect --provider claude \
--source desktop=/data/claude/desktop \
--source laptop=/data/claude/laptop
Copied OpenCode sources point to the data directory containing opencode.db:
uv run cli-consumption collect --provider opencode \
--source desktop=/data/opencode/desktop \
--source laptop=/data/opencode/laptop
Copied Pi sources point to the agent directory containing sessions/:
uv run cli-consumption collect --provider pi \
--source desktop=/data/pi/desktop \
--source laptop=/data/pi/laptop
SQLite and PostgreSQL
A file path selects SQLite. A SQLAlchemy URL selects PostgreSQL:
uv run cli-consumption collect --database usage.sqlite
uv run cli-consumption collect \
--database postgresql+psycopg://usage@localhost/cli_consumption
Pass credentials through environment variables or a secret manager rather than shell
history. CLI_CONSUMPTION_DATABASE can supply the database setting.
Central collector API
Offline imports are the simplest choice for personal use and air-gapped machines. A central API is useful for recurring collection across machines.
Start the collector locally:
export CLI_CONSUMPTION_API_TOKEN="$(your-secret-provider)"
uv run cli-consumption serve \
--database postgresql+psycopg://usage@localhost/cli_consumption \
--host 0.0.0.0
Send a snapshot from another machine:
export CLI_CONSUMPTION_API_TOKEN="$(your-secret-provider)"
uv run cli-consumption sync --endpoint https://usage.example.test
The application refuses to bind beyond localhost without a token. Production deployments must also place TLS and normal operational controls in front of the ASGI server. See Architecture for trade-offs.
Commands
cli-consumption collect Collect local or copied provider data into SQL
cli-consumption sync Collect and send a snapshot to a central API
cli-consumption serve Run the central collection API
cli-consumption export Write the HTML dashboard and optional CSV tables
cli-consumption providers Show supported and planned providers
Run uv run cli-consumption COMMAND --help for every option.
Development
uv sync --all-groups
uv run pre-commit install
uv run pre-commit run --all-files
uv run ruff format --check .
uv run ruff check .
uv run ty check
uv run pytest --cov --cov-report=term-missing
uv build
Development follows short-lived branches and squash-merged pull requests into a
protected main. Read CONTRIBUTING.md and AGENTS.md
before changing the project.
License
Licensed under the Apache License 2.0. It provides permissive reuse plus an explicit patent grant and contribution protections appropriate for an extensible developer tool.
Metadata
Release files for cli-consumption 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cli_consumption-0.0.5.tar.gz | 96.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cli_consumption-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 149.6 kB
Release files / cli_consumption-0.0.5.tar.gz
| Download URL | cli_consumption-0.0.5.tar.gz |
|---|---|
| Size | 96.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5867a589b0266c1546a2ec097650ac6edf53ba7f9966401a0bc760c60cc783fc
|
|
BLAKE2b-256 checksum How to use checksums |
26b1b055ca91a6927c9b03e1d4b9f00ba9118b3a701b00510d4b77254663629b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 26, 2026.
Transparency logRelease files / cli_consumption-0.0.5-py3-none-any.whl
| Download URL | cli_consumption-0.0.5-py3-none-any.whl |
|---|---|
| Size | 52.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f32a527f8769edd847780f65b2490328264219a2a82c54d9b7c66cb3ab536bcc
|
|
BLAKE2b-256 checksum How to use checksums |
36aaaaec8894428323fd9793fa0caa31d8589916d61cf2a9d39ecebf91d51427
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 26, 2026.
Transparency log