Natural-language search that works like grep. Fast, local, GPU-accelerated, and built for coding agents.
- Semantic: Finds concepts ("where do transactions get created?"), not just strings.
- GPU-Accelerated: CUDA on NVIDIA GPUs, Metal on Apple Silicon.
- Local & Private: 100% local embeddings. No API keys required.
- Auto-Isolated: Each repository gets its own index automatically.
- On-Demand Grammars: Tree-sitter WASM grammars download automatically as needed.
- Agent-Ready: Native MCP server and Claude Code integration.
Quick Start
-
Install
cargo install smgrep
Or build from source:
git clone https://github.com/can1357/smgrep
cd smgrep
cargo build --release
For CPU-only builds (no CUDA):
cargo build --release --no-default-features
-
Setup (Recommended)
smgrep setup
Downloads embedding models (~500MB) and tree-sitter grammars upfront. If you skip this, models download automatically on first use.
-
Search
cd my-repo
smgrep "where do we handle authentication?"
Your first search will automatically index the repository. Each repository is automatically isolated with its own index. Switching between repos "just works".
Coding Agent Integration
Claude Code
- Run
smgrep claude-install
- Open Claude Code (
claude) and ask questions about your codebase.
- The plugin auto-starts the
smgrep serve daemon and provides semantic search.
MCP Server
smgrep includes a built-in MCP (Model Context Protocol) server:
smgrep mcp
This exposes a sem_search tool that agents can use for semantic code search. The server auto-starts the background daemon if needed.
Commands
smgrep [query]
The default command. Searches the current directory using semantic meaning.
smgrep "how is the database connection pooled?"
Options:
| Flag | Description | Default |
|---|
-m <n> | Max total results to return | 10 |
--per-file <n> | Max matches per file | 1 |
-c, --content | Show full chunk content | false |
--compact | Show file paths only | false |
--scores | Show relevance scores | false |
-s, --sync | Force re-index before search | false |
--dry-run | Show what would be indexed | false |
--json | JSON output format | false |
--no-rerank | Skip ColBERT reranking | false |
--plain | Disable ANSI colors | false |
Examples:
# General concept search
smgrep "API rate limiting logic"
# Deep dive (more matches per file)
smgrep "error handling" --per-file 5
# Just the file paths
smgrep "user validation" --compact
# JSON for scripting
smgrep "config parsing" --json
smgrep index
Manually indexes the repository.
smgrep index # Index current dir
smgrep index --dry-run # See what would be indexed
smgrep index --reset # Delete and re-index from scratch
smgrep serve
Runs a background daemon with file watching for instant searches.
- Keeps LanceDB and embedding models resident for fast responses
- Watches the repo and incrementally re-indexes on change
- Communicates via Unix socket (or TCP on Windows)
smgrep serve # Start daemon for current repo
smgrep serve --path /repo # Start for specific path
smgrep stop / smgrep stop-all
Stop running daemons.
smgrep stop # Stop daemon for current repo
smgrep stop-all # Stop all smgrep daemons
smgrep clean
Remove index data and metadata for a store.
smgrep clean # Clean current directory's store
smgrep clean my-store # Clean specific store by ID
smgrep clean --all # Clean all stores
smgrep status
Show status of running daemons.
smgrep list
Lists all indexed repositories and their metadata.
smgrep doctor
Checks installation health, model availability, and grammar status.
smgrep doctor
GPU Acceleration
smgrep uses candle for ML inference with optional CUDA support.
With CUDA (default):
Requires CUDA toolkit installed with environment configured: