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.4---56# Intelligent Agent Routing78> **Purpose**: Automatically analyze user requests and route them to the most appropriate specialist agent(s) without requiring explicit user mentions.910## Core Principle1112> **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.1314---1516## How It Works1718### 1. Request Analysis1920Before responding to ANY user request, perform automatic analysis:2122```mermaid23graph TD24 A[User Request] --> B[ANALYZE]25 B --> C[Keywords]26 B --> D[Domains]27 B --> E[Complexity]28 C --> F[SELECT AGENT]29 D --> F30 E --> F31 F --> G[Apply Trust-Grade Context]32 G --> H[AUTO-INVOKE with governance]33```3435### 2. Agent Selection Matrix3637| User Intent | Keywords | Selected Agent(s) | Auto-invoke? |38| ----------------- | ----------------------------------- | -------------------------- | ------------ |39| **Architecture** | "design", "structure", "pattern" | `architect` | ✅ YES |40| **Planning** | "plan", "roadmap", "sprint" | `planner` | ✅ YES |41| **Code Review** | "review", "check", "audit" | `code-reviewer` | ✅ YES |42| **Security** | "security", "vulnerability", "auth" | `security-reviewer` | ✅ YES |43| **Testing** | "test", "coverage", "e2e" | `tdd-guide` + `e2e-runner` | ✅ YES |44| **Build Errors** | "error", "build", "compile" | `build-error-resolver` | ✅ YES |45| **Refactoring** | "refactor", "clean", "improve" | `refactor-cleaner` | ✅ YES |46| **Documentation** | "docs", "readme", "document" | `doc-updater` | ✅ YES |47| **Knowledge** | "learn", "remember", "pattern" | `knowledge-agent` | ✅ YES |48| **Complex Task** | Multiple domains detected | `planner` → multi-agent | ⚠️ ASK FIRST |4950---5152## Domain Detection Rules5354### Single-Domain Tasks (Auto-invoke Single Agent)5556| Domain | Patterns | Agent |57| ---------------- | ------------------------------------- | -------------------------- |58| **Architecture** | design, pattern, structure, layer | `architect` |59| **Planning** | plan, task, sprint, milestone | `planner` |60| **Security** | auth, jwt, password, vulnerability | `security-reviewer` |61| **Testing** | test, jest, coverage, e2e, playwright | `tdd-guide` / `e2e-runner` |62| **Build** | error, compile, typescript, lint | `build-error-resolver` |63| **Refactor** | clean, refactor, improve, optimize | `refactor-cleaner` |64| **Docs** | readme, document, api-docs | `doc-updater` |6566### Multi-Domain Tasks (Orchestration Required)6768If request matches **2+ domains from different categories**, escalate to `planner` for orchestration:6970```71Example: "Create a secure login with tests"72→ Detected: Security + Testing + Backend73→ Auto-invoke: planner (orchestration mode)74→ Planner will handle: security-reviewer, architect, tdd-guide75```7677---7879## Complexity Assessment8081### SIMPLE (Direct agent invocation)8283- Single file edit84- Clear, specific task85- One domain only86- Example: "Fix the TypeScript error in auth.ts"8788**Action**: Auto-invoke respective agent8990### MODERATE (2-3 agents)9192- 2-3 files affected93- Clear requirements94- 2 domains max95- Example: "Add API endpoint with tests"9697**Action**: Auto-invoke relevant agents sequentially9899### COMPLEX (Orchestration required)100101- Multiple files/domains102- Architectural decisions needed103- Unclear requirements104- Example: "Build a new feature vertical"105106**Action**: Auto-invoke `planner` → will ask Socratic questions107108---109110## Implementation Rules111112### Rule 1: Silent Analysis113114**DO NOT announce "I'm analyzing your request..."**115116- ✅ Analyze silently117- ✅ Inform which agent is being applied118- ❌ Avoid verbose meta-commentary119120### Rule 2: Inform Agent Selection121122**DO inform which expertise is being applied:**123124```markdown125🤖 **Applying `@security-reviewer` expertise...**126127I will review the authentication implementation with the following focus:128[Continue with specialized response]129```130131### Rule 3: Trust-Grade Context132133**Always apply project governance context:**134135- Load relevant governance rules136- Apply session state context137- Enforce pre-task checklists138139### Rule 4: Override Capability140141**User can still explicitly mention agents:**142143```144User: "Use @architect to review this"145→ Override auto-selection146→ Use explicitly mentioned agent147```148149---150151## Integration with Project Governance152153### With Session State154155- Check `session-state.json` for active context156- Inherit project-specific configurations157- Maintain Trust-Grade continuity158159### With Governance Rules160161- Apply relevant governance rules162- Enforce professional standards163- Maintain project architecture alignment164165### With Checklists166167- Trigger pre-task checks for complex operations168- Validate against session-end protocols169- Ensure documentation updates170171---172173## Summary1741751. **Analyze every request** before responding1762. **Select best agent(s)** using the matrix1773. **Inform user** which expertise is applied1784. **Maintain governance** through Trust-Grade protocols1795. **Stay seamless** - user shouldn't notice the routing