Skip to main content

code-meter

Local AI Coding Token Usage Tracker, Prompt Log & Cost Estimator

code-meter (also available via claude-meter, codex-meter, antigravity-meter, and agy-meter aliases) is a production-quality local CLI application designed to track local usage for Claude Code, OpenAI Codex, and Google Antigravity, including tokens (input, output, cache-read, cache-write), session prompts, and code change history over time.

It features an extensible multi-provider architecture so all AI coding agents operate seamlessly within unified analytics and SQLite storage.


🔒 Privacy First

  • 100% Local: Operates completely offline using your local filesystem.
  • No Gateway / Telemetry: code-meter is NOT an API gateway, proxy, or interceptor.
  • Zero Uploads: No prompts, assistant responses, source code files, or conversation texts are uploaded anywhere. Only local token metrics, session prompts, and diff logs are saved to SQLite.
  • No API Key Required: Analyzes existing local session logs generated by Claude Code (~/.claude), OpenAI Codex (~/.codex), and Google Antigravity (~/.gemini/antigravity-ide).

📦 Installation

From PyPI (Standard Installation)

pip install code-meter

Local / Development (Editable Mode)

git clone https://github.com/dhanushnayak/code-meter.git
cd code-meter
pip install -e .

🚀 Basic Usage

Simply run:

code-meter

Or use one of the provider aliases (claude-meter, codex-meter, antigravity-meter, agy-meter).

This launches the interactive Rich terminal dashboard displaying key metrics, model breakdowns, project breakdowns, today's usage, and token burn rates.


🛠️ CLI Commands

Command Description
code-meter Open interactive Rich terminal dashboard
code-meter scan Force an incremental scan of local usage directories
code-meter today Summary of token usage and cost for today
code-meter week Summary of token usage and cost for the past 7 days
code-meter month Summary of token usage and cost for the past 30 days
code-meter status View system status (scanned files, records, prompts, code edits, DB size)
code-meter prompts View log of user prompts asked per session over time
code-meter history View log of code edits, file writes, and snapshots recorded per session
code-meter diffs View formatted code diff summaries saved in SQLite
code-meter report Detailed aggregated report with optional filters
code-meter models Usage and cost breakdown by model
code-meter projects Usage and cost breakdown by working project directory
code-meter sessions Usage and cost breakdown by session ID
code-meter export Export usage records to CSV or JSON format
code-meter config Display active configuration settings and file paths
code-meter watch Live file watcher mode for real-time dashboard updates

🔍 Filters & Examples

Combine filters on reporting, prompts, and history commands:

# Filter report by provider, project, model, and timeframe
code-meter report --provider codex --model gpt-4o --days 30
code-meter report --provider antigravity --model gemini-2.5-flash

# View prompts for a specific session or project
code-meter prompts --project rag-agent --limit 20

# View code changes and diffs for a file or session
code-meter history --file src/main.py
code-meter diffs --session abc12345

# Export usage stats to CSV or JSON
code-meter export --format csv --days 7 --output usage_report.csv

⚙️ Configuration

Configuration is stored in ~/.config/code-meter/config.toml (or Windows %APPDATA%/code-meter/config.toml).

[general]
database = "~/.local/share/code-meter/usage.db"

[claude_code]
directory = "~/.claude"

[codex]
directory = "~/.codex"

[antigravity]
directory = "~/.gemini/antigravity-ide"

[ui]
refresh_seconds = 2

[pricing]
currency = "USD"

Environment variables take precedence:

  • CODE_METER_DB
  • CODE_METER_CLAUDE_DIR
  • CODE_METER_CODEX_DIR
  • CODE_METER_ANTIGRAVITY_DIR
  • CODE_METER_REFRESH

🧩 Architecture

Claude Code (~/.claude)  Codex (~/.codex)  Antigravity (~/.gemini/antigravity-ide)
         │                       │                       │
         ▼                       ▼                       ▼
ClaudeCodeProvider        CodexProvider          AntigravityProvider
         │                       │                       │
         └───────────────────────┼───────────────────────┘
                                 ▼
         UsageRecord / SessionPrompt / SessionCodeChange (Pydantic models)
                                 │
                                 ▼
            Database Repository & Incremental Scanner (SQLite)
                                 │
                                 ▼
              Pricing Engine (Multi-Provider Model Pricing Tables)
                                 │
                                 ▼
             Analytics Engine (Token counts, Costs, Aggregations)
                                 │
                                 ▼
             Terminal UI & Typer CLI Commands
        │
        ▼

UsageRecord / SessionPrompt / SessionCodeChange (Pydantic models) │ ▼ Database Repository & Incremental Scanner (SQLite) │ ▼ Pricing Engine (Model Pricing Tables) │ ▼ Analytics Engine (Token counts, Costs, Aggregations) │ ▼ Terminal UI & Typer CLI Commands


---

## 🧪 Running Tests

```bash
pytest -v

📜 License

Distributed under the MIT License. See LICENSE for details.

Download files

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

Source Distribution

code_meter-0.2.0.tar.gz (35.0 kB view details)

Uploaded Source

Built Distribution

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

code_meter-0.2.0-py3-none-any.whl (41.8 kB view details)

Uploaded Python 3

File details

Details for the file code_meter-0.2.0.tar.gz.

File metadata

  • Download URL: code_meter-0.2.0.tar.gz
  • Upload date:
  • Size: 35.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.3

File hashes

Hashes for code_meter-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ad2179ca7ad4c0e0d27c9f3d06e5257a399a588429fd528eef2e28ca306f523b
MD5 301f4dce15cfe8e326126c3a2871846c
BLAKE2b-256 96bd134db325886f0cd1ba7c8ce877108bc8a6ea1461054da1994aaeabf37f66

See more details on using hashes here.

File details

Details for the file code_meter-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: code_meter-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 41.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.3

File hashes

Hashes for code_meter-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0eb6c4f18114c4a1ef59a54c613dcbec9f45f5919f8c2e26bbb585eaab0eff5c
MD5 476da4475b51b20a9f065d78ec3d5ba5
BLAKE2b-256 f2b277f50211139c99197fde6f4f1f92c5f6c279c8539c07ad68c47472666e68

See more details on using hashes here.

Release history Release notifications | RSS feed

0.7.0

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

This release

0.2.0 This release

2 files

0.1.0

2 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