Overview and Motivation
Routed is a universal, local-first routing engine designed to eliminate the agent skill context-bloat problem. As AI coding environments (Claude Code, Antigravity, Cursor, Windsurf, LM Studio, Ollama) expand their skill ecosystems, developers frequently install dozens or hundreds of specialized skills.
Preloading all installed skills into the agent's system prompt consumes between 15,000 and 40,000 tokens per interaction. This overhead leads to three severe issues:
- Runaway Token Expenses: Teams pay thousands of dollars per month sending full catalogs of unused skill schemas on every single message turn.
- Degraded Agent Reasoning: Large prompts introduce attention dilution and hallucinated skill activations when unrelated tool definitions overwhelm the model context.
- Increased Latency: Transferring massive prompt payloads over the network adds 1.2 to 3.5 seconds of round-trip latency to every turn.
Routed intercepts prompts locally, evaluates candidate skills in sub-milliseconds on CPU, and injects only the concise specifications required for the current task.
Architecture and Pipeline
Routed evaluates prompts using a deterministic, multi-tier scoring pipeline running entirely on local CPU cycles. The execution flow operates as follows:
User Prompt (/route or terminal)
|
+--> 1. Trivial Check (isNoSkill) ---------> Returns 0 skills (clean context)
|
+--> 2. Clause Segmentation ---------------> Splits compound prompts ("A and B")
|
+--> 3. Parallel Scoring Pipeline:
| |-- Exact & Alias Match (10% weight)
| |-- Okapi BM25 Lexical (35% weight)
| |-- Dense Vector Cosine (50% weight)
| \-- Metadata & Tags (5% weight)
|
+--> 4. Composite Scorer ------------------> Normalizes and weights scores
|
\--> 5. Multi-Skill Dispatch --------------> Resolves qualifying skills in sub-20ms
By combining dense semantic representations with lexical precision, Routed avoids the blind spots of keyword-only search while maintaining the speed and predictability of local computation.
Hybrid Scoring Formula
Candidate skills are ranked using a composite score calculated from four distinct signals:
CompositeScore = (0.50 * SemanticScore) + (0.35 * BM25Score) + (0.10 * ExactScore) + (0.05 * MetadataScore)
This distribution ensures semantic understanding takes precedence while preserving exact match determinism and lexical filtering.
1. Semantic Embeddings (50% Weight)
Dense semantic vector representation evaluates conceptual similarity using cosine distance. In the native CLI, Routed utilizes quantized local ONNX models (such as Snowflake Arctic Embed S or all-MiniLM-L6-v2) running locally via ONNX Runtime on CPU.
Semantic scoring allows Routed to map user intents to appropriate skills even when the prompt shares zero lexical tokens with the skill name or description:
- Prompt: "audit access controls and examine privilege escalations" → Matches
security-audit - Prompt: "find where my program is consuming runaway ram" → Matches
memory-leak-debugging - Prompt: "write automated unit specs before writing implementation" → Matches
tdd
2. Lexical BM25 (35% Weight)
Lexical scoring uses an optimized Okapi BM25 implementation with document length normalization (parameters: k1 = 1.2, b = 0.75). The lexical engine includes two critical preprocessing stages:
Action Stop Word Suppression
Conversational noise and common imperative verbs (such as run, execute, make, write, build, test, please, need, help) are suppressed during indexing and query tokenization. This prevents generic verbs from artificially inflating candidate relevance.
Technical Synonym Decomposition
Routed automatically maps developer shorthand and technical jargon to standard skill terms:
auth→authentication,authorization,login,oauthoom→memory leak,out of memory,heapk8s→kubernetes,cluster,deploymentsec/audit→security,vulnerability,threatperf→performance,optimization,latency
3. Exact and Alias Matching (10% Weight)
When a developer explicitly requests a specific skill by name or known alias (for instance: "run 007 audit" or "use tdd approach"), the exact matcher immediately assigns maximum confidence (1.0).
This prevents semantic ambiguity from overriding direct, intentional user commands.
Multi-Skill Resolution
Real-world software prompts often require multiple cooperating skills. Consider the prompt:
"run a security audit and threat modeling for my web application"
Routed decomposes compound sentences containing conjunctions (such as and, with, alongside) into individual task clauses:
- Clause 1:
run a security audit for my web application - Clause 2:
threat modeling for my web application
Skills scoring above the qualification threshold (multiSkillThreshold = 0.25) are returned in selectedSkills (up to 5 items), allowing the agent to activate all necessary competencies simultaneously.
Trivial Prompt Filtering (isNoSkill)
Not every developer turn requires a specialized skill. Common activities such as fixing syntax errors, checking status, or answering simple programming questions do not warrant skill injection:
"fix typo in line 42""format this json file""what does this git command do"
For these queries, Routed flags isNoSkill: true and injects 0 skills. The AI agent proceeds with its standard core capabilities, saving prompt tokens and avoiding context distraction.
Architecture Comparison
| Dimension | Routed (Local CPU) | Cloud LLM Routing | Static Skill Dumping |
|---|---|---|---|
| Token Cost per Turn | $0.00 (Zero tokens) | 500 to 2,000 paid tokens | 15,000 to 40,000 prompt tokens |
| Routing Latency | Sub-20ms (Local CPU) | 1,200ms to 3,500ms network API | 0ms (but slow inference) |
| Data Privacy | 100% Local (Air-gapped) | User prompt sent to cloud | All prompt data sent to cloud |
| Determinism | High (Hybrid Scorer) | Low (Model prompt drift) | None (Unranked dump) |
| Compound Handling | Clause decomposition | Variable | Context pollution |
Supported Environments
Routed automatically configures adapters across leading AI coding tools:
| Environment | Configuration Target | Integration Method |
|---|---|---|
| Model Context Protocol (MCP) | claude_desktop_config.json, .cursor/mcp.json |
JSON-RPC 2.0 stdio server (routed mcp) |
| LM Studio | ~/.cache/lm-studio/mcp.json |
Local MCP server for local GPU models |
| Ollama | ~/.ollama/routed/routed-tools.json |
Direct tool schemas and Modelfiles |
| Antigravity | ~/.gemini/config/skills/route/SKILL.md |
Native skill dispatch hook |
| Claude Code | ~/.claude/skills/route/SKILL.md |
Slash command and terminal interceptor |
| Cursor | .cursor/rules/routed.mdc |
Rule-based prompt routing and MCP |
| Codeium Windsurf | ~/.codeium/windsurf/mcp_config.json |
Cascade MCP tool provider |
| Continue.dev | ~/.continue/config.json |
Local IDE tool provider for Ollama |
Model Context Protocol (MCP) Integration
Routed can run as an MCP server over standard input/output (stdio). When attached to LM Studio, Cursor, Claude Desktop, or Windsurf, the host environment does not need to load 50+ tool schemas into context.
Instead, the host model invokes the lightweight route_skill tool. Routed evaluates the prompt on CPU in under 20ms and returns only the matching skill specifications.
Configuration Snippet
{
"mcpServers": {
"routed": {
"command": "routed",
"args": ["mcp"]
}
}
}
Direct Ollama Integration
For developers using local open-weight models via Ollama, Routed provides direct command integration:
# Generate standard tool schemas for Ollama /api/chat
routed ollama tools
# Route a prompt and produce a ready-to-run Ollama API payload
routed ollama route "audit firestore security rules"
# Generate a customized Modelfile with dynamic skill injection
routed ollama modelfile --skill security-audit
Installation Guide
Zero-Install Evaluation (via npx)
Run Routed instantly in any directory without global installation:
npx routed route "refactor authentication and add unit tests" --explain
Global npm Installation
npm install -g routed
Interactive Setup Wizard
Detect installed AI coding tools and configure local adapters automatically:
routed setup
Standalone Platform Installers
Download precompiled binaries directly from GitHub Releases:
- macOS:
RoutedSetup.pkgorRoutedSetup.dmg - Linux:
RoutedSetup.deborrouted-linux-x64.tar.gz - Windows:
RoutedSetup.exeorInstall-Routed.ps1
CLI Command Reference
| Command | Description | Example |
|---|---|---|
routed setup |
Run interactive setup wizard across tools | routed setup |
routed route "<prompt>" |
Find matching skill(s) for a coding prompt | routed route "write tests with TDD" |
routed scan |
Scan local directories and update index | routed scan |
routed skills |
List all discovered and indexed skills | routed skills |
routed adapters |
Manage /route adapters across AI tools | routed adapters install |
routed doctor |
Run system health diagnostics and repair | routed doctor --fix |
routed mcp |
Start Model Context Protocol server over stdio | routed mcp |
routed ollama <cmd> |
Ollama tool schemas, routes, and Modelfiles | routed ollama tools |
routed reindex |
Incrementally re-index and re-embed skills | routed reindex |
routed watch |
Continuously monitor skill directories for changes | routed watch |
routed feedback |
Manage routing preferences and adjustments | routed feedback --list |
routed benchmark |
Benchmark routing accuracy and latency | routed benchmark |
routed update |
Check for updates and upgrade Routed | routed update --check |
routed uninstall |
Safely uninstall Routed and clean adapters | routed uninstall --dry-run |
Frequently Asked Questions
Are user prompts ever transmitted to third-party servers?
No. All prompt routing is executed 100% locally on your machine. All tokenization, BM25 ranking, and ONNX vector embedding operations take place on local CPU. Routed has zero telemetry and zero external API dependencies for routing.
What happens if adapter setup encounters a partial failure across multiple hosts?
Routed follows an idempotent desired-state convergence model with zero blast radius. Each host adapter runs in an isolated boundary: if Cursor installs successfully but Claude Code fails (for example, due to a file permission), Cursor remains fully operational. Running routed doctor --fix reconciles any missing adapters in a single step.
Does local routing introduce noticeable latency?
No. Benchmark execution times average under 20 milliseconds on local CPU. In browser environments via WebAssembly, evaluation typically finishes in under 2 milliseconds, making it imperceptible compared to remote cloud API calls (1,200ms to 3,500ms).
How does Routed handle multilingual developer prompts?
Routed natively handles German, Spanish, French, Japanese, and 100+ languages without manual language toggling. Multilingual token decomposition handles German compound words and non-Latin character sets automatically.