← Reddit

CC-Ledger: Claude Code Cost Tracker (Per-Session and Per-PR)

Reddit · PerceptionKind7603 · May 21, 2026
cc-ledger is a local Rust binary that serves as a Claude Code hook, logging each turn to SQLite instantly to catch runaway sessions and provide per-PR cost tracking without needing an API key. The tool was developed after a session consumed most of the creator's quota without triggering dashboard alerts and a single PR showed 40x the median cost with no visibility into the source. Users can access analytics through a SwiftBar menu bar plugin for macOS, a web dashboard at ccledger.dev, or the CLI.

Detailed Analysis

CC-Ledger is an open-source Rust-based tool developed to address a significant gap in Anthropic's Claude Code offering: real-time, granular cost visibility at the session and pull request level. Built by a developer at Delta HQ and published on GitHub, the tool registers itself as a Claude Code hook, intercepting and logging each conversational turn to a local SQLite database the moment it completes. This architecture allows users to monitor token consumption and associated costs live, rather than discovering overruns after the fact through delayed or incomplete dashboard reporting.

The motivation behind the project is notably practical and rooted in a direct pain point. The developer reports that a single Claude Code session consumed a substantial portion of their usage quota without any alert or intervention from Anthropic's own dashboard. Compounding the problem, one pull request was found to have cost approximately 40 times the developer's median PR cost, yet the native tooling offered no mechanism to surface or explain that anomaly. These are not edge cases — they represent a class of observability problem that becomes increasingly consequential as AI-assisted development is integrated into professional engineering workflows where budgets and rate limits are real constraints.

The tool offers multiple interfaces for consuming its data: a SwiftBar macOS menu bar plugin for ambient awareness, a web dashboard hosted at ccledger.dev, and a CLI for programmatic or terminal-based access. Notably, it operates entirely without requiring an API key, relying instead on locally captured hook data, which has privacy and security advantages for teams wary of routing sensitive usage metadata through third-party services. The local SQLite storage also ensures persistence and queryability independent of Anthropic's own infrastructure.

CC-Ledger reflects a broader pattern emerging around frontier AI developer tools: the gap between the raw capability of systems like Claude Code and the operational maturity of their surrounding infrastructure. While the underlying models have advanced rapidly, the management layer — cost attribution, usage auditing, anomaly detection, and budget enforcement — has lagged behind. This creates an opening for community-built tooling to fill institutional voids, much as the early DevOps ecosystem built observability layers atop cloud providers before those providers offered native equivalents.

The project also highlights a structural challenge specific to agentic AI workflows. Unlike traditional API calls with predictable token counts, multi-turn agentic sessions involving code generation, tool use, and iterative refinement can exhibit highly variable and non-linear cost profiles. A single poorly scoped task or an agent caught in a reasoning loop can disproportionately inflate costs in ways that conventional usage dashboards, designed around simpler request-response patterns, are poorly equipped to surface. CC-Ledger's per-PR granularity is particularly significant in this regard, as it enables cost to be attributed to specific engineering decisions rather than diffused into aggregate monthly totals — a prerequisite for any serious cost governance in AI-augmented software development teams.

Read original article →