
Search Hierarchy
- 459 installs
- 3.9k repo stars
- Updated January 26, 2026
- parcadei/continuous-claude-v3
search-hierarchy is a Claude agent skill that routes codebase queries to the most token-efficient search tool—AST-grep, LEANN, Grep, or Read—for developers optimizing agent search cost during code exploration.
About
search-hierarchy is a continuous-claude-v3 skill that picks the most token-efficient search tool for each codebase query type. Structural pattern queries like def foo, class Bar, import X, or @decorator go to AST-grep with roughly 50 tokens of output. Semantic conceptual questions route to LEANN at about 100 tokens when path-only results suffice. Literal identifier lookups use Grep, and full-context understanding falls back to Read at 1500+ tokens as a last resort. Developers reach for search-hierarchy when agents burn context on naive full-file reads.
- search-hierarchy
Search Hierarchy by the numbers
- 459 all-time installs (skills.sh)
- +2 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #905 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/parcadei/continuous-claude-v3 --skill search-hierarchyAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 459 |
|---|---|
| repo stars | ★ 3.9k |
| Last updated | January 26, 2026 |
| Repository | parcadei/continuous-claude-v3 ↗ |
Which search tool should agents use for code queries?
Use search-hierarchy for development tasks
Who is it for?
Developers tuning Claude Code agents who want a decision tree that minimizes tokens across structural, semantic, and literal codebase searches.
Skip if: One-off manual file opens when the correct target file and line are already known.
When should I use this skill?
An agent needs to search a codebase and should pick AST-grep, LEANN, Grep, or Read based on query type.
What you get
Token-efficient search results from AST-grep, LEANN, Grep, or targeted Read calls.
- Routed search results
- Token-efficient file locations
By the numbers
- AST-grep outputs ~50 tokens for structural queries
- LEANN outputs ~100 tokens for path-only semantic queries
- Read costs 1500+ tokens as last-resort full context
Files
Search Tool Hierarchy
Use the most token-efficient search tool for each query type.
Decision Tree
Query Type?
├── STRUCTURAL (code patterns)
│ → AST-grep (~50 tokens output)
│ Examples: "def foo", "class Bar", "import X", "@decorator"
│
├── SEMANTIC (conceptual questions)
│ → LEANN (~100 tokens if path-only)
│ Examples: "how does auth work", "find error handling patterns"
│
├── LITERAL (exact identifiers)
│ → Grep (variable output)
│ Examples: "TemporalMemory", "check_evocation", regex patterns
│
└── FULL CONTEXT (need complete understanding)
→ Read (1500+ tokens)
Last resort after finding the right fileToken Efficiency Comparison
| Tool | Output Size | Best For |
|---|---|---|
| AST-grep | ~50 tokens | Function/class definitions, imports, decorators |
| LEANN | ~100 tokens | Conceptual questions, architecture, patterns |
| Grep | ~200-2000 | Exact identifiers, regex, file paths |
| Read | ~1500+ | Full understanding after finding the file |
Hook Enforcement
The grep-to-leann.sh hook automatically: 1. Detects query type (structural/semantic/literal) 2. Blocks and suggests AST-grep for structural queries 3. Blocks and suggests LEANN for semantic queries 4. Allows literal patterns through to Grep
DO
- Start with AST-grep for code structure questions
- Use LEANN for "how does X work" questions
- Use Grep only for exact identifier matches
- Read files only after finding them via search
DON'T
- Use Grep for conceptual questions (returns nothing)
- Read files before knowing which ones are relevant
- Use Read when AST-grep would give file:line
- Ignore hook suggestions
Examples
# STRUCTURAL → AST-grep
ast-grep --pattern "async def $FUNC($$$):" --lang python
# SEMANTIC → LEANN
leann search opc-dev "how does authentication work" --top-k 3
# LITERAL → Grep
Grep pattern="check_evocation" path=opc/scripts
# FULL CONTEXT → Read (after finding file)
Read file_path=opc/scripts/z3_erotetic.pyOptimal 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 savedRelated skills
How it compares
Use search-hierarchy to enforce a token budget across search tools; default to Grep or Read only when query type is unknown.
FAQ
When should search-hierarchy use AST-grep?
search-hierarchy routes structural code pattern queries—such as def foo, class Bar, import X, or @decorator—to AST-grep, which returns roughly 50 tokens of output.
What is the most expensive search option in search-hierarchy?
Read is the last resort in search-hierarchy for full-context understanding and typically costs 1500+ tokens, used only after cheaper AST-grep, LEANN, or Grep searches locate the target.