← ClaudeAtlas

code-retrieval-usagelisted

This skill should be used when indexing or searching a code/script corpus with the tree-sitter retriever, wanting AST-boundary chunk spans plus an enclosing function/class breadcrumb on hits, or handling the RuntimeError raised when the treesitter extra is not installed.
josix/agentic-retrieval · ★ 0 · AI & Automation · score 72
Install: claude install-skill josix/agentic-retrieval
# Code Retrieval Usage (tree-sitter) AST-boundary ("cAST") chunking for code and script corpora, via `TreeSitterRetriever` (`retrieval/retrievers.py`), backed by [tree-sitter-language-pack](https://github.com/Goldziher/tree-sitter-language-pack) grammars. ## What it is `retrieval.ast_chunker.chunk_code` parses a file with tree-sitter and splits it at AST node boundaries (cAST, arXiv 2506.15655): consecutive sibling nodes are greedily merged into a chunk while their combined non-whitespace character count stays under a budget; a node too large to fit alone is recursed into instead of merged; a leaf node that still doesn't fit is hard-split by lines. Every chunk keeps the project's 1-based `[start_line, end_line]` span convention, plus a dotted breadcrumb `context` (e.g. `"Bar.baz"` for a method `baz` nested in class `Bar`) built by walking the ancestor scopes the chunker actually recursed into — a whole small file kept as one chunk gets an empty `context`. `TreeSitterRetriever` subclasses `LexicalRetriever`: it prefixes each document's `context` breadcrumb into its ranked text (so a query like "Bar baz" can match purely via the enclosing-scope name), then ranks with the same TF-IDF + BM25 + RRF as every other lexical retriever in this plugin. Tree-sitter is only needed at chunking time (`retrieval.project_loader.load_ast_chunk_documents`) — the retriever class itself has zero optional dependencies. ## When to use it (vs lexical / dense / lucene) **Strengths:** - Chunk bo