ClaudeMap

Claude Code Routing

A measured, plain-Claude-Code rebuild of the Spotify setup that cut token usage 90%: a cheap model does the reading and the boilerplate, Claude keeps the thinking.

SDKs & Toolingroutinghaikucosthooksbenchmark

A plain Claude Code rebuild of the setup a Spotify product manager published in September 2026 (Portal cut their Claude Code token usage by 90%) — theirs runs on Portal and Gemini Flash, this one needs nothing but the claude CLI you already have and Haiku. Three pieces: bin/code-write sends a spec plus a reference file to Haiku, which writes predictable code (tests, type stubs, config) straight to disk while Claude never reads either; bin/bulk-read sends whole files to Haiku in one call and returns dense bullets with line numbers, so the files never enter Claude's context; and hooks/block-big-reads.sh is a PreToolUse hook that stops any full read over 350 lines and points Claude at the two scripts, while targeted reads pass. Then it measures: Claude Code 2.1.270, Opus 5, on psf/requests, four tasks each run with and without. The honest numbers — the hook never fired (Claude avoided full reads on its own once nudged), bulk-read was never called, and the win came from code-write on boilerplate: the S4 type stub cost $0.59 vs $0.82 and covered 51 of 57 functions vs 42, while S3 test-writing got worse ($1.22 vs $0.96, 11 tests vs 17, 243s vs 90s).

What it does

  • Three pieces, plain Claude Code: code-write (Haiku writes boilerplate to disk), bulk-read (files in, dense bullets out, Claude's context untouched), and a 350-line full-read block hook
  • Settings: BLOCK_MIN_LINES (default 350), CHEAP_MODEL (default haiku), CLAUDE_BIN if claude is not on PATH; install.sh backs up settings.json before touching it
  • Reproducible benchmark: four scenarios on psf/requests with a runner and analysis in benchmark/, one command to rerun (benchmark/run.sh opus, about $6-7)
  • Negative results published too: the hook never fired across the four tasks and bulk-read was never called — Claude self-routed once the scripts existed

When to use it

Cost-conscious heavy Claude Code users who want routing with receipts — including the honest finding that routing pays on boilerplate (type stubs), not on judgment work like writing tests against an existing style.

Getting started

git clone https://github.com/ToolMonsters/claude-code-routing
cd claude-code-routing && ./install.sh   # copies scripts, hook and skills into ~/.claude (backs up settings.json first)
# then restart Claude Code

# reproduce the benchmark (clones psf/requests into benchmark/work):
benchmark/run.sh opus

Things to know

MIT. Not affiliated with Spotify. One run per benchmark cell — treat small gaps as noise, the author's own words. Ranged reads (offset/limit) pass the hook regardless of size; in S2 Claude slipped 545 lines through that door. The cheap model's spend is billed in separate claude -p calls, so it does not show in /cost — the scripts print it to stderr. Do not route debugging, architecture or anything subtle to the cheap model; Spotify's own account includes a worker missing a thread-safety bug Claude caught in seconds.

Repository

ToolMonsters/claude-code-routing

Charted

Related on the map

  • Harness Bridge

    SDK / Tool

    A local launcher that points Claude Code and seven other coding harnesses at any OpenAI-, Anthropic- or Responses-compatible endpoint — without editing a single config file.

    • launcher
    • local-models
    • cli
    • menu-bar
  • Claude for Siri

    SDK / Tool

    Answers macOS Spotlight and Siri prompts with your signed-in Claude Code account — an experimental macOS 27 model-delegation provider.

    • macos
    • siri
    • spotlight
    • model-delegation
  • Extract your own local chat history from ten AI coding assistants into one normalized JSONL — for fine-tuning, analytics, or backing up years of conversations. Standard library only.

    • cli
    • data-export
    • jsonl
    • backup