can1357/smgrep
can1357/smgrep · 1 plugin
Marketplace Semantic code search tool with GPU acceleration
Install
The repo has no one-line install. Follow its README.
Plugins 1
After adding the marketplace, install one with /plugin install <name>@smgrep.
- 1smgrepSemantic code search for Claude Code. High-performance Rust implementation with automatic project indexing.
/plugin install smgrep@smgrep
Files
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 --releaseFor 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 servedaemon and provides semantic search.
MCP Server
smgrep includes a built-in MCP (Model Context Protocol) server:
smgrep mcpThis 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" --jsonsmgrep 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 scratchsmgrep 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 pathsmgrep stop / smgrep stop-all
Stop running daemons.
smgrep stop # Stop daemon for current repo
smgrep stop-all # Stop all smgrep daemonssmgrep 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 storessmgrep 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 doctorGPU Acceleration
smgrep uses candle for ML inference with optional CUDA support.
With CUDA (default):
Requires CUDA toolkit installed with environment configured:
export CUDA_ROOT=/usr/local/cuda # or your CUDA installation path
export PATH="$CUDA_ROOT/bin:$PATH"
cargo build --releaseEmbedding speed is significantly faster on NVIDIA GPUs.
CPU-only:
cargo build --release --no-default-featuresEnvironment variables:
SMGREP_DISABLE_GPU=1- Force CPU even when CUDA is availableSMGREP_BATCH_SIZE=N- Override batch size (auto-adapts on OOM)
Architecture
smgrep combines several techniques for high-quality semantic search:
-
Smart Chunking: Tree-sitter parses code by function/class boundaries, ensuring embeddings capture complete logical blocks. Grammars download on-demand as WASM modules.
-
Hybrid Search: Dense embeddings (sentence-transformers) for broad recall, ColBERT reranking for precision.
-
Quantized Storage: ColBERT embeddings are quantized to int8 for efficient storage in LanceDB.
-
Automatic Repository Isolation: Stores are named by git remote URL or directory hash.
-
Incremental Indexing: File watcher detects changes and updates only affected chunks.
Supported languages (37): TypeScript, TSX, JavaScript, Python, Go, Rust, C, C++, C#, Java, Kotlin, Scala, Ruby, PHP, Elixir, Haskell, OCaml, Julia, Zig, Lua, Odin, Objective-C, Verilog, HTML, CSS, XML, Markdown, JSON, YAML, TOML, Bash, Make, Starlark, HCL, Terraform, Diff, Regex
Configuration
smgrep uses a TOML config file at ~/.smgrep/config.toml. All options can also be set via environment variables with the SMGREP_ prefix.
Config File
# ~/.smgrep/config.toml
# ============================================================================
# Models
# ============================================================================
# Dense embedding model (HuggingFace model ID)
# Used for initial semantic similarity search
dense_model = "ibm-granite/granite-embedding-small-english-r2"
# ColBERT reranking model (HuggingFace model ID)
# Used for precise reranking of search results
colbert_model = "answerdotai/answerai-colbert-small-v1"
# Model dimensions (must match the models above)
dense_dim = 384
colbert_dim = 96
# Query prefix (some models require a prefix like "query: ")
query_prefix = ""
# Maximum sequence lengths for tokenization
dense_max_length = 256
colbert_max_length = 256
# ============================================================================
# Performance
# ============================================================================
# Batch size for embedding computation
# Higher = faster but more memory. Auto-reduces on OOM.
default_batch_size = 48
max_batch_size = 96
# Maximum threads for parallel processing
max_threads = 32
# Force CPU inference even when CUDA is available
disable_gpu = false
# Low-impact mode: reduces resource usage for background indexing
low_impact = false
# Fast mode: skip ColBERT reranking for quicker (but less precise) results
fast_mode = false
# ============================================================================
# Server
# ============================================================================
# TCP port for daemon communication
port = 4444
# Idle timeout: shutdown daemon after this many seconds of inactivity
idle_timeout_secs = 1800 # 30 minutes
# How often to check for idle timeout
idle_check_interval_secs = 60
# Timeout for embedding worker operations (milliseconds)
worker_timeout_ms = 60000
# ============================================================================
# Debug
# ============================================================================
# Enable model loading debug output
debug_models = false
# Enable embedding debug output
debug_embed = false
# Enable profiling
profile_enabled = false
# Skip saving metadata (for testing)
skip_meta_save = falseEnvironment Variables
Any config option can be set via environment variable with the SMGREP_ prefix:
# Examples
export SMGREP_DISABLE_GPU=true
export SMGREP_DEFAULT_BATCH_SIZE=24
export SMGREP_IDLE_TIMEOUT_SECS=3600| Variable | Description | Default |
|---|---|---|
SMGREP_STORE |
Override store name | auto-detected |
SMGREP_DISABLE_GPU |
Force CPU inference | false |
SMGREP_DEFAULT_BATCH_SIZE |
Embedding batch size | 48 |
SMGREP_LOW_IMPACT |
Reduce resource usage | false |
SMGREP_FAST_MODE |
Skip reranking | false |
Ignoring Files
smgrep respects .gitignore and .smignore files.
Create .smignore in your repository root:
# Ignore generated files
dist/
*.min.js
# Ignore test fixtures
test/fixtures/
Manual Store Management
- View all stores:
smgrep list - Override auto-detection:
smgrep --store custom-name "query" - Data location:
~/.smgrep/
Troubleshooting
- Index feels stale? Run
smgrep indexto refresh. - Weird results? Run
smgrep doctorto verify models and grammars. - Need a fresh start?
smgrep index --resetor delete~/.smgrep/. - GPU OOM? Batch size auto-reduces, or set
SMGREP_DISABLE_GPU=1.
Building from Source
git clone https://github.com/can1357/smgrep
cd smgrep
cargo build --release
# Run tests
cargo testAcknowledgments
smgrep is inspired by osgrep and mgrep by MixedBread.
License
Licensed under the Apache License, Version 2.0.
See LICENSE for details.
{
"$schema": "https://anthropic.com/claude-code/marketplace.schema.json",
"name": "smgrep",
"owner": {
"name": "can1357",
"email": "me@can.ac"
},
"plugins": [
{
"name": "smgrep",
"source": "./plugins/smgrep",
"description": "Semantic code search for Claude Code. High-performance Rust implementation with automatic project indexing.",
"version": "0.1.0",
"author": {
"name": "can1357",
"email": "me@can.ac"
},
"skills": [
"./skills/smgrep"
]
}
]
}Facts
- Kind
- Marketplace
- Repo
- can1357/smgrep
- Group
- Uncategorized
- Marketplace name
- smgrep
- Owner
- can1357
- License
- Apache-2.0
- Language
- Rust
- Created
- 2025-11-27
- Forks
- 7
- Plugins
- 1
- 1f/prompts.chatf/prompts.chatf.k.a. Awesome ChatGPT Prompts. Share, discover, and collect prompts from the community. Free and open source — self-host for your organization with complete privacy.
- 2affaan-m/everything-claude-codeaffaan-m/everything-claude-codeThe agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
- 3obra/superpowersobra/superpowersAn agentic skills framework & software development methodology that works.
- 4anthropics/skillsanthropics/skillsPublic repository for Agent Skills
- 5anthropics/claude-codeanthropics/claude-codeClaude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.
- 6nextlevelbuilder/ui-ux-pro-max-skillnextlevelbuilder/ui-ux-pro-max-skillAn AI skill that provides design intelligence for building professional UI/UX across multiple platforms.