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 Web Dashboard on http://localhost:5005 (auto-opens browser)
code-meter ui --terminal Launch live interactive Rich terminal UI
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.5.0.tar.gz (43.6 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.5.0-py3-none-any.whl (50.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: code_meter-0.5.0.tar.gz
  • Upload date:
  • Size: 43.6 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.5.0.tar.gz
Algorithm Hash digest
SHA256 665bc4f0b1a426560141887df3a8b152d3e7a146ff4186cfa307862e3f110dcb
MD5 136fdcef14e943b2e92bad20a6000bbd
BLAKE2b-256 4218558ea06a2515582b4cdd958a6a98b50f6cd3aff8b91c8f7d66ea76ac1f08

See more details on using hashes here.

File details

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

File metadata

  • Download URL: code_meter-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 50.6 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.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d6b93dfd5681447c2640a1edf45ab0e626443950466d44bd162ecd1de2c2c20c
MD5 aee139c9898db870f81c4f5c32def557
BLAKE2b-256 419f963c0c4beb76a8aadc785063a8162596f443cef67644823e08e3e70de517

See more details on using hashes here.

Release history Release notifications | RSS feed

0.7.0

2 files

0.6.0

2 files

This release

0.5.0 This release

2 files

0.4.0

2 files

0.3.0

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