Grep
grepSearch cached files for exact strings or regex patterns, returning line-numbered matches with optional path and limit filters.
Instructions
Search cached file contents for an exact string or regex.
Fast, exact, line-numbered matching over files already in the cache — it
does NOT touch disk, so index files first with warm, which costs a few
dozen tokens however many files it covers (empty results usually mean the
files aren't cached). A pattern that is not a
valid regex is an error, never an empty result, so zero matches always
means zero matches. For concept-level questions where you don't know the
exact term, use search instead.
Counts are complete unless the response says otherwise: if a cap stops the
scan, complete comes back false with limit_reached naming which one, so
total_matches is never mistaken for the total that exists.
Each file's hits come back as "<line>:<text>" strings under lines, with
context lines using - instead of :. Paths are relative to the root
the response names, when there is one worth naming. The cache is shared
across projects, so a relative path — or none — searches only the
current project; an absolute path reaches files anywhere.
A repeated group wrapping an unbounded quantifier ((a+)+) is rejected
rather than run — it can take exponential time and cannot be interrupted
once started. Drop the redundant repeat, or pass fixed_string=true.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Optional filter — an exact path, a path suffix, a directory (matching every cached file beneath it), or a glob. | |
| output | No | How much to return — `matches` (default), `paths` for the matching files without their lines, or `count` for the totals alone. | matches |
| pattern | Yes | A regular expression, or a literal string when `fixed_string=true`. | |
| max_files | No | Cap on the number of files returned. | |
| max_matches | No | Cap on total matches returned across all files. | |
| fixed_string | No | Match `pattern` literally instead of as a regex. | |
| context_lines | No | Lines of surrounding context to include around each match. Overlapping windows are merged, so no line is sent twice. | |
| case_sensitive | No | Match case-sensitively. |