Your code is a database.
Why query it with full-text search?
smartgrep uses tree-sitter to parse your source into a structured symbol index. Coding agents can query it the way you'd query a database, and the queries are easy for people to read.
curl -fsSL https://raw.githubusercontent.com/rohitkg98/smartgrep/main/install.sh | sh
grep: terse, brittle, and you need regex skills to read it
grep -rn "^pub\s\+fn\|pub async fn" src/commands/ | grep -v "//\|mod.rs"
smartgrep: reads like a sentence
smartgrep query "functions where visibility = public and file contains 'commands/'"
Why agents use it
Structural, not textual
Ask for functions, classes, methods, traits, dependencies and references directly. There's no raw text to pattern-match and no noise to parse.
One call, one answer
Compose filters and pipeline stages, and batch several questions with ;. Agents answer in one call what used to take several greps.
You can see what the agent asked
Every call is logged. Run smartgrep log to see exactly what your agent was looking for, in plain language.
Always fresh
Queries index automatically, and the index rebuilds when source files change.
Install
macOS, Linux, FreeBSD, Android (Termux):
curl -fsSL https://raw.githubusercontent.com/rohitkg98/smartgrep/main/install.sh | sh
Windows (PowerShell):
irm https://raw.githubusercontent.com/rohitkg98/smartgrep/main/install.ps1 | iex
Both scripts install a prebuilt binary from the latest release, so you don't need Rust. Each release includes a SHA256SUMS file, and the scripts check the download against it. To build from source instead, run cargo install --git https://github.com/rohitkg98/smartgrep (Rust 1.70+).
Make a project agent-ready
cd your-project
smartgrep init
smartgrep init builds the index, adds a short smartgrep section to CLAUDE.md and/or AGENTS.md, installs the Claude Code skill and adds .smartgrep/ to .gitignore. To preview the changes first, run smartgrep init --dry-run.
The query DSL
source [where conditions] [| stage] [| stage] ...
| What you want to know | smartgrep |
|---|---|
| All public functions | functions where visibility = public |
| Spring REST controllers | classes where attributes contains '@RestController' |
| Methods on UserService | methods where parent = UserService |
| Structs with 5+ fields | structs | with fields | where field_count > 5 |
| What Config depends on | symbol Config | with deps |
Pipeline stages: with fields, with params, with deps, with refs, with signature, show, where, sort, limit. The full reference is in the README.
Supported languages
RustJavaGoTypeScriptPython
Language-agnostic IR means adding a language takes only one new parser.