smart-routing
3
总安装量
1
周安装量
#61543
全站排名
安装命令
npx skills add https://github.com/wasintoh/toh-framework --skill smart-routing
Agent 安装分布
opencode
1
codex
1
claude-code
1
Skill 文档
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: IDE DETECTION â
â âââ Claude Code â Parallel execution enabled â
â âââ Other IDEs â Sequential execution only â
â â
â STEP 4: AGENT SELECTION & EXECUTION â
â âââ Route to appropriate agent(s) â
â â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
ð Intent Classification Matrix
Primary Patterns â Agent Mapping
| Pattern Category | Keywords (EN) | Keywords (TH) | Primary Agent | Confidence |
|---|---|---|---|---|
| Create UI | create, add, make, build + page/component/UI | สรà¹à¸²à¸, à¹à¸à¸´à¹à¸¡, à¸à¸³ + หà¸à¹à¸²/component | UI Agent | HIGH |
| Add Logic | logic, state, function, hook, validation | logic, state, function, à¹à¸à¸´à¹à¸¡ logic | Dev Agent | HIGH |
| Fix Bug | bug, error, broken, fix, not working | bug, error, à¸à¸±à¸, à¹à¸¡à¹à¸à¸³à¸à¸²à¸, à¹à¸à¹ | Fix Agent | HIGH |
| Improve Design | prettier, beautiful, design, polish, style | สวย, design, à¸à¸£à¸±à¸ design | Design Agent | HIGH |
| Testing | test, check, verify | test, à¸à¸à¸ªà¸à¸, à¹à¸à¹à¸ | Test Agent | HIGH |
| Connect Backend | connect, database, Supabase, API, backend | à¹à¸à¸·à¹à¸à¸¡, database, Supabase | Connect Agent | HIGH |
| Deploy | deploy, ship, production, publish | deploy, ship, à¸à¸¶à¹à¸ production | Ship Agent | HIGH |
| LINE Platform | LINE, LIFF, Mini App | LINE, LIFF | LINE Agent | HIGH |
| Mobile Platform | mobile, iOS, Android, Expo, React Native | mobile, มืà¸à¸à¸·à¸ | Mobile Agent | HIGH |
| New Project | new project, start, build app, create system | project à¹à¸«à¸¡à¹, สรà¹à¸²à¸ app | Vibe Agent | HIGH |
| Planning | plan, analyze, PRD, architecture | วาà¸à¹à¸à¸, วิà¹à¸à¸£à¸²à¸°à¸«à¹ | Plan Agent | HIGH |
| AI/Prompt | prompt, AI, chatbot, system prompt | prompt, AI, chatbot | Dev Agent + prompt-optimizer | HIGH |
| Continue | continue, resume, go on | à¸à¸³à¸à¹à¸, à¸à¹à¸ | Memory â Last Agent | MEDIUM |
| Complex Request | Multiple features, system, e-commerce, etc. | ระà¸à¸ + หลาย features | Plan Agent | MEDIUM |
| Vague Request | help, fix it, make better (without context) | à¸à¹à¸§à¸¢à¸à¹à¸§à¸¢, à¹à¸à¹à¸à¸µ | Ask Clarification | LOW |
ð¯ Confidence Scoring Algorithm
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
ð¥ï¸ IDE Detection
Detection Method
function detectIDE(): 'claude-code' | 'cursor' | 'gemini' | 'codex' | 'unknown' {
// Check for IDE-specific markers
// Claude Code detection
if (hasClaudeCodeMarkers()) {
return 'claude-code';
}
// Cursor detection
if (hasCursorRules()) {
return 'cursor';
}
// Gemini CLI detection
if (hasGeminiConfig()) {
return 'gemini';
}
// Codex CLI detection
if (hasCodexConfig()) {
return 'codex';
}
return 'unknown';
}
Execution Strategy by IDE
| IDE | Multi-Agent Strategy | Reason |
|---|---|---|
| Claude Code | Parallel (spawn sub-agents) | Native support for parallel tool calls |
| Cursor | Sequential | More predictable, follows diff flow |
| Gemini CLI | Sequential | Safer execution model |
| Codex CLI | Sequential | Linear task processing |
| Unknown | Sequential (default) | Safe fallback |
ð 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
| Situation | Example | Action |
|---|---|---|
| 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
| Situation | Example | Action |
|---|---|---|
| Clear intent | “create login page” | Execute directly |
| Memory provides context | “continue” + active task exists | Resume from memory |
| Reasonable default exists | “add a button” | Add to current page context |
ð¨ Skill Loading by Intent
| Detected Intent | Skills to Load |
|---|---|
| New Project | vibe-orchestrator, design-mastery, business-context, response-format |
| Create UI | ui-first-builder, design-excellence, response-format |
| Add Logic | dev-engineer, error-handling, response-format |
| Fix Bug | debug-protocol, error-handling, response-format |
| Connect Backend | backend-engineer, integrations, response-format |
| Improve Design | design-excellence, design-mastery, response-format |
| AI/Chatbot | prompt-optimizer, dev-engineer, response-format |
| Testing | test-engineer, error-handling, response-format |
| Planning | plan-orchestrator, business-context, response-format |
Note: response-format skill is ALWAYS loaded for proper output formatting.
ð¾ Memory Integration
Pre-Routing Memory Check
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
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
- Memory ALWAYS first – Never route without checking context
- Confidence drives action – Trust the scoring system
- Plan Agent is your friend – When in doubt, route to Plan
- IDE awareness matters – Parallel only in Claude Code
- response-format always loaded – Every response needs 3 sections
Smart Routing Skill v1.0.0 – Intelligent Request Routing Engine