Ripgrep search
rgSearch file contents with regex to find text across files and return structured match rows; filter by glob, ignore case, count per file, or extract matched substrings.
Instructions
Search file contents with ripgrep. Returns files as [file, "line:text", ...] rows (a context line is "line-text"), [file, count] under countPerFile, [file] under filesOnly. Use glob (string or array, '!' to exclude) to filter files, ignoreCase for case-insensitive search, filesOnly for just filenames, countPerFile for match counts per file, maxPerFile to cap hits per file. For 'collect all X' tasks use only:true to return just the matched substrings (one row per hit) — add replace ($1 capture groups) to extract structured values.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| glob | No | File glob filter(s); a string or array. Prefix with '!' to exclude (e.g. ['*.ts','!*.test.ts']) | |
| only | No | Return only the matched substring(s), not the whole line — one row per match. Best for collecting tokens (versions, names, URLs) | |
| path | No | Directory or file to search (default: cwd) | |
| context | No | Lines of context around each match | |
| pattern | No | Required. Regex pattern to search for | |
| replace | No | Rewrite each match with this template ($1, $2 capture groups) and return the result; implies only-match extraction | |
| filesOnly | No | Only return filenames, not matched lines | |
| ignoreCase | No | Case-insensitive search | |
| maxPerFile | No | Cap matches per file (rg --max-count), independent of maxResults — keeps one hot file from dominating | |
| maxResults | No | Max results to return across all files (default 30). When the cap bites, the response reports the true totalMatches so you can decide whether to narrow the pattern or raise the cap | |
| countPerFile | No | Return match counts grouped by file instead of individual matches | |
| fixedStrings | No | Treat pattern as literal string | |
| maxLineLength | No | Window matched line text to ~this many chars centered on the match, so long/minified lines don't dump in full (0 = unlimited, default 120) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| files | Yes | ||
| retained | No | ||
| truncated | No | Present only when maxResults cut the matches | |
| matchCount | No | Matches returned; with countPerFile, the sum of counts | |
| totalMatches | No |