Claude Carbon
Track the live carbon footprint and energy usage of your Claude Code sessions across both the terminal and the Claude desktop app.
claude plugin validate to auditGuide →Reads local project files, settings, transcripts, or environment variables.
Statically scanned from hooks & source. Learn how to audit

claude-carbon is an open source Claude Code plugin that tracks the carbon footprint of your sessions: a live CO2 estimate computed locally from your token usage, in the terminal status line and in the Code tab of the Claude desktop app, next to the session's API-equivalent cost. In the desktop app, /carbon-panel opens a pane with a pixel molecule coloured by this session's CO2 against the median of your past sessions, your usage over the period you pick, its warming stripes, and a button for your yearly card.
What claude-carbon does
/carbon-panel: a pane in the Claude desktop app with your CO2 molecule, your usage and the warming stripes of your sessions (in a terminal, the session in the band above the prompt). See the mod- Adds a live CO2 estimate to the Claude Code status line, and the session's CO2 under the prompt in the Claude desktop app, each next to the session's API-equivalent cost
- Persists each session to a local SQLite database, so history survives the 30-day transcript purge
- Backfills historical data from existing
~/.claudetranscripts - Slash commands:
/carbon-report(text),/carbon-card(PNG),/carbon-pr(footprint of a pull request) - A README badge with your all-time total, and a public methodology with every factor sourced
About the
$figure. It is an API equivalent: what your session would cost at Anthropic's pay-as-you-go API list prices. On a Pro, Max or Ultra subscription you do not pay it; it shows the value of what you used, next to its CO2. See How it works.
Install
In Claude Code, type:
/plugin install claude-carbon --marketplace gwittebolle/claude-carbon
Claude Code asks you to confirm the marketplace, shows what the plugin installs, then asks where to install it: pick Install for you. The same line works on macOS, Linux and Windows. In the Code tab of the Claude desktop app, if the line is not taken, paste this message instead and accept when Claude asks:
Install the claude-carbon plugin for me: claude plugin install claude-carbon --marketplace gwittebolle/claude-carbon
Then quit Claude Code completely, open it again and start a new session. Your CO2 now shows next to the session's cost:
- in a terminal, in the status line:
$0.50 · 65gCO₂ - in the desktop app, under the prompt:
This session: 3.6 gCO₂ · $0.12
The plugin sets that status line once, at its first session start, and only when you have none: another tool's status line is left as it is (to add the CO2 to it, see ccstatusline). /carbon-report gives your totals, and /carbon-panel opens the pane in the desktop app. The $ is an API-equivalent cost, not what your subscription bills. To update later, run /carbon-update.

If the install stops
- macOS opens a window about "command line developer tools". That is
git, which Claude Code needs to fetch the plugin and a Mac without developer tools does not have yet. Click Install, wait until it finishes (a few minutes), then install again. - "jq is not installed" or "sqlite3 is not installed". Tell Claude: "Install what is missing.", then restart Claude Code. Every Mac has
sqlite3, and macOS 15 and later also havejq. On an older Mac, Claude can installjqwith Homebrew, or the installer (under Other ways to install) fetches the officialjqitself, checked against its published checksum. On Windows,/carbon-panelnames the one missing and Claude can install it withwinget. Ifwingetanswers "Access is denied", security software on the PC is blocking it: allowwingetthere, then try again. - Windows says Git Bash is missing. Install Git for Windows (Claude Code needs it on Windows anyway), quit the app completely and reopen it, then install again in a new session. Claude Code looks for Git Bash when a session starts, so a session open during the Git install still runs without it.
- Installed from Anthropic's community marketplace and the plugin fails to load? The
co2-tracker@claude-communityentry is pinned to a release from August 2026 that current Claude Code rejects ("Duplicate hooks file detected"). Run/plugin uninstall co2-tracker@claude-community, then install as above.
Other ways to install
-
The installer, a script that clones this repository and wires everything into
~/.claude/settings.jsonitself. Paste this message into Claude Code, or run the command after the colon yourself in a terminal:Install claude-carbon for me by running this command: curl -fsSL https://raw.githubusercontent.com/gwittebolle/claude-carbon/main/install.sh | bashOn Windows, in PowerShell (it needs Git for Windows and two packages first, see Windows):
Install claude-carbon for me by running this command in PowerShell: irm https://raw.githubusercontent.com/gwittebolle/claude-carbon/main/install.ps1 | iexIf the mode selector under the prompt shows Auto, pick Manual first: auto mode blocks a command that downloads a script and runs it. You can read install.sh before running it.
-
With Node.js:
npx claude-carbonruns the same installer.
Use one way only: the plugin and the installer together would run every hook twice. Already installed with the installer? Nothing to change, /carbon-update keeps it up to date.
Not covered: the chat and Cowork tabs and the web app (claude.ai/code). Their sessions run on Anthropic's servers, so nothing reaches your machine to count.
Example report
Generate yours with /carbon-card in Claude Code. The summary and detailed PNGs land in
~/Downloads/claude-carbon/ (the Windows Downloads folder follows the system setting, so a
OneDrive-redirected one is honoured) and the folder opens in your file manager, with the
card selected on macOS. CLAUDE_CARBON_EXPORT_DIR picks another folder;
CLAUDE_CARBON_NO_OPEN=1 skips the opening.
Without Playwright or Chromium there is no PNG and the command still finishes: the summary
card is saved as an HTML page in the same folder and opens in your browser, scaled to fit the
window, and a screenshot of it does the job.
The token count on the card is every token Claude processed, cache reads included, as ccusage counts them; the grey line under it gives the share of cache reads. The card's footer says where to find the tool, claude-carbon sur GitHub / claude-carbon on GitHub, with the address below it.
From the 1st to the 10th of each month the status line ends with 📊 September: 84.2kgCO₂ · /carbon-card:
the total of the month just closed, the bar the card draws for it, in the same format as the
session figure. It is read from carbon.db once a day while the nudge shows, and kept in
~/.claude/claude-carbon/last-month-total. A month with fewer than 7 days of sessions gets no
nudge, so a fresh install is not pushed to share a near-empty card. Generating a card
clears it for the month; it goes quiet on its own after the 10th. In December it gives the year
so far instead, 📊 2026: 1444.4kgCO₂ · /carbon-card, and stays the whole month, the card covering
the calendar year. From the 1st to the 10th of January it gives the year just ended, and over those
days /carbon-card covers that year, whole, unless you pass a period or that year has no session (the
card keeps those ten days even when the reminder is turned off). CLAUDE_CARBON_CARD_NUDGE_UNTIL_DAY
moves the cut-off (0 removes the nudge, December included), CLAUDE_CARBON_NO_CARD_NUDGE=1 removes the nudge. Nothing is posted anywhere:
sharing stays a human decision.
Advanced options (CLI)
# Since a specific date
bash ~/code/claude-carbon/scripts/generate-report.sh --since 2026-03-01
# All time
bash ~/code/claude-carbon/scripts/generate-report.sh --all
# A closed period (--until is an exclusive upper bound: this one stops at June 30th)
bash ~/code/claude-carbon/scripts/generate-report.sh --since 2026-01-01 --until 2026-07-01
Custom install directory
curl -fsSL https://raw.githubusercontent.com/gwittebolle/claude-carbon/main/install.sh | CLAUDE_CARBON_DIR=~/my-path/claude-carbon bash
The env var has to sit on the bash side of the pipe, not the curl side, or the installer never sees it.
Second Claude environment (CLAUDE_CONFIG_DIR)
If you run a second Claude Code environment out of its own config directory, e.g.
alias claude-work="CLAUDE_CONFIG_DIR=~/.claude-work claude"
install claude-carbon into that same directory by passing CLAUDE_CONFIG_DIR to the installer:
curl -fsSL https://raw.githubusercontent.com/gwittebolle/claude-carbon/main/install.sh | CLAUDE_CONFIG_DIR=~/.claude-work bash
The status line, the hooks, 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.
Manual install
git clone https://github.com/gwittebolle/claude-carbon.git ~/code/claude-carbon
bash ~/code/claude-carbon/scripts/setup.sh
bash ~/code/claude-carbon/scripts/configure-settings.sh
The second script merges the block below into ~/.claude/settings.json (additively: an existing status line or third-party hooks are left alone) and symlinks the /carbon-* commands. To wire it by hand instead, skip it and add:
{
"statusLine": {
"type": "command",
"command": "~/code/claude-carbon/scripts/statusline.sh"
},
"hooks": {
"Stop": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "~/code/claude-carbon/scripts/persist-session.sh"
}
]
}
],
"SessionEnd": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "~/code/claude-carbon/scripts/persist-on-exit.sh"
}
]
}
],
"SessionStart": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "~/code/claude-carbon/scripts/safety-rescan.sh"
}
]
}
],
"SubagentStop": [
{
"matcher": ".+",
"hooks": [
{
"type": "command",
"command": "~/code/claude-carbon/scripts/agent-stop.sh"
}
]
}
]
}
}
The Stop hook records the session after each turn, and SessionEnd records it once more as it closes, so a last turn interrupted before Stop fired is still counted. The SessionStart one re-scans for sessions both missed (crash, kill) and drives the daily update check the status line reads; without it you are never told a new version exists. SubagentStop records the branch an agent worked on, for /carbon-pr.
Restart Claude Code.
For teams
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:
- Free calculator and per-model factor sheets - the exact versioned factors of this repo, browsable.
- TokenClimate - hosted team dashboards. Both sides share this repo's golden vectors, verified weekly in CI.
The OSS points there from five places: a one-line footer in /carbon-report, a small credit on the /carbon-card PNGs, the last line of a /carbon-pr comment, the foot of the /carbon-panel pane and the url field of CITATION.cff. No status-line promo, no email capture: nothing leaves your machine.
PR dev footprint (/carbon-pr)
The number reviewers rarely see is what the PR cost to develop: your local Claude Code sessions while building the branch. /carbon-pr (or scripts/generate-pr-report.sh) sums the recorded sessions of the current branch and posts one sticky comment on its open PR, through your own gh auth. Run it after your push; running it again updates the same comment in place.
**Claude Code carbon report** · developing this PR
| CO2e | Cost* | Tokens (in + cache write + out) | Cache reads | Sessions |
|---|---|---|---|---|
| **124 g** | $3.00 | 180k | 1.5M | 2 |
Under the table come the car equivalence, a foldable token detail per model and a one-line footer.
How the sessions are attributed: the Stop hook stores each session's git branch (read from the transcript), and the report selects project + branch. Sessions recorded before this column existed carry no branch; scripts/backfill.sh repairs them while their transcripts are still on disk (about 30 days). A session whose last folder is a subdirectory of the repo is stored under the subdirectory's name and stays out of the sum. A session that ends on another branch than it started is attributed to where it finished.
How its agents are attributed: an agent counts with its session, unless it worked on a branch of its own. A session on main that sends agents to build a PR in a worktree puts their share on the PR's branch, and the comment then says how many sessions recorded elsewhere it includes. A SubagentStop hook (agent-stop.sh) reads the branch as each agent ends, while its worktree still exists:
- an agent that ran in a worktree of its own (Claude Code's isolated and workflow agents) counts on the branch that worktree has then, unless Claude Code named it (
worktree-agent-*,worktree-wf_*) or it is detached; - an agent that ran in the session's folder counts on the worktree its tool calls name in at least half of those that give a place (a command, a file path), and no other as often: absolute paths,
~/,../from the repository's folder when the worktree sits beside it,./when it sits inside. Never the repository's main folder, nor the session's own. This one is a deduction from the agent's commands.
The hook stores that agent's tokens, CO2 and cost, per model, in an agent_usage table, with the repository and the worktree's folder; the session's own row does not change. The report takes those agents out of their session's branch and adds them to theirs, as long as the session's row holds all its agents (agents_collected = 2: the Stop hook or the rescan read every agent transcript), was written after the agent ended (in a later second) and was recorded with the current method (not a v1 row). An agent that worked in another repository than its session's is not recorded, and one recorded before its repository was moved stays with its session. Forks are left out (they replay their parent's messages), and so is the work a session does itself in a worktree. Only agents that end with this version installed are attributed: nothing is rebuilt for past sessions.
The hook needs Claude Code 2.1.69 or later, the first to give SubagentStop the agent's type (its id and transcript came in 2.0.42); with an older one it records nothing. Claude Code's own agents (prompt suggestions, /btw) are left out. In a session run without --agent their type is empty: the hook's matcher skips them from 2.1.275, the script itself before that. With --agent they carry that agent's name and pass the matcher; the script skips them because their transcript is not one the session's row reads.
The hook runs synchronously, before the agent's result reaches the session: on a Mac, about 0.1 to 0.3 s for most agents, up to about 1 to 2 s for one whose transcript passes 100 MB, since it reads that transcript whole. Claude Code writes transcripts asynchronously: when the agent's final message is not in it yet, the hook reads it again every 0.2 s, for 1 s at most, then counts what is there. A database kept busy for more than about 10 s (a long read elsewhere) loses the record, and the agent counts with its session.
For every PR of a repository
A repository can ask for the report on its pull requests. Its maintainers commit this in .claude/settings.json, a change the team reviews like any other:
{ "env": { "CLAUDE_CARBON_PR": "1" } }
Nothing is posted on that alone. The first time a developer who has the plugin opens a pull request there with Claude Code (gh pr create), Claude asks them once whether to post the report of their own sessions under their own GitHub account. Their answer stays on their machine, per repository (pr-consent.tsv in the data folder):
- yes: the comment is posted when that answer ends, then updated in place after each
git pushorgh pr createClaude runs there, once the answer that pushed is recorded and while the pushed branch is still the one checked out. A push you type yourself in a terminal triggers nothing. One comment per PR, and never by itself on a PR whose branch lives in a fork. - no, or no answer: nothing is posted and the question does not come back.
/carbon-prstill works when they run it.
Change your answer from the repository with scripts/generate-pr-report.sh --consent yes or --consent never (after a yes typed in a terminal, the first comment comes with your next push or gh pr create in Claude Code); a yes is only taken once the question was put to you there, which also covers a question that never showed because the turn was interrupted. The answer is kept under the repository's origin URL (without credentials): rename the remote and the question comes back once. A repository cannot answer for you: the answers are never read from a config folder or a database placed inside the repository, and posted by itself the comment only goes to the repository origin names, whatever GH_REPO says. CLAUDE_CARBON_NO_PR_AUTO=1 in your own environment turns the question and the posting off everywhere. To stop it for the repository, remove the CLAUDE_CARBON_PR line. It needs the plugin's hooks (a marketplace install): an installer-only clone is not asked and posts nothing by itself. It is meant for a team's repository; on a public project, contributors from outside would see comments they did not ask for.
The repository's total
scripts/generate-pr-report.sh --summary reads back, through gh, the reports already posted on the repository's merged pull requests and totals them per month merged and per author. --since 2026-10-01 narrows it. It prints in your terminal only, posts nothing and does not read your database: the figures are the ones each author posted.
Month merged PRs Sessions CO2e Cost
2026-09 2 4 1.8 kg $57.26
2026-10 1 1 69 g $1.92
Author PRs Sessions CO2e Cost
alice 2 2 644 g $19.18
bob-dev 1 3 1.2 kg $40.00
Total: 3 PRs, 5 sessions, 1.8 kg CO2e, $59.18 at API list price.
A comment in the older one-line form, or edited by hand, is counted as unread and left out. It covers the pull requests that carry a report, not the repository's whole footprint, and reads at most 100 of them at a time.
Outside such a repository, turning it off is the default: nothing is posted unless you run it. --dry-run previews the comment, --pr <number> targets a specific PR of the repository (one opened from a fork is refused: run the command from the fork's clone instead), and deleting the comment on GitHub is the full cleanup. Once agents of the repository are on record, the report counts, from whichever folder it runs, the sessions of the repository's main folder, of the worktree the branch is checked out in and of the worktrees its agents worked in, even removed since. A branch checked out nowhere whose name sessions of other folders also carry is refused: nothing is posted rather than a figure that may lack them.
How it works
Three data paths, two levels of accuracy:
| Script | Trigger | Data source | Subagents | Cache reads | Accuracy |
|---|---|---|---|---|---|
backfill.sh | Manual / setup | JSONL files | Included | Counted (8% energy) | Best estimate |
persist-session.sh | Stop + SessionEnd hooks | JSONL files | Included | Counted (8% energy) | Best estimate |
statusline.sh | Every turn (live) | carbon.db row | Included | Counted (8% energy) | One turn late |
backfill and persist-session parse the raw JSONL transcripts (main session, subagent files and the transcripts of the agents a workflow starts), applying per-model emission factors. They deduplicate assistant messages by (message.id, requestId), so resumed and compacted sessions are not double-counted (this matches ccusage; without it the token sum inflates roughly 3x). Each session stores its raw token breakdown (input, cache write, cache read, output), which feeds the SQLite database used by reports.
An agent's transcript stops changing once the agent is done, so its totals are kept in ~/.claude/claude-carbon/usage-cache/ (one small file per session, removed by the daily re-scan 45 days after it was last written) and read again only when the file's size, modification or change time, or inode changes (the file a symlink points to). An agent with a line that does not parse yet, cut by a write in progress, is never kept. The main transcript is always read in full. CLAUDE_CARBON_NO_USAGE_CACHE=1 reads everything every time and writes no cache.
Cost is the theoretical API list value (pay-as-you-go), not your subscription price: input, output, cache write, and cache read (0.1x input) at current Anthropic rates, set in data/prices.json. Cache writes are billed per TTL tier, 1.25x input for the 5-minute tier and 2x for the 1-hour one; each session's split is read from its transcript rather than assumed (Claude Code writes at the 1-hour tier). On deduplicated data it matches ccusage.
statusline reads this session's row from carbon.db at each turn, so the CO2 it shows is the session total on the same basis as the reports, one turn behind at most. Before that row exists (first turn, or no database yet) it falls back to an estimate from context_window.total_input_tokens, which is the size of the current context rather than a running total: subagents are invisible to it and every compaction sends it back down. Either way the status line displays, it never feeds the reports.
The status line
Segments, left to right: project + git branch, model + context window %, API-equivalent session cost + CO2, subscription quota % + reset time. The quota is the 5-hour window, or the weekly one when no 5-hour window is open (always, on a verified Ultra account; on Pro and Max, between a 5-hour window's reset and your next request): Use 41% 7d ↻Thu, the reset as a weekday while it is more than a day away. A 🔥 prefix appears when the sustained burn rate would overshoot 100% of the limit by the end of the window (once usage reaches 15%, after a grace of 15 min for the 5-hour window and of a day for the weekly one).
Where the CO2 shows up. The status line is a feature of the Claude Code terminal UI. It is displayed only when you run
claudein a terminal, including the integrated terminal of VS Code or JetBrains. The IDE extensions' chat panel has no status line at all, so nothing is displayed there even though the hooks still run and your sessions are recorded:/carbon-reportcovers them. If you use the VS Code panel and want the live CO2, open a terminal in VS Code (Ctrl+`) and runclaudefrom there. The web app (claude.ai/code) runs neither the status line nor the hooks, so nothing is displayed or recorded there. The desktop app does not display the status line either; the plugin's mod draws the CO2 in its Code tab.
Quota source. The percentage is Anthropic's own, the same data Claude Code displays in /usage. No heuristic, no token-limit file to seed. Two sources in order:
- stdin (preferred): the
rate_limitsClaude Code passes in the statusline JSON,five_hourfirst, elseseven_day. Whenrate_limitsis there, a window it leaves out does not exist, and nothing else is asked. - OAuth API fallback, only when stdin has no
rate_limits(before the session's first response, or with an older Claude Code):GET https://api.anthropic.com/api/oauth/usagewith the bearer token from macOS Keychain,CLAUDE_CODE_OAUTH_TOKEN, or~/.claude/.credentials.json, at most once a minute whether it answers or not. The answer is cached in~/.claude/claude-carbon/oauth-usage.json; a window without a reset time, or whose reset has passed, is left out.
Accurate on Pro, Max and Ultra.
Surviving the 30-day transcript purge
Claude Code deletes JSONL transcripts after about 30 days, so the SQLite database is the durable record. The Stop and SessionEnd hooks capture each session before its transcript ages out, and a once-a-day background re-scan (SessionStart hook, safety-rescan.sh) catches any session they missed while its transcript still exists, including one whose transcript kept growing after its row was written. Because each row stores raw token counts, recompute.sh regenerates cost and CO2 from data/factors.json + data/prices.json at any time, with no transcript needed. When Anthropic changes a price or a factor is revised, edit the config and run:
bash scripts/recompute.sh
Sessions recorded since September 2026 are re-derived model by model, exactly. Older sessions without a per-model split keep their stored values; --include-unsplit re-derives them at their dominant model, an approximation (see METHODOLOGY.md, "Surviving the 30-day transcript purge").
Commands
| Command | What it does |
|---|---|
/carbon-report | Text report with totals, car equivalent, share of a 2 t budget, top sessions |
/carbon-card | Generate shareable PNG report cards |
/carbon-badge | Shields.io badge of your total footprint for your READMEs |
/carbon-pr | Post the dev footprint of the current branch on its PR |
/carbon-update | Update to the latest version, whichever way you installed |
Scripts (run automatically, rarely needed manually)
| Script | What it does |
|---|---|
setup.sh | Init database, backfill historical sessions, show total |
statusline.sh | Status line script (called automatically by Claude Code) |
persist-session.sh | Stop hook (saves session data after each turn) |
persist-on-exit.sh | SessionEnd hook (saves the session once more as it closes, in the background) |
safety-rescan.sh | SessionStart hook (throttled background re-scan, catches missed sessions) |
agent-stop.sh | SubagentStop hook (the branch an agent worked on, for /carbon-pr) |
backfill.sh | Re-parse all historical JSONL transcripts (incl. subagents) |
recompute.sh | Re-derive cost/CO2 from stored tokens after a price/factor change (no transcripts needed) |
generate-report.sh | Export PNG report cards (CLI, with --since / --until / --all) |
generate-badge.sh | Print the shields.io badge markdown + URL (CLI) |
generate-pr-report.sh | Post the branch's dev footprint on its PR (CLI, --dry-run / --pr) |
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.
Badge
/carbon-badge prints a ready-to-paste shields.io badge with your measured all-time footprint and the month it was taken, clickable to the methodology:
That badge is live, not a mockup: the author's own total, 1,208 sessions measured between 15 January 2026 and 16 September 2026. It is one developer's footprint, not the project's.
[](https://github.com/gwittebolle/claude-carbon/blob/main/METHODOLOGY.md)
The badge is a static image built from your local database, so the number is measured, not estimated on the fly, and nothing is sent anywhere. The month in the message says how old the figure is; re-run /carbon-badge whenever you want to refresh both.
It is one developer's total, so it belongs in your profile README or a personal project. In a team or organisation repository, reviewers will ask what produced the number and why it links out of the organisation, and they will be right to.
Numbers follow the locale the report uses (fr prints 12,4 kg, us and the world default print 12.4 kg); CLAUDE_CARBON_LOCALE forces a set.
The mod: /carbon-panel and the CO2 of each answer
The claude-carbon plugin also holds a Claude Code mod that shows the CO2 of each answer when it ends, computed locally with the same formula and factors as the status line, and the session's total with its API-price cost.
-
Terminal, including the integrated terminal of an editor and the JetBrains plugin: at the right end of the line that closes each answer,
✻ Worked for 38s · done 10:32 PM 16 gCO₂. A line keeps its own answer's figure when it is drawn again (a resize, a scroll, ctrl+o); a line drawn for the first time later, such as one only ctrl+o shows, gets no figure. -
Desktop app, Code tab: a line under the answer, only for an unusual answer.
-
An unusual answer shows the ratio, and the subagents' share when they weighed on it:
230 gCO₂ · 14× your median. An answer is unusual when it is above the 97th percentile of your last 200 answers, over 3× their median and at least 10 g, which is about one answer in 27; none is flagged before 50 answers are recorded. -
The session total is pinned under the prompt, CO2 and API-price cost:
This session: 142 gCO₂ · $3.41, in FrenchCette session : 142 gCO₂ · 3,41 $. It shows unless the claude-carbon status line already gives it or theshowSessionTotaloption is off (both in a terminal only, see ccstatusline). The cost is the pay-as-you-go API list price of the same requests as the CO2, fromdata/prices.jsonwith the formula of/carbon-report, cache writes at the 1-hour tier Claude Code uses; under a cent it reads< $0.01, and it is left out when the price list cannot be read, then until the total starts over, so the cost never covers only part of the requests. It is what the usage would cost on the API, not what a subscription bills. On a subscription the entry ends with the quota as the status line shows it,Use 23% ↻14:00(Usage 23 % ↻14:00): the share of the 5-hour window used and the local time it resets, or without a 5-hour window the weekly one,Use 41% 7d ↻Sat(Usage 41 % 7j ↻sam.), read from Claude Code itself after each answer, with no network call. Then come the status line's two hints:⬆ 1.18.0 /carbon-updatewhen a newer version is out, and from the 1st to the 10th of the month the month just closed with its total,📊 September: 84.2 kgCO₂ · /carbon-card, until you make the card. Background subagents, which is how Claude Code starts most of them, count in the session total only: never in an answer, nor in your median. A foreground subagent counts in the answer that started it, not in the next one. -
/carbon-panelopens a pane with the mascot, a pixel CO2 molecule. Its colour compares this session with the median of your past sessions, from dark blue (under an eighth of it) to dark red (over eight times it). Until 10 sessions are recorded it compares with a starting reference of 0.5 kgCO₂ instead, so it has a colour from the first answer. It hops a pixel up and down while Claude works, faster as it gets redder, and pulls faces as it goes: it looks around before the first answer, blinks and glances aside at work, smiles through a light session and sweats through a heavy one, reacts to each answer, winks at rest, and falls asleep after five minutes without a turn.- In the desktop app the pane opens on the right, its tab titled "claude-carbon", in two blocks. Under the molecule, the colour scale, the eight colours from blue to red, with a marker under this session's. This session: its CO2, answers, subagents and model, its context window's fill and API-price value, and a small molecule per subagent, coloured by its own CO2. My usage: the period you pick (the last 7 or 30 days, 12 months, everything, or two dates you type,
01/05/2026), its figures as tiles (CO2 as the reports sum it, change against the same length of time before, sessions, API-price value, car equivalence), then warming stripes of that period, a day, a week or a month a stripe after its length, each coloured against the median of the periods shown. The stripe under the pointer lights up and its date, total and sessions show under the stripes. A tile with an (i) shows its note when you click the (i), and hides it at a second click: the API-price value is what this usage costs billed through the API, and a Pro, Max or Ultra subscription covers some or all of it (which session was billed how is not recorded, so the pane never says what you paid). A gear beside "My usage" turns the change, the API-price value, the car, the split by project (off until you turn it on, each folder with its share and kgCO2) and the detail on or off; the pane keeps your choices for the next session. The detail (off until you turn it on) splits the period by kind of token, uncached input, cache writes, cache reads and output: two coloured bars give each kind's share of the tokens and of the CO2 (the part under the pointer lights up and its figures show under the bar), then a line per kind its tokens, energy and CO2 with their shares. The CO2 of each session is the one stored, split with the weights the factors give each kind (cache reads 0.08 of an input token, output about 21 times one), so the parts add up to what was stored; a session stored with older factors (before July 2026), whose CO2 no longer matches its tokens, is left out and the block says over how many sessions it splits; the energy is the one the factors start from (energy per token, PUE included, converted to CO2 with the AWS us-east grid at 287 gCO2/kWh), found back by dividing that CO2 by the same intensity. It needs the tokens by kind insessions-history.tsv, which the hooks write from this version on: after an update, the detail shows from the next answer. A "Get my 2026 card" button puts/carbon-cardin an empty prompt for you to send (the card covers the calendar year so far, whatever range the pane shows); it never sends it and leaves a draft you have started alone. A few short lines at the foot link to this repository, the author's LinkedIn profile and TokenClimate, the business version. - In the terminal
/carbon-paneltyped at the prompt shows this session in the band right above it, in the classic and the fullscreen rendering alike (sent from the desktop app or a phone to a session running in a terminal, through Remote Control, it opens the side pane there instead): a small molecule of 13 columns by 4 rows in half blocks, and beside it the session's CO2, answers, subagents (a dot each, in its colour), model, context window and API-price value. The period and the stripes live in the desktop app. - Run
/carbon-panelagain to close the pane or clear the band. The command is also a skill of the plugin, so the desktop app lists it; where the mod does not run (the VS Code chat panel, a cloud session) it only says where the pane opens.
- In the desktop app the pane opens on the right, its tab titled "claude-carbon", in two blocks. Under the molecule, the colour scale, the eight colours from blue to red, with a marker under this session's. This session: its CO2, answers, subagents and model, its context window's fill and API-price value, and a small molecule per subagent, coloured by its own CO2. My usage: the period you pick (the last 7 or 30 days, 12 months, everything, or two dates you type,
-
The stripes' history is
sessions-history.tsv, which the Stop hook writes next tocarbon.dbafter each answer, read-only on the database. Every recorded session is in it, older rows as they were stored (they keep the factors of their time and are never recomputed), so the stripes, the median and the totals count what/carbon-reportcounts. Another session running at the same time counts with its total so far. With no database yet (before the first session start of a plugin installed alone, or withjqorsqlite3missing), the pane shows the molecule and says what the history waits for.
Claude Code draws mods in the terminal and in the desktop app's Code tab only: nothing appears in the VS Code extension's chat panel, in cloud sessions or with claude -p. Mods need Claude Code 2.1.287 or later (2.1.286 in the desktop app).
The mod comes with the plugin. Already installed from the marketplace: run /plugin marketplace update claude-carbon and /plugin update claude-carbon@claude-carbon, then restart Claude Code.
The plugin alone records your sessions, and sets the terminal status line when you have none (see Install):
/plugin install claude-carbon --marketplace gwittebolle/claude-carbon
At the first session start after the install, the plugin creates its database in ~/.claude/claude-carbon/ and fills it with the sessions whose transcripts are still on disk (about the last 30 days, every project), then records each session as it goes. A one-time message says so at one of the next session starts. It needs jq and sqlite3: when one is missing nothing is created, and /carbon-panel names it. This happens once: a database you delete is not brought back (delete the auto-setup file beside it to ask for a new one), a database path set with CLAUDE_CARBON_DB is never created for you, and CLAUDE_CARBON_NO_AUTOSETUP=1 turns it off. From then on the daily background check for a newer release runs as it does for the installer (CLAUDE_CARBON_NO_UPDATE_NOTIFIER=1 to opt out).
In a team repository
To offer the plugin to everyone who works in a repository, commit this in its .claude/settings.json:
{
"extraKnownMarketplaces": {
"claude-carbon": { "source": { "source": "github", "repo": "gwittebolle/claude-carbon" } }
},
"enabledPlugins": { "claude-carbon@claude-carbon": true }
}
Enabling it in the repository does not download it to anyone's machine, since the plugin comes from a remote marketplace: each collaborator runs claude plugin install claude-carbon@claude-carbon --scope project once in their clone, after trusting the folder. Anyone who does not want it sets "claude-carbon@claude-carbon": false under enabledPlugins in their own .claude/settings.local.json. Each person's figures stay on their machine.
The curl, PowerShell and npm installers set up the status line, the database and the hooks, and copy the mod alone to ~/.claude/skills/claude-carbon/, which Claude Code loads as claude-carbon@skills-dir. /carbon-update keeps that copy up to date. The copy holds no hook, so nothing runs twice. Restart Claude Code after the install; the mod loads once the folder you open is trusted. Its median starts from zero: answers recorded by another install of the mod do not carry over. With this copy the mod shows in the terminal, in the editor's integrated terminal and in the desktop app's Code tab.
To turn it off, run claude plugin disable claude-carbon@skills-dir. To remove it, run the installer with CLAUDE_CARBON_NO_MOD=1 on the bash side (curl … | CLAUDE_CARBON_NO_MOD=1 bash); keep the variable set, in your shell or in the env block of settings.json, or the next /carbon-update puts it back. The installer leaves alone a skills/claude-carbon/ folder it did not make, and skips the copy while the claude-carbon plugin is enabled. Pick one of the two: the plugin added on top of an installer runs the hooks twice.
Turn the per-answer figure off with the showPerTurn option in /config. The mod writes no database, starts no process, makes no network call and never changes what Claude does; besides its own data files, it reads only sessions-history.tsv, the two release flags of the daily check (plugin-update-check.json, update-check.json), last-card-month, and the two files the SessionStart hook leaves when it finds no database (setup-needed, auto-setup). Text is in French when the first of CLAUDE_CARBON_LOCALE, LC_ALL, LC_MESSAGES and LANG that is set starts with fr, and in English otherwise. When none is set, as in the desktop app and often on Windows, the language setting decides (Français, English), then English.
The mod's own tests run with bash tests/run-mod-kit.sh, under claude plugin test, which mocks the engine: no login needed. CI runs them on every push with Claude Code 2.1.296.
Using with ccstatusline
Claude Code accepts a single statusLine command, so claude-carbon's full status line and 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
~/code/claude-carbon/scripts/statusline.sh --segment
(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 · 35gCO₂. Segment mode never touches the network. Recording to the local database is unaffected either way: persistence runs from hooks, not from the status line.
With the segment in ccstatusline, the mod's session entry under the prompt shows the total a second time. Turn it off with the showSessionTotal option in /config; the desktop app, which has no status line, keeps it.
Emission factors
Factors from Jegham et al. 2025, 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.
| Model | Read for the first time (input, cache write) | Re-read (cache read) | Written (output) | Basis |
|---|---|---|---|---|
| Fable | 156 | 12.5 | 3304 | Extrapolated (2x Opus) |
| Opus | 78 | 6.2 | 1652 | Extrapolated (2x Sonnet) |
| Sonnet | 39 | 3.1 | 826 | 3-point fit (Jegham v6) |
| Haiku | 10 | 0.8 | 207 | Extrapolated (0.25x Sonnet) |
In gCO2e per million tokens. In a Claude Code session, about 98% of the tokens are context Claude re-reads at each step. Each of them weighs little, but together they make about 60% of the CO2; the text Claude writes is under 1% of the tokens and about 30% of the CO2 (30 days of the author's sessions, October 2026).
Important: these are order-of-magnitude estimates, not precise measurements.
- 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; independent public estimates land within the same order of magnitude. Fable, Opus and Haiku are extrapolated (no public data from Anthropic on per-model energy consumption): Opus = 2x Sonnet (honest band 2x-5x), Haiku = 0.25x, Fable = 2x Opus. See METHODOLOGY.md.
- 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 toexclude_modelsindata/factors.jsonto exclude more models by name. - 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 most of the prefill compute; the factor is the residual. This is an engineering estimate derived from the literature, not Anthropic's 0.1x billing ratio. The decode-phase re-read of the cache grows with context length x generated tokens and is not modelled yet; every session stores that product (output_context_sum) so a calibrated term can be applied to history later. See METHODOLOGY.md. - Reviewed against the April-September 2026 literature (measurement papers, provider disclosures, the Watershed framework) with a sensitivity run on 30 days of real transcripts: no factor moved, the displayed figure is more likely low than high, next review March 2027. See Where the estimate stands.
- 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.
- Anthropic does not publish Scope 1, 2, or 3 emissions. These estimates are independent and based on academic research, not provider data.
The car equivalent in reports and cards follows your locale, since a km by car emits up to ~1.7x more in one country than in another: ADEME's 142 gCO2e/km on a French locale, EPA's 393 gCO2e/mile on a US locale, a 200 gCO2/km world average otherwise, an undetected locale included. Force a set with CLAUDE_CARBON_LOCALE (fr, us, world, or any locale string). The factors live in data/factors.json under equivalences.
/carbon-report also gives this calendar year's total as a share of 2 tCO2e, the 2050 per-person target for a whole footprint (ADEME, Nos Gestes Climat, from the IPCC 1.5 °C scenarios; also Carbone 4, Faire sa part ?, 2019). It is there for scale: the 2 t covers everything a person emits in a year, AI included. Sources and caveats: METHODOLOGY.md.
Facto
Details
- Author
- @gwittebolle
- GitHub Stars
- 256
- Sub-category
- Dashboards
- License
- MIT
- Added
- 7 months ago
- Last synced
- 1 day ago
- Events hooked
StopSessionEndSubagentStopSessionStartPostToolUse
Weekly Mods Digest
Top new Claude Code mods and install commands, once a week. No fluff, unsubscribe anytime.

