Skip to main content

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, Aider, Gemini CLI, Kilo Code, Pi, OpenCode, and the core Claude Code local transcript format are supported.

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 Kilo Code to read ~/.local/share/kilo/kilo.db instead:

uv run cli-consumption collect --provider kilo --database usage.sqlite

Select Pi to read ~/.pi/agent/sessions/ instead:

uv run cli-consumption collect --provider pi --database usage.sqlite

Select Gemini CLI to read ~/.gemini/tmp/*/chats/ instead:

uv run cli-consumption collect --provider gemini --database usage.sqlite

Select Aider to read a local analytics log configured at ~/.aider/analytics.jsonl instead:

export AIDER_ANALYTICS_LOG="$HOME/.aider/analytics.jsonl"
uv run cli-consumption collect --provider aider --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 Kilo Code sources point to the data directory containing kilo.db:

uv run cli-consumption collect --provider kilo \
  --source desktop=/data/kilo/desktop \
  --source laptop=/data/kilo/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

Copied Gemini CLI sources point to the configuration directory containing tmp/:

uv run cli-consumption collect --provider gemini \
  --source desktop=/data/gemini/desktop \
  --source laptop=/data/gemini/laptop

Copied Aider sources point to a directory containing analytics.jsonl:

uv run cli-consumption collect --provider aider \
  --source desktop=/data/aider/desktop \
  --source laptop=/data/aider/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.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cli-consumption 0.0.8
File Size Uploaded
cli_consumption-0.0.8.tar.gz 105.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cli-consumption 0.0.8
File Interpreter ABI Platform
cli_consumption-0.0.8-py3-none-any.whl Python 3 none any Details

Total release size: 170.5 kB

Release files / cli_consumption-0.0.8.tar.gz

Download URL cli_consumption-0.0.8.tar.gz
Size 105.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9309224a32d0237cbf18d1a542ef6793a47154a6e1b600d1c157cf1b44068b6f
BLAKE2b-256 checksum
How to use checksums
45370df7847a6a89c72d1baa3939f90a0880973a2449c716d79b7296ab57ad99
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

Release files / cli_consumption-0.0.8-py3-none-any.whl

Download URL cli_consumption-0.0.8-py3-none-any.whl
Size 64.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
53bfd2845159ab528257f92a7518db0ba0932f0f1d38a7c77d71ea349e9a702f
BLAKE2b-256 checksum
How to use checksums
9b34331b3360d03b0b2d7dffabd5d0273904a91bdee549eadebbfb97cba052eb
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

Release history Release notifications | RSS feed

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.18

2 release files

0.0.17

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

This release

0.0.8 This release

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page