# Repository Briefing: gwittebolle/claude-carbon
> Source: https://repoforai.com/repo/gwittebolle/claude-carbon (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/gwittebolle/claude-carbon
- **Official Docs / Website**: https://tokenclimate.com
- **Category**: Coding, Skills & MCP (AI 编程 / Skills / MCP)
- **Primary Language**: Shell
- **License**: MIT
- **Engineering Health**: A+ (88/100 · Maintenance 35/35 · Adoption 13/25 · Releases 20/20 · License 20/20)
- **Latest Release**: v1.21.0 (2026-11-30) — https://github.com/gwittebolle/claude-carbon/releases
- **Review Snapshot**: 2026-12-01
- **Deployment / Stack Signals**: CLI, Local AI
- **Momentum**: 259 ★ total (+0 24h / +3 7d) · 24 forks
- **Topics**: `ai-sustainability`, `carbon-emissions`, `carbon-footprint`, `claude-code`, `green-it`, `anthropic`, `claude-plugin`, `climate`, `statusline`, `sustainability`, `green-coding`, `carbon-accounting`
- **When to Use**: Best for: Claude Code developers who want local emissions estimates, usage trends that survive transcript cleanup, and optional PR summaries. Skip if: You need audited emissions, actual subscription charges, or a centralized inventory across developers and AI tools.

## Overview
```text
### Architecture & Core Mechanics
claude-carbon is a Shell-based Claude Code plugin with a `claude-carbon` CLI entry point. Its integration uses Claude Code hooks, slash commands, and status-line settings. `persist-session.sh` runs on Stop and SessionEnd, while `backfill.sh` imports retained JSONL transcripts. Both process the main session, subagents, and workflow agents, deduplicating assistant records by `(message.id, requestId)` before saving token counts to local SQLite.

On the hot path, `statusline.sh` reads the session row in `carbon.db` instead of rescanning transcripts every turn. The main transcript is read in full during persistence; completed agent totals can be reused if the transcript's file metadata is unchanged. An agent transcript with a partially written line is not cached. Set `CLAUDE_CARBON_NO_USAGE_CACHE=1` to disable cache reads and writes.

### Key Capabilities & Differentiators
The accounting engine applies per-model emission factors to Anthropic Claude usage, recording input, cache writes, cache reads, and output separately. Cache reads count toward total tokens and use an 8% energy factor in the model. The terminal status line and Claude desktop Code tab show estimated session emissions alongside API list-price equivalents. SQLite preserves recorded history after transcript cleanup, while backfill can recover only logs still on disk.

`/carbon-report` produces text totals; `/carbon-panel` compares the current session with the user's historical median and shows period usage and warming stripes. `/carbon-card` generates shareable cards. `/carbon-pr` aggregates sessions by project and branch, can attribute qualifying worktree-agent usage to another branch, and creates or updates one sticky comment using the developer's `gh` authentication.

### Trade-offs & Limitations
The strongest use is comparing personal usage over time, not measuring absolute emissions. The CO₂ figures are factor-based estimates rather than metered energy or verified emissions, and the dollar figure is API list-price equivalence, not a subscription charge. Compared with ccusage, the plugin uses the same deduplication approach but adds carbon factors, desktop visualization, and PR reporting. The live display trades freshness for a simpler read path and can lag by one turn.

PR figures describe the developer's recorded Claude Code activity, not the full footprint of a PR. Attribution can follow the branch where a session ends, and sessions recorded under a subdirectory can be left out. Older records without branch metadata can be repaired only while their transcripts survive. The MIT-licensed plugin is a fit for individual local tracking; centralized team reporting is a separate hosted offering. Optional PR publication sends a summary to GitHub and should be treated separately from local accounting.

### Hardware & Deployment Guide
Install the plugin through Claude Code's plugin marketplace on macOS, Linux, or Windows, then fully restart and begin a new session. The Shell-based integration needs `jq` and `sqlite3`, plus Git Bash on Windows; the package manifest declares Node.js >=18. GitHub PR posting uses `gh`, and PNG cards need Playwright and Chromium; without that rendering stack, the summary falls back to HTML.

For manual setup, `scripts/setup.sh` and `scripts/configure-settings.sh` install and wire the hooks and commands. `CLAUDE_CONFIG_DIR` can isolate separate Claude environments, including their databases. Accounting runs locally without a hosted service. v1.20.0 introduced first-session status-line registration only when none exists; v1.20.1 moved the command for Homebrew packaging without changing its interface; v1.21.0 defaults to English and the world car factor when no locale is detected.
```

## Key Capabilities
```text
- Persistence: Stop and SessionEnd hooks write transcript-derived totals to local SQLite; backfill imports still-retained sessions.
- Accounting: Deduplicates assistant records by `(message.id, requestId)` and stores separate input, cache-write, cache-read, and output counts.
- Responsiveness: The per-turn status line reads `carbon.db`, trading freshness for a simpler read path and a one-turn lag.
- Reporting: `/carbon-panel` compares the session with its historical median; `/carbon-card` exports PNGs or an HTML summary when browser rendering is unavailable.
- PR attribution: `/carbon-pr` aggregates local sessions by project and branch, with `SubagentStop` capturing eligible worktree branches before they disappear.
- Publication controls: Optional automatic PR posting requires local, per-repository consent and does not post automatically to fork PRs.
```

## Quick Start / Clone
```bash
curl -fsSL https://raw.githubusercontent.com/gwittebolle/claude-carbon/main/install.sh | CLAUDE_CARBON_DIR=~/my-path/claude-carbon bash
```
