Intelligent Agent Routing
Purpose: Automatically analyze user requests and route them to the most appropriate specialist agent(s) without requiring explicit user mentions.
Core Principle
The AI should act as an intelligent Project Manager, analyzing each request and automatically selecting the best specialist(s) for the job while maintaining Trust-Grade governance.
How It Works
1. Request Analysis
Before responding to ANY user request, perform automatic analysis:
graph TD
A[User Request] --> B[ANALYZE]
B --> C[Keywords]
B --> D[Domains]
B --> E[Complexity]
C --> F[SELECT AGENT]
D --> F
E --> F
F --> G[Apply Trust-Grade Context]
G --> H[AUTO-INVOKE with governance]
2. Agent Selection Matrix
| User Intent |
Keywords |
Selected Agent(s) |
Auto-invoke? |
| Architecture |
"design", "structure", "pattern" |
architect |
✅ YES |
| Planning |
"plan", "roadmap", "sprint" |
planner |
✅ YES |
| Code Review |
"review", "check", "audit" |
code-reviewer |
✅ YES |
| Security |
"security", "vulnerability", "auth" |
security-reviewer |
✅ YES |
| Testing |
"test", "coverage", "e2e" |
tdd-guide + e2e-runner |
✅ YES |
| Build Errors |
"error", "build", "compile" |
build-error-resolver |
✅ YES |
| Refactoring |
"refactor", "clean", "improve" |
refactor-cleaner |
✅ YES |
| Documentation |
"docs", "readme", "document" |
doc-updater |
✅ YES |
| Knowledge |
"learn", "remember", "pattern" |
knowledge-agent |
✅ YES |
| Complex Task |
Multiple domains detected |
planner → multi-agent |
⚠️ ASK FIRST |
Domain Detection Rules
Single-Domain Tasks (Auto-invoke Single Agent)
| Domain |
Patterns |
Agent |
| Architecture |
design, pattern, structure, layer |
architect |
| Planning |
plan, task, sprint, milestone |
planner |
| Security |
auth, jwt, password, vulnerability |
security-reviewer |
| Testing |
test, jest, coverage, e2e, playwright |
tdd-guide / e2e-runner |
| Build |
error, compile, typescript, lint |
build-error-resolver |
| Refactor |
clean, refactor, improve, optimize |
refactor-cleaner |
| Docs |
readme, document, api-docs |
doc-updater |
Multi-Domain Tasks (Orchestration Required)
If request matches 2+ domains from different categories, escalate to planner for orchestration:
Example: "Create a secure login with tests"
→ Detected: Security + Testing + Backend
→ Auto-invoke: planner (orchestration mode)
→ Planner will handle: security-reviewer, architect, tdd-guide
Complexity Assessment
SIMPLE (Direct agent invocation)
- Single file edit
- Clear, specific task
- One domain only
- Example: "Fix the TypeScript error in auth.ts"
Action: Auto-invoke respective agent
MODERATE (2-3 agents)
- 2-3 files affected
- Clear requirements
- 2 domains max
- Example: "Add API endpoint with tests"
Action: Auto-invoke relevant agents sequentially
COMPLEX (Orchestration required)
- Multiple files/domains
- Architectural decisions needed
- Unclear requirements
- Example: "Build a new feature vertical"
Action: Auto-invoke planner → will ask Socratic questions
Implementation Rules
Rule 1: Silent Analysis
DO NOT announce "I'm analyzing your request..."
- ✅ Analyze silently
- ✅ Inform which agent is being applied
- ❌ Avoid verbose meta-commentary
Rule 2: Inform Agent Selection
DO inform which expertise is being applied:
🤖 **Applying `@security-reviewer` expertise...**
I will review the authentication implementation with the following focus:
[Continue with specialized response]
Rule 3: Trust-Grade Context
Always apply project governance context:
- Load relevant governance rules
- Apply session state context
- Enforce pre-task checklists
Rule 4: Override Capability
User can still explicitly mention agents:
User: "Use @architect to review this"
→ Override auto-selection
→ Use explicitly mentioned agent
Integration with Project Governance
With Session State
- Check
session-state.json for active context
- Inherit project-specific configurations
- Maintain Trust-Grade continuity
With Governance Rules
- Apply relevant governance rules
- Enforce professional standards
- Maintain project architecture alignment
With Checklists
- Trigger pre-task checks for complex operations
- Validate against session-end protocols
- Ensure documentation updates
Summary
- Analyze every request before responding
- Select best agent(s) using the matrix
- Inform user which expertise is applied
- Maintain governance through Trust-Grade protocols
- Stay seamless - user shouldn't notice the routing
1---2name: intelligent-routing3description: Automatic agent selection and intelligent task routing. Analyzes user requests and selects the best specialist agent(s) for Trust-Grade execution.4version: 1.0.05---67# Intelligent Agent Routing89> **Purpose**: Automatically analyze user requests and route them to the most appropriate specialist agent(s) without requiring explicit user mentions.1011## Core Principle1213> **The AI should act as an intelligent Project Manager**, analyzing each request and automatically selecting the best specialist(s) for the job while maintaining Trust-Grade governance.1415---1617## How It Works1819### 1. Request Analysis2021Before responding to ANY user request, perform automatic analysis:2223```mermaid24graph TD25 A[User Request] --> B[ANALYZE]26 B --> C[Keywords]27 B --> D[Domains]28 B --> E[Complexity]29 C --> F[SELECT AGENT]30 D --> F31 E --> F32 F --> G[Apply Trust-Grade Context]33 G --> H[AUTO-INVOKE with governance]34```3536### 2. Agent Selection Matrix3738| User Intent | Keywords | Selected Agent(s) | Auto-invoke? |39| ----------------- | ----------------------------------- | -------------------------- | ------------ |40| **Architecture** | "design", "structure", "pattern" | `architect` | ✅ YES |41| **Planning** | "plan", "roadmap", "sprint" | `planner` | ✅ YES |42| **Code Review** | "review", "check", "audit" | `code-reviewer` | ✅ YES |43| **Security** | "security", "vulnerability", "auth" | `security-reviewer` | ✅ YES |44| **Testing** | "test", "coverage", "e2e" | `tdd-guide` + `e2e-runner` | ✅ YES |45| **Build Errors** | "error", "build", "compile" | `build-error-resolver` | ✅ YES |46| **Refactoring** | "refactor", "clean", "improve" | `refactor-cleaner` | ✅ YES |47| **Documentation** | "docs", "readme", "document" | `doc-updater` | ✅ YES |48| **Knowledge** | "learn", "remember", "pattern" | `knowledge-agent` | ✅ YES |49| **Complex Task** | Multiple domains detected | `planner` → multi-agent | ⚠️ ASK FIRST |5051---5253## Domain Detection Rules5455### Single-Domain Tasks (Auto-invoke Single Agent)5657| Domain | Patterns | Agent |58| ---------------- | ------------------------------------- | -------------------------- |59| **Architecture** | design, pattern, structure, layer | `architect` |60| **Planning** | plan, task, sprint, milestone | `planner` |61| **Security** | auth, jwt, password, vulnerability | `security-reviewer` |62| **Testing** | test, jest, coverage, e2e, playwright | `tdd-guide` / `e2e-runner` |63| **Build** | error, compile, typescript, lint | `build-error-resolver` |64| **Refactor** | clean, refactor, improve, optimize | `refactor-cleaner` |65| **Docs** | readme, document, api-docs | `doc-updater` |6667### Multi-Domain Tasks (Orchestration Required)6869If request matches **2+ domains from different categories**, escalate to `planner` for orchestration:7071```72Example: "Create a secure login with tests"73→ Detected: Security + Testing + Backend74→ Auto-invoke: planner (orchestration mode)75→ Planner will handle: security-reviewer, architect, tdd-guide76```7778---7980## Complexity Assessment8182### SIMPLE (Direct agent invocation)8384- Single file edit85- Clear, specific task86- One domain only87- Example: "Fix the TypeScript error in auth.ts"8889**Action**: Auto-invoke respective agent9091### MODERATE (2-3 agents)9293- 2-3 files affected94- Clear requirements95- 2 domains max96- Example: "Add API endpoint with tests"9798**Action**: Auto-invoke relevant agents sequentially99100### COMPLEX (Orchestration required)101102- Multiple files/domains103- Architectural decisions needed104- Unclear requirements105- Example: "Build a new feature vertical"106107**Action**: Auto-invoke `planner` → will ask Socratic questions108109---110111## Implementation Rules112113### Rule 1: Silent Analysis114115**DO NOT announce "I'm analyzing your request..."**116117- ✅ Analyze silently118- ✅ Inform which agent is being applied119- ❌ Avoid verbose meta-commentary120121### Rule 2: Inform Agent Selection122123**DO inform which expertise is being applied:**124125```markdown126🤖 **Applying `@security-reviewer` expertise...**127128I will review the authentication implementation with the following focus:129[Continue with specialized response]130```131132### Rule 3: Trust-Grade Context133134**Always apply project governance context:**135136- Load relevant governance rules137- Apply session state context138- Enforce pre-task checklists139140### Rule 4: Override Capability141142**User can still explicitly mention agents:**143144```145User: "Use @architect to review this"146→ Override auto-selection147→ Use explicitly mentioned agent148```149150---151152## Integration with Project Governance153154### With Session State155156- Check `session-state.json` for active context157- Inherit project-specific configurations158- Maintain Trust-Grade continuity159160### With Governance Rules161162- Apply relevant governance rules163- Enforce professional standards164- Maintain project architecture alignment165166### With Checklists167168- Trigger pre-task checks for complex operations169- Validate against session-end protocols170- Ensure documentation updates171172---173174## Summary1751761. **Analyze every request** before responding1772. **Select best agent(s)** using the matrix1783. **Inform user** which expertise is applied1794. **Maintain governance** through Trust-Grade protocols1805. **Stay seamless** - user shouldn't notice the routing