Ficus
A local carbon ledger for Claude Code. It reads your session transcripts,
estimates the electricity, water and CO2e behind them, keeps the total in your
statusline, and records the offsets and donations you buy against it.
Everything runs on your machine. No network calls, no telemetry, no installer.

Documentation → — install, where the
data comes from, how every figure is calculated, and the research behind each
organisation it links to.
Live demo dashboard →
(fabricated data: fake sessions, fake purchases, fake receipt)
Install
You need bash, jq and sqlite3. Nothing else, and there is nothing to add
to a package manager.
git clone https://github.com/Magonia-Research/ficus.git
cd ficus
bash scripts/setup.sh
setup.sh checks those three dependencies, creates
~/.claude/carbon-ledger/carbon.db, writes factors.env, backfills whatever
transcripts are still on disk, and prints a hook block. Paste it into
~/.claude/settings.json and reload Claude Code:
{
"hooks": {
"Stop": [{ "matcher": "", "hooks": [{ "type": "command", "command": "<repo>/scripts/persist-session.sh" }] }],
"SessionStart": [{ "matcher": "", "hooks": [{ "type": "command", "command": "<repo>/scripts/safety-rescan.sh" }] }]
}
}
For /carbon, /carbon-offset and /carbon-review, symlink the three skills:
ln -s "$PWD/skills/carbon/SKILL.md" ~/.claude/commands/carbon.md
ln -s "$PWD/skills/carbon-offset/SKILL.md" ~/.claude/commands/carbon-offset.md
ln -s "$PWD/skills/carbon-review/SKILL.md" ~/.claude/commands/carbon-review.md
Each skill resolves the repo through $CARBON_LEDGER_DIR, so export that in
your shell profile pointing at your clone.
The statusline segment is opt-in and merges into your own
~/.claude/statusline.sh. docs/statusline-segment.md
walks through it; statusline-snippet.sh at the repo root is the reference
implementation.

Right of the rule, read from the ledger: ∑ ⚡ all-time electricity, 💧 water,
💨 CO2e; then 💨 outstanding/emitted tonnes and $owed/total to clear the
balance at the removal price. Both pairs count down: the left number is what is
still to settle, the right is the whole job, and both go negative rather than
clamping once you pass carbon-neutral. The row underneath is this conversation only,
recomputed on every repaint: energy, water, CO2e, and ▲ what removing it would
cost (in cents below a dollar). Everything left of the rule is Claude Code's own
status JSON, including that first dollar figure — it is the price of the tokens,
not the price of removing their carbon.
That session row is the roughest number on the screen by design: it reads
context_window rather than parsing the transcript, so it counts cache reads as
ordinary input and never sees subagent tokens. The ledger deduplicates properly,
and when the two disagree the ledger is right. Every value is broken down on the
documentation site.
State lives in ~/.claude/carbon-ledger/ (database, receipts, exports,
dashboards). CARBON_LEDGER_DB overrides the database path and everything else
is derived from it, which is how the tests run against throwaway sandboxes.
Where the numbers come from
No vendor publishes per-query energy for a hosted model. Every figure in this
tool is an estimate carrying roughly ±50% uncertainty. Trends and relative
comparisons hold up; absolute values are indicative, and none of it is fit for
regulatory reporting.
No script hardcodes a constant. They all live in data/*.json next to a
_source field, and these are the ones that matter: