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.1.0.tar.gz (33.5 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.1.0-py3-none-any.whl (39.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: code_meter-0.1.0.tar.gz
  • Upload date:
  • Size: 33.5 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.1.0.tar.gz
Algorithm Hash digest
SHA256 b023e13e050225f0c7476800b27c19a2853bb6ba9fd5d47c4d25ea186052455e
MD5 315c73aab1b441d0fd8fb77b5501dccb
BLAKE2b-256 c7213a98379276b7969e75fe8710e4c7dfcf239947da1f4d793a0f129db61d94

See more details on using hashes here.

File details

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

File metadata

  • Download URL: code_meter-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 39.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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c5ad99c1448cdbb850fc8144e420bee7d15243f35df6003c0107401b0233ff91
MD5 75397325be55ff03227cb3a5827cf18d
BLAKE2b-256 6e8290ae1a8827e9c92fb90021b754efe9fd454cd2a7c957ff82daf952e2fd4b

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

0.2.0

2 files

This release

0.1.0 This release

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