Skip to content

Intelligent model orchestration for Claude Code - routes queries to optimal Claude model (Haiku/Sonnet/Opus) based on complexity. It also includes many more features. If this project is working well for you and would like to support me, just help spread the word. Thanks!

License

Notifications You must be signed in to change notification settings

0xrdan/claude-router

Claude Router

Intelligent model orchestration for Claude Code - Automatically routes queries to the optimal Claude model (Haiku/Sonnet/Opus) based on complexity, reducing costs by up to 80% without sacrificing quality.

What Makes This Novel

What Exists What Claude Router Does
Multi-provider routers (OpenRouter, etc.) Intra-Claude optimization (Haiku/Sonnet/Opus)
Manual /model switching Automatic routing via UserPromptSubmit hook
Generic LLM complexity scoring Coding-task specific pattern recognition
External API wrapper approach Native Claude Code integration using subagents

Technical Achievements:

  • Zero-latency rule-based classification with LLM fallback
  • Token-optimized agent definitions (3.4k vs 11.9k tokens)
  • Multi-turn context awareness and follow-up detection
  • Persistent knowledge system across sessions

Key Metrics

Metric Value
Classification latency ~0ms (rules) or ~100ms (LLM fallback)
Classification cost $0 (rules) or ~$0.001 (Haiku fallback)
Cost savings (simple queries) ~80% (Haiku vs Opus)
Cost savings (mixed workload) Est. 50-70%
Additional savings (orchestration) ~40% on complex tasks

Installation

# Step 1: Add the marketplace (one-time, per project)
/plugin marketplace add 0xrdan/claude-plugins

# Step 2: Install the plugin
/plugin install claude-router

# Step 3: Restart Claude Code session to activate

That's it! The plugin automatically routes queries - no configuration needed.

# Update
/plugin marketplace update 0xrdan-plugins

# Uninstall
/plugin uninstall claude-router

Migrating from old marketplace? If you previously installed via claude-router-marketplace, run:

/plugin uninstall claude-router@claude-router-marketplace
/plugin marketplace remove claude-router-marketplace

Then follow the installation steps above.

Quick Start

Automatic routing works out of the box:

  • Simple queries → Haiku (fast, cheap)
  • Coding tasks → Sonnet (balanced)
  • Complex analysis → Opus (powerful)

Manual override when needed:

/route opus "Design a microservice architecture"
/route haiku "What is JSON?"

View statistics:

/router-stats

Commands

Command Description
/route <model> Override routing for a query
/router-stats View usage statistics
/learn Extract insights from conversation
/knowledge View knowledge base status
/orchestrate Execute complex tasks with forking
/router-analytics Generate HTML dashboard
/retry Retry with escalated model
/router-plugins Manage plugin integrations

See Configuration & Commands for full documentation.

Documentation

Document Description
How It Works Default vs Router behavior, cost savings
Routing Rules Classification rules, example output
Configuration All commands and settings
Knowledge System Persistent learning across sessions
Architecture Project structure, data flow
Roadmap Completed phases, coming soon
Contributing How to contribute

How It Works

Claude Router intercepts queries and routes them to the optimal model:

"What is JSON?"        → Haiku   (~$0.01)  ✓ Fast, cheap
"Fix this typo"        → Haiku   (~$0.01)  ✓ Fast, cheap
"Run all tests"        → Sonnet  (~$0.03)  ✓ Balanced
"Design architecture"  → Opus    (~$0.06)  ✓ Powerful

For complex tasks, the Opus Orchestrator delegates subtasks to cheaper models:

  • Opus handles strategy → expensive reasoning
  • Haiku handles file reads → cheap I/O
  • Sonnet handles edits → balanced implementation

Result: Same quality, ~40% less cost on complex workflows.

See How It Works for detailed comparison.

Contributing

Sharing and Contributions are welcome! See CONTRIBUTING.md for guidelines.

License

MIT License - see LICENSE for details.


Built for the Claude Code community | Report Issues | @dannymonteiro

About

Intelligent model orchestration for Claude Code - routes queries to optimal Claude model (Haiku/Sonnet/Opus) based on complexity. It also includes many more features. If this project is working well for you and would like to support me, just help spread the word. Thanks!

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •