Documentation
¶
Overview ¶
Command routing-spike measures how much of a Claude Code archive is bulk I/O that could be routed to a cheap worker model.
It is Stage 0 of the routing-savings spec: the measurement that decides whether the rest of the feature is built. It writes nothing, changes nothing, and reads only the transcripts Claude Code already keeps.
go run ./cmd/routing-spike # ~/.claude/projects go run ./cmd/routing-spike -dir /path/to/projects go run ./cmd/routing-spike -json # machine-readable
What it counts, and why that is not obvious ¶
The unit is **tokens**, taken from the transcript's own `usage` accounting, never bytes on disk. A screenshot is 600 KB of base64 and about 1.5k tokens; measuring bytes makes images look like the dominant cost when they are not. An earlier pass of this spike made exactly that mistake and reached the opposite conclusion, which is why `-bytes` still exists: it reproduces the wrong answer beside the right one so the size of the error stays visible.
The cost of a tool result is not its size either. Content written into the context is billed once as a cache write and then re-read on every remaining turn, so a file read early in a long session is charged many times over. The spec's unit is therefore `T * (1 + turns_left)` — token-turns — and the denominator is every context token-turn in the same sessions, not just the tool results. Both errors have burned this product before: counting each re-read at full price overstates, counting only the first read understates.