| Crates.io | searchgrep |
| lib.rs | searchgrep |
| version | 0.1.0 |
| created_at | 2026-01-01 19:43:12.480252+00 |
| updated_at | 2026-01-01 19:43:12.480252+00 |
| description | Semantic grep for the AI era - natural language code search |
| homepage | https://github.com/RandomsUsernames/sgrep |
| repository | https://github.com/RandomsUsernames/sgrep |
| max_upload_size | |
| id | 2017367 |
| size | 16,414,869 |
Semantic grep for the AI era
Natural language code search powered by Rust
Search your codebase using natural language. Ask questions like "where are authentication errors handled" or "database connection pooling logic" and get instant results.
# Install
brew install RandomsUsernames/sgrep/sgrep
# Index & Search
sgrep index .
sgrep search "error handling for API requests"
| Traditional grep | sgrep |
|---|---|
grep -r "error" finds literal matches |
Finds code by meaning |
| Requires knowing exact terms | Use natural language |
| Misses synonyms and related code | Understands context |
| No AI integration | Works with Claude, Cursor, etc. |
brew tap RandomsUsernames/sgrep
brew install sgrep
npx sgrep # Run directly
npm install -g sgrep # Install globally
git clone https://github.com/RandomsUsernames/sgrep.git
cd sgrep
cargo install --path .
# 1. Index your codebase
sgrep index .
# 2. Search with natural language
sgrep search "authentication middleware"
# 3. Get AI-powered answers
sgrep ask "how does the login flow work"
# 4. View codebase structure
sgrep map
Find code by meaning, not just keywords. The query "handle user login" will find authentication code even if it doesn't contain those exact words.
sgrep search "database connection pooling"
sgrep search "where are errors logged" --content
Get synthesized answers about your codebase using GPT.
sgrep ask "explain the authentication flow"
sgrep ask "what testing framework is used"
Get a structural overview of your code - functions, classes, and their relationships.
sgrep map # Full codebase map
sgrep map src/ # Specific directory
Integrates directly with Claude Code, Cursor, and other MCP-compatible tools.
sgrep setup # Interactive setup for AI tools
| Mode | Flag | Best For |
|---|---|---|
| Balanced | (default) | General search |
| Code | --code |
Code-specific queries |
| Hybrid | --hybrid |
Best quality (slower) |
sgrep setup # Interactive MCP setup
Or manually add to your MCP config:
{
"mcpServers": {
"sgrep": {
"command": "sgrep",
"args": ["mcp-server"]
}
}
}
sgrep skill # Interactive setup
sgrep skill claude # Claude only
sgrep skill all # All tools
| Command | Description |
|---|---|
sgrep index <path> |
Index a directory |
sgrep search <query> |
Semantic search |
sgrep ask <question> |
AI-powered Q&A |
sgrep map [path] |
Codebase structure map |
sgrep setup |
Configure MCP for AI tools |
sgrep skill [tool] |
Install as skill |
sgrep status |
Show index status |
sgrep config |
Configure settings |
sgrep search "query" [options]
-m, --max-results <n> Max results (default: 10)
-c, --content Show code snippets
-a, --answer Generate AI answer
--code Code-optimized model
--hybrid Best quality (BGE + CodeRankEmbed)
~/.sgrep/sgrep config --api-key sk-... # Set OpenAI key (for answers)
sgrep config --show # Show config
| Variable | Description |
|---|---|
OPENAI_API_KEY |
For --answer and ask commands |
OPENAI_BASE_URL |
Custom API endpoint |
sgrep respects .gitignore and .sgrepignore.
# Find auth code
sgrep search "user authentication and sessions"
# With code preview
sgrep search "database queries" --content
# Best quality search
sgrep search --hybrid "vector embeddings"
# Architecture overview
sgrep ask "what's the project architecture"
# View structure
sgrep map src/
Contributions welcome! Please open an issue or PR.