home / skills / zpankz / mcp-skillset / skill-rag-router

skill-rag-router skill

/skill-rag-router

This skill discovers and routes to the most relevant skills using semantic search and knowledge graphs to match user intent.

npx playbooks add skill zpankz/mcp-skillset --skill skill-rag-router

Review the files below or copy the command above to add this skill to your agents.

Files (5)
SKILL.md
2.2 KB
---
name: skill-rag-router
description: Semantic skill discovery and routing using GraphRAG, vector embeddings, and multi-tool search. Automatically matches user intent to the most relevant skills from 144+ available options using ck semantic search, LEANN RAG, and knowledge graph relationships. Triggers on /meta queries, complex multi-domain tasks, explicit skill requests, or when task complexity exceeds threshold (files>20, domains>2, complexity>=0.7).
---

# Skill RAG Router

Intelligent skill discovery and routing system using semantic search and knowledge graph relationships.

## Capabilities

1. **Semantic Skill Search**: Uses `ck --sem` for meaning-based skill matching
2. **Hybrid Search**: Combines semantic + keyword matching via `ck --hybrid`
3. **Session Awareness**: Integrates with beads/bd for session context
4. **Memory Integration**: Uses claude-mem for cross-session learning

## Trigger Conditions

Activate this skill when:
- User explicitly requests skill discovery (`/meta`, "find a skill for...")
- Task complexity score >= 0.7
- Task involves > 20 files
- Task spans > 2 domains (frontend, backend, security, etc.)
- User asks "what skill can help with..."

## Usage

```bash
# Explicit invocation
/meta [query]

# Examples
/meta "optimize prompts for RAG pipeline"
/meta "debug authentication flow"
/meta "refactor legacy codebase"
```

## Search Implementation

```bash
# Semantic search for skills
ck --sem "[query]" ~/.claude/skills/ --jsonl --top-k 5

# Hybrid search (semantic + keyword)
ck --hybrid "[query]" ~/.claude/skills/ --threshold 0.6

# Index skills
ck --index ~/.claude/skills/ --model bge-small --quiet
```

## Output Format

Returns ranked skill suggestions with:
- Skill name and path
- Confidence score (0-1)
- Relevant snippet from SKILL.md
- Trigger match explanation

## Integration Points

- **SessionStart**: Indexes skills, loads routing cache
- **UserPromptSubmit**: Analyzes prompts for skill suggestions
- **beads/bd**: Session-aware task tracking
- **claude-mem**: Cross-session routing patterns

## Scripts

- `scripts/index-skills.sh`: Index all skills with ck
- `scripts/router.sh`: Main routing logic
- `scripts/suggest-skills.sh`: Intent → skill matching for hooks

Overview

This skill provides semantic discovery and routing across a large skillset using GraphRAG, vector embeddings, and hybrid search. It automatically matches user intent to the best-fitting skill from 144+ options and returns ranked suggestions with confidence and context. It is optimized for multi-domain, high-complexity tasks and session-aware routing.

How this skill works

The router performs semantic search using ck --sem and a hybrid semantic+keyword option to find candidate skills. It enriches matches with a knowledge graph (GraphRAG) and session memory signals to compute confidence and explain trigger matches. Output includes skill name/path, confidence score, relevant snippet, and why the skill was chosen.

When to use it

  • User explicitly asks for skill discovery (e.g., /meta queries or "find a skill for...")
  • Task complexity score is >= 0.7 or involves many interdependent steps
  • Project spans more than two domains (frontend, backend, security, etc.)
  • Working with large file sets (more than 20 files) or monorepos
  • You want session-aware routing that adapts from past interactions

Best practices

  • Invoke with a concise, goal-oriented prompt to improve semantic matching
  • Use /meta for explicit discovery or when handoff to another skill is likely
  • Keep session context (beads/bd) enabled so routing learns patterns over time
  • Re-index skills after major updates to maintain embedding accuracy
  • Combine semantic and hybrid search when queries include exact keywords

Example use cases

  • Find the best skill to refactor a legacy authentication flow spanning frontend and backend
  • Route a complex RAG pipeline optimization request to an expert skill
  • Discover skills to debug cross-service performance regressions across 30 files
  • Suggest relevant skills for multi-domain security hardening and compliance
  • Automatically pick a skill for automated testing and CI/CD remediation

FAQ

What triggers the router automatically?

It triggers on /meta queries, explicit skill requests, tasks with complexity >= 0.7, when files > 20, or when the task spans more than two domains.

How are confidence scores calculated?

Scores combine semantic similarity, hybrid keyword signals, GraphRAG relationship strength, and session-memory priors to produce a 0-1 confidence value.