Metadata-Version: 2.5
Name: havrin
Version: 0.4.0
Summary: See where your Claude Code usage goes, from your own local session logs
Project-URL: Homepage, https://havrin.dev
Author: Gavin Schiller
License-Expression: MIT
License-File: havrin/LICENSE
Keywords: claude,claude-code,cost,llm,usage
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# havrin

See where your Claude Code usage goes, and what a few changes would have saved, from the logs Claude Code already
keeps on your machine. Free and MIT licensed. No signup, no API calls, and nothing leaves your computer.

```sh
pipx install havrin
havrin estimate            # what Havrin would have saved over your last 30 days
havrin meter --what-if     # where your usage went, and what each change would have saved
havrin                     # the same in a local page in your browser
```

Python 3.9 or later, no dependencies. Linux, macOS and Windows.

No pipx yet? Install it with `sudo apt install pipx` (Ubuntu, Debian), `sudo dnf install pipx` (Fedora),
`sudo apk add pipx` (Alpine) or `brew install pipx` (macOS), run `pipx ensurepath`, and open a new terminal.
Without pipx, `python3 -m pip install --user havrin` works where your Python allows it; Ubuntu, Debian and Alpine
refuse it (`externally-managed-environment`).

## What it reads

Only the session logs Claude Code writes on this machine: `~/.claude/projects` (or `$CLAUDE_CONFIG_DIR/projects`;
`--dir PATH` reads another directory). It counts tokens, models and characters. It never prints, stores or sends
the content of your prompts, code or files, and it makes no network requests. The local page serves only on
127.0.0.1 and never runs anything for you.

## `havrin estimate`

```
Havrin estimate · your last 30 days of Claude Code
  298 sessions · 393.0M Opus input-token equivalents at list prices

  With HVR-1 fully on: about 38% less usage
    your Opus work moves to Sonnet (Opus is 76% of your usage today)
  Automatic parts only: up to 4% less
    up to 9% if you also act on the context heads-up at 150k tokens
  On a Claude plan, expect less: plans don't count usage in proportion to list price (havrin.dev/method#plan).
  ...
```

(Example layout; your numbers come from your own logs.)

- **Opus input-token equivalents** is the unit for all of it: every token from your logs at its model's list
  price and its kind's price (cache reads are cheap, output is expensive), counted in tokens of Opus input.
- **HVR-1 fully on** re-prices your Opus usage at Sonnet's list price, half of Opus's. That's what the Havrin plugin
  does when you turn it fully on.
- **Automatic parts only** re-prices the subagents Havrin moves to Sonnet without being asked. It assumes Havrin
  reaches every one of them, so it's a ceiling.
- **The context heads-up** adds what you'd save by compacting once a conversation passes 150k tokens, if you act
  on it.
- **On a Claude plan** the saving is likely smaller than at list prices: in Havrin's measurement, a plan counted a
  dollar of Opus work as about 0.74 of a dollar of Sonnet work (a rough estimate, range 0.46 to 1.09), so the
  meter doesn't turn a list-price saving into plan headroom. Details: havrin.dev/method#plan.

Every figure is a replay: the same tokens, priced again. A replay can't tell whether Claude's results would stay as
good. [havrin.dev](https://havrin.dev) shows what was measured on benchmark tasks graded by hidden tests.

## `havrin meter`

Where the usage went:
- the total, in input-equivalent tokens (weighted by kind) and in Opus input-token equivalents (at each model's
  price);
- each kind's share of cost: uncached input, cache writes, cache reads, output;
- each model's share of cost, and the subagents' share;
- characters each tool added to the context, and characters Claude wrote.

Add any of these:

| option | what it adds |
|---|---|
| `--what-if` | what a few changes would have saved: all Opus work on Sonnet, subagents only, Havrin's automatic routing, compacting at 150k tokens |
| `--levers` | each change's replayed effect in one table, and per project the base context and the commands, skills and MCP servers used |
| `--lean` | per project, the skills and tools it never used and the settings that would drop them |
| `--subagent-types` | subagent cost by type, and the model each one asked for |
| `--context-ranking` | the kinds of tool output (`git diff`, `pytest`, whole-file reads...) that fill the context most, and re-reads of unchanged files |
| `--sessions` | one line per session log |
| `--days N` | the period, in days (default 30) |
| `--sonnet-ratio R`, `--cap N` | the replays' Sonnet price as a share of Opus's (default 0.5) and compaction point in tokens (default 150000) |

`havrin meter --help` lists them all. A replay that would cost more says so ("costs 3% more").

## Havrin

The Havrin plugin for Claude Code acts on these numbers. It's in a free beta at [havrin.dev](https://havrin.dev).

To remove the meter: `pipx uninstall havrin` (or `python3 -m pip uninstall havrin` if you installed it with pip).
It writes no files.
