A powerful search tool built on regular expressions.
GrepSearch file contents using regular expressions, file globs, and type filters, with automatic decoding of legacy encodings for accurate matching.
Instructions
A powerful search tool for file contents.
Usage:
ALWAYS use Grep for search tasks. NEVER invoke grep or rg as a Bash command.
Supports full regular expressions, file glob filters, file type filters, context lines, match-only output, multiline matching, pagination, file lists, and per-file counts.
Use output_mode=files_with_matches when you only need file paths; this is the default.
Use output_mode=content to see matching lines. Line numbers are included by default.
Use output_mode=count to see match counts per file.
Results are limited to 250 entries by default; use head_limit and offset for pagination.
Every file is decoded according to its nearest project .encoding-rules, so legacy encoded content is searched as Unicode transparently.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| -A | No | Show lines after each match | |
| -B | No | Show lines before each match | |
| -C | No | Show lines before and after each match | |
| -i | No | Case-insensitive search | |
| -n | No | Show line numbers in content mode. Defaults to true. | |
| -o | No | Print only matching non-empty parts of each line | |
| glob | No | Glob pattern used to filter files, for example *.js or **/*.ts | |
| path | No | File or directory to search. Defaults to the current working directory. | |
| type | No | File type filter such as js, ts, py, rust, go, or java | |
| offset | No | Skip the first N result lines or entries | |
| context | No | Alias for -C | |
| pattern | Yes | The regular expression pattern to search for in file contents | |
| multiline | No | Enable multiline matching where dot also matches newlines | |
| head_limit | No | Limit returned lines or entries. Defaults to 250; 0 means unlimited. | |
| output_mode | No | Output mode. Defaults to files_with_matches. |