RAGgrep
Local semantic search for codebases — find code using natural language queries.
RAGgrep indexes your code and lets you search it using natural language. Everything runs locally — no external API calls required.
Features
- Zero-config search — Just run
raggrep query and it works. Index is created and updated automatically.
- Multi-language support — Deep understanding of TypeScript, JavaScript, Python, Go, and Rust with AST-aware parsing.
- Vocabulary-based search — Search
user to find getUserById, fetchUserData, UserService, etc. Understands code naming conventions.
- Local-first — All indexing and search happens on your machine. No cloud dependencies.
- Incremental — Only re-indexes files that have changed. Instant search when nothing changed.
- Watch mode — Keep the index fresh in real-time as you code.
- Hybrid search — Combines semantic similarity with keyword matching for best results.
- Literal boosting — Exact identifier matches get priority. Use backticks for precise matching:
`AuthService`.
- Semantic expansion — Domain-specific synonyms improve recall (function ↔ method, auth ↔ authentication).
Installation
npm install -g raggrep
npx raggrep query "your search"
Usage
Search Your Code
cd your-project
raggrep query "user authentication"
That's it. The first query creates the index automatically. Subsequent queries are instant if files haven't changed. Modified files are re-indexed on the fly.
Example Output
Index updated: 42 indexed
RAGgrep Search
==============
Searching for: "user authentication"
Found 3 results:
1. src/auth/authService.ts:24-55 (login)
Score: 34.4% | Type: function | via TypeScript | exported
export async function login(credentials: LoginCredentials): Promise<AuthResult> {
const { email, password } = credentials;
2. src/auth/session.ts:10-25 (createSession)
Score: 28.2% | Type: function | via TypeScript | exported
export function createSession(user: User): Session {
3. src/users/types.ts:3-12 (User)
Score: 26.0% | Type: interface | via TypeScript | exported
export interface User {
id: string;
Watch Mode
Keep your index fresh in real-time while you code:
raggrep index --watch
This monitors file changes and re-indexes automatically. Useful during active development when you want instant search results.
┌─────────────────────────────────────────┐
│ Watching for changes... (Ctrl+C to stop) │
└─────────────────────────────────────────┘
[Watch] language/typescript: 2 indexed, 0 errors
CLI Reference
Commands
raggrep query <query>
raggrep index
raggrep status
raggrep reset
Query Options
raggrep query "user login"
raggrep query "error handling" --top 5
raggrep query "database" --min-score 0.2
raggrep query "interface" --type ts
raggrep query "auth" --filter src/auth
raggrep query "api" -f src/api -f src/routes
raggrep query "\`AuthService\` class"
--top <n> | -k | Number of results to return (default: 10) |
--min-score <n> | -s | Minimum similarity score 0-1 (default: 0.15) |
--type <ext> | -t | Filter by file extension (e.g., ts, tsx, js) |
--filter <path> | -f | Filter by path or glob pattern (can be used multiple times) |
--help | -h | Show help message |
Filtering by File Type
Use glob patterns with --filter to search specific file types:
raggrep query "service controller" --filter "*.ts"
raggrep query "component state" --filter "*.tsx"
raggrep query "deployment workflow" --filter "*.md"
raggrep query "mock setup" --filter "*.test.ts"
raggrep query "api handler" --filter "src/**/*.ts"
Multiple Filters (OR Logic)
Use multiple --filter flags to match files that match any of the patterns:
raggrep query "component" --filter "*.ts" --filter "*.tsx"
raggrep query "api" --filter src/api --filter src/routes
raggrep query "config" --filter "*.json" --filter "*.yaml" --filter config/
This is useful when you know whether you're looking for code or documentation.
Index Options
raggrep index
raggrep index --watch
raggrep index --verbose
raggrep index --concurrency 8
raggrep index --model bge-small-en-v1.5
--watch | -w | Watch for file changes and re-index automatically |
--verbose | -v | Show detailed progress |
--concurrency <n> | -c | Number of parallel workers (default: auto based on CPU) |
--model <name> | -m | Embedding model to use |
--help | -h | Show help message |
Other Commands
raggrep status
raggrep reset
raggrep --version
How It Works
- First query — Creates the index (takes 1-2 min for ~1000 files)
- Subsequent queries — Uses cached index (instant if no changes)
- Files changed — Re-indexes only modified files automatically
- Files deleted — Stale entries cleaned up automatically
The index is stored in a system temp directory, keeping your project clean.
What Gets Indexed
Supported Languages
TypeScript/JavaScript (.ts, .tsx, .js, .jsx, .mjs, .cjs)
- AST-parsed for functions, classes, interfaces, types, enums
- Full file chunks for broad context
- JSDoc and comment association
Python (.py)
- AST-parsed for functions, classes, decorators
- Docstring extraction and association
- Fallback regex parsing for robustness
Go (.go)
- AST-parsed for functions, methods, structs, interfaces
- Doc comment extraction (
// style)
- Exported symbol detection
Rust (.rs)
- AST-parsed for functions, structs, traits, impls, enums
- Doc comment extraction (
/// and //! style)
- Visibility detection (
pub)
Markdown (.md)
- Hierarchical chunking at multiple heading levels (H1-H5)
- Each heading level creates separate searchable chunks
- Nested content included for context
JSON (.json)
- Structure-aware with key/value extraction
- Path-based indexing
Other formats: .yaml, .yml, .toml, .sql, .txt — Keyword search and full-text indexing
Automatically Ignored
node_modules, dist, build, .git, .next, .cache, __pycache__, target, and other common build/dependency directories
Opencode Integration
RAGgrep can be integrated with opencode to provide semantic code search capabilities within the AI coding assistant.
Installation
Install the raggrep tool for opencode:
raggrep opencode install
This creates the tool file at ~/.config/opencode/tool/raggrep.ts.
Usage in Opencode
Once installed, you can search your codebase directly within opencode:
- Search for code using natural language: "user authentication flow"
- Filter by file types and paths
- Get context-aware results with scores and locations
The tool supports all the same search options as the CLI:
- Number of results (
top)
- Minimum similarity score (
minScore)
- File type filtering (
type)
- Path filtering (
filter)
Documentation
Requirements
- Node.js 18+ or Bun 1.0+
- ~50MB disk space for models (cached at
~/.cache/raggrep/models/)
License
MIT