Metadata-Version: 2.4
Name: cc-cost
Version: 1.1.0
Summary: Claude Code transcript cost analyzer
Author-email: Lobster Labs <thelobsterlabs@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/lob-labs/cc-cost
Project-URL: Repository, https://github.com/lob-labs/cc-cost
Keywords: claude,claude-code,anthropic,cost,tokens,cli
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# cc-cost

A tiny Claude Code cost analyzer. Parses Claude Code session transcript JSONL files
and reports per-session cost, prompt-cache hit rate, tool-call distribution, and the
top expensive turns.

Knowing your cache hit rate is load-bearing for cost — a session at 91% hit rate
costs ~10× less than the same work at 0%.

## Install

```bash
curl -O https://raw.githubusercontent.com/lob-labs/cc-cost/main/cc-cost.py
chmod +x cc-cost.py
```

No dependencies beyond Python 3.9+.

## Use

```bash
# Scan all sessions under ~/.claude/projects
./cc-cost.py

# A specific transcript
./cc-cost.py ~/.claude/projects/-home-foo/<id>.jsonl

# Single project
./cc-cost.py --project -home-foo

# JSON output (for automation)
./cc-cost.py --json

# Get specific cost-optimization recommendations
./cc-cost.py --diagnose <transcript.jsonl>

# Show only the top 5 most expensive sessions
./cc-cost.py --top 5
```

## Sample output

```
=== <session>.jsonl ===
  model:           claude-opus-4-7
  turns:           62
  input tokens:             232
  output tokens:         10,016
  cache write:          216,089
  cache read:         2,179,125
  cache hit rate:         91.0%   (higher = cheaper)
  total cost USD:  $     8.0750
  tool calls:
    Bash                           40
    Write                          2
    ToolSearch                     1
  top 5 expensive turns:
    $ 0.6993  [...]
```

## Why

When debugging "why was this session $40," the answer is almost always one of:
- Low cache hit rate (long static context not marked `cache_control`)
- Many redundant tool calls (each one re-pays the prompt)
- Long-output explanations the model generated unprompted

This shows you which of those is biting you, fast.

## Tip jar

If this saved you money, consider tipping:

- **Venmo**: [@lobsterlabs](https://venmo.com/u/lobsterlabs)
- **USDC on Base / any EVM**: `0xE0c311585d2000afF6b8020e30912Ac37ffe406a`
- **USDC on Solana / SOL**: `4a6YaVijdv79iXvXvXFu67kVBPFA6n8YSwYXt3ECj6ND`

## License

MIT.

