Back to skills
SkillHub ClubShip Full StackFull Stack

intelligent-router

Analyzes user questions and automatically dispatches optimal agents/skills/plugins

Packaged view

This page reorganizes the original catalog entry around fit, installability, and workflow context first. The original raw source lives below.

Stars
5
Hot score
82
Updated
March 20, 2026
Overall rating
C2.0
Composite score
2.0
Best-practice grade
C67.6

Install command

npx @skill-hub/cli install primadetaautomation-primadata-marketplace-intelligent-router
automationorchestrationworkflowagent-dispatch

Repository

Primadetaautomation/primadata-marketplace

Skill path: .claude/skills/intelligent-router

Analyzes user questions and automatically dispatches optimal agents/skills/plugins

Open repository

Best for

Primary workflow: Ship Full Stack.

Technical facets: Full Stack.

Target audience: everyone.

License: Unknown.

Original source

Catalog source: SkillHub Club.

Repository owner: Primadetaautomation.

This is still a mirrored public skill entry. Review the repository before installing into production workflows.

What it helps with

  • Install intelligent-router into Claude Code, Codex CLI, Gemini CLI, or OpenCode workflows
  • Review https://github.com/Primadetaautomation/primadata-marketplace before adding intelligent-router to shared team environments
  • Use intelligent-router for development workflows

Works across

Claude CodeCodex CLIGemini CLIOpenCode

Favorites: 0.

Sub-skills: 0.

Aggregator: No.

Original source / Raw SKILL.md

---
name: intelligent-router
description: Analyzes user questions and automatically dispatches optimal agents/skills/plugins
triggers: []
version: 1.0.0
agents: []
activation: smart-auto-detect
context_levels:
  minimal: Router logic and decision framework
  detailed: Complete routing matrix and examples
  full: Scripts and testing tools
---

# šŸŽÆ Intelligent Router - Smart Agent/Skill/Plugin Dispatch

## Overview

The Intelligent Router is an **automatic orchestration system** that analyzes user questions and intelligently selects the optimal combination of:
- šŸ¤– **Agents** (specialized subagents)
- šŸŽÆ **Skills** (knowledge bundles)
- šŸ”Œ **Plugins** (global tools)
- šŸ“š **Docs** (project documentation)
- šŸ› ļø **Tools** (native Claude tools)

**Design Philosophy: B - Medium Router**
- āœ… Auto-loads relevant skills
- āœ… Auto-dispatches primary agent
- šŸ’” Suggests optional agents (you choose)
- šŸ“Š Transparent reporting (you see everything)

## When This Skill Activates

**Smart Auto-Detect** triggers on:
- āœ… Questions with 5+ words
- āœ… Action verbs: "maak", "bouw", "fix", "deploy", "test", etc.
- āœ… Complex requests (multiple domains)

**Skips on:**
- āŒ Simple questions: "Wat is X?", "Hoe werkt Y?"
- āŒ Short queries (< 5 words)
- āŒ Informational requests

## How It Works

### Phase 1: Analysis
```
User Question
    ↓
Intent Detection (analyze-intent.js)
    ↓
Match Against Routing Matrix
    ↓
Calculate Match Scores
    ↓
Identify Domains & Complexity
```

### Phase 2: Resource Collection
```
Collect ALL Matched Routes
    ↓
Primary Route = Highest Score
    ↓
Gather:
  - Skills from all matches
  - Plugins from all matches
  - Docs from all matches
  - Tools from primary route
  - Optional agents from secondary matches
```

### Phase 3: Dispatch
```
Auto-Load:
  āœ… Skills (via skill-loader.js)
  āœ… Docs (loaded into context)
  āœ… Plugins (activated)

Auto-Dispatch:
  āœ… Primary Agent (Task tool)

Suggest:
  šŸ’” Optional Agents (you choose to dispatch)
  šŸ’” Additional tools
  šŸ’” Memory check (episodic-memory)
```

### Phase 4: Transparent Reporting
```
Display Formatted Analysis:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
šŸŽÆ INTELLIGENT ROUTER ANALYSIS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

šŸ“Š Detected Intent: [...]
šŸ“ Complexity: [SIMPLE|MEDIUM|HIGH|COMPLEX]
šŸŽÆ Domains: [...]

āœ… AUTO-LOADED SKILLS: [...]
āœ… AUTO-DISPATCHED: [agent] → [reason]
šŸ’” OPTIONAL DISPATCH: [suggestions]

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

## Routing Matrix

The router uses `routing-matrix.json` with 20+ predefined routes:

### Critical Routes (Always Priority)
- **memory_recall** - Episodic memory search
- **security_review** - OWASP compliance, vulnerability scanning
- **authentication** - User auth, login systems
- **complex_feature** - Multi-domain features → master-orchestrator

### High Priority Routes
- **backend_api** - REST/GraphQL API development
- **backend_database** - SQL, schema design, queries
- **frontend_ui** - React/Vue components, UI work
- **testing_unit** - TDD, unit/integration tests
- **architecture** - System design, tech stack decisions
- **debugging** - Bug fixes, error resolution

### Medium Priority Routes
- **ux_design** - UI/UX, dashboards, premium interfaces
- **testing_e2e** - Playwright, browser automation
- **data_engineering** - ETL pipelines, data warehouses
- **deployment** - CI/CD, production deploys
- **ai_ml_integration** - LLM, RAG, vector databases
- **accessibility** - WCAG compliance, inclusive design

### Specialized Routes
- **code_search** - Finding code, codebase analysis
- **browser_automation** - Web scraping, UI testing
- **git_operations** - Worktrees, branching
- **documentation** - Writing docs, README files

## Complexity Assessment

Router automatically determines complexity:

### Simple (1 domain, < 10 words)
- Single file edit
- Small bug fix
- Quick query
→ **Auto-dispatch:** Direct to specialist agent

### Medium (2 domains, 10-30 words)
- New feature in one area
- Moderate refactoring
- Standard API endpoint
→ **Auto-dispatch:** Primary agent + suggest related agents

### High (3 domains, 30-50 words)
- Cross-cutting feature
- Security + functionality
- Multiple file changes
→ **Auto-dispatch:** Primary agent + optional specialists

### Complex (3+ domains, complex requirements)
- Complete new module
- System redesign
- Multi-domain integration
→ **Requires:** master-orchestrator with sub-agents

## Progressive Context Loading

Router uses 3 levels for skills:

### Level 1: Always Load
- Core principles (2-5KB)
- Quick reference
- Essential patterns

### Level 2: Load on Request
- Detailed patterns (10-15KB)
- Complete examples
- Architecture guidance

### Level 3: Full Context
- All scripts
- Templates
- Automation tools

**Default:** Router loads Level 1 for all matched skills
**Escalation:** Request Level 2/3 if needed

## Example Routing Scenarios

### Example 1: Simple Bug Fix
```
User: "Fix deze error in login.ts"

Router Analysis:
  Intent: Bug fixing
  Complexity: SIMPLE
  Domains: debugging, backend

Auto-Loaded:
  - systematic-debugging skill
  - testing-fundamentals skill

Auto-Dispatched:
  - senior-fullstack-developer

Optional:
  - qa-testing-engineer (regression tests)
```

### Example 2: Authentication System
```
User: "Maak een login systeem met registratie"

Router Analysis:
  Intent: User authentication
  Complexity: HIGH
  Domains: security, backend, frontend

Auto-Loaded:
  - security-essentials skill
  - backend-development-patterns skill
  - testing-fundamentals skill

Auto-Dispatched:
  - backend-specialist (primary)

Optional:
  - security-specialist (OWASP review)
  - frontend-specialist (login UI)
  - qa-testing-engineer (security tests)

Docs Loaded:
  - docs/security.md
  - docs/backend.md
```

### Example 3: Complete Feature
```
User: "Bouw een dashboard met gebruikers, data visualisatie en export"

Router Analysis:
  Intent: Multi-domain feature
  Complexity: COMPLEX
  Domains: frontend, backend, data, ux

Auto-Loaded:
  - backend-development-patterns skill
  - testing-fundamentals skill
  - brainstorming skill

Auto-Dispatched:
  - master-orchestrator
    Sub-agents (parallel):
      - backend-specialist (API)
      - frontend-specialist (Dashboard UI)
      - data-engineer (Data pipeline)
      - ux-design-expert (Charts/UX)
      - qa-testing-engineer (Test strategy)
```

### Example 4: Database Query
```
User: "Optimaliseer deze SQL query die te langzaam is"

Router Analysis:
  Intent: Database optimization
  Complexity: MEDIUM
  Domains: data-engineering, backend

Auto-Loaded:
  - backend-development-patterns skill

Auto-Dispatched:
  - data-engineer

Tools Activated:
  - sql-universal-expert

Optional:
  - senior-fullstack-developer (code refactor)

Docs Loaded:
  - docs/backend.md
```

## Usage

### Automatic (Recommended)
Router activates automatically when:
1. User asks question with 5+ words
2. Question contains action verbs
3. Question seems like a task (not just info)

No manual activation needed!

### Manual Testing
Test router analysis before dispatching:

```bash
# Analyze a question
node .claude/skills/intelligent-router/scripts/analyze-intent.js analyze "Maak een API"

# Get JSON output
node .claude/skills/intelligent-router/scripts/analyze-intent.js analyze "Fix bug" --json
```

### Integration with Hooks
Router integrates via `.claude/hooks/pre-prompt.sh` (optional):
```bash
#!/bin/bash
# Activate intelligent-router for every question
# Router internally checks if it should activate
```

## Configuration

### Customize Routing Matrix
Edit `routing-matrix.json` to:
- Add new routes
- Modify trigger keywords
- Adjust priorities
- Add custom agents/skills

### Customize Auto-Detect
Edit `auto_detect_config` in routing-matrix.json:
```json
{
  "min_word_count": 5,
  "action_verbs": ["maak", "bouw", "fix", ...],
  "skip_keywords": ["wat is", "hoe werkt", ...],
  "always_check_memory": true
}
```

### Complexity Thresholds
Adjust in `complexity_thresholds`:
```json
{
  "simple": {
    "max_words": 10,
    "max_domains": 1,
    "auto_dispatch": true
  },
  ...
}
```

## Router Decision Tree

```
User Question
    ↓
[Should Activate?]
    ā”œā”€ No → Normal response (skip router)
    └─ Yes → Continue
         ↓
    [Find Matches]
         ↓
    [No Matches?]
         ā”œā”€ Yes → Normal response
         └─ No → Continue
              ↓
         [Analyze Complexity]
              ↓
         [Simple/Medium/High] → Auto-dispatch primary agent
         [Complex] → Dispatch master-orchestrator
              ↓
         [Display Analysis]
              ↓
         [Execute Dispatch]
```

## Best Practices

### For Users
- āœ… Be specific in your questions (better matching)
- āœ… Use action verbs when you want work done
- āœ… Trust the router's suggestions
- āœ… Dispatch optional agents if they make sense

### For Developers
- āœ… Keep routing-matrix.json updated
- āœ… Add new routes for new capabilities
- āœ… Test routes with analyze-intent.js
- āœ… Monitor which routes get triggered most
- āœ… Refine trigger keywords based on usage

## Troubleshooting

### Router Not Activating
```bash
# Check question meets criteria
node scripts/analyze-intent.js analyze "your question"

# If "activate: false", question too simple
# Solution: Add more context or action verbs
```

### Wrong Agent Dispatched
```bash
# Check routing matrix matches
cat routing-matrix.json | grep -A 5 "your_keyword"

# Update triggers if needed
```

### Skills Not Loading
```bash
# Verify skills exist
node ../skill-loader.js list

# Check skill names in routing-matrix.json match
```

## Metrics & Improvement

Track router effectiveness:
- **Activation rate** - How often it activates vs skips
- **Accuracy** - Did it pick right agent/skills?
- **User satisfaction** - Did suggestions help?
- **Iteration count** - How many back-and-forth needed?

Store in: `.claude-memory/router-metrics.md`

## Version History

### v1.0.0 (Initial Release)
- Smart auto-detect activation
- 20+ predefined routes
- Complexity assessment
- Multi-level skill loading
- Transparent reporting
- Optional agent suggestions

## Future Enhancements

Planned features:
- [ ] Learning from past routing decisions
- [ ] User preference tracking
- [ ] Route effectiveness scoring
- [ ] Dynamic route creation
- [ ] Integration with episodic-memory for pattern learning
- [ ] Web UI for route visualization

## Resources

- **Routing Matrix:** `routing-matrix.json`
- **Intent Analyzer:** `scripts/analyze-intent.js`
- **Examples:** `examples/routing-scenarios.md`
- **Tests:** `examples/test-cases.md`

---

**Version:** 1.0.0
**Author:** CLAUDE Framework Team
**License:** MIT
**Compatibility:** Claude Code 1.0+, Claude 3.5 Sonnet+


---

## Referenced Files

> The following files are referenced in this skill and included for context.

### scripts/analyze-intent.js

```javascript
#!/usr/bin/env node

/**
 * Intelligent Intent Analyzer
 * Smart auto-detection for routing user questions to appropriate agents/skills
 * Version: 1.0.0
 */

const fs = require('fs');
const path = require('path');

const MATRIX_PATH = path.join(__dirname, '..', 'routing-matrix.json');

/**
 * Load routing matrix
 */
function loadRoutingMatrix() {
  try {
    const matrix = JSON.parse(fs.readFileSync(MATRIX_PATH, 'utf8'));
    return matrix;
  } catch (error) {
    console.error('Failed to load routing matrix:', error.message);
    process.exit(1);
  }
}

/**
 * Analyze if question should trigger router
 * @param {string} question - User's question/request
 * @param {Object} config - Auto-detect configuration
 * @returns {boolean} - Whether to activate router
 */
function shouldActivateRouter(question, config) {
  const normalized = question.toLowerCase().trim();
  const wordCount = normalized.split(/\s+/).length;

  // Skip if too short
  if (wordCount < config.min_word_count) {
    return false;
  }

  // Skip if it's just a question about concepts
  const isSimpleQuestion = config.skip_keywords.some(keyword =>
    normalized.startsWith(keyword)
  );
  if (isSimpleQuestion) {
    return false;
  }

  // Activate if contains action verbs
  const hasActionVerb = config.action_verbs.some(verb =>
    normalized.includes(verb)
  );
  if (hasActionVerb) {
    return true;
  }

  // Activate if long enough and seems like a task
  if (wordCount >= 10) {
    return true;
  }

  return false;
}

/**
 * Calculate match score for a route
 * @param {string} question - User's question
 * @param {Object} route - Route configuration
 * @returns {number} - Match score (0-100)
 */
function calculateMatchScore(question, route) {
  const normalized = question.toLowerCase();
  let score = 0;
  let matchedTriggers = [];

  // Check trigger keywords
  route.triggers.forEach(trigger => {
    if (normalized.includes(trigger.toLowerCase())) {
      score += 10;
      matchedTriggers.push(trigger);
    }
  });

  // Bonus for multiple trigger matches
  if (matchedTriggers.length > 1) {
    score += matchedTriggers.length * 5;
  }

  // Priority boost
  const priorityBoost = {
    'critical': 20,
    'high': 10,
    'medium': 5,
    'low': 0
  };
  score += priorityBoost[route.priority] || 0;

  return { score, matchedTriggers };
}

/**
 * Find matching routes for question
 * @param {string} question - User's question
 * @param {Object} matrix - Routing matrix
 * @returns {Array} - Sorted array of matching routes
 */
function findMatchingRoutes(question, matrix) {
  const matches = [];

  Object.entries(matrix.routes).forEach(([routeName, route]) => {
    const { score, matchedTriggers } = calculateMatchScore(question, route);

    if (score > 0) {
      matches.push({
        routeName,
        route,
        score,
        matchedTriggers
      });
    }
  });

  // Sort by score (highest first)
  matches.sort((a, b) => b.score - a.score);

  return matches;
}

/**
 * Determine domains involved
 * @param {Array} matches - Matched routes
 * @returns {Array} - List of domains
 */
function identifyDomains(matches) {
  const domains = new Set();

  matches.forEach(match => {
    // Extract domain from route name (e.g., "backend_api" -> "backend")
    const domain = match.routeName.split('_')[0];
    domains.add(domain);
  });

  return Array.from(domains);
}

/**
 * Assess complexity based on matches and question
 * @param {string} question - User's question
 * @param {Array} matches - Matched routes
 * @param {Array} domains - Identified domains
 * @param {Object} thresholds - Complexity thresholds
 * @returns {string} - Complexity level
 */
function assessComplexity(question, matches, domains, thresholds) {
  const wordCount = question.split(/\s+/).length;
  const domainCount = domains.length;

  // Complex if multiple domains
  if (domainCount >= (thresholds.complex.min_domains || 3)) {
    return 'complex';
  }

  // High if multiple matches with high priority
  const highPriorityMatches = matches.filter(m =>
    m.route.priority === 'critical' || m.route.priority === 'high'
  );
  if (highPriorityMatches.length >= 2 || domainCount === 3) {
    return 'high';
  }

  // Medium if moderate word count or 2 domains
  if (wordCount >= thresholds.medium.max_words || domainCount === 2) {
    return 'medium';
  }

  // Simple otherwise
  return 'simple';
}

/**
 * Select primary route/agent
 * @param {Array} matches - Matched routes
 * @returns {Object|null} - Primary route or null
 */
function selectPrimaryRoute(matches) {
  if (matches.length === 0) return null;

  // Highest scored route is primary
  return matches[0];
}

/**
 * Collect all unique skills from matches
 * @param {Array} matches - Matched routes
 * @returns {Array} - List of skills to load
 */
function collectSkills(matches) {
  const skills = new Set();

  matches.forEach(match => {
    match.route.skills.forEach(skill => skills.add(skill));
  });

  return Array.from(skills);
}

/**
 * Collect all unique plugins from matches
 * @param {Array} matches - Matched routes
 * @returns {Array} - List of plugins
 */
function collectPlugins(matches) {
  const plugins = new Set();

  matches.forEach(match => {
    match.route.plugins.forEach(plugin => plugins.add(plugin));
  });

  return Array.from(plugins);
}

/**
 * Collect all relevant docs from matches
 * @param {Array} matches - Matched routes
 * @returns {Array} - List of docs to load
 */
function collectDocs(matches) {
  const docs = new Set();

  matches.forEach(match => {
    match.route.docs.forEach(doc => docs.add(doc));
  });

  return Array.from(docs);
}

/**
 * Determine optional agents to suggest
 * @param {Array} matches - Matched routes
 * @param {Object} primary - Primary route
 * @returns {Array} - List of optional agents
 */
function determineOptionalAgents(matches, primary) {
  const optional = new Set();

  matches.slice(1, 4).forEach(match => {
    // Add agents from secondary matches
    if (match.route.agent && match.route.agent !== primary?.route?.agent) {
      optional.add({
        agent: match.route.agent,
        reason: match.route.intent,
        priority: match.route.priority
      });
    }

    // Add explicitly defined optional agents
    if (match.route.optional_agents) {
      match.route.optional_agents.forEach(agent => {
        optional.add({
          agent,
          reason: `Related to ${match.route.intent}`,
          priority: 'optional'
        });
      });
    }
  });

  return Array.from(optional);
}

/**
 * Main analysis function
 * @param {string} question - User's question/request
 * @returns {Object} - Complete analysis result
 */
function analyzeIntent(question) {
  const matrix = loadRoutingMatrix();
  const config = matrix.auto_detect_config;

  // Check if should activate
  const shouldActivate = shouldActivateRouter(question, config);

  if (!shouldActivate) {
    return {
      activate: false,
      reason: 'Question too simple or informational'
    };
  }

  // Find matching routes
  const matches = findMatchingRoutes(question, matrix);

  if (matches.length === 0) {
    return {
      activate: false,
      reason: 'No matching routes found'
    };
  }

  // Analyze
  const domains = identifyDomains(matches);
  const complexity = assessComplexity(question, matches, domains, matrix.complexity_thresholds);
  const primary = selectPrimaryRoute(matches);
  const skills = collectSkills(matches);
  const plugins = collectPlugins(matches);
  const docs = collectDocs(matches);
  const optionalAgents = determineOptionalAgents(matches, primary);

  return {
    activate: true,
    analysis: {
      question,
      intent: primary.route.intent,
      complexity,
      domains,
      matchCount: matches.length,
      topMatches: matches.slice(0, 3).map(m => ({
        route: m.routeName,
        score: m.score,
        triggers: m.matchedTriggers
      }))
    },
    dispatch: {
      primary: {
        agent: primary.route.agent,
        route: primary.routeName,
        reason: primary.route.intent,
        score: primary.score
      },
      skills,
      plugins,
      docs,
      tools: primary.route.tools,
      optionalAgents,
      checkMemory: config.always_check_memory
    },
    recommendations: {
      autoDispatch: matrix.complexity_thresholds[complexity]?.auto_dispatch ?? true,
      requiresConfirmation: matrix.complexity_thresholds[complexity]?.requires_confirmation ?? false,
      notes: primary.route.notes || null
    }
  };
}

/**
 * Format analysis for display
 * @param {Object} result - Analysis result
 * @returns {string} - Formatted output
 */
function formatAnalysis(result) {
  if (!result.activate) {
    return `Router: Skipped (${result.reason})`;
  }

  const { analysis, dispatch, recommendations } = result;

  let output = '\n';
  output += '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
  output += 'šŸŽÆ INTELLIGENT ROUTER ANALYSIS\n';
  output += '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n';

  // Analysis Section
  output += `šŸ“Š Detected Intent: ${analysis.intent}\n`;
  output += `šŸ“ Complexity: ${analysis.complexity.toUpperCase()}\n`;
  output += `šŸŽÆ Domains: ${analysis.domains.join(', ')}\n`;
  output += `šŸ” Matches: ${analysis.matchCount} routes\n\n`;

  // Skills Section
  if (dispatch.skills.length > 0) {
    output += 'āœ… AUTO-LOADED SKILLS:\n';
    dispatch.skills.forEach(skill => {
      output += `   - ${skill}\n`;
    });
    output += '\n';
  }

  // Plugins Section
  if (dispatch.plugins.length > 0) {
    output += 'šŸ”Œ PLUGINS AVAILABLE:\n';
    dispatch.plugins.forEach(plugin => {
      output += `   - ${plugin}\n`;
    });
    output += '\n';
  }

  // Docs Section
  if (dispatch.docs.length > 0) {
    output += 'šŸ“š RELEVANT DOCS:\n';
    dispatch.docs.forEach(doc => {
      output += `   - ${doc} (auto-loaded)\n`;
    });
    output += '\n';
  }

  // Primary Agent
  if (dispatch.primary.agent) {
    output += 'āœ… AUTO-DISPATCHED:\n';
    output += `   - ${dispatch.primary.agent}\n`;
    output += `     → ${dispatch.primary.reason}\n`;
    if (recommendations.notes) {
      output += `     Note: ${recommendations.notes}\n`;
    }
    output += '\n';
  }

  // Memory Check
  if (dispatch.checkMemory) {
    output += '🧠 EPISODIC MEMORY:\n';
    output += '   - Checking past conversations (recommended)\n\n';
  }

  // Optional Agents
  if (dispatch.optionalAgents.length > 0) {
    output += 'šŸ’” OPTIONAL DISPATCH (you choose):\n';
    dispatch.optionalAgents.forEach(opt => {
      output += `   [ ] ${opt.agent}\n`;
      output += `       → ${opt.reason}\n`;
    });
    output += '\n';
    output += 'šŸ‘‰ Use Task tool to dispatch additional agents\n\n';
  }

  // Tools Available
  if (dispatch.tools && dispatch.tools.length > 0) {
    output += 'šŸ› ļø TOOLS ACTIVATED:\n';
    output += `   ${dispatch.tools.join(', ')}\n\n`;
  }

  output += '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';

  return output;
}

// CLI Interface
if (require.main === module) {
  const command = process.argv[2];

  if (command === 'analyze') {
    const question = process.argv.slice(3).join(' ');

    if (!question) {
      console.error('Usage: analyze-intent.js analyze "your question here"');
      process.exit(1);
    }

    const result = analyzeIntent(question);
    console.log(formatAnalysis(result));

    // Output JSON if --json flag
    if (process.argv.includes('--json')) {
      console.log('\nJSON Output:');
      console.log(JSON.stringify(result, null, 2));
    }
  } else {
    console.log(`
Intelligent Intent Analyzer

Usage:
  analyze-intent.js analyze "your question"    - Analyze a question
  analyze-intent.js analyze "question" --json  - Output JSON result

Examples:
  analyze-intent.js analyze "Maak een login systeem"
  analyze-intent.js analyze "Fix deze bug in auth.ts"
  analyze-intent.js analyze "Deploy to production"
    `);
  }
}

// Export for programmatic use
module.exports = {
  analyzeIntent,
  formatAnalysis,
  shouldActivateRouter
};

```

### examples/routing-scenarios.md

```markdown
# Intelligent Router - Test Scenarios

## Purpose
Test cases to validate router behavior across different question types and complexities.

## Test Scenarios

### 1. Simple Bug Fix
**Input:** "Fix deze error in login.ts"

**Expected Output:**
```
Activate: true
Intent: Bug fixing
Complexity: SIMPLE
Domains: debugging

Auto-Loaded Skills:
  - systematic-debugging
  - testing-fundamentals

Auto-Dispatched:
  - senior-fullstack-developer

Optional:
  - qa-testing-engineer
```

### 2. Authentication System
**Input:** "Maak een login systeem met gebruikers registratie"

**Expected Output:**
```
Activate: true
Intent: User authentication
Complexity: HIGH
Domains: authentication, backend, security

Auto-Loaded Skills:
  - security-essentials
  - backend-development-patterns
  - testing-fundamentals

Auto-Dispatched:
  - backend-specialist

Optional:
  - security-specialist
  - frontend-specialist
  - qa-testing-engineer

Docs:
  - docs/security.md
  - docs/backend.md
```

### 3. Complete Dashboard Feature
**Input:** "Bouw een dashboard met gebruikers lijst, charts en export functionaliteit"

**Expected Output:**
```
Activate: true
Intent: Multi-domain feature
Complexity: COMPLEX
Domains: frontend, backend, data, ux

Auto-Loaded Skills:
  - backend-development-patterns
  - testing-fundamentals
  - brainstorming

Auto-Dispatched:
  - master-orchestrator
    Sub-agents:
      - backend-specialist
      - frontend-specialist
      - data-engineer
      - ux-design-expert
      - qa-testing-engineer

Docs:
  - docs/backend.md
  - docs/frontend.md
```

### 4. Simple Question (Should Skip)
**Input:** "Wat is TDD?"

**Expected Output:**
```
Activate: false
Reason: Question too simple or informational
```

### 5. Database Query Optimization
**Input:** "Optimaliseer deze SQL query die te traag is"

**Expected Output:**
```
Activate: true
Intent: Database optimization
Complexity: MEDIUM
Domains: data-engineering, backend

Auto-Loaded Skills:
  - backend-development-patterns

Auto-Dispatched:
  - data-engineer

Tools:
  - sql-universal-expert

Optional:
  - senior-fullstack-developer

Docs:
  - docs/backend.md
```

### 6. Security Review
**Input:** "Review deze auth code voor security vulnerabilities"

**Expected Output:**
```
Activate: true
Intent: Security audit
Complexity: HIGH
Domains: security

Auto-Loaded Skills:
  - security-essentials
  - production-code-standards

Auto-Dispatched:
  - security-specialist

Tools:
  - Grep
  - Bash

Docs:
  - docs/security.md
```

### 7. API Development
**Input:** "Maak een REST API voor producten met CRUD endpoints"

**Expected Output:**
```
Activate: true
Intent: API development
Complexity: MEDIUM
Domains: backend

Auto-Loaded Skills:
  - backend-development-patterns
  - testing-fundamentals

Auto-Dispatched:
  - backend-specialist

Tools:
  - Read
  - Write
  - Edit
  - Bash

Docs:
  - docs/backend.md
```

### 8. Frontend Component
**Input:** "Maak een React component voor product kaart met image en prijs"

**Expected Output:**
```
Activate: true
Intent: Frontend development
Complexity: MEDIUM
Domains: frontend

Auto-Loaded Skills:
  - testing-fundamentals

Auto-Dispatched:
  - frontend-specialist

Tools:
  - Read
  - Write
  - Edit

Docs:
  - docs/frontend.md
```

### 9. Deployment
**Input:** "Deploy deze app naar Railway production"

**Expected Output:**
```
Activate: true
Intent: Deploy to production
Complexity: HIGH
Domains: deployment

Auto-Loaded Skills:
  - deployment-workflows

Plugins:
  - railway-mcp-server

Tools:
  - Bash
  - mcp__railway-mcp-server

Docs:
  - docs/infrastructure.md
```

### 10. Code Search
**Input:** "Waar wordt de calculateTotal functie gebruikt?"

**Expected Output:**
```
Activate: true
Intent: Finding code
Complexity: SIMPLE
Domains: code_search

Plugins:
  - primadata-enhanced-toolkit

Auto-Dispatched:
  - code-searcher

Tools:
  - Grep
  - Read
  - Glob
```

### 11. E2E Testing
**Input:** "Maak E2E tests voor het checkout proces"

**Expected Output:**
```
Activate: true
Intent: End-to-end testing
Complexity: HIGH
Domains: testing_e2e

Auto-Loaded Skills:
  - testing-fundamentals

Auto-Dispatched:
  - playwright-test-agent

Tools:
  - Bash
  - mcp__chrome-devtools

Docs:
  - docs/testing.md
```

### 12. UX Design
**Input:** "Design een premium dashboard met data visualisatie charts"

**Expected Output:**
```
Activate: true
Intent: UI/UX design
Complexity: MEDIUM
Domains: ux_design

Plugins:
  - primadata-enhanced-toolkit

Auto-Dispatched:
  - ux-design-expert

Tools:
  - Read
  - Write
  - WebFetch

Docs:
  - docs/frontend.md
```

### 13. Short Question (Should Skip)
**Input:** "Fix typo"

**Expected Output:**
```
Activate: false
Reason: Question too simple or informational (< 5 words)
```

### 14. Informational (Should Skip)
**Input:** "Hoe werkt authentication in deze app?"

**Expected Output:**
```
Activate: false
Reason: Question too simple or informational (skip keyword: "hoe werkt")
```

### 15. Git Workflow
**Input:** "Maak een git worktree voor deze feature branch"

**Expected Output:**
```
Activate: true
Intent: Git workflows
Complexity: SIMPLE
Domains: git_operations

Auto-Loaded Skills:
  - superpowers:using-git-worktrees

Tools:
  - Bash
```

## Running Tests

```bash
# Test individual scenarios
cd .claude/skills/intelligent-router/scripts
./analyze-intent.js analyze "Fix deze error in login.ts"
./analyze-intent.js analyze "Maak een login systeem"

# Test all scenarios (create test runner)
npm test  # (if package.json configured)

# Manual validation
# Compare actual output with expected output above
```

## Success Criteria

- āœ… Correct activation detection (activate vs skip)
- āœ… Accurate intent identification
- āœ… Appropriate complexity assessment
- āœ… Correct primary agent selection
- āœ… Relevant skills loaded
- āœ… Useful optional agent suggestions
- āœ… Appropriate docs recommended

## Known Edge Cases

1. **Ambiguous questions** - May match multiple routes equally
   - Solution: Highest priority route wins

2. **Very long questions** - May trigger multiple high matches
   - Solution: master-orchestrator for complex scenarios

3. **Non-English questions** - Trigger keywords are mixed NL/EN
   - Solution: Both Dutch and English keywords in matrix

4. **Technical jargon** - May not match any triggers
   - Solution: Expand trigger keywords based on usage

## Metrics to Track

- **Activation Rate:** % of questions that activate router
- **Accuracy:** % of correct primary agent selections
- **Relevance:** % of users who dispatch suggested optional agents
- **Iteration Count:** Average back-and-forth needed

Store in: `.claude-memory/router-metrics.md`

```