AI product Open source

sgrep

sgrep is a Rust command-line tool from Context.dev for searching local code and documents with plain-English queries. It combines ripgrep file discovery with lexical BM25 matching and semantic matching from small static embedding models, returning source passages with file paths and line ranges rather than generated answers. It can also rank ripgrep results supplied through standard input or JSON.

View repository Mentioned in 2 videos ↓

Overview

The tool splits source into passages using Chonkie and Tree-sitter, using syntax-aware chunks for supported programming languages and text chunks for prose. Its code and text modes use local Potion Code and Potion Base models; embeddings are created by averaging fixed token vectors into 256-number representations, then combining semantic and lexical scores with exact identifier matches prioritized. The first search downloads the models and required parsers, after which cached searches can run offline without an account, hosted index, model server, or per-query API call. It requires Rust and ripgrep and is released under the MIT license.

What sgrep is used for

2 uses taken from transcripts — each links to the moment in the video.

  • Rust command-line tool built over Ripgrep that searches code by meaning; you write a plain-English question and get matching snippets with file paths and line numbers, mixing keyword and semantic matching from small static embedding models so it runs locally without a model server.

  • An open-source local semantic grep from context.dev, a ripgrep extension that finds passages by words and meaning. Written in Rust, it pairs ripgrep with static embeddings combining semantic similarity with BM25, needs no index or daemon, works offline, and can discover candidates or rerank ripgrep matches for coding agents.

Videos mentioning sgrep

2 in the library.