claude-carbon 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +63 -15
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -3,9 +3,13 @@
3
3
  [![GitHub stars](https://img.shields.io/github/stars/gwittebolle/claude-carbon)](https://github.com/gwittebolle/claude-carbon/stargazers)
4
4
  [![License: MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE)
5
5
  [![GitHub release](https://img.shields.io/github/v/release/gwittebolle/claude-carbon)](https://github.com/gwittebolle/claude-carbon/releases)
6
+ [![npm](https://img.shields.io/npm/v/claude-carbon)](https://www.npmjs.com/package/claude-carbon)
7
+ [![CI](https://github.com/gwittebolle/claude-carbon/actions/workflows/ci.yml/badge.svg)](https://github.com/gwittebolle/claude-carbon/actions/workflows/ci.yml)
6
8
 
7
9
  Track the carbon footprint of your Claude Code sessions.
8
10
 
11
+ ![Live CO2 in the Claude Code status line](docs/demo.gif)
12
+
9
13
  **1. Install (or update):**
10
14
 
11
15
  ```bash
@@ -67,6 +71,9 @@ bash ~/code/claude-carbon/scripts/generate-report.sh --since 2026-03-01
67
71
 
68
72
  # All time
69
73
  bash ~/code/claude-carbon/scripts/generate-report.sh --all
74
+
75
+ # A closed period (--until is an exclusive upper bound: this one stops at June 30th)
76
+ bash ~/code/claude-carbon/scripts/generate-report.sh --since 2026-01-01 --until 2026-07-01
70
77
  ```
71
78
 
72
79
  </details>
@@ -75,9 +82,30 @@ bash ~/code/claude-carbon/scripts/generate-report.sh --all
75
82
  <summary>Custom install directory</summary>
76
83
 
77
84
  ```bash
78
- CLAUDE_CARBON_DIR=~/my-path/claude-carbon curl -fsSL https://raw.githubusercontent.com/gwittebolle/claude-carbon/main/install.sh | bash
85
+ curl -fsSL https://raw.githubusercontent.com/gwittebolle/claude-carbon/main/install.sh | CLAUDE_CARBON_DIR=~/my-path/claude-carbon bash
79
86
  ```
80
87
 
88
+ The env var has to sit on the `bash` side of the pipe, not the `curl` side, or the installer never sees it.
89
+
90
+ </details>
91
+
92
+ <details>
93
+ <summary>Second Claude environment (CLAUDE_CONFIG_DIR)</summary>
94
+
95
+ If you run a second Claude Code environment out of its own config directory, e.g.
96
+
97
+ ```bash
98
+ alias claude-work="CLAUDE_CONFIG_DIR=~/.claude-work claude"
99
+ ```
100
+
101
+ install claude-carbon into that same directory by passing `CLAUDE_CONFIG_DIR` to the installer:
102
+
103
+ ```bash
104
+ curl -fsSL https://raw.githubusercontent.com/gwittebolle/claude-carbon/main/install.sh | CLAUDE_CONFIG_DIR=~/.claude-work bash
105
+ ```
106
+
107
+ The status line, the Stop hook, the database and the `/carbon-*` commands all live under that config dir, so each environment tracks its own sessions independently. When `CLAUDE_CONFIG_DIR` is unset everything falls back to `~/.claude` as before.
108
+
81
109
  </details>
82
110
 
83
111
  <details>
@@ -121,7 +149,7 @@ Restart Claude Code.
121
149
  claude-carbon measures one developer's sessions, locally. If the question comes from your CTO, a client RFP or a CSR committee, the same methodology exists as a hosted layer:
122
150
 
123
151
  - [Free calculator and per-model factor sheets](https://tokenclimate.com/calculator) - the exact versioned factors of this repo, browsable.
124
- - [Bilan IA](https://tokenclimate.com/bilan) - a self-serve, shareable report of your organisation's real Claude usage (cost, CO2e, water, energy), generated in minutes from an Anthropic admin key. The key is never stored; the methodology annex is citation-ready.
152
+ - [Bilan IA](https://tokenclimate.com/bilan/en?ref=github) - a self-serve, shareable report of your organisation's real Claude usage (cost, CO2e, water, energy), generated in minutes from an Anthropic admin key. The key is never stored; the methodology annex is citation-ready.
125
153
  - [TokenClimate](https://tokenclimate.com) - hosted team dashboards. Both sides share this repo's golden vectors, verified weekly in CI.
126
154
 
127
155
  The only places the OSS points there are a one-line footer in `/carbon-report` and a small credit on the `/carbon-card` PNGs. No status-line promo, no email capture: nothing leaves your machine.
@@ -171,15 +199,25 @@ bash scripts/recompute.sh
171
199
  | `safety-rescan.sh` | SessionStart hook (throttled background re-scan, catches missed sessions) |
172
200
  | `backfill.sh` | Re-parse all historical JSONL transcripts (incl. subagents) |
173
201
  | `recompute.sh` | Re-derive cost/CO2 from stored tokens after a price/factor change (no transcripts needed) |
174
- | `generate-report.sh` | Export PNG report cards (CLI, with `--since` / `--all`) |
202
+ | `generate-report.sh` | Export PNG report cards (CLI, with `--since` / `--until` / `--all`) |
175
203
 
176
204
  Note: backfill now derives project names from the transcript's `cwd` (matching the live hook). Sessions backfilled before this change keep their old, possibly truncated names; delete those rows and re-run `backfill.sh` to normalize them.
177
205
 
178
206
  </details>
179
207
 
208
+ ## Using with ccstatusline
209
+
210
+ Claude Code accepts a single `statusLine` command, so claude-carbon's full status line and [ccstatusline](https://github.com/sirmalloc/ccstatusline) cannot run side by side. If ccstatusline drives your status line, embed the CO2 segment instead: in the ccstatusline TUI, add a `Custom Command` widget pointing to
211
+
212
+ ```
213
+ ~/code/claude-carbon/scripts/statusline.sh --segment
214
+ ```
215
+
216
+ (adjust the path if you installed with `CLAUDE_CARBON_DIR`). The widget receives the same status JSON on stdin and prints just the cost + CO2 pair, e.g. `$0.68 · 35g CO₂`. Segment mode never touches the network. Recording to the local database is unaffected either way: persistence runs from hooks, not from the status line.
217
+
180
218
  ## Emission factors
181
219
 
182
- Factors from [Jegham et al. 2025](https://arxiv.org/abs/2505.09598), a peer-reviewed study measuring energy consumption of LLM inference on AWS infrastructure.
220
+ Factors from [Jegham et al. 2025](https://arxiv.org/abs/2505.09598), an arXiv preprint that estimates the energy consumption of LLM inference on AWS infrastructure from public API performance data (latency, throughput) over inferred hardware configurations.
183
221
 
184
222
  | Model | Input (gCO2e/Mtok) | Output (gCO2e/Mtok) | Basis |
185
223
  | ------ | ------------------ | ------------------- | -------------------------- |
@@ -190,7 +228,7 @@ Factors from [Jegham et al. 2025](https://arxiv.org/abs/2505.09598), a peer-revi
190
228
 
191
229
  **Important: these are order-of-magnitude estimates, not precise measurements.**
192
230
 
193
- - Sonnet factors are a 3-point least-squares fit to the three measured Claude 3.7 Sonnet per-query energies in Jegham et al. v6 (0.950 / 2.989 / 5.671 Wh), giving a ~21:1 output:input ratio. The value is cross-validated against [EcoLogits](https://ecologits.ai): its independent estimate for Sonnet brackets the same range. Fable, Opus and Haiku are extrapolated (no public data from Anthropic on per-model energy consumption); Opus = 2x Sonnet matches both the current EcoLogits Opus 4.5+ parameter ratio and the Anthropic price ratio (honest band 2x-5x).
231
+ - Sonnet factors are a 3-point least-squares fit to the three Claude 3.7 Sonnet per-query energies estimated in Jegham et al. v6 (0.950 / 2.989 / 5.671 Wh), giving a ~21:1 output:input ratio. The value is consistent with [EcoLogits](https://ecologits.ai): its independent estimate for Sonnet brackets the same range (a wide band, so this is a consistency check, not proof). Fable, Opus and Haiku are extrapolated (no public data from Anthropic on per-model energy consumption); Opus = 2x Sonnet matches both the current EcoLogits Opus 4.5+ parameter ratio and the Anthropic price ratio (honest band 2x-5x).
194
232
  - Sessions run on non-Anthropic models (e.g. local models behind `ANTHROPIC_BASE_URL`) are stored with their raw tokens but zero cost/CO2 and excluded from reports - a datacenter factor doesn't apply to them. Add patterns to `exclude_models` in `data/factors.json` to exclude more models by name.
195
233
  - Cache read tokens are counted at a reduced factor (default 0.08 of an input token, set in `data/factors.json`). A cached token skips prefill compute but still incurs decode-phase memory reads, so it is cheap but not free. This is an engineering estimate derived from the literature, not Anthropic's 0.1x billing ratio. See [METHODOLOGY.md](METHODOLOGY.md).
196
234
  - Carbon intensity uses the AWS region grid (location-based, 0.287 kgCO2e/kWh), not real-time grid data. This sits at the low end of the location-based range; the US national average is ~380 g/kWh.
@@ -239,7 +277,7 @@ Measuring is step one. Here are concrete levers to reduce your AI carbon footpri
239
277
 
240
278
  ### Use the right model for the task
241
279
 
242
- Output tokens cost ~21x more energy than input tokens (the marginal output:input ratio from Jegham v6). Opus consumes ~2x more than Sonnet per token.
280
+ Output tokens cost ~21x more energy than input tokens (the marginal output:input ratio fit on Jegham v6). Opus is estimated at ~2x Sonnet per token (uncertainty band 2x-5x, see METHODOLOGY.md).
243
281
 
244
282
  ```json
245
283
  {
@@ -249,7 +287,7 @@ Output tokens cost ~21x more energy than input tokens (the marginal output:input
249
287
  }
250
288
  ```
251
289
 
252
- Use Opus for architecture and planning. Sonnet for daily work. Haiku for subagents (exploration, file reading, reviews). This alone can cut your emissions by 60%.
290
+ Use Opus for architecture and planning. Sonnet for daily work. Haiku for subagents (exploration, file reading, reviews). As an indicative estimate with this tool's factors, this alone can cut your emissions by up to ~60% vs all-Opus.
253
291
 
254
292
  ### Install RTK (Rust Token Killer)
255
293
 
@@ -296,18 +334,20 @@ Output tokens are the most expensive in both cost and energy.
296
334
 
297
335
  ### Combined impact
298
336
 
299
- | Lever | Estimated reduction |
300
- | -------------------- | ----------------------- |
301
- | Right model per task | -60% vs all-Opus |
302
- | RTK | -70% on CLI tokens |
303
- | Thinking cap at 10k | -70% on thinking tokens |
304
- | Haiku subagents | -80% on exploration |
305
- | **All combined** | **-50 to 70% total** |
337
+ These reductions are indicative estimates, not measurements on a benchmark workload. The RTK figure comes from RTK's own documentation. The Haiku rows follow from this tool's own factors (Haiku = 0.5x Sonnet = 0.25x Opus per token): -50% when your subagents would otherwise run Sonnet, -75% when they would run Opus. They inherit the 0.5x extrapolation, the widest uncertainty band in the tool (see METHODOLOGY.md); if most of your usage is already Haiku, your absolute total rides on that band, so read it as an order of magnitude.
338
+
339
+ | Lever | Estimated reduction |
340
+ | -------------------- | ---------------------------- |
341
+ | Right model per task | -60% vs all-Opus |
342
+ | RTK | -70% on CLI tokens |
343
+ | Thinking cap at 10k | -70% on thinking tokens |
344
+ | Haiku subagents | -75% vs Opus, -50% vs Sonnet |
345
+ | **All combined** | **-50 to 70% total** |
306
346
 
307
347
  ### Further reading
308
348
 
309
349
  - [IEA - Energy and AI (2025)](https://www.iea.org/reports/energy-and-ai/) - data center projections
310
- - [Jegham et al. - How Hungry is AI?](https://arxiv.org/abs/2505.09598) - per-model energy measurements
350
+ - [Jegham et al. - How Hungry is AI?](https://arxiv.org/abs/2505.09598) - per-model energy estimates
311
351
  - [UCL/UNESCO - 90% AI energy reduction](https://www.ucl.ac.uk/news/2025/jul/practical-changes-could-reduce-ai-energy-demand-90) - frugal AI approaches
312
352
  - [GreenIT.fr - AI impacts 2025-2030](https://www.greenit.fr/impacts-ia-monde-2025-2030-rapport/) - French data
313
353
 
@@ -315,6 +355,14 @@ Output tokens are the most expensive in both cost and energy.
315
355
 
316
356
  Every Claude Code session uses real compute, real energy, real emissions. The number is small per query, but it adds up. Making it visible is the first step to owning it.
317
357
 
358
+ ## Citing
359
+
360
+ If claude-carbon's numbers or methodology end up in your article, talk or product, a citation is appreciated. GitHub's "Cite this repository" button generates BibTeX/APA from [CITATION.cff](CITATION.cff). Short form:
361
+
362
+ > Wittebolle, G. (2026). claude-carbon: carbon footprint tracker for Claude Code sessions. https://github.com/gwittebolle/claude-carbon
363
+
364
+ The shareable report cards already carry this attribution in their footer, so reposting a card as-is credits the tool.
365
+
318
366
  ## Open source
319
367
 
320
368
  claude-carbon is free and open source under the [MIT license](LICENSE). Contributions welcome.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-carbon",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Track the carbon footprint of your Claude Code sessions",
5
5
  "bin": {
6
6
  "claude-carbon": "bin/claude-carbon.js"