Выбор поискового инструмента по типу запроса
engineering
search-hierarchy is a Claude Code skill that routes each code search query to the most token-efficient tool based on query type, reducing unnecessary token consumption during codebase navigation. It implements a four-branch decision tree: AST-grep (~50 tokens) for structural queries such as function definitions, class declarations, and decorators; LEANN (~100 tokens) for semantic questions about architecture and error-handling patterns; Grep (200–2000 tokens) for exact identifiers and regex matches; and Read (1500+ tokens) as a last resort once the target file is already known. The bundled grep-to-leann.sh hook enforces the hierarchy automatically — it detects the query type, blocks suboptimal tool choices, and suggests the correct alternative. Developers working with large repositories benefit most: the optimal flow of AST-grep followed by a single Read can skip irrelevant files entirely, saving thousands of tokens per session.
- #search-optimization
- #code-search
- #token-efficiency
- #ast-grep
- #semantic-search