Plugin discovery and context-aware routing system for Claude Code.
Smart Router solves the problem of having many installed plugins without knowing which one to use. It automatically discovers all your installed plugins (21+ in most setups) and intelligently routes you to the best tool based on your task context and preferences.
When you have multiple plugins installed:
- 3+ code review agents - Which one should you use?
- Multiple brainstorming skills - Which fits your task?
- Various testing tools - What's best for this situation?
Without Smart Router, Claude Code may not consistently use your installed tools, or you have to manually remember and select them each time.
- SessionStart Hook - Scans your plugins on session start, builds a registry
- UserPromptSubmit Hook - Detects when you need a tool, suggests matches
- Smart Router Skill - Ranks options by context and routes intelligently
- β
Auto-discovery - Scans
~/.claude/plugins/and.claude/commands/ - β Smart caching - Hash-based invalidation, rebuilds only when plugins change
- β Context-aware - Routes based on file types, project structure
- β User preferences - Auto-route, show menu, or context-based (configurable)
- β Lightweight - Fast registry lookup, minimal overhead
Step 1: Add the marketplace
/plugin marketplace add Blockchain-Oracle/smart-routerStep 2: Install the plugin
/plugin install smart-router@smart-router-marketplaceThat's it! Smart Router is now active and will automatically discover your plugins on the next session.
# Clone directly to your global plugins directory
git clone https://github.com/Blockchain-Oracle/smart-router ~/.claude/plugins/smart-router# Test locally before installing
cd /path/to/smart-router
claude --plugin-dir .Use the interactive configuration command:
/smart-router:configureThis will guide you through setting up your preferences with questions and validation.
Alternatively, create .claude/smart-router.local.md manually:
---
routingMode: auto # auto | ask | context
showReasoning: true # Show why tool was chosen
excludePlugins: # Plugins to ignore
- plugin-name
priorityOrder: # Override default ranking
- superpowers
- pr-review-toolkit
---auto- Automatically picks best tool, no questions asked (fastest)ask- Shows menu of options, lets you choose (most control)context- Uses file context to decide automatically (balanced)
Smart Router now includes an optional UserPromptSubmit hook that reminds Claude to check Smart Router BEFORE making tool decisions.
What it does:
- Fires when you submit task-related prompts (testing, brainstorming, debugging, etc.)
- Reminds Claude to check Smart Router first
- Shows registry stats (how many tools available)
- Trains Claude to always consider all available tools
Smart filtering:
- Only fires on task keywords: test, brainstorm, review, debug, build, design, game, etc.
- Silent on simple prompts like "what's 2+2" (no spam!)
- Training mode - builds good habits over time
Example:
You: "I want to test my code"
β
Hook: "π― Before I start, let me check Smart Router first..."
β
Claude: [checks Smart Router, sees all testing tools, picks best one]
Setup:
The /smart-router:configure command now asks if you want to enable the hook. It will:
- Read your existing
.claude/settings.json(if it exists) - MERGE the hook configuration (never overwrites existing hooks)
- Set up the early reminder hook
Manual setup:
If you prefer manual control, add to .claude/settings.json:
{
"hooks": {
"UserPromptSubmit": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "python3 ${CLAUDE_PLUGIN_ROOT}/hooks/smart-router-enforcer.py",
"timeout": 5
}
]
}
]
}
}Note: The merge logic ensures your existing hooks (from other plugins or custom setup) are preserved.
Just work normally! Smart Router runs in the background:
You: "I need a code review"
β Smart Router detects need
β Auto-routes to best code review tool
β Review happens seamlessly
Set up your routing preferences interactively:
/smart-router:configureGuides you through:
- Routing mode selection (auto/ask/context)
- Display preferences (show reasoning)
- Priority order (preferred plugins)
- Exclusions (plugins to ignore)
Force rebuild the plugin registry:
/smart-router:rebuildUseful after:
- Installing new plugins
- Updating existing plugins
- Debugging routing issues
- Scans
~/.claude/plugins/cache/for installed plugins - Scans
.claude/commands/for local commands (e.g., BMAD) - Extracts capabilities from plugin manifests and descriptions
- Computes hash of plugin directories
- Builds
.claude/.cache/agent-registry.json(if changed)
{
"version": "1.0",
"lastBuilt": "2025-12-19T12:00:00Z",
"hash": "abc123...",
"capabilities": {
"code-review": [
{
"plugin": "superpowers",
"type": "skill",
"entry": "skills/code-reviewer/SKILL.md",
"description": "General code review with TDD focus"
}
]
}
}Tools are ranked by:
- File context - Game files? Prefer game-dev agents
- User preference - From
.claude/smart-router.local.md - Plugin specialty - From description keywords
- Alphabetical - Tie-breaker
You: "Review this PR"
Smart Router:
- Detects: code-review capability needed
- Finds: 3 matching tools
- Context: Backend API files
- Routes to: pr-review-toolkit (specialized for PRs)
You: "Help me design this feature"
Smart Router:
- Detects: brainstorming capability needed
- Finds: 2 matching tools
- User preference: auto mode
- Routes to: superpowers:brainstorming (highest priority)
You: "Build a game with backend API"
Smart Router:
- Detects: Multiple specializations needed
- Suggests: Use git3 workflow for parallel agents
- Routes to: dispatching-parallel-agents skill
- Result: game-dev + backend-dev agents work concurrently
βββββββββββββββββββββββββββββββββββββββββββ
β SessionStart Hook β
β (Build/Update Registry on Start) β
βββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββ
β .claude/.cache/ β
β agent-registry.json β
β (Cached Plugin Capabilities) β
βββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββ
β UserPromptSubmit Hook β
β (Detect Routing Needs) β
βββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββ
β Smart Router Skill β
β (Rank, Select, Route) β
βββββββββββββββββββββββββββββββββββββββββββ
- Node.js 18+ (for TypeScript hooks)
- pnpm (for installing dependencies)
- Claude Code
The hooks are already compiled and ready to use! If you need to modify them:
cd smart-router/hooks
# Install dependencies (already done if node_modules/ exists)
pnpm install
# Recompile TypeScript after changes
npx tscHooks run automatically when Claude Code triggers their events. To manually test:
Test Registry Builder (runs on SessionStart):
cd smart-router/hooks
echo '{"session_id":"test","cwd":"/tmp"}' | node registry-builder.jsTest Routing Detector (runs on UserPromptSubmit):
cd smart-router/hooks
echo '{"prompt":"I need code review","cwd":"/tmp"}' | node routing-detector.jsSee hooks in action:
# Install the plugin and start a session - hooks run automatically!
/plugin marketplace add Blockchain-Oracle/smart-router
/plugin install smart-router@smart-router-marketplace
# Registry builds on session start (SessionStart hook)
# Routing suggestions appear when you ask for help (UserPromptSubmit hook)Registry not building:
- Check
.claude/.cache/directory exists - Run
/smart-router:rebuildmanually - Check hook logs with
claude --debug
Tools not being suggested:
- Verify plugins are installed and enabled
- Check
.claude/smart-router.local.mdexcludePlugins - Ensure descriptions match common capability keywords
Wrong tool being selected:
- Adjust
priorityOrderin settings - Switch
routingModetoaskto see all options - Check file context is being detected correctly
This plugin is designed to work with the broader Claude Code plugin ecosystem. To add support for new capability types or improve ranking logic, see skills/smart-router/references/ for architecture details.
MIT
Blockchain Oracle Email: BlockchainOracle.dev@gmail.com