| name | search-router |
| description | Choose the right search tool for each query type |
| user-invocable | false |
Search Tool Router
Use the most token-efficient search tool for each query type.
When to Use
- Searching for code patterns
- Finding where something is implemented
- Looking for specific identifiers
- Understanding how code works
Decision Tree
Query Type?
โโโ CODE EXPLORATION (symbols, call chains, data flow)
โ โ TLDR Search - 95% token savings
โ DEFAULT FOR ALL CODE SEARCH - use instead of Grep
โ Examples: "spawn_agent", "DataPoller", "redis usage"
โ Command: tldr search "query" .
โ
โโโ STRUCTURAL (AST patterns)
โ โ AST-grep (/ast-grep-find) - ~50 tokens output
โ Examples: "def foo", "class Bar", "import X", "@decorator"
โ
โโโ SEMANTIC (conceptual questions)
โ โ TLDR Semantic - 5-layer embeddings (P6)
โ Examples: "how does auth work", "find error handling patterns"
โ Command: tldr semantic search "query"
โ
โโโ LITERAL (exact text, regex)
โ โ Grep tool - LAST RESORT
โ Only when TLDR/AST-grep don't apply
โ Examples: error messages, config values, non-code text
โ
โโโ FULL CONTEXT (need complete understanding)
โ Read tool - 1500+ tokens
Last resort after finding the right file
Token Efficiency Comparison
| Tool | Output Size | Best For |
|---|
| TLDR | ~50-500 | DEFAULT: Code symbols, call graphs, data flow |
| TLDR Semantic | ~100-300 | Conceptual queries (P6, embedding-based) |
| AST-grep | ~50 tokens | Function/class definitions, imports, decorators |
| Grep | ~200-2000 | LAST RESORT: Non-code text, regex |
| Read | ~1500+ | Full understanding after finding the file |
Examples
tldr search "spawn_agent" .
tldr search "redis" . --layer call_graph
/ast-grep-find "async def $FUNC($$$):" --lang python
tldr semantic search "how does authentication work"
Grep pattern="check_evocation" path=opc/scripts
Read file_path=opc/scripts/z3_erotetic.py
Optimal Flow
1. AST-grep: "Find async functions" โ 3 file:line matches
2. Read: Top match only โ Full understanding
3. Skip: 4 irrelevant files โ 6000 tokens saved
Related Skills
/tldr-search - DEFAULT - Code exploration with 95% token savings
/ast-grep-find - Structural code search
/morph-search - Fast text search