Smart Routing logo

Smart Routing

Community
wasintoh
smart-routing

Intelligent request routing for /toh command. Analyzes user intent, assesses confidence, surveys the runtime (2-step, per orchestration-protocol), and routes to the appropriate agent(s). Memory-first approach ensures context awareness. Triggers: /toh command, natural language requests, ambiguous inputs.

Overview

Publisherwasintoh
Repositorytoh-framework
Skill namesmart-routing
Stars
96
Forks
19
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by wasintoh on GitHub. Read the source before you install it.

Installation

Install the Smart Routing AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/wasintoh/toh-framework.git /tmp/toh-framework
mkdir -p .claude/skills
cp -r /tmp/toh-framework/src/skills/smart-routing .claude/skills/smart-routing
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Smart Routing in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Smart Routing on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Smart Routing is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Smart Routing Skill

Intelligent routing engine for the /toh smart command. Routes any natural language request to the right agent(s).


🧠 Routing Pipeline

┌─────────────────────────────────────────────────────────────────┐
│                    USER REQUEST                                 │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  STEP 0: MEMORY CHECK (ALWAYS FIRST!)                          │
│  ├── Read .toh/memory/active.md                                │
│  ├── Read .toh/memory/summary.md                               │
│  ├── Read .toh/memory/decisions.md                             │
│  └── Build context understanding                               │
│                                                                 │
│  STEP 1: INTENT CLASSIFICATION                                 │
│  ├── Pattern matching (keywords, phrases)                      │
│  ├── Context inference (from memory)                           │
│  └── Scope detection (simple/complex)                          │
│                                                                 │
│  STEP 2: CONFIDENCE SCORING                                    │
│  ├── HIGH (80%+) → Direct execution                            │
│  ├── MEDIUM (50-80%) → Plan Agent first                        │
│  └── LOW (<50%) → Ask for clarification                        │
│                                                                 │
│  STEP 3: RUNTIME SURVEY (2-step — orchestration-protocol A)    │
│  ├── Identity: declared by loaded context file +               │
│  │   .toh/capabilities.json                                    │
│  └── Probe: teams env flag + version gates only                │
│                                                                 │
│  STEP 4: AGENT SELECTION & EXECUTION                           │
│  └── Route to appropriate agent(s)                             │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

📊 Intent Classification Matrix

Illustrative heuristics only — native agent-description matching makes the actual call (see /toh); do not compute or display confidence scores.

Primary Patterns → Agent Mapping

Pattern CategoryKeywords (EN)Keywords (TH)Primary AgentConfidence
Create UIcreate, add, make, build + page/component/UIสร้าง, เพิ่ม, ทำ + หน้า/componentUI AgentHIGH
Add Logiclogic, state, function, hook, validationlogic, state, function, เพิ่ม logicDev AgentHIGH
Fix Bugbug, error, broken, fix, not workingbug, error, พัง, ไม่ทำงาน, แก้Fix AgentHIGH
Improve Designprettier, beautiful, design, polish, styleสวย, design, ปรับ designDesign AgentHIGH
Testingtest, check, verifytest, ทดสอบ, เช็คTest AgentHIGH
Connect Backendconnect, database, Supabase, API, backendเชื่อม, database, SupabaseConnect AgentHIGH
Deploydeploy, ship, production, publishdeploy, ship, ขึ้น productionShip AgentHIGH
LINE PlatformLINE, LIFF, LINE MINI AppLINE, LIFFLINE AgentHIGH
Mobile Platformmobile, iOS, Android, PWA, Capacitormobile, มือถือMobile AgentHIGH
New Projectnew project, start, build app, create systemproject ใหม่, สร้าง appVibe AgentHIGH
Planningplan, analyze, PRD, architectureวางแผน, วิเคราะห์Plan AgentHIGH
AI/Promptprompt, AI, chatbot, system promptprompt, AI, chatbotDev Agent + prompt-optimizerHIGH
Continuecontinue, resume, go onทำต่อ, ต่อMemory → Last AgentMEDIUM
Complex RequestMultiple features, system, e-commerce, etc.ระบบ + หลาย featuresPlan AgentMEDIUM
Vague Requesthelp, fix it, make better (without context)ช่วยด้วย, แก้ทีAsk ClarificationLOW

🎯 Confidence Scoring Algorithm

Illustrative heuristics only — native agent-description matching makes the actual call (see /toh); do not compute or display confidence scores.

typescript
interface ConfidenceFactors {
  keywordMatch: number;      // 0-40 points
  contextClarity: number;    // 0-30 points
  memorySupport: number;     // 0-20 points
  scopeDefinition: number;   // 0-10 points
}

function calculateConfidence(request: string, memory: Memory): number {
  let score = 0;
  
  // Keyword matching (0-40 points)
  // Strong match with primary patterns = 40
  // Partial match = 20
  // No match = 0
  score += keywordMatchScore(request);
  
  // Context clarity (0-30 points)
  // Specific page/component mentioned = 30
  // General area mentioned = 15
  // No specifics = 0
  score += contextClarityScore(request);
  
  // Memory support (0-20 points)
  // Request relates to active task = 20
  // Request relates to project = 10
  // No memory context = 0
  score += memorySupportScore(request, memory);
  
  // Scope definition (0-10 points)
  // Single clear task = 10
  // Multiple related tasks = 5
  // Unclear scope = 0
  score += scopeDefinitionScore(request);
  
  return score; // 0-100
}

// Thresholds
const HIGH_CONFIDENCE = 80;    // Execute directly
const MEDIUM_CONFIDENCE = 50;  // Route to Plan Agent
// Below 50 = Ask for clarification

🖥️ Runtime Survey (2-step — never guess the IDE)

Step 1 — Identity (declared)

Your runtime identity is declared by the platform context file that loaded you (CLAUDE.md = Claude Code · .cursor/rules/*.mdc = Cursor · AGENTS.md = Codex or ZCode, whichever the **Runtime:** line inside it names · .agents/rules/toh-framework.md = Antigravity · GEMINI.md = Gemini CLI, legacy). Confirm capabilities from .toh/capabilities.json (written by the installer). No detection heuristics — the identity is stated, not inferred.

Step 2 — Runtime probe (only what install time cannot know)

Probe exactly: the CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS env flag, plus the Claude Code version gates for /goal and workflows. Nothing else.

Execution mode

Choose from the execution ladder in orchestration-protocol (Section B) — the full decision table lives there, once. Summary only:

  • Claude Code → ladder: teams > subagents > sequential
  • Cursor (2.4+) → native subagents in .cursor/agents/, one task at a time
  • Antigravity → file-based subagents via invoke_subagent, one task at a time
  • Codex / ZCode / Gemini (legacy) → sequential TOH LOOP in-session

🔄 Routing Decision Tree

Request arrives
┌─────────────────────────────────────┐
│ 1. Load Memory Context              │
└─────────────────────────────────────┘
┌─────────────────────────────────────┐
│ 2. Is request "continue"/"ทำต่อ"?   │
├── YES → Read memory, resume task   │
└── NO → Continue analysis           │
┌─────────────────────────────────────┐
│ 3. Calculate Confidence Score       │
└─────────────────────────────────────┘
      ├── Score >= 80 (HIGH)
      │   └─→ Select agent based on intent
      │       └─→ Execute directly
      ├── Score 50-79 (MEDIUM)
      │   └─→ Route to Plan Agent
      │       └─→ Plan Agent analyzes & routes
      └── Score < 50 (LOW)
          └─→ Ask clarifying question
              └─→ Wait for user response

📋 Clarification Patterns

When to Ask

SituationExampleAction
No verb/action"the login"Ask: "What would you like to do with login?"
No target"make it work"Ask: "Which page/component should I fix?"
Multiple interpretations"improve it"Ask: "Design, performance, or features?"
Missing context + no memory"fix it"Ask: "What's broken? Describe the issue."

When NOT to Ask

SituationExampleAction
Clear intent"create login page"Execute directly
Memory provides context"continue" + active task existsResume from memory
Reasonable default exists"add a button"Add to current page context

🎨 Skill Loading by Intent

Detected IntentSkills to Load
New Projectvibe-orchestrator, design-craft, business-context, engineer-harness
Create UIui-first-builder, design-craft, engineer-harness
Add Logicdev-engineer, error-handling, engineer-harness
Fix Bugdebug-protocol, error-handling, engineer-harness
Connect Backendbackend-engineer, integrations, engineer-harness
Improve Designdesign-craft, engineer-harness
AI/Chatbotprompt-optimizer, dev-engineer, engineer-harness
Testingtest-engineer, error-handling, engineer-harness
Planningplan-orchestrator, business-context, engineer-harness

Note: engineer-harness skill is ALWAYS loaded for proper output formatting and next-step suggestions.


💾 Memory Integration

Pre-Routing Memory Check

markdown
Before routing, ALWAYS:
1. Read .toh/memory/active.md
   - Current task context
   - In-progress work
   - Blockers
   
2. Read .toh/memory/summary.md
   - Project overview
   - Completed features
   - Tech stack used
   
3. Read .toh/memory/decisions.md
   - Past architectural decisions
   - Design choices
   - Naming conventions

Use memory to:
- Boost confidence (if request matches active work)
- Provide context (for ambiguous "it" references)
- Maintain consistency (follow established patterns)

Post-Execution Memory Save

markdown
After routing completes, ALWAYS:
1. Update .toh/memory/active.md
   - Mark completed items
   - Update current focus
   - Set next steps
   
2. Add to .toh/memory/decisions.md
   - If new decisions were made
   
3. Update .toh/memory/summary.md
   - If feature was completed

⚠️ NEVER finish without saving memory!

📌 Examples

Example 1: High Confidence → Direct

Request: "/toh สร้างหน้า dashboard"

Analysis:
- Keyword match: "สร้าง" + "หน้า" = Create UI (40 pts)
- Context clarity: "dashboard" = specific page (30 pts)
- Memory: Project has other pages (15 pts)
- Scope: Single page (10 pts)
Total: 95 pts = HIGH

Route: UI Agent (direct)

Example 2: Medium Confidence → Plan First

Request: "/toh build e-commerce"

Analysis:
- Keyword match: "build" = Create (40 pts)
- Context clarity: "e-commerce" = general concept (10 pts)
- Memory: New project (0 pts)
- Scope: Multiple features (0 pts)
Total: 50 pts = MEDIUM

Route: Plan Agent first → then execute plan

Example 3: Low Confidence → Ask

Request: "/toh fix it"

Analysis:
- Keyword match: "fix" (20 pts)
- Context clarity: "it" = unclear (0 pts)
- Memory: No recent bugs (0 pts)
- Scope: Unknown (0 pts)
Total: 20 pts = LOW

Action: Ask "What would you like me to fix? Please describe the issue."

⚠️ Critical Rules

  1. Memory ALWAYS first - Never route without checking context
  2. Confidence drives action - Trust the scoring system
  3. Plan Agent is your friend - When in doubt, route to Plan
  4. Survey, don't guess - Identity is declared; execution mode comes from orchestration-protocol's ladder
  5. engineer-harness always loaded - Every response needs 3 sections + next steps

Smart Routing Skill v1.0.0 - Intelligent Request Routing Engine

Frequently asked questions

What does the Smart Routing AI skill do?

Intelligent request routing for /toh command. Analyzes user intent, assesses confidence, surveys the runtime (2-step, per orchestration-protocol), and routes to the appropriate agent(s). Memory-first approach ensures context awareness. Triggers: /toh command, natural language requests, ambiguous inputs.

Why use Smart Routing on TypingMind?

Because you install it once and use it with any model. Smart Routing is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Smart Routing in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/wasintoh/toh-framework/tree/main/src/skills/smart-routing. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Smart Routing?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Smart Routing?

As many as you like. As long as a model supports skills, you can use Smart Routing with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Smart Routing AI skill free?

Yes. It is published on GitHub by wasintoh under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇