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.


🖥️ Interactive Rich Terminal UI

code-meter includes a full-featured, responsive Rich Terminal User Interface that presents live token metrics, USD costs, user queries, and model outputs in real-time.

+--------------------------------------------------------------------+
|                             CODE METER                             |
|                              Overview                              |
+--------------------------------------------------------------------+
+--------------------------- Key Metrics ----------------------------+
| Requests:                                                        3 |
| Input Tokens:                                                 1.5K |
| Output Tokens:                                                 400 |
| Cache Read:                                                    300 |
| Total Tokens:                                                 2.2K |
| Estimated Cost:                                              $0.02 |
+--------------------------------------------------------------------+
| BY MODEL            | Tokens   | Cost                              |
| gemini-2.5-flash    | 2.20K    | $0.02                             |
+--------------------------------------------------------------------+
| RECENT USER QUERIES / PROMPTS                                      |
| 09-01 12:00 | antigravity | Build an interactive dashboard UI     |
+--------------------------------------------------------------------+
| RECENT OUTPUTS & CODE EDITS                                       |
| 09-01 12:01 | WRITE_FILE  | src/main.py | + print('Hello')        |
+--------------------------------------------------------------------+

🛠️ CLI Commands

Command Description
code-meter Open main interactive Rich terminal dashboard UI
code-meter ui Launch live interactive Rich terminal UI watching all AI log directories
code-meter watch Live watch mode (auto-refreshes UI as AI agents write logs)
code-meter update-pricing Fetch latest real-time token pricing for 2,800+ models
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 and queries asked over time
code-meter history View log of code modifications, file writes, and assistant actions
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

🔍 Filters & Examples

Combine filters on reporting, prompts, and history commands:

# Update real-time token costs for 2,800+ models
code-meter update-pricing

# 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 (Auto Daily Sync & Live Model Pricing)
                                 │
                                 ▼
             Analytics Engine (Token counts, Costs, Aggregations)
                                 │
                                 ▼
          Rich Terminal UI & Interactive Dashboard Commands

🧪 Running Tests

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.3.0.tar.gz (36.2 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.3.0-py3-none-any.whl (42.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: code_meter-0.3.0.tar.gz
  • Upload date:
  • Size: 36.2 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.3.0.tar.gz
Algorithm Hash digest
SHA256 03cb77dbfa8c22df69dee8cd75170c074f734d2fe66adb7f2ede1a3daee236ba
MD5 8ddf92d4369f578b78b0170c2a4adbe4
BLAKE2b-256 afa734718729c2c330c9eb2e73a0bef6ad466b772f046763d3f87419ce2d8b58

See more details on using hashes here.

File details

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

File metadata

  • Download URL: code_meter-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 42.5 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7ea8b67786a90d4a4bcdd8916771ae920c721f5da0037417d86ece144a8e79b2
MD5 3190b95f3c38edc17e62156b9bc7afd1
BLAKE2b-256 115b5ae36ee6fc8c82bedbb9a3a8c0a59a3c5bde80ab442bf0b0aeaa011c32d3

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

This release

0.3.0 This release

2 files

0.2.0

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