Skip to main content

aimpg

Miles per gallon for AI coding. Find out how much energy your AI coding agent used, and which of your commits it went into.

uvx aimpg report

Example output:

AI energy in window .......................... 6.99 kWh – 57.39 kWh  (4,744 requests)
  matched to commits ......................... 5.87 kWh – 47.96 kWh  (223 commits: 223 exact, 0 fuzzy, 0 grace)
  exact-match share of in-repo energy: 84%, any match: 84%
  no commit from this session yet ............ 1.11 kWh – 9.38 kWh  (609 requests)

Median direct energy per kept commit: 27.2 Wh – 212.9 Wh

Most energy-hungry commits:
       213.2 Wh – 1.71 kWh  my-app 2ef4297 fix: date parsing for day-first locales

What it does

aimpg reads the Claude Code session logs already on your machine (~/.claude/projects). It works out which AI requests produced which of your git commits, and prints an energy receipt:

  • Energy per kept commit, as a low–high range in Wh
  • Discarded work: energy that went into commits that never reached your main branch
  • The most and least energy-hungry commits
  • Unmatched energy: work that produced no commit (yet), shown openly rather than hidden

Privacy

Everything runs locally. aimpg report makes no network calls (unless you pass --fetch, which runs git fetch). Nothing is uploaded, and your code and prompts never leave your machine.

How it matches requests to commits

  1. Exact: when the agent runs git commit, the commit lands while that tool call is running. We match commits to those call windows, including slow commits where pre-commit hooks run for minutes.
  2. Time segments: within a session, the requests made since the previous commit belong to the next one, in whatever repo it lands. A 2h+ break starts a new work burst. Only the final burst counts as the commit's direct energy, and earlier bursts are shown as lead-up.
  3. Fuzzy (fallback): commits you make by hand are matched only if you authored them (your user.email), within 2 hours of the session, and only if they touch files the session edited. Teammates' commits are never claimed.

On the author's own history, a hand-labeled check of 20 commits matched 20/20 to the right session (evals/).

How energy is estimated

Model sizes for Claude aren't public, so every number is a range, never a single figure. The formula is physical, not price-based:

  • Prefill: compute energy for every fresh or cache-written input token.
  • Decode: each output token re-reads the model weights and the whole KV cache, so long contexts make every output token more expensive.
  • Cache reads: free when the cache is still in GPU memory, a reload when it isn't.
  • Overhead: server and datacenter overhead (PUE) on top.

Per-operation energy comes from From Tokens to Watt-hours. Server overhead and PUE come from EcoLogits. Model-size classes are labeled assumptions. Every coefficient and its source is in aimpg/factors.json.

Options

aimpg report [--days 30] [--logs ~/.claude/projects] [--fetch]

Limits (honest list)

  • Claude Code logs only, for now.
  • Work before a 2h+ break is reported as a commit's lead-up, separate from its direct energy. A multi-day feature that genuinely needed that earlier work will look cheaper in the direct number, so check the lead-up too.
  • Commits less than 7 days old show as pending until we can tell whether they were kept.

Roadmap

Next is aimpg replay: rerun your own past commits through different setups (for example Claude Code with and without a token saver) to prove which one saves energy without breaking your tests. See docs/designs/aimpg-design.md.

License

MIT

Metadata

Release files for aimpg 0.1.0

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

Source distribution (sdist)

Source distribution for aimpg 0.1.0
File Size Uploaded
aimpg-0.1.0.tar.gz 53.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aimpg 0.1.0
File Interpreter ABI Platform
aimpg-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 78.2 kB

Release files / aimpg-0.1.0.tar.gz

Download URL aimpg-0.1.0.tar.gz
Size 53.9 kB
Tags Source
SHA-256 checksum
How to use checksums
795ba478a8efdf150c54c97d35723580f46987af4672659033d9b4b0d53a2279
BLAKE2b-256 checksum
How to use checksums
ce7c7cc72b70030c2c3ec1246637eddebe1f5fcba93933e8c5cfc273e55f968f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / aimpg-0.1.0-py3-none-any.whl

Download URL aimpg-0.1.0-py3-none-any.whl
Size 24.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
73c17b6bdde236b476010914a11e20dd6f4523e3153d741a6b98621e707a7b8a
BLAKE2b-256 checksum
How to use checksums
c4014b4d9aeddbc4789e2a43e86b3cf19bc8ac10369eadad3bc1cb968d12184b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

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.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

This release

0.1.0 This release

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