llmgrep
Semantic Code Search for Magellan Databases
Fast, reliable search of code indexed by Magellan with LLM-optimized output.
⚠️ Requires Magellan
llmgrep requires Magellan to function.
Magellan provides the code graph database that llmgrep queries. You must run magellan watch on your codebase before using llmgrep.
# Install Magellan first
# Watch your project (builds database)
# Now llmgrep can search
The Code Intelligence Toolset
llmgrep is part of a coordinated toolset built on sqlitegraph. All tools share a common SQLite graph database and are designed to work together for AI-assisted code understanding.
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Magellan │ ───► │ llmgrep │ ───► │ Mirage │
│(Symbols & │ │ (Semantic │ │(CFG & Paths)│
│ Call Graph)│ │ Search) │ │ │
└─────────────┘ └─────────────┘ └─────────────┘
│ │ │
└────────────────────┴─────────────────────┘
│
┌──────▼──────┐
│ sqlitegraph │
│ (Database) │
└─────────────┘
│
┌──────▼──────┐
│ splice │
│(Edit using │
│ spans) │
└─────────────┘
| Tool | Purpose | Repository | Install |
|---|---|---|---|
| sqlitegraph | Graph database foundation | github.com/oldnordic/sqlitegraph | cargo add sqlitegraph |
| Magellan | Call graph indexing, symbol navigation | github.com/oldnordic/magellan | cargo install magellan |
| llmgrep | Semantic code search | github.com/oldnordic/llmgrep | cargo install llmgrep |
| Mirage | CFG analysis, path enumeration | github.com/oldnordic/mirage | cargo install mirage-analyzer |
| splice | Precision code editing | github.com/oldnordic/splice | cargo install splice |
What is llmgrep?
llmgrep queries Magellan's code graph database to find symbols, references, and call relationships. Emits deterministic, schema-aligned JSON for LLM consumption.
What llmgrep is NOT
- ❌ A code indexer (use Magellan)
- ❌ An embedding or semantic search tool
- ❌ A CFG analysis tool (use Mirage)
- ❌ A code editing tool (use splice)
What llmgrep IS
- ✅ Read-only query tool for Magellan databases
- ✅ Symbol search with regex and intelligent ranking
- ✅ Reference and call graph traversal
- ✅ AST-aware structural search
- ✅ Magellan algorithm integration (condense, paths, cycles, reachable, dead-code, slice)
- ✅ Raw AST tree queries
- ✅ LLM-optimized JSON output
Installation
Or build from source:
Quick Start
1. Install the Toolset
# Install all tools for complete workflow
2. Index Your Project
# Magellan watches your source and builds database
3. Search with llmgrep
# Basic symbol search
# Reference search
# Regex with JSON output
Commands
| Command | Description |
|---|---|
search |
Search symbols, references, calls |
ast |
Query raw AST tree for a file |
find-ast |
Find AST nodes by kind |
Search Options
Search mode: --mode {symbols|references|calls|auto}
Filters: --path, --kind, --language, --regex, --fqn, --symbol-id
Metrics: --min-complexity, --max-complexity, --min-fan-in, --min-fan-out
AST filtering: --ast-kind, --with-ast-context, --min-depth, --max-depth, --inside, --contains
Algorithm filters: --condense, --paths-from, --paths-to, --reachable-from, --dead-code-in, --in-cycle, --slice-backward-from, --slice-forward-from
Sorting: --sort-by {relevance|position|fan-in|fan-out|complexity|nesting-depth}
Output: --output {human|json|pretty}
Examples
Basic Search
# Relevance-ranked (LLM-friendly)
# Position-sorted (faster)
# Sort by complexity
AST Filtering
# Find all loops
# Find deeply nested code
# Find closures within functions
Magellan Algorithm Integration
# Find symbols in strongly connected components
# Find symbols on execution paths from main
# Find symbols on paths between two symbols
# Find dead code (unreachable from main)
# Find symbols in dependency cycles
# Backward slice: code affecting target
# Forward slice: code affected by source
AST Commands (v2.1)
# Get full AST tree for a file
# Get AST node at specific position
# Limit output for large files
# Find all function definitions
# Find all loops
Requirements
- Magellan 2.1.0+ — Required for code indexing
- sqlitegraph 1.3.0+ — Included automatically
Documentation
llmgrep search --help— Built-in usage examplesMANUAL.md— Full manual with all optionsCHANGELOG.md— Version history
License
GPL-3.0-only. See LICENSE.md.
Related Projects
- sqlitegraph — Graph database library
- Magellan — Call graph indexer
- Mirage — CFG analysis
- splice — Precision editing