ygrep
A fast, local, indexed code search tool optimized for AI coding assistants. Written in Rust using Tantivy for full-text indexing.

Features
- Literal text matching - Works like grep by default, special characters included (
$variable,{% block,->get(,@decorator) - Regex support - Use
-rflag for regex patterns (fn\s+main,TODO|FIXME) - Code-aware tokenizer - Preserves
$,@,#as part of tokens (essential for PHP, Shell, Python, etc.) - Subtoken matching - camelCase and snake_case identifiers are split into subtokens, so
sendalso findssendCampaign,send_email, etc. - Multi-word AND queries -
"campaign sending"returns results where all terms appear in the file, not just exact adjacent phrases - Filename search - Search matches file paths too, not just content
- Fast indexed search - Tantivy-powered BM25 ranking, instant results
- Incremental indexing - Only re-indexes changed files based on mtime; no-op runs complete in ~10ms
- Non-blocking AI hooks - Background indexing on session start, never slows down your AI tool
- Interactive dashboard - TUI for managing indexes, toggling watchers, and viewing live activity
- File watching - Incremental index updates on file changes
- Optional semantic search - HNSW vector index with local semantic model (all-MiniLM-L6-v2)
- Symlink handling - Follows symlinks with cycle detection
- AI-optimized output - Clean, minimal output with file paths and line numbers
Installation
Homebrew (macOS/Linux)
From Source
# Using cargo (full features, requires ONNX Runtime)
# Text search only (no ONNX dependency, faster build)
# Or build release
Quick Start
1. Install for your AI tool
2. Index your project
3. Search
That's it! The AI tool will now use ygrep for code searches.
Usage
Searching
# Basic search (literal text matching by default)
# Regex search (use -r or --regex)
# Subtoken matching (automatic with indexed search)
# Case-sensitive search (default is case-insensitive)
# Context lines around matches
# With options
# Verbose mode (debug search pipeline)
# Output formats (AI format is default)
Indexing
Indexing is incremental by default - only files with changed modification times are re-indexed. A no-op run (nothing changed) completes in ~10ms. Use --rebuild to force a full re-index.
The --semantic and --text flags are sticky - once set, subsequent ygrep index commands (without flags) will remember and use the same mode. This also applies to ygrep watch.
When upgrading ygrep to a new version with schema changes, the index is automatically rebuilt on the next ygrep index run.
File Watching
File watching automatically uses the same mode (text or semantic) as the original index.
Status
Index Management
Example output:
# 2 indexes (24.0 MB)
1bb65a32a7aa44ba 319.4 KB [text]
/path/to/project
c4f2ba4712ed98e7 23.7 MB [semantic]
/path/to/another-project
Dashboard
Interactive TUI for monitoring and managing all your indexes in one place:
The dashboard shows a table of all indexes with workspace path, size, file count, last indexed time, and watch state. Below the table is a live activity log showing real-time file indexing events.
Key bindings:
| Key | Action |
|---|---|
j/k or ↑/↓ |
Navigate entries |
w |
Toggle watch (off/active) |
r |
Re-index workspace |
d |
Delete index (with confirmation) |
s |
Cycle sort column (Name, Size, Files, Indexed, Watch) |
S |
Toggle sort order (ascending/descending) |
/ |
Filter by workspace name |
Tab |
Switch focus between table and activity log |
? |
Help overlay |
q |
Quit |
Updating
ygrep automatically checks for updates once per day (in the background, after search) and shows a hint when a new version is available:
ygrep v3.2.0 available (current: v3.1.6). Run `ygrep update` to upgrade.
If installed via Homebrew or cargo, ygrep update will suggest the appropriate command (brew upgrade ygrep or cargo install ygrep-cli) instead of self-updating.
Semantic Search (Optional)
Enable semantic search for better results on natural language queries:
# Build semantic index (one-time, slower - mode is remembered)
# Search automatically uses hybrid mode when semantic index exists
# Force text-only search (single query, doesn't change index mode)
# Future index/watch commands remember the mode
# Convert back to text-only index
Semantic search uses the all-MiniLM-L6-v2 model (~25MB, downloaded on first use).
Note: Semantic search requires ONNX Runtime and is only available on certain platforms:
- ✅ macOS ARM64 (Apple Silicon)
- ✅ Linux x86_64
- ❌ macOS x86_64 (Intel) (text search only)
- ❌ Windows x86_64 (text search only)
- ❌ Linux ARM64/ARMv7/musl (text search only)
On unsupported platforms, ygrep works normally with BM25 text search - the --semantic flag will print a warning.
AI Tool Integration
ygrep integrates with popular AI coding assistants:
Claude Code
After installation, restart Claude Code. The plugin:
- Runs
ygrep indexin the background on session start (non-blocking) - Provides a skill that teaches Claude to prefer ygrep over built-in search
Important: At the start of each session, run /ygrep to load the skill. This tells Claude to use ygrep for code searches instead of its built-in Grep/Glob tools. Without loading the skill, Claude will default to its slower built-in search.
OpenCode
Codex
Example Output
AI Format (Default)
Optimized for AI assistants - single line header with score and match type:
# 5 results (3 text + 2 semantic)
src/config.rs:45 (85%) +
pub struct Config {
src/main.rs:12 (72%) ~
fn main() -> Result<()> {
src/lib.rs:100 (65%)
let workspace = Workspace::open(&config)?;
Format: path:line (score%) [match_indicator]
+= Hybrid match (both text AND semantic)~= Semantic only (no exact text match)- No indicator = Text only
JSON Format
Full metadata with --json:
Each hit includes match_type: "Text", "Semantic", or "Hybrid".
Pretty Format
Human-readable with --pretty:
# 5 results (3 text + 2 semantic)
src/config.rs:45-67
45: pub struct Config {
46: pub data_dir: PathBuf,
47: pub max_file_size: u64,
src/main.rs:12-28
12: fn main() -> Result<()> {
13: let config = Config::load()?;
14: let workspace = Workspace::open(&config)?;
How It Works
- Indexing: Walks directory tree, indexes text files with Tantivy using a code-aware tokenizer
- Incremental updates: Compares file modification times against the index using fast columnar fields; only changed, new, or deleted files are processed
- Tokenizer: Custom tokenizer preserves code characters (
$,@,#,-,_) as part of tokens, and emits subtokens for camelCase and snake_case identifiers - Search: BM25-ranked literal search (default) or regex matching with
-rflag, plus optional semantic search - Results: Returns matching files with line numbers and context
Development
Running Tests
Code Quality
Building
Configuration
Index data stored in:
- macOS:
~/Library/Application Support/ygrep/indexes/ - Linux:
~/.local/share/ygrep/indexes/
Upgrading
# Self-update (downloads latest release binary)
# Via Homebrew
# Indexes auto-rebuild when schema changes are detected
# If upgrading to v3.0.6+, rebuild is required for filename search
Windows Build Prerequisites: C++ SDK & Build Tools
Building this project on Windows requires MSVC Build Tools and the Windows SDK because several dependencies compile native C/C++ code.
Install Rust
Install MSVC Build Tools
Install Visual Studio Build Tools 2022 (or latest) with the following workloads:
- "Desktop development with C++" — includes MSVC compiler and Windows SDK
- Alternatively, install the individual components: MSVC v143+ C++ build tools and Windows 10/11 SDK
Download: https://visualstudio.microsoft.com/visual-cpp-build-tools/
Dependencies that require C/C++ compilation
| Crate | Why | Used by |
|---|---|---|
ort-sys |
ONNX Runtime C++ bindings | ort → fastembed (ML inference) |
onig_sys |
Oniguruma regex engine (C library) | onig |
zstd-sys |
Zstandard compression (C library) | zstd |
ring |
Cryptography (C/assembly) | rustls (TLS) |
The cc crate handles compiling C/C++ code from Rust build scripts, and find-msvc-tools (used by ort-sys) locates the MSVC installation on your system.
fastembed → ort → ort-sys is the primary reason MSVC Build Tools are needed, since ONNX Runtime is a substantial C++ dependency.
Build
The compiled binary will be at target\release\ygrep.exe. To make it available system-wide, either:
- Copy to a directory already on your PATH:
- Or add the build output directory to your PATH:
Go to Settings > System > About > Advanced system settings > Environment Variables, then add the
target\releasepath to your userPathvariable.
License
MIT