Using NadirClaw with Claude Code
Claude Code burns through Sonnet 4.5 tokens faster than you'd expect. A typical refactoring session can rack up $2-3 in API costs. NadirClaw cuts that by 50-70% by routing simple tasks to cheaper models automatically.
How It Works
Claude Code sends every prompt to whatever model you configured. NadirClaw sits between Claude Code and Anthropic, classifies each prompt, and routes trivial stuff (doc lookups, simple edits, boilerplate) to Haiku while keeping complex reasoning on Sonnet.
You don't change how you work. The savings happen invisibly.
Setup
1. Install NadirClaw
git clone https://github.com/doramirdor/NadirClaw.git
cd NadirClaw
npm install
2. Configure Your API Keys
Create .env:
ANTHROPIC_API_KEY=sk-ant-xxx
PORT=3000
3. Start the Proxy
npm start
NadirClaw runs on localhost:3000 by default.
4. Point Claude Code at NadirClaw
Instead of using Anthropic's API directly, configure Claude Code to use your local proxy.
Option A: Environment variable
export ANTHROPIC_BASE_URL=http://localhost:3000
claude-code
Option B: Config file
Edit ~/.config/claude-code/config.json:
{
"apiBaseUrl": "http://localhost:3000",
"apiKey": "sk-ant-xxx"
}
(Check Claude Code docs for exact config path on your OS.)
5. Use Claude Code Normally
That's it. Every request now goes through NadirClaw's classifier.
What Gets Routed Where
NadirClaw uses a 200-line logistic regression classifier trained on real coding prompts. Here's what typically happens:
Routed to Haiku (cheap):
- Documentation lookups
- Simple refactoring (rename variable, extract function)
- Boilerplate generation (test stubs, type definitions)
- Quick syntax fixes
- File reads and scans
Routed to Sonnet (smart):
- Architecture decisions
- Complex debugging
- Algorithm design
- Refactoring with business logic changes
- Anything ambiguous or multi-step
The classifier checks:
- Prompt length and complexity
- Question words vs imperative tone
- Code structure mentions
- Technical depth indicators
It's not perfect, but 10ms of overhead is negligible compared to model latency.
Monitoring
NadirClaw logs every request with routing decision:
[HAIKU] "rename this variable to userId"
[SONNET] "refactor this auth flow to support OAuth2 and SAML"
[HAIKU] "add JSDoc comments to this function"
Watch the console while you work. You'll see most trivial tasks hit Haiku.
Expected Savings
Based on real usage:
- Light sessions (mostly edits): 40-50% cost reduction
- Heavy sessions (refactoring + new features): 50-70% reduction
- Pair programming (lots of back-and-forth): 60%+ reduction
Your mileage varies based on how you use Claude Code. The more simple edits you do, the bigger the savings.
Gotchas
1. Local proxy required
NadirClaw runs locally. If you're on a flaky connection or frequently switching networks, the proxy might drop. Set a systemd/launchd service if you want it always-on.
2. Classification mistakes happen
Occasionally a complex task gets routed to Haiku and produces garbage. Just retry the prompt. The cost of one misroute is tiny compared to always using Sonnet.
3. Model version assumptions
NadirClaw defaults to claude-sonnet-4-5 and claude-haiku-4-5. If you use different models in Claude Code, override the routes in config.json.
Why This Beats Manual Rules
You could write routing rules yourself:
if (prompt.includes("refactor")) return "sonnet";
if (prompt.length < 50) return "haiku";
But keyword matching breaks fast. "Refactor this entire auth module to support multiple providers" is not the same as "refactor variable names for clarity."
NadirClaw's classifier understands prompt semantics, not just keywords. It's trained on real coding task distributions, so it learns patterns you'd miss.
Source
Full disclosure: I built NadirClaw. This guide reflects my actual usage with Claude Code over the past month. Savings numbers are from my own API bills.
GitHub: https://github.com/doramirdor/NadirClaw
Issues/questions welcome.
Dor Amir
February 2026
Top comments (0)