SE

search-hierarchy

Optimizes search strategy by directing queries to the most efficient tool.

Install

mkdir -p .claude/skills/search-hierarchy && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/5937" && unzip -o skill.zip -d .claude/skills/search-hierarchy && rm skill.zip

Installs to .claude/skills/search-hierarchy

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Search Tool Hierarchy
21 charsno explicit “when” trigger
Beginner

Key capabilities

  • Executes AST-grep for pattern matching
  • Executes LEANN for conceptual searches
  • Executes Grep for literal identifier matching
  • Executes Read for full context retrieval

How it works

Routes queries through a fixed decision tree that maps specific query types to the most token-efficient tool.

Inputs & outputs

You give it
Natural language query about codebase structure or logic
You get back
Selected tool command and targeted search results

When to use search-hierarchy

  • Finding code patterns efficiently
  • Looking up conceptual information in the codebase
  • Searching for exact identifiers
  • Retrieving full context for deep analysis

About this skill

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 file

Token Efficiency Comparison

ToolOutput SizeBest For
AST-grep~50 tokensFunction/class definitions, imports, decorators
LEANN~100 tokensConceptual questions, architecture, patterns
Grep~200-2000Exact 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.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

When not to use it

  • When you already know the exact file path
  • When the codebase is small enough to read entirely

Prerequisites

ast-grepleann

Limitations

  • Requires the user to classify the query type correctly
  • Highly dependent on the hook toolchain being active

How it compares

It programmatically enforces the use of specialized search tools based on intent to minimize token consumption compared to manual searching.

Compared to similar skills

search-hierarchy side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
search-hierarchy (this skill)17moReviewBeginner
firecrawl-scrape57moReviewBeginner
call-prep36moNo flagsBeginner
adaptyv77moCautionAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

firecrawl-scrape

parcadei

Scrape web pages and extract content via Firecrawl MCP

536

call-prep

anthropics

Prepare for a sales call with account context, attendee research, and suggested agenda. Works standalone with user input and web research, supercharged when you connect your CRM, email, chat, or transcripts. Trigger with "prep me for my call with [company]", "I'm meeting with [company] prep me", "call prep [company]", or "get me ready for [meeting]".

320

adaptyv

davila7

Cloud laboratory platform for automated protein testing and validation. Use when designing proteins and needing experimental validation including binding assays, expression testing, thermostability measurements, enzyme activity assays, or protein sequence optimization. Also use for submitting experiments via API, tracking experiment status, downloading results, optimizing protein sequences for better expression using computational tools (NetSolP, SoluProt, SolubleMPNN, ESM), or managing protein design workflows with wet-lab validation.

79

universal-learner

huangserva

通用学习器 - 从任何领域的Prompt中自动提取可复用元素,持续学习和积累知识

25

youtube-collector

greatSumini

유튜브 채널을 등록하고 새 컨텐츠를 수집하여 자막 기반 요약을 생성하는 skill. 사용자가 (1) 유튜브 채널 등록/관리를 요청하거나, (2) 등록된 채널의 새 영상 수집을 요청하거나, (3) 유튜브 영상 요약을 요청할 때 사용. 데이터는 .reference/ 폴더에 YAML 형식으로 저장됨.

16

batch-research

miantiao-me

批量数据采集技能,负责分批并发调度 researcher agent 抓取所有数据源。

10

Search skills

Search the agent skills registry