Grep
Grep is exact, line-oriented matching over your working tree, delegated to ripgrep. It is always live: it reads files from disk at call time, so it needs no index and can never be stale. By default it is aligned to the same corpus RCE Code indexes — the same ignore rules apply — so its hits correspond to the files your other searches see.
Reach for grep when you know the literal text or a regular expression you are looking for. Unlike lexical or semantic search, it returns precise line and column positions rather than ranked chunks.
How it works
engine.grep(...) shells out to the rg binary with --json and parses the structured output into GrepHit objects. By default it runs as a fixed-string search (literal text), switches on smart-case matching, and applies RCE Code's built-in ignore globs so generated, vendored, and binary paths are skipped — this is what “corpus-aligned” means. Pass raw=True to bypass those ignore globs and search everything ripgrep would otherwise see.
ripgrep must be installed
rg binary on your PATH. If it is missing, engine.grep(...) raises RipgrepNotFound. ripgrep exit codes are handled for you: “no matches” returns an empty list, while a genuine ripgrep error raises RipgrepError.Python API
Every GrepHit is a frozen record with these fields:
| Field | Type | Meaning |
|---|---|---|
file_path | str | Repo-relative path of the matching file |
line | int | 1-indexed line number of the match |
column | int | 1-indexed column of the first submatch on that line |
line_text | str | The full matching line, trailing newline stripped |
context_before | list[str] | Lines of preceding context (empty by default) |
context_after | list[str] | Lines of following context (empty by default) |
Literal search
Regex search
Restricting by glob
CLI
The grep subcommand exposes the literal/regex toggle and prints one line per hit as file:line:column text.
CLI vs. Python surface
rce-code grep command currently exposes only --regex/--literal (and --repo). The richer options — glob, case_sensitive, max_count, and raw — are available through the Python engine.grep(...) call.No index, no staleness
index() and never reports a Freshness — what it returns is exactly what is on disk right now. That makes it the right tool the moment after an edit, before re-indexing.