This skill decides when to route questions between curated skills and Context7 to optimize documentation lookups for frameworks, libraries, and APIs.
npx playbooks add skill jawwad-ali/claude-code-skills --skill knowledge-router
This meta-skill provides decision logic for routing knowledge requests between curated skills and Context7 MCP server.
┌─────────────────────────────────────────────────────────────────┐
│ QUERY ANALYSIS │
└─────────────────────────────┬───────────────────────────────────┘
│
▼
┌─────────────────────┐
│ Check Query Type │
└──────────┬──────────┘
│
┌─────────────────────┼─────────────────────┐
│ │ │
▼ ▼ ▼
┌───────────┐ ┌───────────┐ ┌───────────┐
│ PATTERN │ │ LOOKUP │ │ HYBRID │
│ REQUEST │ │ REQUEST │ │ REQUEST │
└─────┬─────┘ └─────┬─────┘ └─────┬─────┘
│ │ │
▼ ▼ ▼
Use SKILL Use CONTEXT7 Use BOTH
(curated) (dynamic) (layered)
Indicators:
Examples:
"How do I add authentication to FastAPI?" → SKILL
"Create a REST endpoint" → SKILL
"Best practice for error handling" → SKILL
"Set up database connection" → SKILL
Action: Load relevant skill, use curated patterns.
---
Indicators:
Examples:
"What parameters does HTTPException accept?" → CONTEXT7
"Does FastAPI support HTTP/2?" → CONTEXT7
"Error: ValidationError for field X" → CONTEXT7
"What's new in Pydantic v2?" → CONTEXT7
"How do I use the new Annotated syntax?" → CONTEXT7
Action: Query Context7 directly for authoritative docs.
---
Indicators:
Examples:
"Production-ready JWT auth with refresh tokens" → HYBRID
"Integrate FastAPI with Celery" → HYBRID
"Debug this authentication error [paste]" → HYBRID
"Complete WebSocket chat implementation" → HYBRID
Action:
---
| Signal | Route To | Reason |
|--------|----------|--------|
| Common task keywords | Skill | Pre-validated patterns |
| Error message pasted | Context7 | Search for specific error |
| "Latest", "new", "v2" | Context7 | Need current docs |
| "Best practice", "recommended" | Skill | Curated opinions |
| Specific parameter questions | Context7 | API reference |
| Architecture questions | Skill | Curated structures |
| Third-party integration | Context7 first | May not be in skill |
| "Why does X..." | Hybrid | Pattern + explanation |
| Debugging request | Hybrid | Context + specific error |
---
1. Identify the relevant skill (fastapi, nextjs, etc.)
2. Load SKILL.md into context
3. Generate response using curated patterns
4. If skill indicates "ESCALATE" for topic → switch to Hybrid
1. Resolve library ID:
mcp__context7__resolve-library-id(
libraryName: "fastapi",
query: "user's specific question"
)
2. Query documentation:
mcp__context7__query-docs(
libraryId: "/websites/fastapi_tiangolo",
query: "specific topic from user question"
)
3. Synthesize response from fetched docs
1. Load relevant skill for architectural context
2. Generate initial structure using skill patterns
3. Identify gaps or specific details needed
4. Query Context7 for those specifics:
mcp__context7__query-docs(libraryId, "specific detail needed")
5. Merge skill patterns with Context7 details
6. Return unified, comprehensive response
---
| Skill | Covers (Tier 1) | Escalate to Context7 For |
|-------|-----------------|--------------------------|
| fastapi | Routes, Pydantic, Auth, DI, Middleware | WebSocket scaling, GraphQL, specific drivers |
| fastapi-hybrid | Same + built-in escalation triggers | Auto-escalates per topic |
| nextjs-app-router | Pages, Layouts, RSC, Server Actions | Specific Next.js config, edge runtime |
---
| Technology | Library ID | Best For |
|------------|------------|----------|
| FastAPI | /websites/fastapi_tiangolo | Full docs, tutorials |
| FastAPI (GitHub) | /fastapi/fastapi | Source-level details |
| Pydantic | /pydantic/pydantic | Validation, v2 migration |
| SQLAlchemy | /sqlalchemy/sqlalchemy | ORM, async patterns |
| Starlette | /encode/starlette | Low-level ASGI details |
| Next.js | /vercel/next.js | App router, RSC |
| React | /facebook/react | Hooks, patterns |
---
Before finalizing a response, verify:
---
Analysis:
Route: SKILL (fastapi)
---
Analysis:
Route: CONTEXT7
mcp__context7__query-docs("/websites/fastapi_tiangolo", "Depends vs Security dependency injection")---
Analysis:
Route: HYBRID
---
| Scenario | Strategy | Estimated Tokens |
|----------|----------|------------------|
| Single question, common topic | Skill only | ~2,000 (skill load) |
| Single question, specific lookup | Context7 only | ~1,500 (one query) |
| Multi-turn, same topic | Skill (amortized) | ~2,000 total |
| Complex implementation | Hybrid | ~3,500 (skill + 1-2 queries) |
| Debugging session | Hybrid | ~4,000 (skill + error lookups) |
Optimization: For multi-turn conversations on the same technology, load the skill once and only query Context7 for specific gaps.
Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.