---
title: "Discussion on \"How I Route Every Claude Code Prompt to the Right Model\" | Hashnode"
description: "Discussion on \"How I Route Every Claude Code Prompt to the Right Model\". Stop paying Opus prices for simple lookups. A Python hook routes each Claude Code prompt to Haiku, Sonnet or Opus."
url: "https://hashnode.com/posts/how-i-route-every-claude-code-prompt-to-the-right-model/6ac3619078f6d4ba717507a5"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How I Route Every Claude Code Prompt to the Right Model](https://devlore.hashnode.dev/how-i-route-every-claude-code-prompt-to-the-right-model?utm_source=hashnode&utm_medium=feed)

Stop paying Opus prices for simple lookups. A Python hook routes each Claude Code prompt to Haiku, Sonnet or Opus.

Oct 5 · 14 min read · devlore.hashnode.dev  
Read the article

-   [#reduce-token-usage](https://hashnode.com/tag/reduce-token-usage)
-   [#ai-cost-optimization](https://hashnode.com/tag/ai-cost-optimization)
-   [#ai-cost-monitoring](https://hashnode.com/tag/ai-cost-monitoring)
-   [#ai](https://hashnode.com/tag/ai)
-   [#ai-tools](https://hashnode.com/tag/ai-tools)
-   [#ai-tools-for-developers](https://hashnode.com/tag/ai-tools-for-developers)
-   [#ai-agents](https://hashnode.com/tag/ai-agents)
-   [#AI](https://hashnode.com/tag/AI)

## Written by

[Satya Prakash](https://hashnode.com/@satya-prakash)

@satya-prakash · Lucknow, India

  
[View profile](https://hashnode.com/@satya-prakash)

Exploring the intersection of software engineering, system design, and AI — one practical lesson at a time.

Senior Software Engineer with 8+ years of experience designing scalable backend systems and high-traffic platforms. This blog documents my journey exploring system design, backend architecture, cloud infrastructure, and AI — sharing practical engineering lessons from real-world systems.

## Responses 4

Markdown supported · ⌘↵ to post

[Kartik N V J K](https://hashnode.com/@kartik-nvj)

[Oct 5](https://hashnode.com/posts/how-i-route-every-claude-code-prompt-to-the-right-model/6ac3619078f6d4ba717507a5/comment/6ac40dbc4a43bf98c374af44)

Biasing to the stronger model on close scores is the right asymmetry, since over-spending on Opus just costs money while under-routing a hard debug costs you a wrong answer you trust. The part I would instrument is exactly the misroutes you list at the end: keyword matching drifts, and without logging routing decisions against outcomes you cannot tell if the router is actually saving anything. Are you tracking how often the deep tier gets a prompt Haiku would have nailed?

[Satya Prakash](https://hashnode.com/@satya-prakash)

[Oct 6](https://hashnode.com/posts/how-i-route-every-claude-code-prompt-to-the-right-model/6ac3619078f6d4ba717507a5/comment/6ac40dbc4a43bf98c374af44#reply-6ac49b12adecb8826cf72170)

Agreed on the asymmetry. That's why close calls go up a tier: overspending costs money, but a confidently wrong debug costs much more.

To answer your question: no, not yet. Right now I only know which tier a prompt was sent to, not whether a cheaper model would have handled it. So I can't yet say how much the router saves.

My plan is to log every routing decision (prompt hash, scores, tier, escalated or not) to a JSONL file. Then I'll take a sample of prompts that went to Opus, re-run them on Haiku and Sonnet, and compare the answers. That shows how often Opus was overkill, and turns "it probably saves money" into an actual number.

[indiainfranotes](https://hashnode.com/@indiainfranotes)

[Oct 5](https://hashnode.com/posts/how-i-route-every-claude-code-prompt-to-the-right-model/6ac3619078f6d4ba717507a5/comment/6ac3e7fb0461b129b386a35e)

Routing by prompt score is smart, but the costly failures are misroutes in one direction: a hard refactor sent to the cheap tier comes back confidently shallow and costs more in rework than the big model would have. Do you log the cases where you escalated manually after a cheap answer, and feed those back into the scoring rules?

iin1005h23

[Satya Prakash](https://hashnode.com/@satya-prakash)

[Oct 6](https://hashnode.com/posts/how-i-route-every-claude-code-prompt-to-the-right-model/6ac3619078f6d4ba717507a5/comment/6ac3e7fb0461b129b386a35e#reply-6ac49b4626f75c424750ee44)

Yes, that's the failure that matters most. A shallow answer you trust costs more in rework than Opus would have.

Today there are two guards. Claude can move a task up a tier, and Haiku and Sonnet are told to stop and hand off if the work turns out harder than it looked. But I don't log manual escalations yet, so nothing feeds back into the scoring.

That's the next step. Every escalation will be logged with the original prompt and both tiers: automatic hand-offs, Claude moving a task up, and me re-running a task on a stronger model. Each one becomes a labelled example ("this prompt needed deep"). They go into a regression test set, and I'll tune the rules against that set rather than changing weights on gut feel.
