← Back to Discover

cc-cost

A lightweight Python command-line tool that analyses Claude Code session logs to show per-session spend, prompt-cache efficiency and the most costly turns.

Observability & evalsCommand-line tools

What it does

cc-cost reads the transcript files that Claude Code writes for each session and summarises them in the terminal. For every session it shows the model used, the number of turns, token totals, the prompt-cache hit rate, the total cost in US dollars, how many times each tool was called and a ranked list of the most expensive turns. The README argues that cache hit rate drives cost: it says a session at a 91% hit rate costs roughly ten times less than the same work at 0%. It names three common causes of a surprisingly expensive session: long static context that is not marked for caching, many redundant tool calls, and long explanations the model produced unprompted. A --diagnose option produces specific cost-optimisation recommendations for a transcript. Other options scan every session under the default Claude projects folder, limit the report to one project, show only the top N most expensive sessions, or print JSON for automation. It is a single Python file with no dependencies beyond Python 3.9 or later. You can install it with pip install cc-cost or download the script directly. It is released under the MIT licence.

Capabilities

  • Per-session cost report in US dollars
  • Prompt-cache hit rate for each session
  • Breakdown of tool calls and a ranking of the costliest turns
  • --diagnose mode with optimisation recommendations
  • JSON output for automation
  • Single file needing only Python 3.9 or later

When to use it

  • You want to find out why a Claude Code session cost more than expected
  • You want to check whether prompt caching is working across your sessions
  • You want cost data from Claude Code logs inside a script or pipeline